mirror of
https://github.com/HeyPuter/puter.git
synced 2026-01-14 00:50:34 -06:00
fix: add necessary supporting code for funding update
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user