added polling for receiving live messages

This commit is contained in:
erik-sn committed 2020-11-21 09:50:36 -05:00
1 parent be5c038128
commit c5b1e3d8c7
2 files changed
+22 -1

No files matched your search

+12 -1
View File
@@ -69,7 +69,7 @@ async function getMessageGroups(userIdentifier: string): Promise<UnformattedMess
LEFT OUTER JOIN users on users.identifier = npwd_messages_groups.participant_identifier
LEFT OUTER JOIN npwd_messages_labels on npwd_messages_labels.group_id = npwd_messages_groups.group_id
LEFT OUTER JOIN npwd_phone_contacts on npwd_phone_contacts.number = users.phone_number
WHERE npwd_messages_groups.user_identifier = ? AND npwd_messages_groups.participant_identifier != ?
WHERE npwd_messages_groups.participant_identifier = ?
ORDER BY npwd_messages_groups.createdAt DESC
`
const [results] = await pool.query(query, [ userIdentifier, userIdentifier]);
@@ -180,6 +180,17 @@ async function checkIfMessageGroupExists(groupId: string): Promise<boolean> {
return count > 0;
}
async function getParticipantsByGroup(groupId: string): Promise<string[]> {
const query = `
SELECT participant_identifier as identifier
FROM npwd_messages_groups
WHERE group_id = ?;
`;
const [results] = await pool.query(query, [ groupId]);
const rows = (<any>results);
return rows.map((row: any) => row.identifier);
}
/**
* Consolidate raw message groups into a mapping that groups participants
* by the message group. The goal of this is to reduce the rows of message