fix: Bug - Users appear as both online and offline
Align chat message sender ids with per-server presence identities so profile cards opened from message authors resolve the same live user state as the members panel. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import type { User } from '../../shared-kernel';
|
||||
import {
|
||||
buildUserIdentityLookup,
|
||||
findUserEntityByIdentity,
|
||||
resolveUserByIdentity
|
||||
} from './user-identity-lookup.rules';
|
||||
|
||||
function createUser(overrides: Partial<User> = {}): User {
|
||||
return {
|
||||
id: 'server-user-1',
|
||||
oderId: 'server-user-1',
|
||||
username: 'alice',
|
||||
displayName: 'Alice',
|
||||
status: 'online',
|
||||
role: 'member',
|
||||
joinedAt: 1,
|
||||
presenceServerIds: ['room-1'],
|
||||
isOnline: true,
|
||||
...overrides
|
||||
};
|
||||
}
|
||||
|
||||
describe('user-identity-lookup.rules', () => {
|
||||
it('indexes id, oderId, and peerId aliases in buildUserIdentityLookup', () => {
|
||||
const user = createUser({
|
||||
id: 'server-user-1',
|
||||
oderId: 'oder-1',
|
||||
peerId: 'peer-1'
|
||||
});
|
||||
const lookup = buildUserIdentityLookup([user]);
|
||||
|
||||
expect(resolveUserByIdentity(lookup, 'server-user-1')).toBe(user);
|
||||
expect(resolveUserByIdentity(lookup, 'oder-1')).toBe(user);
|
||||
expect(resolveUserByIdentity(lookup, 'peer-1')).toBe(user);
|
||||
});
|
||||
|
||||
it('findUserEntityByIdentity resolves users keyed by a different entity id', () => {
|
||||
const user = createUser({
|
||||
id: 'server-user-1',
|
||||
oderId: 'oder-1'
|
||||
});
|
||||
const entities = {
|
||||
'server-user-1': user
|
||||
};
|
||||
|
||||
expect(findUserEntityByIdentity(entities, 'oder-1')).toBe(user);
|
||||
expect(findUserEntityByIdentity(entities, 'home-user-1')).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user