Skip to content

Commit

Permalink
fix(messaging): ignore cache when socket init (#665)
Browse files Browse the repository at this point in the history
* fix(messaging): ignore cache when socket init

* opts
  • Loading branch information
allardy committed Mar 20, 2024
1 parent a47d33c commit be85034
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/server/src/socket/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class SocketManager {
const userData = parseUserData(socket.handshake.query.userData)

if (creds) {
const user = await this.users.fetch(creds.userId)
const user = await this.users.fetch(creds.userId, { ignoreCache: true })
if (user?.clientId === clientId && (await this.userTokens.verifyToken(user.id, creds.userToken))) {
socket.data.creds = creds
// we don't need to send it back if it was already sent to us
Expand Down
4 changes: 2 additions & 2 deletions packages/server/src/users/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ export class UserService extends Service {
await this.emitter.emit(UserEvents.Updated, { user })
}

public async fetch(id: uuid): Promise<User | undefined> {
public async fetch(id: uuid, opts?: { ignoreCache?: boolean }): Promise<User | undefined> {
const cached = this.cache.get(id)
if (cached) {
if (cached && !opts?.ignoreCache) {
return cached
}

Expand Down

0 comments on commit be85034

Please sign in to comment.