|
|
|
@ -625,7 +625,7 @@ export async function saveMessages(arrayOfMessages: Array<MessageAttributes>): P
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function removeMessage(id: string): Promise<void> {
|
|
|
|
|
const message = await getMessageById(id);
|
|
|
|
|
const message = await getMessageById(id, true);
|
|
|
|
|
|
|
|
|
|
// Note: It's important to have a fully database-hydrated model to delete here because
|
|
|
|
|
// it needs to delete all associated on-disk files along with the database delete.
|
|
|
|
@ -647,11 +647,17 @@ export async function getMessageIdsFromServerIds(
|
|
|
|
|
return channels.getMessageIdsFromServerIds(serverIds, conversationId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function getMessageById(id: string): Promise<MessageModel | null> {
|
|
|
|
|
export async function getMessageById(
|
|
|
|
|
id: string,
|
|
|
|
|
skipTimerInit: boolean = false
|
|
|
|
|
): Promise<MessageModel | null> {
|
|
|
|
|
const message = await channels.getMessageById(id);
|
|
|
|
|
if (!message) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
if (skipTimerInit) {
|
|
|
|
|
message.skipTimerInit = skipTimerInit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new MessageModel(message);
|
|
|
|
|
}
|
|
|
|
@ -725,13 +731,18 @@ export async function getUnreadCountByConversation(conversationId: string): Prom
|
|
|
|
|
|
|
|
|
|
export async function getMessagesByConversation(
|
|
|
|
|
conversationId: string,
|
|
|
|
|
{ limit = 100, receivedAt = Number.MAX_VALUE, type = '%' }
|
|
|
|
|
{ limit = 100, receivedAt = Number.MAX_VALUE, type = '%', skipTimerInit = false }
|
|
|
|
|
): Promise<MessageCollection> {
|
|
|
|
|
const messages = await channels.getMessagesByConversation(conversationId, {
|
|
|
|
|
limit,
|
|
|
|
|
receivedAt,
|
|
|
|
|
type,
|
|
|
|
|
});
|
|
|
|
|
if (skipTimerInit) {
|
|
|
|
|
for (const message of messages) {
|
|
|
|
|
message.skipTimerInit = skipTimerInit;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return new MessageCollection(messages);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|