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') { if (this.get('type') === 'group') {
const groupNumbers = this.getRecipients(); const groupNumbers = this.getRecipients();
this.set({ left: true }); this.set({ left: true });
await window.Signal.Data.updateConversation(this.id, this.attributes, { await window.Signal.Data.updateConversation(this.id, this.attributes, {
Conversation: Whisper.Conversation, Conversation: Whisper.Conversation,
}); });

@ -1,4 +1,4 @@
/* global Whisper, i18n, textsecure, _ */ /* global Whisper, i18n, textsecure, libloki, _ */
// eslint-disable-next-line func-names // eslint-disable-next-line func-names
(function() { (function() {
@ -179,7 +179,8 @@
this.$el.append(this.dialogView.el); this.$el.append(this.dialogView.el);
return this; return this;
}, },
onSubmit(newMembers) { async onSubmit(newMembers) {
const _ = window.Lodash;
const ourPK = textsecure.storage.user.getNumber(); const ourPK = textsecure.storage.user.getNumber();
const allMembers = window.Lodash.concat(newMembers, [ourPK]); const allMembers = window.Lodash.concat(newMembers, [ourPK]);
@ -187,11 +188,31 @@
const notPresentInOld = allMembers.filter( const notPresentInOld = allMembers.filter(
m => !this.existingMembers.includes(m) m => !this.existingMembers.includes(m)
); );
const notPresentInNew = this.existingMembers.filter( const notPresentInNew = this.existingMembers.filter(
m => !allMembers.includes(m) 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) { if (xor.length === 0) {
window.console.log( window.console.log(
'skipping group update: no detected changes in group member list' 'skipping group update: no detected changes in group member list'
@ -203,7 +224,7 @@
window.doUpdateGroup( window.doUpdateGroup(
this.groupId, this.groupId,
this.groupName, this.groupName,
allMembers, filteredMemberes,
this.avatarPath this.avatarPath
); );
}, },

@ -319,6 +319,7 @@ OutgoingMessage.prototype = {
// Default ttl to 24 hours if no value provided // Default ttl to 24 hours if no value provided
async transmitMessage(number, data, timestamp, ttl = 24 * 60 * 60 * 1000) { async transmitMessage(number, data, timestamp, ttl = 24 * 60 * 60 * 1000) {
const pubKey = number; const pubKey = number;
try { try {
// TODO: Make NUM_CONCURRENT_CONNECTIONS a global constant // TODO: Make NUM_CONCURRENT_CONNECTIONS a global constant
const options = { const options = {
@ -647,6 +648,7 @@ OutgoingMessage.prototype = {
this.timestamp, this.timestamp,
ttl ttl
); );
if (!this.isGroup && isFriendRequest && !isSessionRequest) { if (!this.isGroup && isFriendRequest && !isSessionRequest) {
const conversation = ConversationController.get(destination); const conversation = ConversationController.get(destination);
if (conversation) { if (conversation) {
@ -660,16 +662,10 @@ OutgoingMessage.prototype = {
this.errors.push(e); this.errors.push(e);
} }
}); });
await Promise.all(promises); 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.successfulNumbers.length;
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.numberCompleted(); this.numberCompleted();
}, },
async buildAndEncrypt(devicePubKey) { async buildAndEncrypt(devicePubKey) {

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

Loading…
Cancel
Save