Skip to content

Commit

Permalink
refactor: silence user presence retrieval errors (#1114)
Browse files Browse the repository at this point in the history
* refactor: silence user presence retrieval errors

* feat: update presence check to only query users that have joined and share room

* refactor: silence forbidden errors
  • Loading branch information
domw30 authored Oct 20, 2023
1 parent 89cb880 commit 5679f47
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/lib/chat/matrix-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@ export class MatrixClient implements IChatClient {
}

const { presence, last_active_ago } = userPresenceData;

const isOnline = presence === 'online';
const lastSeenAt = last_active_ago ? new Date(Date.now() - last_active_ago).toISOString() : null;

return { lastSeenAt, isOnline };
} catch (error) {
console.error(error);
} catch (error: any) {
if (error && typeof error === 'object' && error.errcode !== 'M_FORBIDDEN') {
console.error(error);
}

return { lastSeenAt: null, isOnline: false };
}
}
Expand Down

0 comments on commit 5679f47

Please sign in to comment.