fix: hide outbound media from gallery
This commit is contained in:
1 parent
c0cc661a2f
commit
488145340d
5 files changed
+65
-4
No files matched your search
@@ -20,6 +20,39 @@ afterEach(async () => {
|
||||
});
|
||||
|
||||
describe('media route username presentation', () => {
|
||||
it('lists received media while excluding items sent by the owning account', async () => {
|
||||
const mediaItem = (id: string, sender: string) => ({
|
||||
accountId: 't2_owner', id, chatUsername: 'alice', chatRoomId: 'room-one', sender,
|
||||
timestamp: 1, originalUrl: `mxc://${id}`, fileName: `${id}.jpg`, relativePath: `${id}.jpg`, createdAt: 2,
|
||||
});
|
||||
const context = {
|
||||
logger: { error: vi.fn() },
|
||||
services: {
|
||||
media: { getMediaItems: vi.fn().mockResolvedValue([
|
||||
mediaItem('received', 'alice'),
|
||||
mediaItem('sent-marker', 'Me'),
|
||||
mediaItem('sent-matrix-id', '@t2_owner:reddit.com'),
|
||||
mediaItem('sent-username', 'owner'),
|
||||
]) },
|
||||
chat: {
|
||||
getCachedConversations: vi.fn().mockResolvedValue([]),
|
||||
resolveSenderDisplay: vi.fn((identity: string) => identity),
|
||||
},
|
||||
redditAccounts: {
|
||||
get: vi.fn().mockReturnValue({ accountId: 't2_owner', redditUsername: 'owner' }),
|
||||
},
|
||||
},
|
||||
} as unknown as WebContext;
|
||||
const app = express().use('/api', createMediaRouter(context));
|
||||
|
||||
const response = await request(app, '/api/media');
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(await response.json()).toEqual([
|
||||
expect.objectContaining({ id: 'received', sender: 'alice' }),
|
||||
]);
|
||||
});
|
||||
|
||||
it('upgrades historical t2 fields through the chat username map', async () => {
|
||||
const context = {
|
||||
logger: { error: vi.fn() },
|
||||
|
||||
Reference in new issue
Block a user