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(); await this.commit();
// the line below makes sure that getNextExpiringMessage will find this message as expiring. // 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 // getNextExpiringMessage is used on app start to clean already expired messages which should have been removed already, but are not
await this.setToExpire(); await this.setToExpire();
const convo = this.getConversation(); const convo = this.getConversation();

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

@ -45,9 +45,7 @@ async function onReadReceipt(receipt: { source: string; timestamp: number; readA
// readBy is only used for private conversations // 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 // 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') || []; let readBy = message.get('read_by') || [];
// TODO Fix this with read receipts const expirationStartTimestamp = message.get('expirationStartTimestamp') || undefined;
// tslint:disable-next-line: no-unnecessary-initializer
const expirationStartTimestamp = undefined;
if (!readBy.length) { if (!readBy.length) {
readBy.push(receipt.source); readBy.push(receipt.source);
@ -62,7 +60,8 @@ async function onReadReceipt(receipt: { source: string; timestamp: number; readA
sent: true, 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 // This will save the message for us while starting the timer
await message.setToExpire(); await message.setToExpire();
} else { } else {

Loading…
Cancel
Save