Skip to content

Commit

Permalink
feat(api): send hasNotificationsEnabled
Browse files Browse the repository at this point in the history
  • Loading branch information
PLhery committed Jun 25, 2023
1 parent 45fbb4d commit 7b920c3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions unfollow-ninja-server/src/api.ts
Expand Up @@ -90,6 +90,7 @@ const router = new Router()
lang: params.lang,
country,
profilePic: session.profilePic,
hasNotificationsEnabled: params.dmLastEventId !== 0,
otherProfiles: Object.values(session.otherProfiles || {}),
};
}
Expand Down
2 changes: 2 additions & 0 deletions unfollow-ninja-server/src/api/auth.ts
Expand Up @@ -183,6 +183,7 @@ export function createAuthRouter(dao: Dao) {
lang: params.lang,
country,
profilePic: session.profilePic,
hasNotificationsEnabled: params.dmLastEventId !== 0,
otherProfiles: Object.values(session.otherProfiles || {}),
})
);
Expand Down Expand Up @@ -275,6 +276,7 @@ export function createAuthRouter(dao: Dao) {
lang: params.lang,
country,
profilePic: session.profilePic,
hasNotificationsEnabled: params.dmLastEventId !== 0,
otherProfiles: Object.values(session.otherProfiles || {}),
};
});
Expand Down
7 changes: 7 additions & 0 deletions unfollow-ninja-server/src/api/user.ts
Expand Up @@ -45,6 +45,13 @@ export function createUserRouter(dao: Dao) {
})
.put('/enable-dms', async (ctx) => {
const session = ctx.session as NinjaSession;

// if the user already has a dmLastEventId, don't do anything
if (await dao.getUserDao(session.userId).getDmLastEventId()) {
ctx.status = 204;
return;
}

const result = await dao.userEventDao.getFilteredUnfollowerEvents(session.userId, 1);
await dao.getUserDao(session.userId).setUserParams({ dmLastEventId: result[0]?.id ?? -1 });
void dao.userEventDao.logWebEvent(
Expand Down

0 comments on commit 7b920c3

Please sign in to comment.