Commit Graph

8115 Commits

Author SHA1 Message Date
Evan Hahn
9274b67d86 Swiftify proto parsing test
I also moved it to the `SignalServiceKit` tests because it's part of
that target, not the `Signal` target.
2022-10-07 01:07:31 +00:00
Nora Trapp
fe07005801 Tag story deletions as story sends 2022-10-06 15:35:54 -07:00
Evan Hahn
836a891204
Use #unavailable where possible, fixing SwiftLint violation
This fixes violations of [SwiftLint's `unavailable_condition` rule][0].
We can now do this because we're on Xcode 14.

[0]: https://realm.github.io/SwiftLint/unavailable_condition.html

Co-Authored-By: Sasha Weiss <sasha@signal.org>
2022-10-06 17:14:49 -05:00
Evan Hahn
349681ff85
Attempt to recover corrupted databases
If a user's database is corrupted, we now try to fix it. I recommend
reviewing `DatabaseRecovery` to see how this works, and
`DatabaseRecoveryViewController` for the bulk of the UI.
2022-10-06 16:42:19 -05:00
Harry
6aa417a41c
Hide/Delete story tweaks
* sort system stories normally after viewing

* scroll to hidden stories after hiding (or unhiding). Scroll to hidden story section after expanding

* if hiding/unhiding/deleting a story from within a viewer, proceed to the next story or context and remove the previous one from the viewer
2022-10-06 13:01:58 -07:00
Harry
86cdf19167
listen for onboarding story changes and update badge count 2022-10-06 12:58:44 -07:00
Harry Sanabria
039571e440 Fix legacy onboarding story cleanup 2022-10-06 12:10:27 -07:00
Sasha Weiss
2c50cce85a
Clean up some dead code around experience upgrades 2022-10-06 13:28:41 -05:00
Nora Trapp
556abddc64 Update the storiesDisabled flag in the accountRecord 2022-10-06 11:08:58 -07:00
Nora Trapp
d34a9da1e2 Fix stories incorrectly being disabled on upgrade 2022-10-06 11:08:58 -07:00
Nora Trapp
5065e898d4 Rev the storiesDisabled storage service field 2022-10-06 11:08:58 -07:00
Nora Trapp
3438fc0fed Allow delete messages to be tagged as stories 2022-10-06 11:08:58 -07:00
Evan Hahn
760e5c1c97
Add PNI registration ID to account attributes
Like "regular" registration IDs, this attaches a PNI registration ID to
account attributes. It's already synced at the right times (see
[`updateAccountAttributesIfNecessaryAttempt`][0]).

Tested this by registering and seeing the payload correctly sent to the
server.

See also: [Android's implementation][1].

[0]: 487405ef08/SignalServiceKit/src/Account/TSAccountManager.swift (L137)
[1]: 6e5f28339d/libsignal/service/src/main/java/org/whispersystems/signalservice/internal/push/PushServiceSocket.java (L378)
2022-10-05 16:13:33 -05:00
Nora Trapp
208d863739 Enable stories for beta users 2022-10-05 12:29:39 -07:00
Nora Trapp
9eb1c52dca Fix test 2022-10-05 12:29:39 -07:00
Nora Trapp
5b7b0ba390 Flag story SKDMs as story sends 2022-10-05 12:24:13 -07:00
Nora Trapp
437f98c2d3 Don't use UD for story prekey requests 2022-10-05 12:24:13 -07:00
Nora Trapp
433d63f003 Flag on websocket and REST message requests that stories are enabled 2022-10-05 12:24:13 -07:00
Nora Trapp
2d341189dd Drop invalid messages with the story flag on the envelope 2022-10-05 12:24:13 -07:00
Nora Trapp
1e613fe438 Use unrestricted sealed sender for story sends 2022-10-05 12:24:13 -07:00
Harry
de564afcaf
remove dataMigration_populateLastReceivedStoryTimestamp 2022-10-05 11:56:02 -07:00
Harry
6160765bf8
Mark onboarding story viewed for users who downloaded and viewed it before view state tracking code changes 2022-10-05 11:15:30 -07:00
Sasha Weiss
a057bde7e8
Reuse NSAttributedString formatting for MessageRequestView 2022-10-05 08:54:50 -07:00
Evan Hahn
160d46ef77
Fix debug assert when proto message has no addresses
This restores the behavior prior to
4a0141be41, where I made a mistake that
affect development builds.

Previously, the generated code looked like this, to prevent
instantiation of `SignalServiceAddress`es with no identifiers:

    // This is a sketch!
    let address: SignalServiceAddress? = {
      guard hasUuid || hasE164 else { return nil }
      let address = SignalServiceAddress(uuid: uuid, e164: e164)
      guard address.isValid else {
        owsFailDebug("address was unexpectedly invalid")
        return nil
      }
      return address
    }()

It makes sense (to me) to do this, because all proto fields are
optional. That means you can have a valid message that lacks both of
these fields, which is allowed. It shouldn't error.

However, I changed it to the equivalent of this, which caused an error
in `SignalServiceAddress`'s initializer:

    let address: SignalServiceAddress? = {
      let address = SignalServiceAddress(uuid: uuid, e164: e164)
      guard address.isValid else {
        return nil
      }
      return address
    }()

This reverts that to avoid the debug assertion failure. I don't think
this ever affected "real" builds beyond some extra logging.
2022-10-05 07:31:59 -07:00
Evan Hahn
56589799cb
Clean up registration ID generation
_This change should have no user impact._

This cleans up the way we generate registration IDs. It:

- Rewrites the generation code in Swift
- Removes the "sneaky transaction" method. I did this for clarity, and
  because we won't use it for much longer
- Turns a log warning into a regular log—generating a registration ID is
  not a problem
- Adds tests

I think this is a useful change on its own, but will be handy for an
upcoming change, too.
2022-10-05 14:09:07 +00:00
Evan Hahn
09a279e55d Swiftify fake message sender
This should only affect tests.

This was a pretty mechanical conversion. I removed some unused variables
while I was here, too.
2022-10-05 10:50:53 +00:00
Evan Hahn
b5e64e9fce Speed up link preview search code
Previously, we collected all URL matches and then searched through them.
Now, we search lazily, which should improve performance.

I added a perf test that repeats a URL a million times. The new code
finishes in ~0.001 seconds on my machine. The old code does not finish.
2022-10-04 14:09:00 -07:00
Evan Hahn
a066511a62 Remove useless test setup/teardown
We had a lot of functions like this, which are useless:

    override func setUp() {
        super.setUp()
    }

This removes them.
2022-10-04 14:06:34 -07:00
Sasha Weiss
814f6c1bf2
Skip inactive experience IDs, and opportunistically clear unknown ones 2022-10-04 12:22:24 -07:00
Sasha Weiss
7fb1da0cec
Migrate ExperienceUpgrade models to SDSCodableModel 2022-10-04 08:52:03 -07:00
Nora Trapp
49ed068fcd Allow sharing text to stories 2022-10-03 21:35:32 -07:00
Nora Trapp
5f3b5e841c Delete stories sent to a private list when it's deleted 2022-10-03 21:35:32 -07:00
Nora Trapp
6eca0a0ef2 Remotely delete all sent stories when deactivating stories 2022-10-03 21:35:32 -07:00
Harry
4100ee177b
Fix story video flickering due to excessive StoryItemMediaView recreation.
* Fix story video flickering due to excessive StoryItemMediaView recreation.

* remove debug assert if no attacgment found on dismiss, only affects debug builds but can happen if deleting while in the viewer

* fix text color for replies button on iOS 13

* pr feedback

* always set caption even if nil
2022-10-03 21:26:50 -07:00
Harry
74228f424e
Add StoryContextAssociatedData to compute story tab badge count without hidden stories
* Add StoryContextAssociatedData and db migrations

* Remove hideStory from ThreadAssociatedData

* Remove lastViewedStoryTimestamp and lastReceivedStoryTimestamp from TSThread

* drop deprecated columns in db migration

* add indexes

* dump schema.sql

* Update unviewed stories SQL query

* fix thread fetching for incoming story messages

* reload story tab badge when StoryContextAssociatedData changes

* Add test for TSGroupModel backwards-compatible deserialization

* move db migration

* Only use StoryContextAssociatedData for story badge count

* update StoryContextAssociatedData lastReceivedTime when a story message is deleted

* catch group threads for outgoing story messages too

* clean up sql query

* Only update lastReceievedStoryTimestamp for remote deletions

* add latestUnexpiredTimestamp to StoryContextAssociatedData
2022-10-03 21:16:01 -07:00
Evan Hahn
4a0141be41
Omit E164 from outgoing envelopes
[Android][0] and [Desktop][1] have already removed this field. This
follows suit.

The highlights:

- `SignalService.proto` removes some fields by making them `reserved`
- `ProtoWrappers.py` updates our code generation to support addresses
  that only have a UUID (previously, you needed both a UUID and E164
  field)
- Most everything else is removing E164s

[0]: 9c266e7995
[1]: 2b0d3cab40
2022-10-03 23:55:39 +00:00
Harry
e7b8f098dd
Increase story video max length to 30.999 seconds for android compatibility 2022-10-03 11:44:49 -07:00
Nora Trapp
55aea652ee Make sure we create a contact thread for any received private story 2022-09-29 16:48:39 -07:00
Max Radermacher
02ca8e2a99
Include http headers on web socket connections
Once initialized, a URLSession’s configuration can’t be changed. In
order to transfer the headers, assign them to the configuration before
assigning the configuration to the session.
2022-09-29 16:36:42 -07:00
Max Radermacher
0db3fb8106 Remove unsupported localizations
Also, clean up “Known Regions” in Xcode.
2022-09-29 16:13:06 -07:00
Nora Trapp
b962b752cb Don't auto-migrate groups on app launch 2022-09-29 09:35:00 -07:00
Nora Trapp
6930ffe2fa Remove old group capabilities 2022-09-29 09:35:00 -07:00
Nora Trapp
dd37ca526d Allow NSE to manage lifetime of proxy relay server 2022-09-27 17:05:05 -07:00
Sasha Weiss
063acc1419
Batch messageId notification cancellations 2022-09-27 14:26:44 -07:00
Evan Hahn
4de8ffa6af
Remove dead accessor from legacy message type
This change should have no user impact.

`TSInvalidIdentityKeyReceivingErrorMessage` had an unused method,
`theirSignalId`. This removes it.

`git grep -i theirSignalId` returns no results after this change.

I think this is a useful change on its own, but will also be useful in
an upcoming change.
2022-09-27 16:05:59 -05:00
Evan Hahn
e2f7ee47f4
Remove unused methods from message processing test
`MessageProcessingIntegrationTest` has some unused methods. These were
added in ec66f3b21e. According to George,
they're no longer needed and may have been added mistakenly.
2022-09-27 11:49:29 -07:00
Evan Hahn
653cb30a59 Use reserved in protobufs
_This change should have no user impact._ And you can see that the only
changes to generated files are in comments.

Before this change, we used comments to denote reserved or deprecated
fields. This works, but I think we should instead use the `reserved`
keyword, which offers a few advantages. From [the protobuf docs][0]:

> If you update a message type by entirely removing a field, or
> commenting it out, future users can reuse the field number when making
> their own updates to the type. This can cause severe issues if they
> later load old versions of the same .proto, including data corruption,
> privacy bugs, and so on. One way to make sure this doesn't happen is
> to specify that the field numbers (and/or names, which can also cause
> issues for JSON serialization) of your deleted fields are reserved.
> The protocol buffer compiler will complain if any future users try to
> use these field identifiers.

This updates our proto files to use `reserved` instead of comments. It
also adds support to our wrapper script. (I moved a few things around in
that script, too, for consistency.)

I think this is a useful change on its own, but I think it'll make
things a little better when we deprecate some fields, which we're
planning to do soon.

[0]: https://developers.google.com/protocol-buffers/docs/proto3#reserved
2022-09-27 18:45:38 +00:00
Harry
da06c1357c
Show my story privacy settings the first time you send to my story
* Add first send story privacy field to AccountRecord proto

* Store hasSetMyStoriesPrivacyKey on StoryManager

* sync hasSetMyStoriesPrivacy state

* Reuse MyStorySettingsViewController in a sheet view controller

* Show my story privacy settings from conversation picker if unset when selecting my story destination

* reload my story row to change subtitle

* pr feedback
2022-09-27 10:06:01 -07:00
Sasha Weiss
ac97aeba92
Migrate to using ExpiredProfileKeyCredentials 2022-09-26 14:33:57 -07:00
Nora Trapp
5e277b6eb4 Reduce logging 2022-09-26 13:48:00 -07:00