Merge pull request #1109 from vincentbavitz/linked-devs-fixes

Mark Failed Message Send to Slave as Error & Retry
pull/1156/head
Vince 5 years ago committed by GitHub
commit c0677d3a2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2330,6 +2330,7 @@
if (this.get('type') === 'group') {
const groupNumbers = this.getRecipients();
this.set({ left: true });
await window.Signal.Data.updateConversation(this.id, this.attributes, {
Conversation: Whisper.Conversation,
});

@ -1,4 +1,4 @@
/* global Whisper, i18n, textsecure, _ */
/* global Whisper, i18n, textsecure, libloki, _ */
// eslint-disable-next-line func-names
(function() {
@ -179,7 +179,8 @@
this.$el.append(this.dialogView.el);
return this;
},
onSubmit(newMembers) {
async onSubmit(newMembers) {
const _ = window.Lodash;
const ourPK = textsecure.storage.user.getNumber();
const allMembers = window.Lodash.concat(newMembers, [ourPK]);
@ -187,11 +188,31 @@
const notPresentInOld = allMembers.filter(
m => !this.existingMembers.includes(m)
);
const notPresentInNew = this.existingMembers.filter(
m => !allMembers.includes(m)
);
// would be easer with _.xor but for some reason we do not have it
const xor = notPresentInNew.concat(notPresentInOld);
// Filter out all linked devices for cases in which one device
// exists in group, but hasn't yet synced with its other devices.
const getDevicesForRemoved = async () => {
const promises = notPresentInNew.map(member =>
libloki.storage.getPairedDevicesFor(member)
);
const devices = _.flatten(await Promise.all(promises));
return devices;
};
// Get all devices for notPresentInNew
const allDevicesOfMembersToRemove = await getDevicesForRemoved();
// If any extra devices of removed exist in newMembers, ensure that you filter them
const filteredMemberes = allMembers.filter(
member => !_.includes(allDevicesOfMembersToRemove, member)
);
const xor = _.xor(notPresentInNew, notPresentInOld);
if (xor.length === 0) {
window.console.log(
'skipping group update: no detected changes in group member list'
@ -203,7 +224,7 @@
window.doUpdateGroup(
this.groupId,
this.groupName,
allMembers,
filteredMemberes,
this.avatarPath
);
},

@ -319,6 +319,7 @@ OutgoingMessage.prototype = {
// Default ttl to 24 hours if no value provided
async transmitMessage(number, data, timestamp, ttl = 24 * 60 * 60 * 1000) {
const pubKey = number;
try {
// TODO: Make NUM_CONCURRENT_CONNECTIONS a global constant
const options = {
@ -647,6 +648,7 @@ OutgoingMessage.prototype = {
this.timestamp,
ttl
);
if (!this.isGroup && isFriendRequest && !isSessionRequest) {
const conversation = ConversationController.get(destination);
if (conversation) {
@ -660,16 +662,10 @@ OutgoingMessage.prototype = {
this.errors.push(e);
}
});
await Promise.all(promises);
// TODO: the retrySend should only send to the devices
// for which the transmission failed.
// ensure numberCompleted() will execute the callback
this.numbersCompleted += this.errors.length + this.successfulNumbers.length;
// Absorb errors if message sent to at least 1 device
if (this.successfulNumbers.length > 0) {
this.errors = [];
}
this.numbersCompleted += this.successfulNumbers.length;
this.numberCompleted();
},
async buildAndEncrypt(devicePubKey) {

@ -441,22 +441,15 @@ export class ConversationHeader extends React.Component<Props> {
isGroup,
isFriend,
isKickedFromGroup,
isArchived,
isPublic,
isRss,
onResetSession,
onSetDisappearingMessages,
// onShowAllMedia,
onShowGroupMembers,
onShowSafetyNumber,
onArchive,
onMoveToInbox,
timerOptions,
onBlockUser,
onUnblockUser,
// hasNickname,
// onClearNickname,
// onChangeNickname,
} = this.props;
if (isPublic || isRss) {
@ -499,34 +492,14 @@ export class ConversationHeader extends React.Component<Props> {
const blockHandlerMenuItem = !isMe &&
!isGroup &&
!isRss && <MenuItem onClick={blockHandler}>{blockTitle}</MenuItem>;
// const changeNicknameMenuItem = !isMe &&
// !isGroup && (
// <MenuItem onClick={onChangeNickname}>{i18n('changeNickname')}</MenuItem>
// );
// const clearNicknameMenuItem = !isMe &&
// !isGroup &&
// hasNickname && (
// <MenuItem onClick={onClearNickname}>{i18n('clearNickname')}</MenuItem>
// );
const archiveConversationMenuItem = isArchived ? (
<MenuItem onClick={onMoveToInbox}>
{i18n('moveConversationToInbox')}
</MenuItem>
) : (
<MenuItem onClick={onArchive}>{i18n('archiveConversation')}</MenuItem>
);
return (
<React.Fragment>
{/* <MenuItem onClick={onShowAllMedia}>{i18n('viewAllMedia')}</MenuItem> */}
{disappearingMessagesMenuItem}
{showMembersMenuItem}
{showSafetyNumberMenuItem}
{resetSessionMenuItem}
{blockHandlerMenuItem}
{/* {changeNicknameMenuItem}
{clearNicknameMenuItem} */}
{archiveConversationMenuItem}
</React.Fragment>
);
}

Loading…
Cancel
Save