fix: add necessary supporting code for funding update

This commit is contained in:
KernelDeimos
2025-05-17 22:14:17 -04:00
parent ea405e5cb6
commit 1c19086592
2 changed files with 17 additions and 0 deletions

View File

@@ -17,6 +17,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
const { Actor } = require("./auth/Actor");
const BaseService = require("./BaseService");
const { DB_READ } = require("./database/consts");
@@ -78,6 +79,13 @@ class GetUserService extends BaseService {
await svc_whoami.get_details({ user }, user);
return user;
}
async refresh_actor (actor) {
if ( actor.type.user ) {
actor.type.user = await this.get_user({ username: actor.type.user.username });
}
return actor;
}
async get_user_ (options) {
const services = this.services;

View File

@@ -55,6 +55,15 @@ class CostService extends BaseService {
});
await svc_event.emit('credit.record-cost', event);
}
async record_funding_update ({ old_amount, new_amount }) {
const svc_event = this.services.get('event');
const event = {
actor: Context.get('actor'),
old_amount,
new_amount,
};
await svc_event.emit('credit.funding-update', event);
}
}
module.exports = {