be sure to register outgoing message for medium groups when created

This commit is contained in:
Audric Ackermann 2020-12-01 17:14:43 +11:00
parent 184b1984c3
commit 727261b36a
No known key found for this signature in database
GPG key ID: 999F434D76324AD4
3 changed files with 15 additions and 6 deletions

View file

@ -2,6 +2,8 @@ import React from 'react';
import { Provider } from 'react-redux';
import { bindActionCreators } from 'redux';
import { getMessageQueue } from '../../session';
import { OpenGroupMessage } from '../../session/messages/outgoing';
import { RawMessage } from '../../session/types';
import { createStore } from '../../state/createStore';
import { actions as conversationActions } from '../../state/ducks/conversations';
import { actions as userActions } from '../../state/ducks/user';
@ -117,7 +119,7 @@ export class SessionInboxView extends React.Component<Props, State> {
);
}
private async fetchHandleMessageSentData(m: any) {
private async fetchHandleMessageSentData(m: RawMessage | OpenGroupMessage) {
// nobody is listening to this freshly fetched message .trigger calls
const tmpMsg = await window.Signal.Data.getMessageById(m.identifier, {
Message: window.Whisper.Message,
@ -146,7 +148,7 @@ export class SessionInboxView extends React.Component<Props, State> {
}
private async handleMessageSentSuccess(
sentMessage: any,
sentMessage: RawMessage | OpenGroupMessage,
wrappedEnvelope: any
) {
const fetchedData = await this.fetchHandleMessageSentData(sentMessage);
@ -155,10 +157,12 @@ export class SessionInboxView extends React.Component<Props, State> {
}
const { msg } = fetchedData;
msg.handleMessageSentSuccess(sentMessage, wrappedEnvelope);
void msg.handleMessageSentSuccess(sentMessage, wrappedEnvelope);
}
private async handleMessageSentFailure(sentMessage: any, error: any) {
private async handleMessageSentFailure(
sentMessage: RawMessage | OpenGroupMessage,
error: any) {
const fetchedData = await this.fetchHandleMessageSentData(sentMessage);
if (!fetchedData) {
return;

View file

@ -117,6 +117,8 @@ export async function createMediumGroup(
};
const dbMessage = await addUpdateMessage(convo, groupDiff, 'outgoing');
window.MessageController.register(dbMessage.id, dbMessage);
// be sure to call this before sending the message.
// the sending pipeline needs to know from GroupUtils when a message is for a medium group
@ -175,6 +177,7 @@ export async function createLegacyGroup(
};
const dbMessage = await addUpdateMessage(convo, diff, 'outgoing');
window.MessageController.register(dbMessage.id, dbMessage);
await sendGroupUpdate(convo, diff, groupDetails, dbMessage.id);
@ -214,6 +217,7 @@ export async function leaveMediumGroup(groupId: string) {
sent_at: now,
received_at: now,
});
window.MessageController.register(dbMessage.id, dbMessage);
const ourPrimary = await UserUtil.getPrimary();
const members = convo.get('members').filter(m => m !== ourPrimary.key);
@ -407,6 +411,7 @@ export async function initiateGroupUpdate(
}
const dbMessage = await addUpdateMessage(convo, diff, 'outgoing');
window.MessageController.register(dbMessage.id, dbMessage);
await sendGroupUpdate(convo, diff, updateObj, dbMessage.id);
}

View file

@ -2,14 +2,14 @@ import { EncryptionType } from './EncryptionType';
// TODO: Should we store failure count on raw messages??
// Might be better to have a seperate interface which takes in a raw message aswell as a failure count
export interface RawMessage {
export type RawMessage = {
identifier: string;
plainTextBuffer: Uint8Array;
timestamp: number;
device: string;
ttl: number;
encryption: EncryptionType;
}
};
// For building RawMessages from JSON
export interface PartialRawMessage {