feat: Add notifications
This commit is contained in:
18
electron/cqrs/queries/handlers/getMessagesSince.ts
Normal file
18
electron/cqrs/queries/handlers/getMessagesSince.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { DataSource, MoreThan } from 'typeorm';
|
||||
import { MessageEntity } from '../../../entities';
|
||||
import { GetMessagesSinceQuery } from '../../types';
|
||||
import { rowToMessage } from '../../mappers';
|
||||
|
||||
export async function handleGetMessagesSince(query: GetMessagesSinceQuery, dataSource: DataSource) {
|
||||
const repo = dataSource.getRepository(MessageEntity);
|
||||
const { roomId, sinceTimestamp } = query.payload;
|
||||
const rows = await repo.find({
|
||||
where: {
|
||||
roomId,
|
||||
timestamp: MoreThan(sinceTimestamp)
|
||||
},
|
||||
order: { timestamp: 'ASC' }
|
||||
});
|
||||
|
||||
return rows.map(rowToMessage);
|
||||
}
|
||||
Reference in New Issue
Block a user