Skip to content

Commit

Permalink
Fix attempt for issue signalapp#3728
Browse files Browse the repository at this point in the history
  • Loading branch information
NFM-8 committed Nov 9, 2019
1 parent 483b2b3 commit 8b1e197
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions js/modules/web_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ function initialize({
sendMessagesUnauth,
setSignedPreKey,
updateDeviceName,
unlinkDevice,
};

function _ajax(param) {
Expand Down Expand Up @@ -670,6 +671,14 @@ function initialize({
});
}

function unlinkDevice(deviceId) {
return _ajax({
call: 'devices',
httpType: 'DELETE',
urlParameters: "/" + deviceId
});
}

function registerKeys(genKeys) {
const keys = {};
keys.identityKey = _btoa(_getString(genKeys.identityKey));
Expand Down
8 changes: 8 additions & 0 deletions js/views/clear_data_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@
error && error.stack ? error.stack : error
);
}
try {
const deviceId = parseInt(textsecure.storage.user.getDeviceId(), 10);
await textsecure.messaging.unlinkDevice(deviceId);
} catch (error) {
window.log.error('Failed to unlink device:',
error && error.stack ? error.stack : error
);
}
window.restart();
},
render_attributes() {
Expand Down
5 changes: 5 additions & 0 deletions libtextsecure/sendmessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,10 @@ MessageSender.prototype = {
return this.server.getStickerPackManifest(packId);
},

unlinkDevice(deviceId) {
return this.server.unlinkDevice(deviceId);
},

sendRequestConfigurationSyncMessage(options) {
const myNumber = textsecure.storage.user.getNumber();
const myDevice = textsecure.storage.user.getDeviceId();
Expand Down Expand Up @@ -1261,6 +1265,7 @@ textsecure.MessageSender = function MessageSenderWrapper(username, password) {
this.getStickerPackManifest = sender.getStickerPackManifest.bind(sender);
this.sendStickerPackSync = sender.sendStickerPackSync.bind(sender);
this.syncViewOnceOpen = sender.syncViewOnceOpen.bind(sender);
this.unlinkDevice = sender.unlinkDevice.bind(sender);
};

textsecure.MessageSender.prototype = {
Expand Down

0 comments on commit 8b1e197

Please sign in to comment.