remove the forceSave option for unprocessed message too

pull/1495/head
Audric Ackermann 4 years ago
parent 8a800cf58c
commit bb3641b39a

@ -2141,50 +2141,28 @@ async function getNextExpiringMessage() {
}
/* Unproccessed a received messages not yet processed */
async function saveUnprocessed(data, { forceSave } = {}) {
async function saveUnprocessed(data) {
const { id, timestamp, version, attempts, envelope, senderIdentity } = data;
if (!id) {
throw new Error(`saveUnprocessed: id was falsey: ${id}`);
}
if (forceSave) {
await db.run(
`INSERT INTO unprocessed (
id,
timestamp,
version,
attempts,
envelope,
senderIdentity
) values (
$id,
$timestamp,
$version,
$attempts,
$envelope,
$senderIdentity
);`,
{
$id: id,
$timestamp: timestamp,
$version: version,
$attempts: attempts,
$envelope: envelope,
$senderIdentity: senderIdentity,
}
);
return id;
}
await db.run(
`UPDATE unprocessed SET
timestamp = $timestamp,
version = $version,
attempts = $attempts,
envelope = $envelope,
senderIdentity = $senderIdentity
WHERE id = $id;`,
`INSERT OR REPLACE INTO unprocessed (
id,
timestamp,
version,
attempts,
envelope,
senderIdentity
) values (
$id,
$timestamp,
$version,
$attempts,
$envelope,
$senderIdentity
);`,
{
$id: id,
$timestamp: timestamp,

@ -982,9 +982,7 @@ async function saveAllMessages(rawMessages) {
const { conversationId } = messages[0];
await window.Signal.Data.saveMessages(messages, {
forceSave: true,
});
await window.Signal.Data.saveMessages(messages);
window.log.info(
'Saved',

@ -699,9 +699,7 @@ export async function saveMessages(
arrayOfMessages: any,
options?: { forceSave: boolean }
): Promise<void> {
await channels.saveMessages(_cleanData(arrayOfMessages), {
forceSave: options?.forceSave,
});
await channels.saveMessages(_cleanData(arrayOfMessages));
}
export async function removeMessage(id: string): Promise<void> {
@ -872,16 +870,8 @@ export async function getUnprocessedById(id: string): Promise<any> {
return channels.getUnprocessedById(id);
}
export async function saveUnprocessed(
data: any,
options?: {
forceSave: boolean;
}
): Promise<string> {
const id = await channels.saveUnprocessed(
_cleanData(data),
options?.forceSave || false
);
export async function saveUnprocessed(data: any): Promise<string> {
const id = await channels.saveUnprocessed(_cleanData(data));
return id;
}

@ -128,7 +128,7 @@ export interface MessageAttributesOptionals {
export const fillMessageAttributesWithDefaults = (
optAttributes: MessageAttributesOptionals
): MessageAttributes => {
//FIXME audric to do put the default
//FIXME to do put the default
return _.defaults(optAttributes, {
expireTimer: 0, // disabled
id: uuidv4(),

@ -24,6 +24,7 @@ export async function addToCache(
plaintext: ArrayBuffer
) {
const { id } = envelope;
window.log.info(`adding to cache envelope: ${id}`);
const encodedEnvelope = StringUtils.decode(plaintext, 'base64');
const data: any = {
@ -37,7 +38,7 @@ export async function addToCache(
if (envelope.senderIdentity) {
data.senderIdentity = envelope.senderIdentity;
}
return saveUnprocessed(data, { forceSave: true });
return saveUnprocessed(data);
}
async function fetchAllFromCache(): Promise<Array<any>> {

@ -456,7 +456,6 @@ export function initIncomingMessage(data: MessageCreationData): MessageModel {
serverTimestamp,
} = data;
const type = 'incoming';
const messageGroupId = message?.group?.id;
let groupId =
messageGroupId && messageGroupId.length > 0 ? messageGroupId : null;
@ -473,7 +472,7 @@ export function initIncomingMessage(data: MessageCreationData): MessageModel {
serverTimestamp,
received_at: receivedAt || Date.now(),
conversationId: groupId ?? source,
type,
type: 'incoming',
direction: 'incoming', // +
unread: 1, // +
isPublic, // +
@ -484,7 +483,6 @@ export function initIncomingMessage(data: MessageCreationData): MessageModel {
function createSentMessage(data: MessageCreationData): MessageModel {
const now = Date.now();
let sentTo = [];
const {
timestamp,

@ -109,7 +109,6 @@ async function handleRequestDetail(
options: ReqOptions,
lastPromise: Promise<any>
): Promise<void> {
const { textsecure } = window;
const envelope: any = SignalService.Envelope.decode(plaintext);
// After this point, decoding errors are not the server's

Loading…
Cancel
Save