Skip to content

Commit

Permalink
return manager object if manager in oending community
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernardo Vieira committed Nov 23, 2021
1 parent 5ca342d commit fd903c3
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions src/services/app/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ export default class UserService {

const userHello = await this.loadUser(userFromRegistry);
this.updateLastLogin(userFromRegistry.id);
const token = generateAccessToken(user.address, userFromRegistry.id);
const token = generateAccessToken(
user.address,
userFromRegistry.id
);

return {
...userHello,
Expand Down Expand Up @@ -440,7 +443,7 @@ export default class UserService {
},
{
where: { id },
transaction: t
transaction: t,
}
);

Expand Down Expand Up @@ -493,7 +496,7 @@ export default class UserService {
where: { active: true, address: user.address },
}
);
const manager: IManager | null = await this.manager.findOne({
let manager: IManager | null = await this.manager.findOne({
attributes: ['readRules', 'communityId'],
where: { active: true, address: user.address },
});
Expand Down Expand Up @@ -524,6 +527,10 @@ export default class UserService {
if (communityId) {
community = await getCommunity(communityId);
managerInPendingCommunity = true;
manager = {
communityId,
readRules: false,
};
}
}
// until here
Expand Down Expand Up @@ -564,14 +571,18 @@ export default class UserService {
offset?: string;
limit?: string;
},
userId: number,
): Promise<AppNotification[]> {
userId: number
): Promise<AppNotification[]> {
const notifications = await this.appNotification.findAll({
where: {
userId,
},
offset: query.offset ? parseInt(query.offset, 10) : config.defaultOffset,
limit: query.limit ? parseInt(query.limit, 10) : config.defaultLimit,
offset: query.offset
? parseInt(query.offset, 10)
: config.defaultOffset,
limit: query.limit
? parseInt(query.limit, 10)
: config.defaultLimit,
order: [['createdAt', 'DESC']],
});
return notifications as AppNotification[];
Expand All @@ -595,7 +606,9 @@ export default class UserService {
return true;
}

public static async getUnreadNotifications(userId: number): Promise<number> {
public static async getUnreadNotifications(
userId: number
): Promise<number> {
return this.appNotification.count({
where: {
userId,
Expand Down

0 comments on commit fd903c3

Please sign in to comment.