2015-09-07 21:53:43 +00:00
|
|
|
/*
|
|
|
|
* vim: ts=4:sw=4:expandtab
|
2014-05-04 06:34:13 +00:00
|
|
|
*/
|
|
|
|
|
Finish abstracting native client
Firstly, don't initialize textsecure.nativclient unless the browser
supports it. The mimetype-check trick is hewn from nacl-common.js.
Secondly, nativeclient crypto functions will all automatically wait for
the module to load before sending messages, so we needn't register any
onload callbacks outside nativeclient.js. (Previously, if you wanted to
do crypto with native client, you would have to register a call back and
wait for the module to load.) Now that the native client crypto is
encapsulated behind a nice interface, it can handle all that
onload-callback jazz internally: if the module isn't loaded when you
call a nativeclient function, return a promise that waits for the load
callback, and eventually resolves with the result of the requested
command. This removes the need for textsecure.registerOnLoadCallback.
Finally, although native client has its quirks, it's significantly
faster than the alternative (emscripten compiled js), so this commit
also lets the crypto backend use native client opportunistically, if
it's available, falling back to js if not, which should make us
compatible with older versions of chrome and chromium.
2014-11-09 01:26:20 +00:00
|
|
|
;(function() {
|
|
|
|
'use strict';
|
2016-08-09 23:11:46 +00:00
|
|
|
window.onInvalidStateError = function(e) {
|
|
|
|
console.log(e);
|
|
|
|
};
|
|
|
|
|
2016-02-03 01:55:27 +00:00
|
|
|
console.log('background page reloaded');
|
2017-04-13 19:10:42 +00:00
|
|
|
console.log('environment:', window.config.environment);
|
2015-09-25 18:10:25 +00:00
|
|
|
|
2017-07-25 01:43:35 +00:00
|
|
|
var initialLoadComplete = false;
|
2017-07-28 01:38:41 +00:00
|
|
|
window.owsDesktopApp = {};
|
2015-05-23 00:06:49 +00:00
|
|
|
|
Beta versions support: SxS support, in-app env/instance display (#1606)
* Script for beta config; unique data dir, in-app env/type display
To release a beta build, increment the version and add -beta-N to the
end, then go through all the standard release activities.
The prepare-build npm script then updates key bits of the package.json
to ensure that the beta build can be installed alongside a production
build. This includes a new name ('Signal Beta') and a different location
for application data.
Note: Beta builds can be installed alongside production builds.
As part of this, a couple new bits of data are shown across the app:
- Environment (development or test, not shown if production)
- App Instance (disabled in production; used for multiple accounts)
These are shown in:
- The window title - both environment and app instance. You can tell
beta builds because the app name, preceding these data bits, is
different.
- The about window - both environment and app instance. You can tell
beta builds from the version number.
- The header added to the debug log - just environment. The version
number will tell us if it's a beta build, and app instance isn't
helpful.
* Turn on single-window mode in non-production modes
Because it's really frightening when you see 'unable to read from db'
errors in the console.
* aply.sh: More instructions for initial setup and testing
* Gruntfile: Get consistent with use of package.json datas
* Linux: manually update desktop keys, since macros not available
2017-10-30 20:57:13 +00:00
|
|
|
var title = window.config.name;
|
|
|
|
if (window.config.environment !== 'production') {
|
|
|
|
title += ' - ' + window.config.environment;
|
|
|
|
}
|
|
|
|
if (window.config.appInstance) {
|
|
|
|
title += ' - ' + window.config.appInstance;
|
|
|
|
}
|
|
|
|
window.config.title = window.document.title = title;
|
|
|
|
|
2015-09-25 18:10:25 +00:00
|
|
|
// start a background worker for ecc
|
2017-03-08 00:54:46 +00:00
|
|
|
textsecure.startWorker('js/libsignal-protocol-worker.js');
|
2017-05-07 21:18:22 +00:00
|
|
|
Whisper.KeyChangeListener.init(textsecure.storage.protocol);
|
2017-05-22 22:24:24 +00:00
|
|
|
textsecure.storage.protocol.on('removePreKey', function() {
|
|
|
|
getAccountManager().refreshPreKeys();
|
|
|
|
});
|
2015-09-01 23:56:17 +00:00
|
|
|
|
2017-04-13 17:47:30 +00:00
|
|
|
var SERVER_URL = window.config.serverUrl;
|
2017-09-11 16:50:35 +00:00
|
|
|
var CDN_URL = window.config.cdnUrl;
|
2015-09-22 00:05:19 +00:00
|
|
|
var messageReceiver;
|
|
|
|
window.getSocketStatus = function() {
|
|
|
|
if (messageReceiver) {
|
|
|
|
return messageReceiver.getStatus();
|
|
|
|
} else {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
};
|
2017-04-12 00:50:13 +00:00
|
|
|
Whisper.events = _.clone(Backbone.Events);
|
2017-02-14 19:27:59 +00:00
|
|
|
var accountManager;
|
2015-09-01 19:57:02 +00:00
|
|
|
window.getAccountManager = function() {
|
2017-02-14 19:27:59 +00:00
|
|
|
if (!accountManager) {
|
|
|
|
var USERNAME = storage.get('number_id');
|
|
|
|
var PASSWORD = storage.get('password');
|
|
|
|
accountManager = new textsecure.AccountManager(
|
Certificate pinning via node XMLHttpRequest implementation (#1394)
* Add certificate pinning on https service requests
Make https requests to the server using node apis instead of browser apis, so we
can specify our own CA list, which contains only our own CA.
This protects us from MITM by a rogue CA.
As a bonus, this let's us drop the use of non-standard ports and just use good
ol' default 443 all the time, at least for http requests.
// FREEBIE
* Make certificateAuthorities an option on requests
Modify node-based xhr implementation based on driverdan/node-XMLHttpRequest,
adding support for setting certificate authorities on each request.
This allows us to pin our master CA for requests to the server and cdn but not
to the s3 attachment server, for instance. Also fix an exception when sending
binary data in a request: it is submitted as an array buffer, and must be
converted to a node Buffer since we are now using a node based request api.
// FREEBIE
* Import node-based xhr implementation
Add a copy of https://github.com/driverdan/node-XMLHttpRequest@86ff70e, and
expose it to the renderer in the preload script.
In later commits this module will be extended to support custom certificate
authorities.
// FREEBIE
* Support "arraybuffer" responseType on requests
When fetching attachments, we want the result as binary data rather than a utf8
string. This lets our node-based XMLHttpRequest honor the responseType property
if it is set on the xhr.
Note that naively using the raw `.buffer` from a node Buffer won't work, since
it is a reuseable backing buffer that is often much larger than the actual
content defined by the Buffer's offset and length.
Instead, we'll prepare a return buffer based on the response's content length
header, and incrementally write chunks of data into it as they arrive.
// FREEBIE
* Switch to self-signed server endpoint
* Log more error info on failed requests
With the node-based xhr, relevant error info are stored in statusText and
responseText when a request fails.
// FREEBIE
* Add node-based websocket w/ support for custom CA
// FREEBIE
* Support handling array buffers instead of blobs
Our node-based websocket calls onmessage with an arraybuffer instead of a blob.
For robustness (on the off chance we switch or update the socket implementation
agian) I've kept the machinery for converting blobs to array buffers.
// FREEBIE
* Destroy all wacky server ports
// FREEBIE
2017-09-01 15:58:58 +00:00
|
|
|
SERVER_URL, USERNAME, PASSWORD
|
2017-02-14 19:27:59 +00:00
|
|
|
);
|
|
|
|
accountManager.addEventListener('registration', function() {
|
|
|
|
if (!Whisper.Registration.everDone()) {
|
|
|
|
storage.put('safety-numbers-approval', false);
|
|
|
|
}
|
|
|
|
Whisper.Registration.markDone();
|
2017-10-14 00:02:08 +00:00
|
|
|
console.log('dispatching registration event');
|
2017-04-12 00:50:13 +00:00
|
|
|
Whisper.events.trigger('registration_done');
|
2017-02-14 19:27:59 +00:00
|
|
|
});
|
|
|
|
}
|
2016-09-20 20:42:33 +00:00
|
|
|
return accountManager;
|
2015-09-01 19:57:02 +00:00
|
|
|
};
|
|
|
|
|
2015-05-14 22:44:43 +00:00
|
|
|
storage.fetch();
|
2017-08-08 00:24:59 +00:00
|
|
|
|
|
|
|
// We need this 'first' check because we don't want to start the app up any other time
|
|
|
|
// than the first time. And storage.fetch() will cause onready() to fire.
|
|
|
|
var first = true;
|
2015-05-12 22:14:20 +00:00
|
|
|
storage.onready(function() {
|
2017-08-08 00:24:59 +00:00
|
|
|
if (!first) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
first = false;
|
|
|
|
|
2017-10-23 23:02:49 +00:00
|
|
|
ConversationController.load().then(start, start);
|
2017-08-08 00:24:59 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
Whisper.events.on('shutdown', function() {
|
|
|
|
if (messageReceiver) {
|
|
|
|
messageReceiver.close().then(function() {
|
|
|
|
Whisper.events.trigger('shutdown-complete');
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
Whisper.events.trigger('shutdown-complete');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
function start() {
|
2017-10-18 18:57:34 +00:00
|
|
|
var currentVersion = window.config.version;
|
|
|
|
var lastVersion = storage.get('version');
|
|
|
|
storage.put('version', currentVersion);
|
|
|
|
|
|
|
|
if (!lastVersion || currentVersion !== lastVersion) {
|
|
|
|
console.log('New version detected:', currentVersion);
|
|
|
|
}
|
|
|
|
|
2016-02-13 01:18:36 +00:00
|
|
|
window.dispatchEvent(new Event('storage_ready'));
|
2015-09-22 00:05:19 +00:00
|
|
|
|
2017-10-14 00:02:08 +00:00
|
|
|
console.log('listening for registration events');
|
2017-04-12 00:50:13 +00:00
|
|
|
Whisper.events.on('registration_done', function() {
|
2017-10-14 00:02:08 +00:00
|
|
|
console.log('handling registration event');
|
2017-08-08 00:24:59 +00:00
|
|
|
connect(true);
|
2015-08-31 17:40:25 +00:00
|
|
|
});
|
2014-12-20 00:49:18 +00:00
|
|
|
|
2017-04-25 00:59:11 +00:00
|
|
|
var appView = window.owsDesktopApp.appView = new Whisper.AppView({el: $('body')});
|
2017-04-12 21:20:56 +00:00
|
|
|
|
2017-04-12 00:50:13 +00:00
|
|
|
Whisper.WallClockListener.init(Whisper.events);
|
|
|
|
Whisper.RotateSignedPreKeyListener.init(Whisper.events);
|
|
|
|
Whisper.ExpiringMessagesListener.init(Whisper.events);
|
2017-03-31 01:11:13 +00:00
|
|
|
|
2017-08-08 00:24:59 +00:00
|
|
|
if (Whisper.Import.isIncomplete()) {
|
|
|
|
console.log('Import was interrupted, showing import error screen');
|
|
|
|
appView.openImporter();
|
|
|
|
} else if (Whisper.Registration.everDone()) {
|
|
|
|
connect();
|
2017-04-12 21:20:56 +00:00
|
|
|
appView.openInbox({
|
|
|
|
initialLoadComplete: initialLoadComplete
|
|
|
|
});
|
|
|
|
} else {
|
2017-08-08 00:24:59 +00:00
|
|
|
appView.openInstallChoice();
|
2017-03-31 01:11:13 +00:00
|
|
|
}
|
2017-04-12 21:20:56 +00:00
|
|
|
|
2017-07-24 14:58:20 +00:00
|
|
|
Whisper.events.on('showDebugLog', function() {
|
2017-07-24 15:09:26 +00:00
|
|
|
appView.openDebugLog();
|
2017-07-24 14:58:20 +00:00
|
|
|
});
|
2017-04-12 21:20:56 +00:00
|
|
|
Whisper.events.on('unauthorized', function() {
|
|
|
|
appView.inboxView.networkStatusView.update();
|
|
|
|
});
|
|
|
|
Whisper.events.on('reconnectTimer', function() {
|
|
|
|
appView.inboxView.networkStatusView.setSocketReconnectInterval(60000);
|
|
|
|
});
|
2017-04-26 19:12:08 +00:00
|
|
|
Whisper.events.on('contactsync', function() {
|
|
|
|
if (appView.installView) {
|
|
|
|
appView.openInbox();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Whisper.events.on('contactsync:begin', function() {
|
|
|
|
if (appView.installView && appView.installView.showSync) {
|
|
|
|
appView.installView.showSync();
|
|
|
|
}
|
|
|
|
});
|
2017-04-12 21:20:56 +00:00
|
|
|
|
2017-09-01 18:30:41 +00:00
|
|
|
Whisper.Notifications.on('click', function(conversation) {
|
2017-04-28 01:21:52 +00:00
|
|
|
showWindow();
|
2017-09-01 18:30:41 +00:00
|
|
|
if (conversation) {
|
|
|
|
appView.openConversation(conversation);
|
|
|
|
} else {
|
|
|
|
appView.openInbox({
|
|
|
|
initialLoadComplete: initialLoadComplete
|
|
|
|
});
|
|
|
|
}
|
2017-04-25 00:59:11 +00:00
|
|
|
});
|
2017-08-08 00:24:59 +00:00
|
|
|
}
|
2015-08-31 17:40:25 +00:00
|
|
|
|
2016-06-16 22:33:18 +00:00
|
|
|
window.getSyncRequest = function() {
|
|
|
|
return new textsecure.SyncRequest(textsecure.messaging, messageReceiver);
|
|
|
|
};
|
|
|
|
|
Full export, migration banner, and full migration workflow - behind flag (#1342)
* Add support for backup and restore
This first pass works for all stores except messages, pending some scaling
improvements.
// FREEBIE
* Import of messages and attachments
Properly sanitize filenames. Logging information that will help with
debugging but won't threaten privacy (no contact or group names),
where the on-disk directories have this information to make things
human-readable
FREEBIE
* First fully operational single-action export and import!
FREEBIE
* Add migration export flow
A banner alert leads to a blocking ui for the migration. We close the socket and
wait for incoming messages to drain before starting the export.
FREEBIE
* A number of updates for the export flow
1. We don't immediately pop the directory selection dialog box, instead
showing an explicit 'choose directory' button after explaining what is
about to happen
2. We show a 'submit debug log' button on most steps of the process
3. We handle export errors and encourage the user to double-check their
filesystem then submit their log
4. We are resilient to restarts during the process
5. We handle the user cancelling out of the directory selection dialog
differently from other errors.
6. The export process is now serialized: non-messages, then messages.
7. After successful export, show where the data is on disk
FREEBUE
* Put migration behind a flag
FREEBIE
* Shut down websocket before proceeding with export
FREEBIE
* Add MigrationView to test/index.html to fix test
FREEBIE
* Remove 'Submit Debug Log' button when the export process is complete
FREEBIE
* Create a 'Signal Export' directory below user-chosen dir
This cleans things up a bit so we don't litter the user's target
directory with lots of stuff.
FREEBIE
* Clarify MessageReceiver.drain() method comments
FREEBIE
* A couple updates for clarity - event names, else handling
Also the removal of wait(), which wasn't used anywhere.
FREEBIE
* A number of wording updates for the export flow
FREEBIE
* Export complete: put dir on its own line, make text selectable
FREEBIE
2017-08-28 20:06:10 +00:00
|
|
|
Whisper.events.on('start-shutdown', function() {
|
|
|
|
if (messageReceiver) {
|
|
|
|
messageReceiver.close().then(function() {
|
|
|
|
Whisper.events.trigger('shutdown-complete');
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
Whisper.events.trigger('shutdown-complete');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-10-14 00:02:08 +00:00
|
|
|
|
|
|
|
var disconnectTimer = null;
|
|
|
|
function onOffline() {
|
|
|
|
console.log('offline');
|
|
|
|
|
|
|
|
window.removeEventListener('offline', onOffline);
|
|
|
|
window.addEventListener('online', onOnline);
|
|
|
|
|
|
|
|
// We've received logs from Linux where we get an 'offline' event, then 30ms later
|
|
|
|
// we get an online event. This waits a bit after getting an 'offline' event
|
|
|
|
// before disconnecting the socket manually.
|
|
|
|
disconnectTimer = setTimeout(disconnect, 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onOnline() {
|
|
|
|
console.log('online');
|
|
|
|
|
|
|
|
window.removeEventListener('online', onOnline);
|
|
|
|
window.addEventListener('offline', onOffline);
|
|
|
|
|
|
|
|
if (disconnectTimer && isSocketOnline()) {
|
|
|
|
console.log('Already online. Had a blip in online/offline status.');
|
|
|
|
clearTimeout(disconnectTimer);
|
|
|
|
disconnectTimer = null;
|
|
|
|
return;
|
|
|
|
}
|
2017-10-23 21:38:43 +00:00
|
|
|
if (disconnectTimer) {
|
|
|
|
clearTimeout(disconnectTimer);
|
|
|
|
disconnectTimer = null;
|
|
|
|
}
|
2017-10-14 00:02:08 +00:00
|
|
|
|
|
|
|
connect();
|
|
|
|
}
|
|
|
|
|
|
|
|
function isSocketOnline() {
|
|
|
|
var socketStatus = window.getSocketStatus();
|
|
|
|
return socketStatus === WebSocket.CONNECTING || socketStatus === WebSocket.OPEN;
|
|
|
|
}
|
|
|
|
|
|
|
|
function disconnect() {
|
|
|
|
console.log('disconnect');
|
|
|
|
|
|
|
|
// Clear timer, since we're only called when the timer is expired
|
|
|
|
disconnectTimer = null;
|
|
|
|
|
|
|
|
if (messageReceiver) {
|
|
|
|
messageReceiver.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-28 21:58:45 +00:00
|
|
|
var connectCount = 0;
|
2017-08-08 00:24:59 +00:00
|
|
|
function connect(firstRun) {
|
2017-10-06 23:28:13 +00:00
|
|
|
console.log('connect');
|
2017-10-14 00:02:08 +00:00
|
|
|
|
|
|
|
// Bootstrap our online/offline detection, only the first time we connect
|
|
|
|
if (connectCount === 0 && navigator.onLine) {
|
|
|
|
window.addEventListener('offline', onOffline);
|
|
|
|
}
|
|
|
|
if (connectCount === 0 && !navigator.onLine) {
|
|
|
|
console.log('Starting up offline; will connect when we have network access');
|
|
|
|
window.addEventListener('online', onOnline);
|
|
|
|
onEmpty(); // this ensures that the loading screen is dismissed
|
|
|
|
return;
|
|
|
|
}
|
2017-04-12 21:20:56 +00:00
|
|
|
|
2017-09-07 01:21:38 +00:00
|
|
|
if (!Whisper.Registration.everDone()) { return; }
|
2017-08-08 00:24:59 +00:00
|
|
|
if (Whisper.Import.isIncomplete()) { return; }
|
2014-12-20 00:49:18 +00:00
|
|
|
|
2017-09-28 20:12:43 +00:00
|
|
|
if (messageReceiver) {
|
|
|
|
messageReceiver.close();
|
|
|
|
}
|
2015-09-01 19:13:38 +00:00
|
|
|
|
2015-09-22 00:05:19 +00:00
|
|
|
var USERNAME = storage.get('number_id');
|
|
|
|
var PASSWORD = storage.get('password');
|
|
|
|
var mySignalingKey = storage.get('signaling_key');
|
2015-09-01 19:13:38 +00:00
|
|
|
|
2017-09-28 21:58:45 +00:00
|
|
|
connectCount += 1;
|
|
|
|
var options = {
|
|
|
|
retryCached: connectCount === 1,
|
|
|
|
};
|
|
|
|
|
2017-09-29 16:15:28 +00:00
|
|
|
Whisper.Notifications.disable(); // avoid notification flood until empty
|
|
|
|
|
2015-09-22 00:05:19 +00:00
|
|
|
// initialize the socket and start listening for messages
|
2016-04-04 03:06:27 +00:00
|
|
|
messageReceiver = new textsecure.MessageReceiver(
|
2017-09-28 21:58:45 +00:00
|
|
|
SERVER_URL, USERNAME, PASSWORD, mySignalingKey, options
|
2016-04-04 03:06:27 +00:00
|
|
|
);
|
2015-09-22 00:05:19 +00:00
|
|
|
messageReceiver.addEventListener('message', onMessageReceived);
|
Feature: Blue check marks for read messages if opted in (#1489)
* Refactor delivery receipt event handler
* Rename the delivery receipt event
For less ambiguity with read receipts.
* Rename synced read event
For less ambiguity with read receipts from other Signal users.
* Add support for incoming receipt messages
Handle ReceiptMessages, which may include encrypted delivery receipts or read
receipts from recipients of our sent messages.
// FREEBIE
* Rename ReadReceipts to ReadSyncs
* Render read messages with blue double checks
* Send read receipts to senders of incoming messages
// FREEBIE
* Move ReadSyncs to their own file
// FREEBIE
* Fixup old comments on read receipts (now read syncs)
And some variable renaming for extra clarity.
// FREEBIE
* Add global setting for read receipts
Don't send read receipt messages unless the setting is enabled.
Don't process read receipts if the setting is disabled.
// FREEBIE
* Sync read receipt setting from mobile
Toggling this setting on your mobile device should sync it to Desktop. When
linking, use the setting in the provisioning message.
// FREEBIE
* Send receipt messages silently
Avoid generating phantom messages on ios
// FREEBIE
* Save recipients on the outgoing message models
For accurate tracking and display of sent/delivered/read state, even if group
membership changes later.
// FREEBIE
* Fix conversation type in profile key update handling
// FREEBIE
* Set recipients on synced sent messages
* Render saved recipients in message detail if available
For older messages, where we did not save the intended set of recipients at the
time of sending, fall back to the current group membership.
// FREEBIE
* Record who has been successfully sent to
// FREEBIE
* Record who a message has been delivered to
* Invert the not-clickable class
* Fix readReceipt setting sync when linking
* Render per recipient sent/delivered/read status
In the message detail view for outgoing messages, render each recipient's
individual sent/delivered/read status with respect to this message, as long as
there are no errors associated with the recipient (ie, safety number changes,
user not registered, etc...) since the error icon is displayed in that case.
*Messages sent before this change may not have per-recipient status lists
and will simply show no status icon.
// FREEBIE
* Add configuration sync request
Send these requests in a one-off fashion when:
1. We have just setup from a chrome app import
2. We have just upgraded to read-receipt support
// FREEBIE
* Expose sendRequestConfigurationSyncMessage
// FREEBIE
* Fix handling of incoming delivery receipts - union with array
FREEBIE
2017-10-04 22:28:43 +00:00
|
|
|
messageReceiver.addEventListener('delivery', onDeliveryReceipt);
|
2015-09-22 00:05:19 +00:00
|
|
|
messageReceiver.addEventListener('contact', onContactReceived);
|
|
|
|
messageReceiver.addEventListener('group', onGroupReceived);
|
|
|
|
messageReceiver.addEventListener('sent', onSentMessage);
|
Feature: Blue check marks for read messages if opted in (#1489)
* Refactor delivery receipt event handler
* Rename the delivery receipt event
For less ambiguity with read receipts.
* Rename synced read event
For less ambiguity with read receipts from other Signal users.
* Add support for incoming receipt messages
Handle ReceiptMessages, which may include encrypted delivery receipts or read
receipts from recipients of our sent messages.
// FREEBIE
* Rename ReadReceipts to ReadSyncs
* Render read messages with blue double checks
* Send read receipts to senders of incoming messages
// FREEBIE
* Move ReadSyncs to their own file
// FREEBIE
* Fixup old comments on read receipts (now read syncs)
And some variable renaming for extra clarity.
// FREEBIE
* Add global setting for read receipts
Don't send read receipt messages unless the setting is enabled.
Don't process read receipts if the setting is disabled.
// FREEBIE
* Sync read receipt setting from mobile
Toggling this setting on your mobile device should sync it to Desktop. When
linking, use the setting in the provisioning message.
// FREEBIE
* Send receipt messages silently
Avoid generating phantom messages on ios
// FREEBIE
* Save recipients on the outgoing message models
For accurate tracking and display of sent/delivered/read state, even if group
membership changes later.
// FREEBIE
* Fix conversation type in profile key update handling
// FREEBIE
* Set recipients on synced sent messages
* Render saved recipients in message detail if available
For older messages, where we did not save the intended set of recipients at the
time of sending, fall back to the current group membership.
// FREEBIE
* Record who has been successfully sent to
// FREEBIE
* Record who a message has been delivered to
* Invert the not-clickable class
* Fix readReceipt setting sync when linking
* Render per recipient sent/delivered/read status
In the message detail view for outgoing messages, render each recipient's
individual sent/delivered/read status with respect to this message, as long as
there are no errors associated with the recipient (ie, safety number changes,
user not registered, etc...) since the error icon is displayed in that case.
*Messages sent before this change may not have per-recipient status lists
and will simply show no status icon.
// FREEBIE
* Add configuration sync request
Send these requests in a one-off fashion when:
1. We have just setup from a chrome app import
2. We have just upgraded to read-receipt support
// FREEBIE
* Expose sendRequestConfigurationSyncMessage
// FREEBIE
* Fix handling of incoming delivery receipts - union with array
FREEBIE
2017-10-04 22:28:43 +00:00
|
|
|
messageReceiver.addEventListener('readSync', onReadSync);
|
2016-02-20 00:28:08 +00:00
|
|
|
messageReceiver.addEventListener('read', onReadReceipt);
|
2017-06-19 16:08:16 +00:00
|
|
|
messageReceiver.addEventListener('verified', onVerified);
|
2015-09-22 00:05:19 +00:00
|
|
|
messageReceiver.addEventListener('error', onError);
|
2017-07-25 01:43:35 +00:00
|
|
|
messageReceiver.addEventListener('empty', onEmpty);
|
2017-07-25 23:00:06 +00:00
|
|
|
messageReceiver.addEventListener('progress', onProgress);
|
Feature: Blue check marks for read messages if opted in (#1489)
* Refactor delivery receipt event handler
* Rename the delivery receipt event
For less ambiguity with read receipts.
* Rename synced read event
For less ambiguity with read receipts from other Signal users.
* Add support for incoming receipt messages
Handle ReceiptMessages, which may include encrypted delivery receipts or read
receipts from recipients of our sent messages.
// FREEBIE
* Rename ReadReceipts to ReadSyncs
* Render read messages with blue double checks
* Send read receipts to senders of incoming messages
// FREEBIE
* Move ReadSyncs to their own file
// FREEBIE
* Fixup old comments on read receipts (now read syncs)
And some variable renaming for extra clarity.
// FREEBIE
* Add global setting for read receipts
Don't send read receipt messages unless the setting is enabled.
Don't process read receipts if the setting is disabled.
// FREEBIE
* Sync read receipt setting from mobile
Toggling this setting on your mobile device should sync it to Desktop. When
linking, use the setting in the provisioning message.
// FREEBIE
* Send receipt messages silently
Avoid generating phantom messages on ios
// FREEBIE
* Save recipients on the outgoing message models
For accurate tracking and display of sent/delivered/read state, even if group
membership changes later.
// FREEBIE
* Fix conversation type in profile key update handling
// FREEBIE
* Set recipients on synced sent messages
* Render saved recipients in message detail if available
For older messages, where we did not save the intended set of recipients at the
time of sending, fall back to the current group membership.
// FREEBIE
* Record who has been successfully sent to
// FREEBIE
* Record who a message has been delivered to
* Invert the not-clickable class
* Fix readReceipt setting sync when linking
* Render per recipient sent/delivered/read status
In the message detail view for outgoing messages, render each recipient's
individual sent/delivered/read status with respect to this message, as long as
there are no errors associated with the recipient (ie, safety number changes,
user not registered, etc...) since the error icon is displayed in that case.
*Messages sent before this change may not have per-recipient status lists
and will simply show no status icon.
// FREEBIE
* Add configuration sync request
Send these requests in a one-off fashion when:
1. We have just setup from a chrome app import
2. We have just upgraded to read-receipt support
// FREEBIE
* Expose sendRequestConfigurationSyncMessage
// FREEBIE
* Fix handling of incoming delivery receipts - union with array
FREEBIE
2017-10-04 22:28:43 +00:00
|
|
|
messageReceiver.addEventListener('settings', onSettings);
|
2017-06-15 23:12:58 +00:00
|
|
|
|
2016-04-04 03:06:27 +00:00
|
|
|
window.textsecure.messaging = new textsecure.MessageSender(
|
2017-09-11 16:50:35 +00:00
|
|
|
SERVER_URL, USERNAME, PASSWORD, CDN_URL
|
2016-04-04 03:06:27 +00:00
|
|
|
);
|
2017-01-09 14:45:47 +00:00
|
|
|
|
2017-09-14 19:08:10 +00:00
|
|
|
// Because v0.43.2 introduced a bug that lost contact details, v0.43.4 introduces
|
|
|
|
// a one-time contact sync to restore all lost contact/group information. We
|
|
|
|
// disable this checking if a user is first registering.
|
|
|
|
var key = 'chrome-contact-sync-v0.43.4';
|
|
|
|
if (!storage.get(key)) {
|
|
|
|
storage.put(key, true);
|
|
|
|
|
|
|
|
if (!firstRun && textsecure.storage.user.getDeviceId() != '1') {
|
|
|
|
window.getSyncRequest();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Feature: Blue check marks for read messages if opted in (#1489)
* Refactor delivery receipt event handler
* Rename the delivery receipt event
For less ambiguity with read receipts.
* Rename synced read event
For less ambiguity with read receipts from other Signal users.
* Add support for incoming receipt messages
Handle ReceiptMessages, which may include encrypted delivery receipts or read
receipts from recipients of our sent messages.
// FREEBIE
* Rename ReadReceipts to ReadSyncs
* Render read messages with blue double checks
* Send read receipts to senders of incoming messages
// FREEBIE
* Move ReadSyncs to their own file
// FREEBIE
* Fixup old comments on read receipts (now read syncs)
And some variable renaming for extra clarity.
// FREEBIE
* Add global setting for read receipts
Don't send read receipt messages unless the setting is enabled.
Don't process read receipts if the setting is disabled.
// FREEBIE
* Sync read receipt setting from mobile
Toggling this setting on your mobile device should sync it to Desktop. When
linking, use the setting in the provisioning message.
// FREEBIE
* Send receipt messages silently
Avoid generating phantom messages on ios
// FREEBIE
* Save recipients on the outgoing message models
For accurate tracking and display of sent/delivered/read state, even if group
membership changes later.
// FREEBIE
* Fix conversation type in profile key update handling
// FREEBIE
* Set recipients on synced sent messages
* Render saved recipients in message detail if available
For older messages, where we did not save the intended set of recipients at the
time of sending, fall back to the current group membership.
// FREEBIE
* Record who has been successfully sent to
// FREEBIE
* Record who a message has been delivered to
* Invert the not-clickable class
* Fix readReceipt setting sync when linking
* Render per recipient sent/delivered/read status
In the message detail view for outgoing messages, render each recipient's
individual sent/delivered/read status with respect to this message, as long as
there are no errors associated with the recipient (ie, safety number changes,
user not registered, etc...) since the error icon is displayed in that case.
*Messages sent before this change may not have per-recipient status lists
and will simply show no status icon.
// FREEBIE
* Add configuration sync request
Send these requests in a one-off fashion when:
1. We have just setup from a chrome app import
2. We have just upgraded to read-receipt support
// FREEBIE
* Expose sendRequestConfigurationSyncMessage
// FREEBIE
* Fix handling of incoming delivery receipts - union with array
FREEBIE
2017-10-04 22:28:43 +00:00
|
|
|
// If we've just upgraded to read receipt support on desktop, kick off a
|
|
|
|
// one-time configuration sync request to get the read-receipt setting
|
|
|
|
// from the master device.
|
|
|
|
var readReceiptConfigurationSync = 'read-receipt-configuration-sync';
|
|
|
|
if (!storage.get(readReceiptConfigurationSync)) {
|
|
|
|
|
|
|
|
if (!firstRun && textsecure.storage.user.getDeviceId() != '1') {
|
|
|
|
textsecure.messaging.sendRequestConfigurationSyncMessage().then(function() {
|
|
|
|
storage.put(readReceiptConfigurationSync, true);
|
|
|
|
}).catch(function(e) {
|
|
|
|
console.log(e);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-22 00:05:19 +00:00
|
|
|
if (firstRun === true && textsecure.storage.user.getDeviceId() != '1') {
|
2016-09-12 19:09:56 +00:00
|
|
|
if (!storage.get('theme-setting') && textsecure.storage.get('userAgent') === 'OWI') {
|
|
|
|
storage.put('theme-setting', 'ios');
|
|
|
|
}
|
2016-01-14 21:40:26 +00:00
|
|
|
var syncRequest = new textsecure.SyncRequest(textsecure.messaging, messageReceiver);
|
2017-04-13 01:43:00 +00:00
|
|
|
Whisper.events.trigger('contactsync:begin');
|
2016-01-14 21:40:26 +00:00
|
|
|
syncRequest.addEventListener('success', function() {
|
|
|
|
console.log('sync successful');
|
2016-06-16 22:33:18 +00:00
|
|
|
storage.put('synced_at', Date.now());
|
2017-04-13 01:43:00 +00:00
|
|
|
Whisper.events.trigger('contactsync');
|
2016-01-14 21:40:26 +00:00
|
|
|
});
|
|
|
|
syncRequest.addEventListener('timeout', function() {
|
|
|
|
console.log('sync timed out');
|
2017-04-13 01:43:00 +00:00
|
|
|
Whisper.events.trigger('contactsync');
|
2015-10-01 01:47:41 +00:00
|
|
|
});
|
Feature: Blue check marks for read messages if opted in (#1489)
* Refactor delivery receipt event handler
* Rename the delivery receipt event
For less ambiguity with read receipts.
* Rename synced read event
For less ambiguity with read receipts from other Signal users.
* Add support for incoming receipt messages
Handle ReceiptMessages, which may include encrypted delivery receipts or read
receipts from recipients of our sent messages.
// FREEBIE
* Rename ReadReceipts to ReadSyncs
* Render read messages with blue double checks
* Send read receipts to senders of incoming messages
// FREEBIE
* Move ReadSyncs to their own file
// FREEBIE
* Fixup old comments on read receipts (now read syncs)
And some variable renaming for extra clarity.
// FREEBIE
* Add global setting for read receipts
Don't send read receipt messages unless the setting is enabled.
Don't process read receipts if the setting is disabled.
// FREEBIE
* Sync read receipt setting from mobile
Toggling this setting on your mobile device should sync it to Desktop. When
linking, use the setting in the provisioning message.
// FREEBIE
* Send receipt messages silently
Avoid generating phantom messages on ios
// FREEBIE
* Save recipients on the outgoing message models
For accurate tracking and display of sent/delivered/read state, even if group
membership changes later.
// FREEBIE
* Fix conversation type in profile key update handling
// FREEBIE
* Set recipients on synced sent messages
* Render saved recipients in message detail if available
For older messages, where we did not save the intended set of recipients at the
time of sending, fall back to the current group membership.
// FREEBIE
* Record who has been successfully sent to
// FREEBIE
* Record who a message has been delivered to
* Invert the not-clickable class
* Fix readReceipt setting sync when linking
* Render per recipient sent/delivered/read status
In the message detail view for outgoing messages, render each recipient's
individual sent/delivered/read status with respect to this message, as long as
there are no errors associated with the recipient (ie, safety number changes,
user not registered, etc...) since the error icon is displayed in that case.
*Messages sent before this change may not have per-recipient status lists
and will simply show no status icon.
// FREEBIE
* Add configuration sync request
Send these requests in a one-off fashion when:
1. We have just setup from a chrome app import
2. We have just upgraded to read-receipt support
// FREEBIE
* Expose sendRequestConfigurationSyncMessage
// FREEBIE
* Fix handling of incoming delivery receipts - union with array
FREEBIE
2017-10-04 22:28:43 +00:00
|
|
|
|
|
|
|
if (Whisper.Import.isComplete()) {
|
|
|
|
textsecure.messaging.sendRequestConfigurationSyncMessage().catch(function(e) {
|
|
|
|
console.log(e);
|
|
|
|
});
|
|
|
|
}
|
2015-09-01 19:13:38 +00:00
|
|
|
}
|
2015-09-22 00:05:19 +00:00
|
|
|
}
|
2015-09-01 19:13:38 +00:00
|
|
|
|
2017-07-25 01:43:35 +00:00
|
|
|
function onEmpty() {
|
|
|
|
initialLoadComplete = true;
|
|
|
|
|
|
|
|
var interval = setInterval(function() {
|
2017-04-12 21:20:56 +00:00
|
|
|
var view = window.owsDesktopApp.appView;
|
2017-07-25 01:43:35 +00:00
|
|
|
if (view) {
|
|
|
|
clearInterval(interval);
|
|
|
|
interval = null;
|
|
|
|
view.onEmpty();
|
|
|
|
}
|
|
|
|
}, 500);
|
2017-09-29 16:15:28 +00:00
|
|
|
|
|
|
|
Whisper.Notifications.enable();
|
2017-07-25 01:43:35 +00:00
|
|
|
}
|
2017-07-25 23:00:06 +00:00
|
|
|
function onProgress(ev) {
|
|
|
|
var count = ev.count;
|
|
|
|
|
2017-04-12 21:20:56 +00:00
|
|
|
var view = window.owsDesktopApp.appView;
|
2017-07-25 23:00:06 +00:00
|
|
|
if (view) {
|
|
|
|
view.onProgress(count);
|
|
|
|
}
|
|
|
|
}
|
Feature: Blue check marks for read messages if opted in (#1489)
* Refactor delivery receipt event handler
* Rename the delivery receipt event
For less ambiguity with read receipts.
* Rename synced read event
For less ambiguity with read receipts from other Signal users.
* Add support for incoming receipt messages
Handle ReceiptMessages, which may include encrypted delivery receipts or read
receipts from recipients of our sent messages.
// FREEBIE
* Rename ReadReceipts to ReadSyncs
* Render read messages with blue double checks
* Send read receipts to senders of incoming messages
// FREEBIE
* Move ReadSyncs to their own file
// FREEBIE
* Fixup old comments on read receipts (now read syncs)
And some variable renaming for extra clarity.
// FREEBIE
* Add global setting for read receipts
Don't send read receipt messages unless the setting is enabled.
Don't process read receipts if the setting is disabled.
// FREEBIE
* Sync read receipt setting from mobile
Toggling this setting on your mobile device should sync it to Desktop. When
linking, use the setting in the provisioning message.
// FREEBIE
* Send receipt messages silently
Avoid generating phantom messages on ios
// FREEBIE
* Save recipients on the outgoing message models
For accurate tracking and display of sent/delivered/read state, even if group
membership changes later.
// FREEBIE
* Fix conversation type in profile key update handling
// FREEBIE
* Set recipients on synced sent messages
* Render saved recipients in message detail if available
For older messages, where we did not save the intended set of recipients at the
time of sending, fall back to the current group membership.
// FREEBIE
* Record who has been successfully sent to
// FREEBIE
* Record who a message has been delivered to
* Invert the not-clickable class
* Fix readReceipt setting sync when linking
* Render per recipient sent/delivered/read status
In the message detail view for outgoing messages, render each recipient's
individual sent/delivered/read status with respect to this message, as long as
there are no errors associated with the recipient (ie, safety number changes,
user not registered, etc...) since the error icon is displayed in that case.
*Messages sent before this change may not have per-recipient status lists
and will simply show no status icon.
// FREEBIE
* Add configuration sync request
Send these requests in a one-off fashion when:
1. We have just setup from a chrome app import
2. We have just upgraded to read-receipt support
// FREEBIE
* Expose sendRequestConfigurationSyncMessage
// FREEBIE
* Fix handling of incoming delivery receipts - union with array
FREEBIE
2017-10-04 22:28:43 +00:00
|
|
|
function onSettings(ev) {
|
|
|
|
if (ev.settings.readReceipts) {
|
|
|
|
storage.put('read-receipt-setting', true);
|
|
|
|
} else {
|
|
|
|
storage.put('read-receipt-setting', false);
|
|
|
|
}
|
|
|
|
}
|
2017-07-25 01:43:35 +00:00
|
|
|
|
2015-09-22 00:05:19 +00:00
|
|
|
function onContactReceived(ev) {
|
2017-07-21 17:59:41 +00:00
|
|
|
var details = ev.contactDetails;
|
2016-12-17 12:59:07 +00:00
|
|
|
|
2017-07-21 17:59:41 +00:00
|
|
|
var id = details.number;
|
2017-09-11 16:50:35 +00:00
|
|
|
|
|
|
|
if (id === textsecure.storage.user.getNumber()) {
|
|
|
|
// special case for syncing details about ourselves
|
|
|
|
if (details.profileKey) {
|
|
|
|
console.log('Got sync message with our own profile key');
|
|
|
|
storage.put('profileKey', details.profileKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-17 12:59:07 +00:00
|
|
|
var c = new Whisper.Conversation({
|
2017-07-21 17:59:41 +00:00
|
|
|
id: id
|
2016-12-17 12:59:07 +00:00
|
|
|
});
|
2017-07-21 17:59:41 +00:00
|
|
|
var error = c.validateNumber();
|
|
|
|
if (error) {
|
|
|
|
console.log('Invalid contact received', error && error.stack ? error.stack : error);
|
|
|
|
return;
|
2016-12-17 12:59:07 +00:00
|
|
|
}
|
|
|
|
|
2017-09-01 16:10:41 +00:00
|
|
|
return ConversationController.getOrCreateAndWait(id, 'private')
|
2017-08-30 16:35:04 +00:00
|
|
|
.then(function(conversation) {
|
|
|
|
return new Promise(function(resolve, reject) {
|
2017-09-11 16:50:35 +00:00
|
|
|
if (details.profileKey) {
|
|
|
|
conversation.set({profileKey: details.profileKey});
|
|
|
|
}
|
2017-08-30 16:35:04 +00:00
|
|
|
conversation.save({
|
|
|
|
name: details.name,
|
|
|
|
avatar: details.avatar,
|
|
|
|
color: details.color,
|
|
|
|
active_at: conversation.get('active_at') || Date.now(),
|
|
|
|
}).then(resolve, reject);
|
2017-09-01 14:42:41 +00:00
|
|
|
}).then(function() {
|
|
|
|
if (details.verified) {
|
|
|
|
var verified = details.verified;
|
|
|
|
var ev = new Event('verified');
|
|
|
|
ev.verified = {
|
|
|
|
state: verified.state,
|
|
|
|
destination: verified.destination,
|
|
|
|
identityKey: verified.identityKey.toArrayBuffer(),
|
|
|
|
};
|
|
|
|
ev.viaContactSync = true;
|
|
|
|
return onVerified(ev);
|
|
|
|
}
|
2017-08-30 16:35:04 +00:00
|
|
|
});
|
|
|
|
})
|
|
|
|
.then(ev.confirm)
|
|
|
|
.catch(function(error) {
|
|
|
|
console.log(
|
|
|
|
'onContactReceived error:',
|
|
|
|
error && error.stack ? error.stack : error
|
|
|
|
);
|
2017-07-21 17:59:41 +00:00
|
|
|
});
|
2015-09-22 00:05:19 +00:00
|
|
|
}
|
2015-06-01 21:08:21 +00:00
|
|
|
|
2015-09-22 00:05:19 +00:00
|
|
|
function onGroupReceived(ev) {
|
2017-07-21 17:59:41 +00:00
|
|
|
var details = ev.groupDetails;
|
|
|
|
var id = details.id;
|
|
|
|
|
2017-09-01 16:10:41 +00:00
|
|
|
return ConversationController.getOrCreateAndWait(id, 'group').then(function(conversation) {
|
2017-07-21 17:59:41 +00:00
|
|
|
var updates = {
|
|
|
|
name: details.name,
|
|
|
|
members: details.members,
|
|
|
|
avatar: details.avatar,
|
|
|
|
type: 'group',
|
|
|
|
};
|
|
|
|
if (details.active) {
|
|
|
|
updates.active_at = Date.now();
|
|
|
|
} else {
|
|
|
|
updates.left = true;
|
|
|
|
}
|
|
|
|
return new Promise(function(resolve, reject) {
|
|
|
|
conversation.save(updates).then(resolve, reject);
|
|
|
|
}).then(ev.confirm);
|
|
|
|
});
|
2015-09-22 00:05:19 +00:00
|
|
|
}
|
2015-06-01 21:08:21 +00:00
|
|
|
|
2015-09-22 00:05:19 +00:00
|
|
|
function onMessageReceived(ev) {
|
|
|
|
var data = ev.data;
|
2017-09-11 16:50:35 +00:00
|
|
|
if (data.message.flags & textsecure.protobuf.DataMessage.Flags.PROFILE_KEY_UPDATE) {
|
|
|
|
var profileKey = data.message.profileKey.toArrayBuffer();
|
|
|
|
return ConversationController.getOrCreateAndWait(data.source, 'private').then(function(sender) {
|
|
|
|
return sender.setProfileKey(profileKey).then(ev.confirm);
|
|
|
|
});
|
|
|
|
}
|
2017-07-17 22:46:00 +00:00
|
|
|
var message = initIncomingMessage(data);
|
|
|
|
|
2017-07-25 01:43:35 +00:00
|
|
|
return isMessageDuplicate(message).then(function(isDuplicate) {
|
2017-07-17 22:46:00 +00:00
|
|
|
if (isDuplicate) {
|
|
|
|
console.log('Received duplicate message', message.idForLogging());
|
|
|
|
ev.confirm();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-09-01 16:10:41 +00:00
|
|
|
var type, id;
|
|
|
|
if (data.message.group) {
|
|
|
|
type = 'group';
|
|
|
|
id = data.message.group.id;
|
|
|
|
} else {
|
|
|
|
type = 'private';
|
|
|
|
id = data.source;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ConversationController.getOrCreateAndWait(id, type).then(function() {
|
|
|
|
return message.handleDataMessage(data.message, ev.confirm, {
|
|
|
|
initialLoadComplete: initialLoadComplete
|
|
|
|
});
|
2017-07-25 01:43:35 +00:00
|
|
|
});
|
2017-07-17 22:46:00 +00:00
|
|
|
});
|
2015-09-22 00:05:19 +00:00
|
|
|
}
|
2015-06-01 21:08:21 +00:00
|
|
|
|
2015-09-22 00:05:19 +00:00
|
|
|
function onSentMessage(ev) {
|
|
|
|
var now = new Date().getTime();
|
|
|
|
var data = ev.data;
|
|
|
|
|
Feature: Blue check marks for read messages if opted in (#1489)
* Refactor delivery receipt event handler
* Rename the delivery receipt event
For less ambiguity with read receipts.
* Rename synced read event
For less ambiguity with read receipts from other Signal users.
* Add support for incoming receipt messages
Handle ReceiptMessages, which may include encrypted delivery receipts or read
receipts from recipients of our sent messages.
// FREEBIE
* Rename ReadReceipts to ReadSyncs
* Render read messages with blue double checks
* Send read receipts to senders of incoming messages
// FREEBIE
* Move ReadSyncs to their own file
// FREEBIE
* Fixup old comments on read receipts (now read syncs)
And some variable renaming for extra clarity.
// FREEBIE
* Add global setting for read receipts
Don't send read receipt messages unless the setting is enabled.
Don't process read receipts if the setting is disabled.
// FREEBIE
* Sync read receipt setting from mobile
Toggling this setting on your mobile device should sync it to Desktop. When
linking, use the setting in the provisioning message.
// FREEBIE
* Send receipt messages silently
Avoid generating phantom messages on ios
// FREEBIE
* Save recipients on the outgoing message models
For accurate tracking and display of sent/delivered/read state, even if group
membership changes later.
// FREEBIE
* Fix conversation type in profile key update handling
// FREEBIE
* Set recipients on synced sent messages
* Render saved recipients in message detail if available
For older messages, where we did not save the intended set of recipients at the
time of sending, fall back to the current group membership.
// FREEBIE
* Record who has been successfully sent to
// FREEBIE
* Record who a message has been delivered to
* Invert the not-clickable class
* Fix readReceipt setting sync when linking
* Render per recipient sent/delivered/read status
In the message detail view for outgoing messages, render each recipient's
individual sent/delivered/read status with respect to this message, as long as
there are no errors associated with the recipient (ie, safety number changes,
user not registered, etc...) since the error icon is displayed in that case.
*Messages sent before this change may not have per-recipient status lists
and will simply show no status icon.
// FREEBIE
* Add configuration sync request
Send these requests in a one-off fashion when:
1. We have just setup from a chrome app import
2. We have just upgraded to read-receipt support
// FREEBIE
* Expose sendRequestConfigurationSyncMessage
// FREEBIE
* Fix handling of incoming delivery receipts - union with array
FREEBIE
2017-10-04 22:28:43 +00:00
|
|
|
var type, id;
|
|
|
|
if (data.message.group) {
|
|
|
|
type = 'group';
|
|
|
|
id = data.message.group.id;
|
|
|
|
} else {
|
|
|
|
type = 'private';
|
|
|
|
id = data.destination;
|
|
|
|
}
|
|
|
|
|
2017-09-11 16:50:35 +00:00
|
|
|
if (data.message.flags & textsecure.protobuf.DataMessage.Flags.PROFILE_KEY_UPDATE) {
|
Feature: Blue check marks for read messages if opted in (#1489)
* Refactor delivery receipt event handler
* Rename the delivery receipt event
For less ambiguity with read receipts.
* Rename synced read event
For less ambiguity with read receipts from other Signal users.
* Add support for incoming receipt messages
Handle ReceiptMessages, which may include encrypted delivery receipts or read
receipts from recipients of our sent messages.
// FREEBIE
* Rename ReadReceipts to ReadSyncs
* Render read messages with blue double checks
* Send read receipts to senders of incoming messages
// FREEBIE
* Move ReadSyncs to their own file
// FREEBIE
* Fixup old comments on read receipts (now read syncs)
And some variable renaming for extra clarity.
// FREEBIE
* Add global setting for read receipts
Don't send read receipt messages unless the setting is enabled.
Don't process read receipts if the setting is disabled.
// FREEBIE
* Sync read receipt setting from mobile
Toggling this setting on your mobile device should sync it to Desktop. When
linking, use the setting in the provisioning message.
// FREEBIE
* Send receipt messages silently
Avoid generating phantom messages on ios
// FREEBIE
* Save recipients on the outgoing message models
For accurate tracking and display of sent/delivered/read state, even if group
membership changes later.
// FREEBIE
* Fix conversation type in profile key update handling
// FREEBIE
* Set recipients on synced sent messages
* Render saved recipients in message detail if available
For older messages, where we did not save the intended set of recipients at the
time of sending, fall back to the current group membership.
// FREEBIE
* Record who has been successfully sent to
// FREEBIE
* Record who a message has been delivered to
* Invert the not-clickable class
* Fix readReceipt setting sync when linking
* Render per recipient sent/delivered/read status
In the message detail view for outgoing messages, render each recipient's
individual sent/delivered/read status with respect to this message, as long as
there are no errors associated with the recipient (ie, safety number changes,
user not registered, etc...) since the error icon is displayed in that case.
*Messages sent before this change may not have per-recipient status lists
and will simply show no status icon.
// FREEBIE
* Add configuration sync request
Send these requests in a one-off fashion when:
1. We have just setup from a chrome app import
2. We have just upgraded to read-receipt support
// FREEBIE
* Expose sendRequestConfigurationSyncMessage
// FREEBIE
* Fix handling of incoming delivery receipts - union with array
FREEBIE
2017-10-04 22:28:43 +00:00
|
|
|
return ConversationController.getOrCreateAndWait(id, type).then(function(convo) {
|
2017-09-11 16:50:35 +00:00
|
|
|
return convo.save({profileSharing: true}).then(ev.confirm);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-09-22 00:05:19 +00:00
|
|
|
var message = new Whisper.Message({
|
|
|
|
source : textsecure.storage.user.getNumber(),
|
2017-07-17 22:46:00 +00:00
|
|
|
sourceDevice : data.device,
|
2015-09-22 00:05:19 +00:00
|
|
|
sent_at : data.timestamp,
|
|
|
|
received_at : now,
|
|
|
|
conversationId : data.destination,
|
|
|
|
type : 'outgoing',
|
2016-09-21 00:19:51 +00:00
|
|
|
sent : true,
|
|
|
|
expirationStartTimestamp: data.expirationStartTimestamp,
|
2015-09-22 00:05:19 +00:00
|
|
|
});
|
2015-06-01 21:08:21 +00:00
|
|
|
|
2017-07-25 01:43:35 +00:00
|
|
|
return isMessageDuplicate(message).then(function(isDuplicate) {
|
2017-07-17 22:46:00 +00:00
|
|
|
if (isDuplicate) {
|
|
|
|
console.log('Received duplicate message', message.idForLogging());
|
|
|
|
ev.confirm();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-09-01 16:10:41 +00:00
|
|
|
return ConversationController.getOrCreateAndWait(id, type).then(function() {
|
|
|
|
return message.handleDataMessage(data.message, ev.confirm, {
|
|
|
|
initialLoadComplete: initialLoadComplete
|
|
|
|
});
|
2017-07-25 01:43:35 +00:00
|
|
|
});
|
2017-07-17 22:46:00 +00:00
|
|
|
});
|
2015-09-22 00:05:19 +00:00
|
|
|
}
|
2015-06-01 21:08:21 +00:00
|
|
|
|
2017-07-17 22:46:00 +00:00
|
|
|
function isMessageDuplicate(message) {
|
|
|
|
return new Promise(function(resolve) {
|
|
|
|
var fetcher = new Whisper.Message();
|
|
|
|
var options = {
|
|
|
|
index: {
|
|
|
|
name: 'unique',
|
|
|
|
value: [
|
|
|
|
message.get('source'),
|
|
|
|
message.get('sourceDevice'),
|
|
|
|
message.get('sent_at')
|
|
|
|
]
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
fetcher.fetch(options).always(function() {
|
|
|
|
if (fetcher.get('id')) {
|
|
|
|
return resolve(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
return resolve(false);
|
|
|
|
});
|
|
|
|
}).catch(function(error) {
|
|
|
|
console.log('isMessageDuplicate error:', error && error.stack ? error.stack : error);
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function initIncomingMessage(data) {
|
2015-09-22 00:05:19 +00:00
|
|
|
var message = new Whisper.Message({
|
2017-07-17 22:46:00 +00:00
|
|
|
source : data.source,
|
|
|
|
sourceDevice : data.sourceDevice,
|
|
|
|
sent_at : data.timestamp,
|
2017-08-12 00:06:48 +00:00
|
|
|
received_at : data.receivedAt || Date.now(),
|
2017-07-17 22:46:00 +00:00
|
|
|
conversationId : data.source,
|
2016-02-22 05:37:47 +00:00
|
|
|
type : 'incoming',
|
2016-02-26 20:25:32 +00:00
|
|
|
unread : 1
|
2015-09-22 00:05:19 +00:00
|
|
|
});
|
2014-12-20 00:49:18 +00:00
|
|
|
|
2015-09-22 00:05:19 +00:00
|
|
|
return message;
|
|
|
|
}
|
2015-06-01 21:08:21 +00:00
|
|
|
|
2015-09-22 00:05:19 +00:00
|
|
|
function onError(ev) {
|
2017-08-25 21:24:16 +00:00
|
|
|
var error = ev.error;
|
|
|
|
console.log(error);
|
|
|
|
console.log(error.stack);
|
2015-06-19 22:32:25 +00:00
|
|
|
|
2017-08-25 21:24:16 +00:00
|
|
|
if (error.name === 'HTTPError' && (error.code == 401 || error.code == 403)) {
|
2016-09-20 20:42:33 +00:00
|
|
|
Whisper.Registration.remove();
|
2017-04-12 21:11:51 +00:00
|
|
|
Whisper.events.trigger('unauthorized');
|
2015-09-22 00:05:19 +00:00
|
|
|
return;
|
|
|
|
}
|
2015-06-19 22:32:25 +00:00
|
|
|
|
2017-08-25 21:24:16 +00:00
|
|
|
if (error.name === 'HTTPError' && error.code == -1) {
|
2015-09-22 00:05:19 +00:00
|
|
|
// Failed to connect to server
|
|
|
|
if (navigator.onLine) {
|
|
|
|
console.log('retrying in 1 minute');
|
2017-08-08 00:24:59 +00:00
|
|
|
setTimeout(connect, 60000);
|
2017-01-04 03:37:56 +00:00
|
|
|
|
2017-04-12 21:11:51 +00:00
|
|
|
Whisper.events.trigger('reconnectTimer');
|
2015-07-16 20:16:25 +00:00
|
|
|
}
|
2015-09-22 00:05:19 +00:00
|
|
|
return;
|
|
|
|
}
|
2015-07-16 20:16:25 +00:00
|
|
|
|
2015-09-22 00:05:19 +00:00
|
|
|
if (ev.proto) {
|
2017-08-25 21:24:16 +00:00
|
|
|
if (error.name === 'MessageCounterError') {
|
|
|
|
if (ev.confirm) {
|
|
|
|
ev.confirm();
|
|
|
|
}
|
2015-12-04 02:37:45 +00:00
|
|
|
// Ignore this message. It is likely a duplicate delivery
|
|
|
|
// because the server lost our ack the first time.
|
|
|
|
return;
|
|
|
|
}
|
2015-09-22 00:05:19 +00:00
|
|
|
var envelope = ev.proto;
|
2017-08-08 21:03:57 +00:00
|
|
|
var message = initIncomingMessage(envelope);
|
2017-07-25 17:33:28 +00:00
|
|
|
|
2017-08-25 21:24:16 +00:00
|
|
|
return message.saveErrors(error).then(function() {
|
2017-07-25 17:33:28 +00:00
|
|
|
var id = message.get('conversationId');
|
2017-09-01 16:10:41 +00:00
|
|
|
return ConversationController.getOrCreateAndWait(id, 'private').then(function(conversation) {
|
2016-03-25 21:28:09 +00:00
|
|
|
conversation.set({
|
2015-09-22 00:05:19 +00:00
|
|
|
active_at: Date.now(),
|
|
|
|
unreadCount: conversation.get('unreadCount') + 1
|
2015-07-10 19:24:12 +00:00
|
|
|
});
|
2016-03-25 21:28:09 +00:00
|
|
|
|
|
|
|
var conversation_timestamp = conversation.get('timestamp');
|
|
|
|
var message_timestamp = message.get('timestamp');
|
|
|
|
if (!conversation_timestamp || message_timestamp > conversation_timestamp) {
|
|
|
|
conversation.set({ timestamp: message.get('sent_at') });
|
|
|
|
}
|
2017-07-25 17:41:51 +00:00
|
|
|
|
2015-11-07 22:11:13 +00:00
|
|
|
conversation.trigger('newmessage', message);
|
2017-09-29 16:15:28 +00:00
|
|
|
conversation.notify(message);
|
2017-07-25 17:41:51 +00:00
|
|
|
|
2017-08-25 21:24:16 +00:00
|
|
|
if (ev.confirm) {
|
|
|
|
ev.confirm();
|
|
|
|
}
|
|
|
|
|
2017-07-25 17:41:51 +00:00
|
|
|
return new Promise(function(resolve, reject) {
|
|
|
|
conversation.save().then(resolve, reject);
|
|
|
|
});
|
2015-09-15 21:40:37 +00:00
|
|
|
});
|
2015-09-22 00:05:19 +00:00
|
|
|
});
|
2015-05-12 22:14:20 +00:00
|
|
|
}
|
2014-12-20 00:49:18 +00:00
|
|
|
|
2017-08-25 21:24:16 +00:00
|
|
|
throw error;
|
2015-09-22 00:05:19 +00:00
|
|
|
}
|
2015-05-18 20:48:48 +00:00
|
|
|
|
2016-02-20 00:28:08 +00:00
|
|
|
function onReadReceipt(ev) {
|
2016-09-21 22:06:31 +00:00
|
|
|
var read_at = ev.timestamp;
|
|
|
|
var timestamp = ev.read.timestamp;
|
Feature: Blue check marks for read messages if opted in (#1489)
* Refactor delivery receipt event handler
* Rename the delivery receipt event
For less ambiguity with read receipts.
* Rename synced read event
For less ambiguity with read receipts from other Signal users.
* Add support for incoming receipt messages
Handle ReceiptMessages, which may include encrypted delivery receipts or read
receipts from recipients of our sent messages.
// FREEBIE
* Rename ReadReceipts to ReadSyncs
* Render read messages with blue double checks
* Send read receipts to senders of incoming messages
// FREEBIE
* Move ReadSyncs to their own file
// FREEBIE
* Fixup old comments on read receipts (now read syncs)
And some variable renaming for extra clarity.
// FREEBIE
* Add global setting for read receipts
Don't send read receipt messages unless the setting is enabled.
Don't process read receipts if the setting is disabled.
// FREEBIE
* Sync read receipt setting from mobile
Toggling this setting on your mobile device should sync it to Desktop. When
linking, use the setting in the provisioning message.
// FREEBIE
* Send receipt messages silently
Avoid generating phantom messages on ios
// FREEBIE
* Save recipients on the outgoing message models
For accurate tracking and display of sent/delivered/read state, even if group
membership changes later.
// FREEBIE
* Fix conversation type in profile key update handling
// FREEBIE
* Set recipients on synced sent messages
* Render saved recipients in message detail if available
For older messages, where we did not save the intended set of recipients at the
time of sending, fall back to the current group membership.
// FREEBIE
* Record who has been successfully sent to
// FREEBIE
* Record who a message has been delivered to
* Invert the not-clickable class
* Fix readReceipt setting sync when linking
* Render per recipient sent/delivered/read status
In the message detail view for outgoing messages, render each recipient's
individual sent/delivered/read status with respect to this message, as long as
there are no errors associated with the recipient (ie, safety number changes,
user not registered, etc...) since the error icon is displayed in that case.
*Messages sent before this change may not have per-recipient status lists
and will simply show no status icon.
// FREEBIE
* Add configuration sync request
Send these requests in a one-off fashion when:
1. We have just setup from a chrome app import
2. We have just upgraded to read-receipt support
// FREEBIE
* Expose sendRequestConfigurationSyncMessage
// FREEBIE
* Fix handling of incoming delivery receipts - union with array
FREEBIE
2017-10-04 22:28:43 +00:00
|
|
|
var reader = ev.read.reader;
|
|
|
|
console.log('read receipt', reader, timestamp);
|
|
|
|
|
|
|
|
if (!storage.get('read-receipt-setting')) {
|
|
|
|
return ev.confirm();
|
|
|
|
}
|
2017-07-25 01:43:35 +00:00
|
|
|
|
2017-07-17 22:46:00 +00:00
|
|
|
var receipt = Whisper.ReadReceipts.add({
|
Feature: Blue check marks for read messages if opted in (#1489)
* Refactor delivery receipt event handler
* Rename the delivery receipt event
For less ambiguity with read receipts.
* Rename synced read event
For less ambiguity with read receipts from other Signal users.
* Add support for incoming receipt messages
Handle ReceiptMessages, which may include encrypted delivery receipts or read
receipts from recipients of our sent messages.
// FREEBIE
* Rename ReadReceipts to ReadSyncs
* Render read messages with blue double checks
* Send read receipts to senders of incoming messages
// FREEBIE
* Move ReadSyncs to their own file
// FREEBIE
* Fixup old comments on read receipts (now read syncs)
And some variable renaming for extra clarity.
// FREEBIE
* Add global setting for read receipts
Don't send read receipt messages unless the setting is enabled.
Don't process read receipts if the setting is disabled.
// FREEBIE
* Sync read receipt setting from mobile
Toggling this setting on your mobile device should sync it to Desktop. When
linking, use the setting in the provisioning message.
// FREEBIE
* Send receipt messages silently
Avoid generating phantom messages on ios
// FREEBIE
* Save recipients on the outgoing message models
For accurate tracking and display of sent/delivered/read state, even if group
membership changes later.
// FREEBIE
* Fix conversation type in profile key update handling
// FREEBIE
* Set recipients on synced sent messages
* Render saved recipients in message detail if available
For older messages, where we did not save the intended set of recipients at the
time of sending, fall back to the current group membership.
// FREEBIE
* Record who has been successfully sent to
// FREEBIE
* Record who a message has been delivered to
* Invert the not-clickable class
* Fix readReceipt setting sync when linking
* Render per recipient sent/delivered/read status
In the message detail view for outgoing messages, render each recipient's
individual sent/delivered/read status with respect to this message, as long as
there are no errors associated with the recipient (ie, safety number changes,
user not registered, etc...) since the error icon is displayed in that case.
*Messages sent before this change may not have per-recipient status lists
and will simply show no status icon.
// FREEBIE
* Add configuration sync request
Send these requests in a one-off fashion when:
1. We have just setup from a chrome app import
2. We have just upgraded to read-receipt support
// FREEBIE
* Expose sendRequestConfigurationSyncMessage
// FREEBIE
* Fix handling of incoming delivery receipts - union with array
FREEBIE
2017-10-04 22:28:43 +00:00
|
|
|
reader : reader,
|
|
|
|
timestamp : timestamp,
|
|
|
|
read_at : read_at,
|
|
|
|
});
|
|
|
|
|
|
|
|
receipt.on('remove', ev.confirm);
|
|
|
|
|
|
|
|
// Calling this directly so we can wait for completion
|
|
|
|
return Whisper.ReadReceipts.onReceipt(receipt);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onReadSync(ev) {
|
|
|
|
var read_at = ev.timestamp;
|
|
|
|
var timestamp = ev.read.timestamp;
|
|
|
|
var sender = ev.read.sender;
|
|
|
|
console.log('read sync', sender, timestamp);
|
|
|
|
|
|
|
|
var receipt = Whisper.ReadSyncs.add({
|
2016-09-21 22:06:31 +00:00
|
|
|
sender : sender,
|
|
|
|
timestamp : timestamp,
|
|
|
|
read_at : read_at
|
|
|
|
});
|
2017-07-25 01:43:35 +00:00
|
|
|
|
2017-07-17 22:46:00 +00:00
|
|
|
receipt.on('remove', ev.confirm);
|
2017-08-04 01:10:45 +00:00
|
|
|
|
|
|
|
// Calling this directly so we can wait for completion
|
Feature: Blue check marks for read messages if opted in (#1489)
* Refactor delivery receipt event handler
* Rename the delivery receipt event
For less ambiguity with read receipts.
* Rename synced read event
For less ambiguity with read receipts from other Signal users.
* Add support for incoming receipt messages
Handle ReceiptMessages, which may include encrypted delivery receipts or read
receipts from recipients of our sent messages.
// FREEBIE
* Rename ReadReceipts to ReadSyncs
* Render read messages with blue double checks
* Send read receipts to senders of incoming messages
// FREEBIE
* Move ReadSyncs to their own file
// FREEBIE
* Fixup old comments on read receipts (now read syncs)
And some variable renaming for extra clarity.
// FREEBIE
* Add global setting for read receipts
Don't send read receipt messages unless the setting is enabled.
Don't process read receipts if the setting is disabled.
// FREEBIE
* Sync read receipt setting from mobile
Toggling this setting on your mobile device should sync it to Desktop. When
linking, use the setting in the provisioning message.
// FREEBIE
* Send receipt messages silently
Avoid generating phantom messages on ios
// FREEBIE
* Save recipients on the outgoing message models
For accurate tracking and display of sent/delivered/read state, even if group
membership changes later.
// FREEBIE
* Fix conversation type in profile key update handling
// FREEBIE
* Set recipients on synced sent messages
* Render saved recipients in message detail if available
For older messages, where we did not save the intended set of recipients at the
time of sending, fall back to the current group membership.
// FREEBIE
* Record who has been successfully sent to
// FREEBIE
* Record who a message has been delivered to
* Invert the not-clickable class
* Fix readReceipt setting sync when linking
* Render per recipient sent/delivered/read status
In the message detail view for outgoing messages, render each recipient's
individual sent/delivered/read status with respect to this message, as long as
there are no errors associated with the recipient (ie, safety number changes,
user not registered, etc...) since the error icon is displayed in that case.
*Messages sent before this change may not have per-recipient status lists
and will simply show no status icon.
// FREEBIE
* Add configuration sync request
Send these requests in a one-off fashion when:
1. We have just setup from a chrome app import
2. We have just upgraded to read-receipt support
// FREEBIE
* Expose sendRequestConfigurationSyncMessage
// FREEBIE
* Fix handling of incoming delivery receipts - union with array
FREEBIE
2017-10-04 22:28:43 +00:00
|
|
|
return Whisper.ReadSyncs.onReceipt(receipt);
|
2016-02-20 00:28:08 +00:00
|
|
|
}
|
|
|
|
|
2017-06-19 16:08:16 +00:00
|
|
|
function onVerified(ev) {
|
|
|
|
var number = ev.verified.destination;
|
|
|
|
var key = ev.verified.identityKey;
|
2017-06-15 23:37:20 +00:00
|
|
|
var state;
|
|
|
|
|
2017-07-21 17:59:41 +00:00
|
|
|
var c = new Whisper.Conversation({
|
|
|
|
id: number
|
|
|
|
});
|
|
|
|
var error = c.validateNumber();
|
|
|
|
if (error) {
|
|
|
|
console.log(
|
|
|
|
'Invalid verified sync received',
|
|
|
|
error && error.stack ? error.stack : error
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-06-19 16:08:16 +00:00
|
|
|
switch(ev.verified.state) {
|
2017-07-21 17:59:41 +00:00
|
|
|
case textsecure.protobuf.Verified.State.DEFAULT:
|
|
|
|
state = 'DEFAULT';
|
|
|
|
break;
|
|
|
|
case textsecure.protobuf.Verified.State.VERIFIED:
|
|
|
|
state = 'VERIFIED';
|
|
|
|
break;
|
|
|
|
case textsecure.protobuf.Verified.State.UNVERIFIED:
|
|
|
|
state = 'UNVERIFIED';
|
|
|
|
break;
|
2017-06-15 23:37:20 +00:00
|
|
|
}
|
2017-06-15 23:12:58 +00:00
|
|
|
|
2017-07-11 01:25:21 +00:00
|
|
|
console.log('got verified sync for', number, state,
|
|
|
|
ev.viaContactSync ? 'via contact sync' : '');
|
2017-06-20 17:52:06 +00:00
|
|
|
|
2017-09-01 16:10:41 +00:00
|
|
|
return ConversationController.getOrCreateAndWait(number, 'private').then(function(contact) {
|
2017-07-21 17:59:41 +00:00
|
|
|
var options = {
|
|
|
|
viaSyncMessage: true,
|
|
|
|
viaContactSync: ev.viaContactSync,
|
|
|
|
key: key
|
|
|
|
};
|
2017-07-04 00:31:57 +00:00
|
|
|
|
2017-07-21 17:59:41 +00:00
|
|
|
if (state === 'VERIFIED') {
|
|
|
|
return contact.setVerified(options).then(ev.confirm);
|
|
|
|
} else if (state === 'DEFAULT') {
|
|
|
|
return contact.setVerifiedDefault(options).then(ev.confirm);
|
|
|
|
} else {
|
|
|
|
return contact.setUnverified(options).then(ev.confirm);
|
|
|
|
}
|
|
|
|
});
|
2017-06-15 23:12:58 +00:00
|
|
|
}
|
|
|
|
|
2015-09-22 00:05:19 +00:00
|
|
|
function onDeliveryReceipt(ev) {
|
Feature: Blue check marks for read messages if opted in (#1489)
* Refactor delivery receipt event handler
* Rename the delivery receipt event
For less ambiguity with read receipts.
* Rename synced read event
For less ambiguity with read receipts from other Signal users.
* Add support for incoming receipt messages
Handle ReceiptMessages, which may include encrypted delivery receipts or read
receipts from recipients of our sent messages.
// FREEBIE
* Rename ReadReceipts to ReadSyncs
* Render read messages with blue double checks
* Send read receipts to senders of incoming messages
// FREEBIE
* Move ReadSyncs to their own file
// FREEBIE
* Fixup old comments on read receipts (now read syncs)
And some variable renaming for extra clarity.
// FREEBIE
* Add global setting for read receipts
Don't send read receipt messages unless the setting is enabled.
Don't process read receipts if the setting is disabled.
// FREEBIE
* Sync read receipt setting from mobile
Toggling this setting on your mobile device should sync it to Desktop. When
linking, use the setting in the provisioning message.
// FREEBIE
* Send receipt messages silently
Avoid generating phantom messages on ios
// FREEBIE
* Save recipients on the outgoing message models
For accurate tracking and display of sent/delivered/read state, even if group
membership changes later.
// FREEBIE
* Fix conversation type in profile key update handling
// FREEBIE
* Set recipients on synced sent messages
* Render saved recipients in message detail if available
For older messages, where we did not save the intended set of recipients at the
time of sending, fall back to the current group membership.
// FREEBIE
* Record who has been successfully sent to
// FREEBIE
* Record who a message has been delivered to
* Invert the not-clickable class
* Fix readReceipt setting sync when linking
* Render per recipient sent/delivered/read status
In the message detail view for outgoing messages, render each recipient's
individual sent/delivered/read status with respect to this message, as long as
there are no errors associated with the recipient (ie, safety number changes,
user not registered, etc...) since the error icon is displayed in that case.
*Messages sent before this change may not have per-recipient status lists
and will simply show no status icon.
// FREEBIE
* Add configuration sync request
Send these requests in a one-off fashion when:
1. We have just setup from a chrome app import
2. We have just upgraded to read-receipt support
// FREEBIE
* Expose sendRequestConfigurationSyncMessage
// FREEBIE
* Fix handling of incoming delivery receipts - union with array
FREEBIE
2017-10-04 22:28:43 +00:00
|
|
|
var deliveryReceipt = ev.deliveryReceipt;
|
2016-04-09 07:16:21 +00:00
|
|
|
console.log(
|
|
|
|
'delivery receipt from',
|
Feature: Blue check marks for read messages if opted in (#1489)
* Refactor delivery receipt event handler
* Rename the delivery receipt event
For less ambiguity with read receipts.
* Rename synced read event
For less ambiguity with read receipts from other Signal users.
* Add support for incoming receipt messages
Handle ReceiptMessages, which may include encrypted delivery receipts or read
receipts from recipients of our sent messages.
// FREEBIE
* Rename ReadReceipts to ReadSyncs
* Render read messages with blue double checks
* Send read receipts to senders of incoming messages
// FREEBIE
* Move ReadSyncs to their own file
// FREEBIE
* Fixup old comments on read receipts (now read syncs)
And some variable renaming for extra clarity.
// FREEBIE
* Add global setting for read receipts
Don't send read receipt messages unless the setting is enabled.
Don't process read receipts if the setting is disabled.
// FREEBIE
* Sync read receipt setting from mobile
Toggling this setting on your mobile device should sync it to Desktop. When
linking, use the setting in the provisioning message.
// FREEBIE
* Send receipt messages silently
Avoid generating phantom messages on ios
// FREEBIE
* Save recipients on the outgoing message models
For accurate tracking and display of sent/delivered/read state, even if group
membership changes later.
// FREEBIE
* Fix conversation type in profile key update handling
// FREEBIE
* Set recipients on synced sent messages
* Render saved recipients in message detail if available
For older messages, where we did not save the intended set of recipients at the
time of sending, fall back to the current group membership.
// FREEBIE
* Record who has been successfully sent to
// FREEBIE
* Record who a message has been delivered to
* Invert the not-clickable class
* Fix readReceipt setting sync when linking
* Render per recipient sent/delivered/read status
In the message detail view for outgoing messages, render each recipient's
individual sent/delivered/read status with respect to this message, as long as
there are no errors associated with the recipient (ie, safety number changes,
user not registered, etc...) since the error icon is displayed in that case.
*Messages sent before this change may not have per-recipient status lists
and will simply show no status icon.
// FREEBIE
* Add configuration sync request
Send these requests in a one-off fashion when:
1. We have just setup from a chrome app import
2. We have just upgraded to read-receipt support
// FREEBIE
* Expose sendRequestConfigurationSyncMessage
// FREEBIE
* Fix handling of incoming delivery receipts - union with array
FREEBIE
2017-10-04 22:28:43 +00:00
|
|
|
deliveryReceipt.source + '.' + deliveryReceipt.sourceDevice,
|
|
|
|
deliveryReceipt.timestamp
|
2016-04-09 07:16:21 +00:00
|
|
|
);
|
2015-12-09 22:43:53 +00:00
|
|
|
|
2017-07-17 22:46:00 +00:00
|
|
|
var receipt = Whisper.DeliveryReceipts.add({
|
Feature: Blue check marks for read messages if opted in (#1489)
* Refactor delivery receipt event handler
* Rename the delivery receipt event
For less ambiguity with read receipts.
* Rename synced read event
For less ambiguity with read receipts from other Signal users.
* Add support for incoming receipt messages
Handle ReceiptMessages, which may include encrypted delivery receipts or read
receipts from recipients of our sent messages.
// FREEBIE
* Rename ReadReceipts to ReadSyncs
* Render read messages with blue double checks
* Send read receipts to senders of incoming messages
// FREEBIE
* Move ReadSyncs to their own file
// FREEBIE
* Fixup old comments on read receipts (now read syncs)
And some variable renaming for extra clarity.
// FREEBIE
* Add global setting for read receipts
Don't send read receipt messages unless the setting is enabled.
Don't process read receipts if the setting is disabled.
// FREEBIE
* Sync read receipt setting from mobile
Toggling this setting on your mobile device should sync it to Desktop. When
linking, use the setting in the provisioning message.
// FREEBIE
* Send receipt messages silently
Avoid generating phantom messages on ios
// FREEBIE
* Save recipients on the outgoing message models
For accurate tracking and display of sent/delivered/read state, even if group
membership changes later.
// FREEBIE
* Fix conversation type in profile key update handling
// FREEBIE
* Set recipients on synced sent messages
* Render saved recipients in message detail if available
For older messages, where we did not save the intended set of recipients at the
time of sending, fall back to the current group membership.
// FREEBIE
* Record who has been successfully sent to
// FREEBIE
* Record who a message has been delivered to
* Invert the not-clickable class
* Fix readReceipt setting sync when linking
* Render per recipient sent/delivered/read status
In the message detail view for outgoing messages, render each recipient's
individual sent/delivered/read status with respect to this message, as long as
there are no errors associated with the recipient (ie, safety number changes,
user not registered, etc...) since the error icon is displayed in that case.
*Messages sent before this change may not have per-recipient status lists
and will simply show no status icon.
// FREEBIE
* Add configuration sync request
Send these requests in a one-off fashion when:
1. We have just setup from a chrome app import
2. We have just upgraded to read-receipt support
// FREEBIE
* Expose sendRequestConfigurationSyncMessage
// FREEBIE
* Fix handling of incoming delivery receipts - union with array
FREEBIE
2017-10-04 22:28:43 +00:00
|
|
|
timestamp: deliveryReceipt.timestamp,
|
|
|
|
source: deliveryReceipt.source
|
2015-09-22 00:05:19 +00:00
|
|
|
});
|
2017-07-25 01:43:35 +00:00
|
|
|
|
2017-07-17 22:46:00 +00:00
|
|
|
receipt.on('remove', ev.confirm);
|
2017-08-04 01:10:45 +00:00
|
|
|
|
|
|
|
// Calling this directly so we can wait for completion
|
|
|
|
return Whisper.DeliveryReceipts.onReceipt(receipt);
|
2015-09-22 00:05:19 +00:00
|
|
|
}
|
Finish abstracting native client
Firstly, don't initialize textsecure.nativclient unless the browser
supports it. The mimetype-check trick is hewn from nacl-common.js.
Secondly, nativeclient crypto functions will all automatically wait for
the module to load before sending messages, so we needn't register any
onload callbacks outside nativeclient.js. (Previously, if you wanted to
do crypto with native client, you would have to register a call back and
wait for the module to load.) Now that the native client crypto is
encapsulated behind a nice interface, it can handle all that
onload-callback jazz internally: if the module isn't loaded when you
call a nativeclient function, return a promise that waits for the load
callback, and eventually resolves with the result of the requested
command. This removes the need for textsecure.registerOnLoadCallback.
Finally, although native client has its quirks, it's significantly
faster than the alternative (emscripten compiled js), so this commit
also lets the crypto backend use native client opportunistically, if
it's available, falling back to js if not, which should make us
compatible with older versions of chrome and chromium.
2014-11-09 01:26:20 +00:00
|
|
|
})();
|