"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InactiveUsersService = void 0;
const types_1 = require("../../types");
const createInactiveUsersService_1 = require("./createInactiveUsersService");
class InactiveUsersService {
    constructor({ inactiveUsersStore }, { getLogger }, services) {
        this.logger = getLogger('services/client-feature-toggle-service.ts');
        this.inactiveUsersStore = inactiveUsersStore;
        this.userService = services.userService;
    }
    async getInactiveUsers() {
        const users = await this.inactiveUsersStore.getInactiveUsers(createInactiveUsersService_1.DAYS_TO_BE_COUNTED_AS_INACTIVE);
        if (users.length > 0) {
            return users.map((user) => {
                return (0, types_1.serializeDates)({
                    id: user.id,
                    name: user.name,
                    email: user.email,
                    username: user.username,
                    seenAt: user.seen_at,
                    createdAt: user.created_at,
                    patSeenAt: user.pat_seen_at,
                });
            });
        }
        else {
            return [];
        }
    }
    async deleteInactiveUsers(calledByUser, userIds) {
        this.logger.info('Deleting inactive users');
        for (const userid of userIds) {
            if (calledByUser.id !== userid) {
                await this.userService.deleteUser(userid, calledByUser);
            }
        }
    }
}
exports.InactiveUsersService = InactiveUsersService;
//# sourceMappingURL=inactive-users-service.js.map