refactor(db): collapse three markRead variants into markMessageReadForReader (P1-16)
This commit is contained in:
1 parent
62050c9c05
commit
43a03aa5e9
4 files changed
+3
-35
No files matched your search
@@ -227,19 +227,6 @@ export function buildMessageMethods(
|
||||
return readAll<AgentMessageRecord>(sql, ...params);
|
||||
},
|
||||
|
||||
markMessageRead(messageId: string, companyId: string): void {
|
||||
const ts = nowIso();
|
||||
getDb()
|
||||
.prepare(
|
||||
`insert into agent_message_reads (message_id, agent_id, read_at)
|
||||
select id, ?, ?
|
||||
from agent_messages
|
||||
where id = ? and company_id = ?
|
||||
on conflict(message_id, agent_id) do update set read_at = excluded.read_at`,
|
||||
)
|
||||
.run(BOARD_READER_ID, ts, messageId, companyId);
|
||||
},
|
||||
|
||||
markMessageReadForReader(
|
||||
messageId: string,
|
||||
companyId: string,
|
||||
@@ -256,22 +243,5 @@ export function buildMessageMethods(
|
||||
)
|
||||
.run(readerAgentId ?? BOARD_READER_ID, ts, messageId, companyId);
|
||||
},
|
||||
|
||||
markAgentMessageRead(
|
||||
messageId: string,
|
||||
companyId: string,
|
||||
agentId: string,
|
||||
): void {
|
||||
const ts = nowIso();
|
||||
getDb()
|
||||
.prepare(
|
||||
`insert into agent_message_reads (message_id, agent_id, read_at)
|
||||
select id, ?, ?
|
||||
from agent_messages
|
||||
where id = ? and company_id = ?
|
||||
on conflict(message_id, agent_id) do update set read_at = excluded.read_at`,
|
||||
)
|
||||
.run(agentId, ts, messageId, companyId);
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user