Commit Graph

2114 Commits

Author SHA1 Message Date
Daniel Gasienica
a48ba1c774 Selectively run ESLint on js/background.js
Enabling ESLint on a per function basis allows us to incrementally improve the codebase
without requiring large and potentially risky refactorings.
2018-02-15 15:15:00 -05:00
Daniel Gasienica
e6d1cf826b Move async attachment processing to onMessageReceived
We previously processed attachments in `handleDataMessage` which is mostly a synchronous
function, except for the saving of the model. Moving the processing into the already async
`onMessageReceived` improves code clarity.
2018-02-15 15:15:00 -05:00
Daniel Gasienica
e0cc3d8fab Implement attachment process version
Instead of keeping track of last normalization (processing) date, we now keep track of
an internal processing version that will help us understand what kind of processing has
already been completed for a given attachment. This will let us retroactively upgrade
existing attachments.

As we add more processing steps, we can build a processing pipeline that can convert any
attachment processing version into a higher one, e.g. 4 -> 5 -> 6 -> 7.
2018-02-15 15:15:00 -05:00
Daniel Gasienica
ebcb70258a Whitelist browser environment for ESLint 2018-02-15 15:14:59 -05:00
Daniel Gasienica
3eaace6f3a Use MIME module 2018-02-15 15:14:59 -05:00
Daniel Gasienica
ba2cf7770e 🎨 Fix lint errors 2018-02-15 15:14:59 -05:00
Daniel Gasienica
65acc86e85 Add ES2015+ files to JSHint ignored list 2018-02-15 15:14:59 -05:00
Daniel Gasienica
8b6494ae6c Document potentially unexpected autoScale behavior 2018-02-15 15:14:59 -05:00
Daniel Gasienica
213400e4b2 Add MIME type module 2018-02-15 15:14:59 -05:00
Daniel Gasienica
37a726e4fb Return proper Error from blobArrayToBuffer 2018-02-15 15:14:59 -05:00
Daniel Gasienica
164752db56 🎨 Fix ESLint errors 2018-02-15 15:14:59 -05:00
Daniel Gasienica
d498dd79a0 Update Attachment type field definitions 2018-02-15 15:14:59 -05:00
Daniel Gasienica
141155a153 Move blueimp-canvas-to-blob from Bower to npm 2018-02-15 15:14:59 -05:00
Daniel Gasienica
7ccb833e5d 🎨 Clarify data flow 2018-02-15 15:14:59 -05:00
Daniel Gasienica
e7da41591f Use blobUrl for consistency 2018-02-15 15:14:59 -05:00
Daniel Gasienica
523a80eefe Remove just-in-time image auto-orient for lightbox
We can bring this back if our users would like auto-orient for old attachments.
2018-02-15 15:14:59 -05:00
Daniel Gasienica
0739feae9c Remove just-in-time auto-orient of message attachments
We can bring this back if our users would like auto-orient for old attachments. But better
yet, we might implement this as database migration.
2018-02-15 15:14:59 -05:00
Daniel Gasienica
ed43c66f92 Auto-orient JPEG attachments upon receipt 2018-02-15 15:14:59 -05:00
Daniel Gasienica
9638fbc987 Use contentType from model 2018-02-15 15:14:59 -05:00
Daniel Gasienica
032c0ced46 Return Error object for autoOrientImage failures 2018-02-15 15:14:59 -05:00
Daniel Gasienica
ff04bad851 Add options for autoOrientImage output type / quality 2018-02-15 15:14:59 -05:00
Daniel Gasienica
87745b5586 Add Attachment type
Defines various functions on attachments, e.g. normalization (auto-orient JPEGs, etc.)
2018-02-15 15:14:59 -05:00
Daniel Gasienica
59974db5a5 Improve readability 2018-02-15 15:14:59 -05:00
Daniel Gasienica
b5ba96f1e6 Use snake_case for module names
Prevents problems across case-sensitive and case-insensitive file systems.

We can work around this in the future using a lint rule such as
`eslint-plugin-require-path-exists`.
See discussion:
https://github.com/signalapp/Signal-Desktop/pull/2040#discussion_r167365931
2018-02-15 15:14:59 -05:00
Daniel Gasienica
4822f49f22 Auto-orient images in lightbox view 2018-02-15 15:14:59 -05:00
Daniel Gasienica
7317110809 Document magic number for escape key 2018-02-15 15:14:59 -05:00
Daniel Gasienica
c790d07389 Make second View argument an options object 2018-02-15 15:14:59 -05:00
Daniel Gasienica
d07433e3cf Make autoOrientImage module standalone 2018-02-15 15:14:59 -05:00
Daniel Gasienica
c285bf5e33 Replace loadImage with autoOrientImage 2018-02-15 15:14:59 -05:00
Daniel Gasienica
4431854923 Add autoOrientImage module
This module exposes `loadImage` with a `Promise` based interface and pre-
populates `orientation: true` option to auto-orient input. Returns data URL
as string.

The module uses a named export as refactoring references of modules with
`default` (`module.exports`) export references can be error-prone.
See: https://basarat.gitbooks.io/typescript/docs/tips/defaultIsBad.html
2018-02-15 15:14:59 -05:00
Daniel Gasienica
c77063afc6 Auto-orient preview images
See: #998
2018-02-15 15:14:59 -05:00
Daniel Gasienica
06dba5eb8f TODO: Use native Canvas::toBlob
One challenge is that `Canvas::toBlob` is async whereas `dataURLtoBlob` is sync.
2018-02-15 15:14:59 -05:00
Daniel Gasienica
b15c304a31 Make null check strict
Appeases JSHint. ESLint has a nice `smart` option for `eqeqeq` rule:
https://eslint.org/docs/rules/eqeqeq#smart
2018-02-15 15:14:59 -05:00
Daniel Gasienica
ea70b92d9b Use Canvas::toDataURL to preserve ImageView logic
This way, all the other code paths remain untouched in case we want to remove
the auto-orient code once Chrome supports the `image-orientation` CSS property.

See:
- #998
- https://developer.mozilla.org/en-US/docs/Web/CSS/image-orientation
2018-02-15 15:14:59 -05:00
Daniel Gasienica
62fd744f9f Use CSS to constrain auto-oriented images 2018-02-15 15:14:59 -05:00
Daniel Gasienica
f4d3392687 Replace ImageView el with auto-oriented canvas
See: #998
2018-02-15 15:14:59 -05:00
Daniel Gasienica
1602d7f610 Pass Blob to View (for ImageView)
This allows us to do JPEG auto-orientation based on EXIF metadata.
2018-02-15 15:14:59 -05:00
Daniel Gasienica
e6a414f2b2 🔪 Remove newline 2018-02-15 15:14:59 -05:00
Daniel Gasienica
be5cbc9d2b Move ESLint environment configuration into .eslintrc (#2051) 2018-02-15 15:12:20 -05:00
Daniel Gasienica
b6ef67c402 Sync Protocol Buffers with libsignal-service-java (#2046)
Synchronizes our protocol buffers with `libsignal-service-java` project.

**Changes**
- [x] **BREAKING:** Rename `package` from `textsecure` to `signalservice`.
      ⚠️~~Workaround: Rename back to `textsecure`.~~
      Changed all protobuf `package` names across our project.
- [x] Rename `java_` metadata.
- [x] Move `NullMessage`, `ReceiptMessage`, and `Verified`.
- [x] Rename `Contacts.isComplete` to `Contacts.complete`. Confirmed to be
      unreferenced in our project.
- [x] Rename `Settings` to `Configuration` (`textsecure.protobuf.Settings` seems
      to be unused)
  - [x] Rename `libtextsecure` `MessageReceiver` `settings` event to
        `configuration`.
- [x] Rename `ReceiptMessage.timestamps` to `ReceiptMessage.timestamp`.
- [x] Add `AttachmentPointer` `width` and `height`.
- [x] Renamed `IncomingPushMessageSignal.proto` to `SignalService.proto` to
      match server.

---

commit 2b6aa19bf9
Author: Daniel Gasienica <daniel@gasienica.ch>
Date:   Wed Feb 14 19:41:24 2018 -0500

    Rename protobuf `package`: `textsecure` --> `signalservice`

    Brings us closer to `libsignal-service-java`.

commit 91612880a5
Author: Daniel Gasienica <daniel@gasienica.ch>
Date:   Wed Feb 14 19:19:35 2018 -0500

    Rename `SyncMessage.Settings` to `SyncMessage.Configuration`

commit 848eb95599
Author: Daniel Gasienica <daniel@gasienica.ch>
Date:   Tue Feb 13 20:16:43 2018 -0500

    Rename `ReadReceipt` `timestamps` --> `timestamp`

commit 39859e64b4
Author: Daniel Gasienica <daniel@gasienica.ch>
Date:   Wed Feb 14 18:43:42 2018 -0500

    Rename `IncomingPushMessageSignal.proto` to `SignalService.proto`

    This matches the `libsignal-service-java` filename.

commit fd4bfd76af
Author: Daniel Gasienica <daniel@gasienica.ch>
Date:   Tue Feb 13 16:24:36 2018 -0500

    Revert protobuf `package` to `textsecure`

    This was a breaking change and would need to be introduced with additional
    changes.

commit 9f618fa917
Author: Daniel Gasienica <daniel@gasienica.ch>
Date:   Tue Feb 13 16:09:55 2018 -0500

    Sync service protocol buffers with Java project

    Snapshot: 4684a49b2e/protobuf/SignalService.proto
2018-02-15 15:06:14 -05:00
Scott Nonnenberg
2cfdaca3c1 Make our binary comparisons constant time (#2047) 2018-02-14 12:15:26 -08:00
Scott Nonnenberg
7b49180bc0 Big update to new signal branding (#2018) 2018-01-30 14:22:51 -08:00
Scott Nonnenberg
72b7e4ec34 Process expireTimer and block status along with contact/group sync (#1980)
* Mark group as left = false if it is active in contact sync

* Handle expireTimer + blocked state along with contact/group sync
2018-01-29 18:14:39 -08:00
Scott Nonnenberg
fb2ebddaa3 Remove expired message if it expired during database fetch (#1983)
* Log SyncMessage destination, even if it's a group

* Remove disappearing message even if deleted during fetch

This change fixes a potential race condition with disappearing message
removal from the UI. If the UI is in the middle of making a database
request for messages to display, then we need to wait for that to
complete before removing the newly-deleted expired message.
2018-01-23 12:27:34 -08:00
Scott Nonnenberg
33fd9c5dd4 Account setup: confirm first signed prekey, clear prekeys (#1979) 2018-01-17 15:28:32 -08:00
Scott Nonnenberg
c70fb3a254 Video/audio: rely on the browser to detect content type (#1977) 2018-01-17 15:28:12 -08:00
Martino Pilia
7034d8759d Add badge for unread messages to the tray icon (#1934)
This commit adds a badge to the tray icon that displays the number of
unread messages, if there is any. It is implemented by providing
alternative versions of the icon, that replace the default image when a
message is received.

The badge is rendered graphically as a red circle containing the number
of unread messages. Since a different icon file is needed for each
possible number of unread messages, but this number is clearly
unbounded, only the numbers from 1 to 9 are provided. If there are 10 or
more unread messages, a single badge (depicted as "9+") is used.

Resolves #1917
2018-01-17 15:27:58 -08:00
Scott Nonnenberg
743e897541 Left pane: small sorting fix, logging for error cases (#1969) 2018-01-12 16:22:00 -08:00
Scott Nonnenberg
ce01eb7913 Log more info w/http errors, resilient to invalid group members (#1968)
* api.js: HttpError now preserves more of original error info

* Allow invalid conversation to be added to ConversationController

If a number we don't believe is valid comes in as part of a group, we
fall apart. We event prevent display of that conversation. Because we
have 'isValid()' protections in place for the places we create contacts
from user input in desktop (the search bar), we can temporarily add an
invalid contact to our collection (not saving it to the database) to
unblock this group scenario.

Still investigating what kind of phone number is valid in a mobile app
but not valid for us.

* Finish the debuggable error support

* Fix logging in the case of an invalid number
2018-01-12 16:19:26 -08:00
Scott Nonnenberg
bbab4bba10 Fix device ID check, clean up prekey fetch logging (#1961)
* DeviceId is a string, so we use the less-strict comparison

* Clean up prekey fetch logging
2018-01-10 18:12:24 -08:00