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; body?: string;
}, },
timestamp: number timestamp: number
): Promise<boolean>; ): Promise<boolean | number>;
} }
declare class LokiAppDotNetServerAPI implements LokiAppDotNetServerInterface { 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> // This is absolutely yucky ... we need to make it not use Promise<boolean>
try { try {
const result = await MessageSender.sendToOpenGroup(message); const result = await MessageSender.sendToOpenGroup(message);
if (result) { // sendToOpenGroup returns false if failed or a number if succeeded
this.events.emit('success', message); if (typeof result === 'boolean') {
} else {
this.events.emit('fail', message, error); 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) { } catch (e) {
console.warn( console.warn(

@ -98,7 +98,7 @@ function wrapEnvelope(envelope: SignalService.Envelope): Uint8Array {
*/ */
export async function sendToOpenGroup( export async function sendToOpenGroup(
message: OpenGroupMessage message: OpenGroupMessage
): Promise<boolean> { ): Promise<boolean | number> {
/* /*
Note: Retrying wasn't added to this but it can be added in the future if needed. 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. 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 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 () => { describe('open groups', async () => {
let sendToOpenGroupStub: sinon.SinonStub< let sendToOpenGroupStub: sinon.SinonStub<
[OpenGroupMessage], [OpenGroupMessage],
Promise<boolean> Promise<boolean | number>
>; >;
beforeEach(() => { beforeEach(() => {
sendToOpenGroupStub = sandbox sendToOpenGroupStub = sandbox

Loading…
Cancel
Save