Merge pull request #1231 from Bilb/fix-open-groups-ui

pull/1233/head
Audric Ackermann 5 years ago committed by GitHub
commit 4381d0135f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1903,16 +1903,26 @@
await this.sendClosedGroupMessageWithSync(groupUpdateMessage, recipients); await this.sendClosedGroupMessageWithSync(groupUpdateMessage, recipients);
const expireUpdate = { if (groupUpdate.joined && groupUpdate.joined.length) {
timestamp: Date.now(), const expireUpdate = {
expireTimer: this.get('expireTimer'), timestamp: Date.now(),
groupId: this.get('id'), expireTimer: this.get('expireTimer'),
}; groupId: this.get('id'),
};
const expirationTimerMessage = new libsession.Messages.Outgoing.ExpirationTimerUpdateMessage( const expirationTimerMessage = new libsession.Messages.Outgoing.ExpirationTimerUpdateMessage(
expireUpdate expireUpdate
); );
await libsession.getMessageQueue().sendToGroup(expirationTimerMessage); await Promise.all(
groupUpdate.joined.map(async join => {
const device = new libsession.Types.PubKey(join);
await libsession
.getMessageQueue()
.sendUsingMultiDevice(device, expirationTimerMessage)
.catch(log.error);
})
);
}
}, },
async sendGroupInfo(recipient) { async sendGroupInfo(recipient) {

@ -1,6 +1,7 @@
import { LibTextsecureCryptoInterface } from './crypto'; import { LibTextsecureCryptoInterface } from './crypto';
export interface LibTextsecure { export interface LibTextsecure {
messaging: any;
crypto: LibTextsecureCryptoInterface; crypto: LibTextsecureCryptoInterface;
storage: any; storage: any;
SendMessageNetworkError: any; SendMessageNetworkError: any;

@ -419,13 +419,14 @@ MessageSender.prototype = {
return Promise.all(syncPromises); return Promise.all(syncPromises);
}, },
async sendOpenGroupsSyncMessage(conversations) { async sendOpenGroupsSyncMessage(convos) {
// If we havn't got a primaryDeviceKey then we are in the middle of pairing // If we havn't got a primaryDeviceKey then we are in the middle of pairing
// primaryDevicePubKey is set to our own number if we are the master device // primaryDevicePubKey is set to our own number if we are the master device
const primaryDeviceKey = window.storage.get('primaryDevicePubKey'); const primaryDeviceKey = window.storage.get('primaryDevicePubKey');
if (!primaryDeviceKey) { if (!primaryDeviceKey) {
return Promise.resolve(); return Promise.resolve();
} }
const conversations = Array.isArray(convos) ? convos : [convos];
const openGroupsConvos = await libsession.Utils.SyncMessageUtils.filterOpenGroupsConvos( const openGroupsConvos = await libsession.Utils.SyncMessageUtils.filterOpenGroupsConvos(
conversations conversations
@ -453,9 +454,9 @@ MessageSender.prototype = {
}, },
syncReadMessages(reads) { syncReadMessages(reads) {
const myDevice = textsecure.storage.user.getDeviceId(); const myDevice = textsecure.storage.user.getDeviceId();
// FIXME audric currently not in used // FIXME currently not in used
if (myDevice !== 1 && myDevice !== '1') { if (myDevice !== 1 && myDevice !== '1') {
const syncReadMessages = new libsession.Messages.Outgoing.OpenGroupSyncMessage( const syncReadMessages = new libsession.Messages.Outgoing.SyncReadMessage(
{ {
readMessages: reads, readMessages: reads,
} }
@ -467,7 +468,7 @@ MessageSender.prototype = {
}, },
async syncVerification(destination, state, identityKey) { async syncVerification(destination, state, identityKey) {
const myDevice = textsecure.storage.user.getDeviceId(); const myDevice = textsecure.storage.user.getDeviceId();
// FIXME currently not in used
if (myDevice === 1 || myDevice === '1') { if (myDevice === 1 || myDevice === '1') {
return Promise.resolve(); return Promise.resolve();
} }

@ -487,6 +487,19 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
this.setState({ loading: true }); this.setState({ loading: true });
} }
}); });
const openGroupConversation = await OpenGroup.getConversation(serverUrl);
if (openGroupConversation) {
// if no errors happened, trigger a sync with just this open group
// so our other devices joins it
await window.textsecure.messaging.sendOpenGroupsSyncMessage(
openGroupConversation
);
} else {
window.console.error(
'Joined an opengroup but did not find ther corresponding conversation'
);
}
} catch (e) { } catch (e) {
window.console.error('Failed to connect to server:', e); window.console.error('Failed to connect to server:', e);
window.pushToast({ window.pushToast({

Loading…
Cancel
Save