fix delete of open group messages

pull/1295/head
Audric Ackermann 5 years ago
parent 2c45ff73b2
commit 44349079ab
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -30,7 +30,7 @@ export interface LokiPublicChannelAPI {
body?: string;
},
timestamp: number
): Promise<boolean>;
): Promise<boolean | number>;
}
declare class LokiAppDotNetServerAPI implements LokiAppDotNetServerInterface {

@ -61,10 +61,18 @@ export class MessageQueue implements MessageQueueInterface {
// This is absolutely yucky ... we need to make it not use Promise<boolean>
try {
const result = await MessageSender.sendToOpenGroup(message);
if (result) {
this.events.emit('success', message);
} else {
// sendToOpenGroup returns false if failed or a number if succeeded
if (typeof result === 'boolean') {
this.events.emit('fail', message, error);
} else {
const messageEventData = {
pubKey: message.group.groupId,
timestamp: message.timestamp,
serverId: result,
};
this.events.emit('success', message);
window.Whisper.events.trigger('publicMessageSent', messageEventData);
}
} catch (e) {
console.warn(

@ -98,7 +98,7 @@ function wrapEnvelope(envelope: SignalService.Envelope): Uint8Array {
*/
export async function sendToOpenGroup(
message: OpenGroupMessage
): Promise<boolean> {
): Promise<boolean | number> {
/*
Note: Retrying wasn't added to this but it can be added in the future if needed.
The only problem is that `channelAPI.sendMessage` returns true/false and doesn't throw any error so we can never be sure why sending failed.
@ -125,18 +125,4 @@ export async function sendToOpenGroup(
},
timestamp
);
// TODO: The below should be handled in whichever class calls this
/*
const res = await sendToOpenGroup(message);
if (!res) {
throw new textsecure.PublicChatError('Failed to send public chat message');
}
const messageEventData = {
pubKey,
timestamp: messageTimeStamp,
};
messageEventData.serverId = res;
window.Whisper.events.trigger('publicMessageSent', messageEventData);
*/
}

@ -324,7 +324,7 @@ describe('MessageQueue', () => {
describe('open groups', async () => {
let sendToOpenGroupStub: sinon.SinonStub<
[OpenGroupMessage],
Promise<boolean>
Promise<boolean | number>
>;
beforeEach(() => {
sendToOpenGroupStub = sandbox

Loading…
Cancel
Save