Record sent chats in messages repo and blur gallery by default
Threads MessagesRepository through ChatService so first outgoing chat messages are persisted for stats, and extends the repo + DB client to support chat-room-keyed lookups. Adds tests covering the new behavior. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
1 parent
2260388dc8
commit
05c95db6bd
10 files changed
+197
-6
No files matched your search
@@ -171,6 +171,40 @@ describe('MessagesRepository', () => {
|
||||
db = repos.db;
|
||||
});
|
||||
|
||||
it('insertChat stores a chat-originated send and getByChatRoomId returns it', () => {
|
||||
const id = messagesRepo.insertChat({
|
||||
recipient: 'alice',
|
||||
subject: 'alice',
|
||||
message: 'hey there',
|
||||
sentAt: 1700000000000,
|
||||
chatRoomId: '!room123:reddit.com',
|
||||
});
|
||||
expect(id).toBeGreaterThan(0);
|
||||
|
||||
const row = messagesRepo.getByChatRoomId('!room123:reddit.com');
|
||||
expect(row).toBeDefined();
|
||||
expect(row!.postId).toBeNull();
|
||||
expect(row!.chatRoomId).toBe('!room123:reddit.com');
|
||||
expect(row!.recipient).toBe('alice');
|
||||
expect(row!.gotResponse).toBe(false);
|
||||
|
||||
messagesRepo.markGotResponse(id);
|
||||
const updated = messagesRepo.getByChatRoomId('!room123:reddit.com');
|
||||
expect(updated!.gotResponse).toBe(true);
|
||||
});
|
||||
|
||||
it('chat-originated rows appear in getRecent and contribute to stats', () => {
|
||||
messagesRepo.insertChat({
|
||||
recipient: 'bob',
|
||||
subject: 'bob',
|
||||
message: 'hi',
|
||||
sentAt: Date.now(),
|
||||
chatRoomId: '!r1:reddit.com',
|
||||
});
|
||||
const recent = messagesRepo.getRecent(10);
|
||||
expect(recent.some((m) => m.chatRoomId === '!r1:reddit.com')).toBe(true);
|
||||
});
|
||||
|
||||
it('inserts and retrieves a message', () => {
|
||||
const messageId = messagesRepo.insert({
|
||||
postId: 'post1',
|
||||
|
||||
Reference in new issue
Block a user