v0.5.1: bubble for Android 0.5.1 — no double sends when a text with an emoji is cut off mid-send
voip.ms's listing drops emoji, so a send whose reply was lost (here the laptop slept 8 s after Send) never matched its own copy in the listing and went out a second time. Match with the emoji taken out (exact match first), and after an uncertain send only send again once a listing check actually got through; if none can, mark it failed with a note instead.
This commit is contained in:
+24
-1
@@ -3,7 +3,7 @@ import os from 'node:os'
|
||||
import path from 'node:path'
|
||||
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
||||
import { MessageDb } from '../src/main/db'
|
||||
import { sendWithRetry } from '../src/main/send'
|
||||
import { sendWithRetry, UNCHECKED } from '../src/main/send'
|
||||
import { VoipMsError } from '../src/main/voipms'
|
||||
|
||||
let dir: string
|
||||
@@ -59,6 +59,29 @@ describe('sendWithRetry', () => {
|
||||
expect(db.getConversationMessages('5550001111', 'a').map((m) => m.id)).toEqual([99])
|
||||
})
|
||||
|
||||
it('does not resend a text the laptop slept on, though the listing dropped its emoji', async () => {
|
||||
const t = db.insertPending({ did: '5550001111', contact: 'b', direction: 'out', body: 'see you tonight ❤️', ts: 1000 })
|
||||
const cut = Object.assign(new TypeError('fetch failed'), { cause: { code: 'ECONNRESET' } })
|
||||
const attempt = attempts(cut, 99)
|
||||
// Just woken: the first look can't get through, the next one can.
|
||||
const looks = [false, true]
|
||||
const checkSent = async (): Promise<boolean> => {
|
||||
const ok = looks.shift()!
|
||||
if (ok) db.reconcileSent(db.upsertMessages([{ id: 88, did: '5550001111', contact: 'b', direction: 'out', body: 'see you tonight ', ts: 18_000 }]))
|
||||
return ok
|
||||
}
|
||||
await sendWithRetry(t, { db, attempt, checkSent, sleep })
|
||||
expect(attempt.calls).toBe(1)
|
||||
expect(db.getConversationMessages('5550001111', 'b').map((m) => m.id)).toEqual([88])
|
||||
})
|
||||
|
||||
it("marks it failed instead of resending when the listing can't be checked", async () => {
|
||||
const attempt = attempts(timeout(), 99)
|
||||
await sendWithRetry(tempId, { db, attempt, checkSent: async () => false, sleep })
|
||||
expect(attempt.calls).toBe(1)
|
||||
expect(db.getMessage(tempId)).toMatchObject({ status: 'failed', error: UNCHECKED })
|
||||
})
|
||||
|
||||
it('resends right away when the request never left', async () => {
|
||||
const attempt = attempts(offline(), 99)
|
||||
await sendWithRetry(tempId, { db, attempt, checkSent: async () => undefined, sleep })
|
||||
|
||||
Reference in New Issue
Block a user