fix: read receipt messages now show expireTimer correctly

pull/2660/head
William Grant 2 years ago
parent 5398f45a26
commit 46ab397a0f

@ -1190,7 +1190,6 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
await this.commit();
// the line below makes sure that getNextExpiringMessage will find this message as expiring.
// getNextExpiringMessage is used on app start to clean already expired messages which should have been removed already, but are not
await this.setToExpire();
const convo = this.getConversation();

@ -31,7 +31,7 @@ async function generateSignature({
// "expire" || ShortenOrExtend || expiry || messages[0] || ... || messages[N]
const verificationString = `expire${shortenOrExtend}${timestamp}${messageHashes.join('')}`;
const verificationData = StringUtils.encode(verificationString, 'utf8');
// console.log(`WIP: generateSignature verificationString ${verificationString}`);
// window.log.info(`WIP: generateSignature verificationString ${verificationString}`);
const message = new Uint8Array(verificationData);
const sodium = await getSodiumRenderer();
@ -91,7 +91,7 @@ async function verifySignature({
const verificationString = `${pubkey.key}${expiryApplied}${hashes.join('')}`;
const verificationData = StringUtils.encode(verificationString, 'utf8');
// console.log(`WIP: verifySignature verificationString`, verificationString);
// window.log.info(`WIP: verifySignature verificationString`, verificationString);
const sodium = await getSodiumRenderer();
try {
@ -120,10 +120,10 @@ async function processExpirationResults(
// TODO need proper typing for swarm and results
const results: Record<string, { hashes: Array<string>; expiry: number }> = {};
// console.log(`WIP: processExpirationResults start`, swarm, messageHashes);
// window.log.info(`WIP: processExpirationResults start`, swarm, messageHashes);
for (const nodeKey of Object.keys(swarm)) {
// console.log(`WIP: processExpirationResults processing nodeKey`, nodeKey, swarm[nodeKey]);
// window.log.info(`WIP: processExpirationResults processing nodeKey`, nodeKey, swarm[nodeKey]);
if (!isEmpty(swarm[nodeKey].failed)) {
const reason = 'Unknown';
const statusCode = '404';
@ -197,7 +197,7 @@ async function expireOnNodes(targetNode: Snode, params: ExpireParams) {
// parsed.swarm,
// params.messages
// );
// console.log(`WIP: expireOnNodes attempt complete. Here are the results`, expirationResults);
// window.log.info(`WIP: expireOnNodes attempt complete. Here are the results`, expirationResults);
return true;
} catch (e) {
@ -223,7 +223,7 @@ type ExpireMessageOnSnodeProps = {
export async function expireMessageOnSnode(props: ExpireMessageOnSnodeProps) {
const { messageHash, expireTimer, extend, shorten } = props;
console.log(`WIP: expireMessageOnSnode running!`);
window.log.info(`WIP: expireMessageOnSnode running!`);
if (extend && shorten) {
window.log.info(
@ -289,7 +289,7 @@ export async function expireMessageOnSnode(props: ExpireMessageOnSnodeProps) {
try {
const firstSuccessSnode = await firstTrue(promises);
snode = firstSuccessSnode;
console.log(`WIP: expireMessageOnSnode firstSuccessSnode`, firstSuccessSnode);
window.log.info(`WIP: expireMessageOnSnode firstSuccessSnode`, firstSuccessSnode);
} catch (e) {
const snodeStr = snode ? `${snode.ip}:${snode.port}` : 'null';
window?.log?.warn(

@ -45,9 +45,7 @@ async function onReadReceipt(receipt: { source: string; timestamp: number; readA
// readBy is only used for private conversations
// we do not care of who read it. If the length is > 0 , it is read and false otherwise
let readBy = message.get('read_by') || [];
// TODO Fix this with read receipts
// tslint:disable-next-line: no-unnecessary-initializer
const expirationStartTimestamp = undefined;
const expirationStartTimestamp = message.get('expirationStartTimestamp') || undefined;
if (!readBy.length) {
readBy.push(receipt.source);
@ -62,7 +60,8 @@ async function onReadReceipt(receipt: { source: string; timestamp: number; readA
sent: true,
});
if (message.isExpiring() && !expirationStartTimestamp) {
// I think this is redundent since expirationStartTimestamp is always undefined and this the function will null return
if (message.isExpiring() && expirationStartTimestamp) {
// This will save the message for us while starting the timer
await message.setToExpire();
} else {

Loading…
Cancel
Save