Commit Graph

8244 Commits

Author SHA1 Message Date
Nora Trapp
ed437eb9ea Use implicit content hint for SKDMs 2022-11-28 11:19:45 -08:00
Max Radermacher
0fb57a74ae
Fix various bugs in OWSHttpHeaders
First, `OWSHttpHeaders(httpHeaders:)` completely ignored its argument.
This doesn’t actually seem to have led to any bugs in practice; one time
the caller appears to have worked around the bug by adding the headers
again, and another time the caller relied on `allHTTPHeaderFields`
ignoring unrelated values.

Second, `URLRequest` has both `addValue` and `setValue` methods for its
headers. The former will construct a comma-separated list if the header
is already set, and the latter will replace it if it’s already set. (If
the header hasn’t been set, the two are equivalent, which is why call
sites weren’t broken even though they used the wrong method.) This was
broken only in multi-part uploads, but it was broken for "User-Agent"
and "Accept-Language", both of which are non-critical.

Third, `URLRequest`’s `allHTTPHeaderFields` doesn’t behave the way you
might expect. There’s a unit test which demonstrates some of the weird
behaviors, but any fields that aren’t present in the assigned value
aren’t touched. It seems as though most code was written as if calling
this method would fully replace *all* the HTTP headers. (The
`replace(…)` and `removeAllHeaders` methods have been removed because
they didn’t do what you’d think, and they weren’t necessary.)

Also:
* Remove Obj-C support from OWSHttpHeaders
* Move & simplify tests for HTTP Retry-After header
* Remove unused `asConnectionFailureError` method
2022-11-22 11:43:55 -08:00
Evan Hahn
21f2a36125
Add skeleton credit/debit card donation support
This adds very basic support for donations via credit/debit card. It's
missing important features which is why it's behind an internal-only
feature flag.

At a high level, this adds a new screen with a card form. This card data
is submitted to Stripe and then uses the same "rails" as our existing
Apple Pay donations.

This change is missing a few important features, intended to be added
soon:

- [3D Secure][3DS] support
- Validation error messages
- Input formatting (e.g., "1234" becomes "12/34")
- Gift badge support (currently only supports Apple Pay)
- Various smaller UI changes

[3DS]: https://stripe.com/docs/payments/3d-secure
2022-11-22 09:07:36 -06:00
Harry Sanabria
53554be858 Normalize TSPrivateStoryThread migration FTS content 2022-11-18 11:42:00 +11:00
Harry
ce597db502
Update TSPrivateStoryThread indexing migration to be safer 2022-11-17 16:36:49 -08:00
Max Radermacher
6e6327b007
Remove gv1-migration capability 2022-11-17 16:12:06 -08:00
Max Radermacher
0795c5679d
Fix crash when fetching remote megaphones
If censorship circumvention is enabled, we’ll attempt a re-entrant
database query, and that leads to a crash.
2022-11-17 12:21:54 -08:00
Evan Hahn
eb2af17ee6
Swiftify OWSDisappearingMessageFinderTest
This change should have no user impact, as it is test-only.

This was a mechanical conversion. There was only one wrinkle: I had to
move test-only header definitions for `OWSDisappearingMessagesFinder`.
2022-11-16 00:21:23 -08:00
Max Radermacher
50e0405276
Add ContactDiscoveryManager
RATE LIMITS & IS CRITICAL PRIORITY

Before this change, there was a notion of “critical” discovery tasks
that had their own rate limit, and that rate limit was used for
UUIDBackfillTask. In this change, that logic has been generalized to
consider a separate rate limit for additional request types.

QUEUE PRIORITIES

All of the discovery operations were updated to use `.userInitiated` as
their priority. Before this change, the `UUIDBackfillTask` and message
sending flow used lower priorities. However, both of those should use
higher priorities -- the former blocks receiving messages and the latter
blocks outgoing messages. This change allows the code to be simplified.

TESTS

This removes most of the existing `UUIDBackfillTaskTest` test cases
(they were commented out) and all of the `ContactDiscoveryTaskTest` test
cases (which were for the rate limiter, which has been moved elsewhere).

It introduces a few new tests. These aren’t meant to be exhausive;
instead, they’re meant to hit most of the code in the new classes and a
few specific edge cases that aren’t likely to be hit in normal use.
2022-11-15 13:37:28 -08:00
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