SHA256
Реализовать SHiNE_DM v1 с E2EE и tombstone
This commit is contained in:
@@ -660,6 +660,45 @@ export function addSignedMessageToChat({
|
||||
return true;
|
||||
}
|
||||
|
||||
export function deleteSignedMessageByBaseKey(chatId, baseKey) {
|
||||
const normalizedChatId = normalizeDmChatId(chatId);
|
||||
const normalizedBaseKey = String(baseKey || '').trim();
|
||||
if (!normalizedChatId || !normalizedBaseKey) return false;
|
||||
const list = getChatMessages(normalizedChatId);
|
||||
let changed = false;
|
||||
for (let i = list.length - 1; i >= 0; i -= 1) {
|
||||
const row = list[i];
|
||||
if (String(row?.baseKey || '').trim() !== normalizedBaseKey) continue;
|
||||
changed = true;
|
||||
removeStoredMessageRecord(String(row?.messageKey || '').trim());
|
||||
list.splice(i, 1);
|
||||
}
|
||||
if (changed) {
|
||||
sortChatMessagesInPlace(normalizedChatId);
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
export function deleteConversationMessagesBefore(chatId, boundaryTimeMs) {
|
||||
const normalizedChatId = normalizeDmChatId(chatId);
|
||||
const boundary = Number(boundaryTimeMs || 0);
|
||||
if (!normalizedChatId || !Number.isFinite(boundary) || boundary <= 0) return 0;
|
||||
const list = getChatMessages(normalizedChatId);
|
||||
let removed = 0;
|
||||
for (let i = list.length - 1; i >= 0; i -= 1) {
|
||||
const row = list[i];
|
||||
const rowTime = resolveChatMessageTimeMs(row);
|
||||
if (!Number.isFinite(rowTime) || rowTime >= boundary) continue;
|
||||
removed += 1;
|
||||
removeStoredMessageRecord(String(row?.messageKey || '').trim());
|
||||
list.splice(i, 1);
|
||||
}
|
||||
if (removed > 0) {
|
||||
sortChatMessagesInPlace(normalizedChatId);
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
export function markChatRead(chatId) {
|
||||
const normalizedChatId = normalizeDmChatId(chatId);
|
||||
const list = getChatMessages(normalizedChatId);
|
||||
|
||||
Reference in New Issue
Block a user