Commit Graph

8235 Commits

Author SHA1 Message Date
Evan Hahn
108dc85708
Parse disabled regions for upcoming payment methods
See also: [Android's equivalent commit][0].

[0]: c69b91c4db
2022-11-14 16:28:23 -06:00
Jordan Rose
8d9ab17a43 Treat missing pre-keys like other decryption failures
In particular, we want to send a retry request for messages sent with
pre-keys we don't have.
2022-11-14 14:02:48 -08:00
Harry
c554060f75
Use the migration's transaction for each migration's operations
* Use the migration's transaction for each migration's operations

* Add check before running each individual migration plus explanatory comments

* Remove potential race with initial schema setup

* Add result return type to migrations

* add explanatory comment
2022-11-14 12:53:37 -08:00
Harry
1be2c1489b
Require explicitly setting my story privacy settings before sending to my story
* Update checkmark icons (for selection rows only)

* Use selected/unselected checkmarks on my story privacy settings

* Initially show no setting on my stories privacy. Require setting to select My Story in recipient picker

* Clear my story privacy settings from debug ui

* design request: keep the all connections view button if unselected

* Same size for story privacy rows with and without detail text
2022-11-11 13:28:14 -08:00
Evan Hahn
5c55c848d1 Add card validation code
This code is currently dormant, but will be useful in an upcoming
change.

Check the tests to see how this works.
2022-11-11 14:24:41 -06:00
Harry
468b01f5f6
Use a private story context when opening story from a 1:1 story reply 2022-11-11 08:34:42 -08:00
Evan Hahn
20a2cf7311 Use title casing in filenames
This change should have no user impact.

`Error+isRetryable.swift` is now `Error+IsRetryable.swift`, and others
like it.

To find the files, I ran this:

    git ls-files | grep -E '\+[a-z]'
2022-11-10 19:08:44 -08:00
Evan Hahn
ec78cc3a0a
Hide Apple Pay UI when the server disallows your region
_I recommend reviewing this with whitespace changes disabled._

The server's `global.donations.apayDisabledRegions` is a list of regions
(phone number prefixes) where Apple Pay is disallowed. This respects
that.
2022-11-10 16:19:47 -06:00
Evan Hahn
b041410419 Use enums for badge categories
This change should have no user impact.

Previously, badges stored their raw category string (e.g., `"donor"`).
Now, they store an enum.

We already had this enum but never used it!
2022-11-10 15:26:56 -06:00
Evan Hahn
859ef8e9e6
Swiftify test-only call message handler
This change should have no user impact.

This converts `OWSFakeCallMessageHandler` to Swift (renaming it to
`FakeCallMessageHandler`). It was a mechanical conversion.
2022-11-10 12:46:13 -06:00
Sasha Weiss
242dfd2bce
Add all JobQueues to environment, via a wrapper
Currently, only some `JobQueue` types are initialized during startup
(as part of `Environment`, or `SSKEnvironment`). Initialization is
required, however, for a `JobQueue` type to restart any latent jobs.
That means that, for example, a durable `SendGiftBadge` job that failed,
and should be reattempted at a later date, will not in fact be restarted
since no `SendGiftBadgeJobQueue` will be initialized at launch.

This change adds `SSKJobQueues` and `SignalMessagingJobQueues` types,
which are intended to be singletons that hold within them a singleton
job queue for each of our `JobQueue` types. These wrappers are added to
`SSKEnvironment` and `Environment` (from SignalMessaging) respectively,
ensuring that all the `JobQueue`s they contain are initialized as part
of environment setup. The wrappers also avoid the need to add a new
property to the (already large) environment types for each new future
`JobQueue`.

This change also updates all existing call sites that accessed a
`JobQueue` from an environment object, to direct that access now through
the wrapper type.
2022-11-09 14:08:44 -06:00
Evan Hahn
198fc1784a
Consolidate one-time & monthly donation screens
Previously, one-time donations were on one screen and monthly donations
were on another. Now, they're on a single screen with a picker.

Most of the interesting changes are in `DonateViewController`.

Other things of note:

- There are some new TODOs here for existing bugs I didn't fix. For
  example, one-time donations don't do so well if there are any problems
  at all.

- Even though we only support Apple Pay, there's code that alludes to
  additional payment methods. For example,
  `DonateChoosePaymentMethodSheet`. We'll expand on this in the future.

- Users should only be able to select currencies that the server
  supports. For example, you shouldn't be able to select EUR if the
  server doesn't support euros. This wasn't working correctly before,
  but is fixed here.

  We already fixed one part, where users could change to an unsupported
  currency (see dab02f30ae). However, if
  your _default_ currency is unsupported and you didn't change it,
  that's no good. This is unlikely for most users but could happen.

  I fixed this by changing it from (effectively)
  `Locale.current.currencyCode ?? "USD"`, which might not be supported,
  to a preference list, choosing the first one the server likes.

- I skip animations if the Reduce Motion setting is enabled.

- On the donation screen, the logic for the preview badge has changed
  slightly. If you already have a badge, we'll always use that.
2022-11-08 16:27:50 -06:00
Igor Solomennikov
6a7d6c0fae
Switify some code related to ConversationInputToolbar.
* Remove "@objc" attribution in places related to ConversationInputToolbar where that is no longer necessary.
* Swiftify LinkPreviewState protocol.
* Convert ConversationScrollButton to Swift.
2022-11-07 16:32:59 -08:00
Evan Hahn
74d8d25a04 Move SignalServiceKit string tests to correct file
_This change should have no user impact._

We add some stuff to `String` in `SignalServiceKit`.

Before, we tested this in the `SignalTests` target. Now, it's in the
`SignalServiceKitTests` target.

All I did was move some lines. I didn't change the tests at all.

I think this is a good change on its own but it may be useful in an
upcoming change.
2022-11-07 14:31:15 -08:00
Jordan Rose
a87651e7ed Handle incoming group call rings
This adds a table of "cancelled group rings", to handle out-of-order
delivery between a cancellation and a ring. (This can happen when the
cancellation comes from a linked device rather than the original
ringer, though it's very unlikely.) Thirty-minute-old cancellations
are cleared lazily.

This also adds a new IncomingCallControls to replace the usual
CallControls in a GroupCallViewController.

And finally, there's a lot of code that was 1:1-call-specific that now
handles group calls as well, either by being more general or by
checking which kind of call we have.
2022-11-07 09:48:53 -08:00
Jordan Rose
4b6370805b Expose group message filtering, for use in group ring filtering
Most of this is moving a helper function on the internal
GroupMessageProcessor to be a public function on the public
GroupsV2MessageProcessor.
2022-11-07 09:48:53 -08:00
Sasha Weiss
04e2099c65
Remove unused class 2022-11-06 19:31:43 -08:00
george-signal
b9e8235d30
Store rowid for each item in MediaGallerySections
* Encapsulate mutable state of MediaGallerySections.

This is the first baby step toward imbuing
MediaGallerySections with multi-version
concurrency.

* Store rowid for each item in MediaGallerySections

This is necessary for forthcoming asynchronicity
as well as to correct existing problems where an
IndexPath is used as an identifier for an item.
IndexPath is a bad identifier because a database
change can invalidate it at any time. This will be
needed, for example, by an async ensureItemLoaded
method.
2022-11-04 15:23:14 -07:00
Max Radermacher
d3c78a3851
Limit profile credential fetching code to UUIDs
Instead of passing the versioned fetch result through all of the profile
update plumbing, handle it alongside the other versioned fetch code.
2022-11-04 12:38:57 -07:00
Sasha Weiss
73a3be20fb
Fix remote megaphone image JSON key 2022-11-03 17:00:07 -07:00
Max Radermacher
c519e31741 Don’t download avatars before replacing them 2022-11-03 16:58:49 -07:00
Max Radermacher
f5eceb622a Make it explicit where we download missing avatars 2022-11-03 16:58:49 -07:00
Max Radermacher
27c985dcfd Don’t try to fetch profiles for e164s 2022-11-03 13:06:00 -07:00
Max Radermacher
ba238915a3
Clean up avatar download during profile fetches 2022-11-03 13:03:18 -07:00
Sasha Weiss
9d3e4043d1
Conditional for internal remote megaphone test 2022-11-03 12:26:31 -07:00
Max Radermacher
84a670bc2e Remove ReadyFlag.queueMode.
It’s unused and doesn’t appear to have ever been used.
2022-11-03 11:58:44 -07:00
Evan Hahn
771a6f5488 Swiftify OWSDisappearingMessagesJobTest
This is a test-only change.
2022-11-03 11:48:52 -07:00
Evan Hahn
aef20e182b Remove unused groupBy function
`git grep -w groupBy` returns no results after this change.
2022-11-03 11:42:19 -07:00
Sasha Weiss
c7dd7f4c84
Actions for donation megaphone 2022-11-03 11:39:37 -07:00
Igor Solomennikov
2df35033f2
Change TSAttachmentPointerState to a closed enum.
Fix a compiler warning about not handling unknown values.
2022-11-02 15:49:15 -07:00
Sasha Weiss
1cf1872771
Add LocalUserLeaveGroupJobQueue to SSKEnvironment 2022-11-02 10:53:21 -07:00
Sasha Weiss
39f927683f
Be more conservative about when we re-upload the local profile for commitments 2022-11-02 08:54:51 -07:00
Sasha Weiss
a2e138abfb
Ensure logging during NSE initialization is recorded 2022-11-01 20:32:54 -07:00
Evan Hahn
a941c82c14
Prefer isEmpty with strings
This change may improve performance slightly but should have no other
user impact.

`myString.isEmpty` is faster than `myString.count == 0` or equivalent,
because computing `count` may require iterating over the string.

I tried to fix all occurrences of this.

Tested this by sending a message in a group and doing a full
re-registration, just in case I broke something there.
2022-11-01 17:53:46 -05:00
Sasha Weiss
e4f5e48ac9
Remove dead code, and organize some live code 2022-10-31 16:01:35 -07:00
Harry
3bf5b8ed10
Add stories kill switch 2022-10-31 12:30:56 -07:00
Max Radermacher
92ae34ee9c Enable Stories for everyone 2022-10-31 11:33:02 -07:00
Evan Hahn
85a0bb8566 Remove unused blurhash utility
This removes `isDarkBlurHash`. Its last usage was in
875491a7cd.
2022-10-31 09:35:20 -05:00
Evan Hahn
b7cb7eb403
Test TSContactThread's canSendChatMessagesToThread() 2022-10-28 16:16:00 -05:00
Ehren Kret
38af2a8a65 fix missed CGFloat for thumbnail 2022-10-28 15:46:32 -05:00
Ehren Kret
ab61bbc3a6
cleanup more xcode warnings 2022-10-28 13:54:31 -05:00
Ehren Kret
8e44265440 cleanup more unsigned v signed warnings 2022-10-28 13:53:08 -05:00
Ehren Kret
9a1e269e91 remove several signed conversion warnings 2022-10-28 11:56:12 -05:00
Sasha Weiss
6526a8a164
Remove all references to local 'subscriptionMegaphone' 2022-10-28 09:47:58 -07:00
Max Radermacher
f2afe8d45b Skip already-cached values in BulkProfileFetch
If we queue N UUIDs [1, 2, ..., N], we’ll send a request to fetch all of
them. If we queue those same N UUIDs again, we’ll stop processing after
the first one, without sending any fetch request.

We’ll start processing again the next time `process()` is called. This
could happen in response to network availability changing, or it could
happen in response to scheduling the N+1’th UUID. (Though, we won’t
necessarily fetch the N+1’th UUID in this case -- we’ll fetch the 2nd.)

These cached results also expire after a few minutes or a few hours,
depending on the most recent result. Therefore, this fetcher may behave
somewhat erratically, where it fetches profiles, stops for a few
minutes, then starts fetching profiles again.
2022-10-27 19:55:44 -07:00
Max Radermacher
39d85c255a
Persist updates as part of fetch profile promise
As far back as 823927685d, the profile
updates were asynchronous. At that point it time, it didn’t matter
because there wasn’t a completion block; callers couldn’t know when the
updates *should* be complete, so it didn’t matter when they finished.

However, in 856fef7664 a Promise result
was added, presumably to allow callers to know when it was safe to check
GV2 capabilities. Now, a cursory reading of the API would suggest that
all changes were persisted once the Promise was resolved.

This can result in bugs, such as [this example][0], where we fetch the
profile and then check a capability in the database. Even though it’ll
*probably* be the case, there’s no guarantee that the updated profile
will be persisted when we try to fetch the latest capability.

[0]: 465d00664b/Signal/src/ViewControllers/AppSettings/Donations/BadgeGiftingConfirmationViewController.swift (L69-L88)
2022-10-27 19:54:24 -07:00
Sasha Weiss
4ecb3e4bf2
Wire up the remote megaphone model to a view 2022-10-26 17:56:14 -07:00
Jordan Rose
e02855349c Don't trap in debug builds on oversized downloads 2022-10-26 17:23:44 -07:00
Sasha Weiss
44a7b9a3c3
Parse and check country-code CSV from remote megaphones 2022-10-26 16:03:52 -07:00
Evan Hahn
4675434c6c Add FiatMoney type
This change should have no user impact.

We commonly pair a currency, like USD, and an amount, like 1.23. This
adds the `FiatMoney` struct. It's a simple struct with two fields.

After adding it, I tried to use it everywhere. (It's possible I missed a
spot.)

I think this is a useful change on its own, but it'll be nice for an
upcoming change, too.

See also: [Android's equivalent class][0].

[0]: cb65347bb3/core-util/src/main/java/org/signal/core/util/money/FiatMoney.java (L1)
2022-10-26 17:04:51 -05:00