Commit Graph

4674 Commits

Author SHA1 Message Date
Max Radermacher
56154557dd
Add isStructurallyValidE164
This merges & replaces `resemblesE164:` and `isValidE164`.

Co-authored-by: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com>
2023-02-13 13:45:00 -08:00
Max Radermacher
2f0bc4a690
Require a serviceId for storage service contacts 2023-02-13 12:44:45 -08:00
Max Radermacher
db2678e86b
Filter storage service contacts more consistently 2023-02-13 10:48:54 -08:00
Max Radermacher
1a0efe6fbb Don’t mark recipients without a UUID as registered 2023-02-13 10:46:18 -08:00
Max Radermacher
5259866822
Delete invalid storage service identifiers 2023-02-10 18:03:08 -08:00
Max Radermacher
c13ebc7482
Consolidate storage service code 2023-02-10 17:58:51 -08:00
Max Radermacher
0b10138c5a
Send sync request messages once per version 2023-02-10 10:24:41 -08:00
Max Radermacher
3c0c309048
Ignore update/delete requests that are empty
This isn’t required for correctness; it’s a performance optimization.
2023-02-09 13:51:04 -08:00
Evan Hahn
8e33543e7a Change Promise to Guarantee because it always resolves
This promise always resolves, so let's make it a `Guarantee`.

This change should have no user impact.
2023-02-08 14:11:30 -08:00
Max Radermacher
57b21b308d Swiftify pre key request parameters 2023-02-08 12:08:00 -08:00
Sasha Weiss
e5f1af6c2e
Support lookup-by-username 2023-02-08 10:16:57 -08:00
Harry
003cc19e62
Update SignalCoreKit. Use explicit DispatchQueue instead of relying on the implicit type on promise 'on' params
* Use explicit DispatchQueue instead of relying on the implicit type on promise 'on' params

* Update SignalCoreKit
2023-02-07 16:14:39 -08:00
Jordan Rose
8d2e937446 If a user has no phone number, don't look for them in system contacts
...when trying to see if we have cached name components for them.
(This was only an error in debug builds; it fell through to the
correct behavior in release builds.)
2023-02-07 14:30:18 -08:00
Jordan Rose
bed8b8d0d7 Avoid new transactions in StorageServiceProtoAccountRecord.build(...)
GRDB doesn't support reentrancy even for read transactions.
2023-02-07 13:51:26 -08:00
Sasha Weiss
70d018a55d
.redundantChange should not be considered retryable 2023-02-07 12:57:51 -08:00
Max Radermacher
d826b358f1 Remove your own SignalAccount on linked devices 2023-02-07 12:09:50 -08:00
Pete Walters
ac919fcf43
Update Donation UI to handle inactive/failed payments
The Donations screen doesn't currently handle backend
subscription failures well. An example of this is when
the backend encounters a repeated payment processing
failure. Currently, in these situations the donation
screens will display an active donation along with the
renewal date.

To remedy this, the UI now checks that the subscription
status is 'active' before displaying any of the
active subscription UI.
2023-02-06 13:31:07 -06:00
Adam Mork
728862da6f
[Payments] Biometry Payments Lock
* payment lock

* add 30 day timeout to showing the payment lock suggestion

* fix linting

* update comment

* Payment Lock: Fix project file & submodules (#4878)

* revert ringrtc changes

* revert pods changes

* fix project file

* PR Comment suggestions and fixes

* PR suggestions

* revert screen lock to previous implementation

* rename OWSPaymentLock to OWSPaymentsLock (missing plural s), remove
super-class dependency. Make OWSPaymentsLock more "swifty".

* revert changes to call-site for OWSScreenLock

* update call-sites for OWSPaymentsLock

* forgot to add PaymentOnboarding class and localization comment improvements

* change function call-site

* Remove OWSLocalAuthentication from project

* remove OWSLocalAuth from project file

* make edge-case default more secure if storage not ready

* fix project file

* lint fix

* fix linting errors

* Revert compact format style for OWSLocalizedString

* fix localization call-sites to use literals, update localization file after autogen

* Add new Payments Lock Prompt view to be shown after activating payments. Factor out the BiometryType "current biometry" into its own class with helpers to easily getting the devices current setup.

* fix linting issues, sort project file, and autogen localizations

* require payments lock to look at the recovery phrase

* fix linting issue

* fix missing localizations (caused by dynamic creation in previous commit)

* use Pods commit from signal/main

* re-run linter on latest commits

* new header comments for new branch files

* update submodule commits

* Use existing secondsInDay constant kDayInterval, use weak self guard statement instead of optional self in escaping closure.

* Revert submodule changes

* Remove duplicate copyright headers

* Revert copyright header changes

* Restore some missing translations

* Add localization for unknown LocalAuthentication error/state.

* remove Pods changes

* linting

* use submodule commits from main

* subclass the old Objc OWSViewController super-class, should fix CICD

* change capitalized Passcode to lower-case in non-title situation.

* remove early exit guard from biometryType computed function. Reason being that the type can be gathered from a policy that evaluates to false. In a case where the user has a FaceID phone but its disabled, the messaging would be incorrect. removing the early exit evaluates the biometryType which apple provides even if the policy returns false.

* inline snooze date

* inject write transaction to some convenience methods to reduce database overhead when multiple calls need to happen at the same time.

* make combined set and snooze function, update combined call-site

* rename long function

* use false instead of sender.on to avoid sneaky view issues

* add tryToUnlockPromise function to clean up call sites

* change superclass, fix Promise statement

* call super class function

* remove objc

* add unlock failed action sheet helper class and put at all relevant call-sites, still need to test though.

* add unlock failed action sheet helper class and put at all relevant call-sites, still need to test though. linting

* project file changes for new file

* re-render payments lock toggle after failure to change setting.

re-render payments lock toggle after failure to change setting.

* move around action sheet call-site to account for an action sheet already being presented. remove unecc. return

* fix merge conflicts, linting

* re-gen strings file

---------

Co-authored-by: Max Radermacher <max@signal.org>
2023-02-03 12:56:54 -08:00
Harry
6576349613
Migrate KeyBackupService to the Swift Way™️
* Put KeyBackupService in its own folder

* Put SDSKeyValueStore in its own directory

* Put SDSDatabaseStorage in its own directory

* Stop doing useless dispatches in SDSTransactable

* Add V2 DB classes

* Wrap SDSKeyValueStore in a protocol and factory

* Make TSConstantsProtocol public to take it as a param in other places

* Take explicit transactions and do single lookups in TSAccountManager registration state methods

* Take explicit transaction on OWS2FAManager

* Make KeyBackupService an instance that takes dependencies on init

* Protocolize KeyBackupService

* Put Dependencies+SSK in its own directory

* Add DependenciesBridge

* add ViewControllerContext

* used shared context in OnboardingController

* Don't check KeyBackupService in RemoteConfigManager; the one and only callsite already checks it separately

* All the random cleanup that needed to happen to get the app to build again.

* Add mock dbv2 classes

* Migrate existing KeyBackupServiceTests

* Namespace KBS shims

* DBV2 -> DB, after changing the min swiftlint type length to 2 chars

* add toy example

* Unwrap writes as reads

* pr comments

* pr comments 2: return of the nits

* final Pr comment
2023-02-02 09:42:05 -08:00
Max Radermacher
b04c3ed590
Update SignalAccount handling for CDSv2 2023-02-01 17:45:54 -08:00
Max Radermacher
60888c85c0
Improve storage service system contact handling
- If we’re a primary device and the name is wrong, update it.
- If we’re a linked device and the name hasn’t changed, don’t update it.
2023-02-01 16:55:39 -08:00
Max Radermacher
77d37b7a3a
Clean up system contact processing code 2023-02-01 16:55:14 -08:00
Max Radermacher
3417fe2e20
Handle system contacts on linked devices
* Remove old migration code
* Rename some files
2023-02-01 16:18:59 -08:00
Max Radermacher
015803297a
Add .notAllowed to editingAuthorization for iPad 2023-02-01 11:33:37 -08:00
Max Radermacher
0c3cec9146
Update SignalCoreKit
* Update filterForDisplay call sites
2023-01-31 12:34:07 -08:00
Evan Hahn
c5a71adc06 Remove rarely-seen YDB onboarding screen
We used to use [YapDatabase] but [removed it in early 2021][1] after a
[migration to GRDB that started in 2019][2].

If you haven't opened the app since before we dropped YDB--in other
words, since early 2021--you'll see the following text on a screen
before you open the app:

> Because you've been inactive for a long period of time, you must
> register again to use Signal.

Tapping "Next" will send you into the normal registration flow.

I think this is a tiny number of users, so I removed this screen and
associated code. This will help simplify future onboarding code.

[1]: 86b8eb08b8
[2]: 2a5683b843
[YapDatabase]: https://github.com/signalapp/YapDatabase
2023-01-31 10:21:46 -08:00
Max Radermacher
3a1556ca46 Clean up & Swiftify allSortedContacts 2023-01-30 12:15:11 -08:00
Sasha Weiss
80bc728169
Update username selection strings 2023-01-27 15:51:22 -08:00
Evan Hahn
cc92abdc90
Clean up "delete subscriber ID" request
This is similar to 227f05e932.

This change should have no user impact.

This changes the "delete subscriber ID" request in the following ways:

- Adds tests
- Converts it to Swift
- Renames `deleteSubscriptionIDRequest` to `deleteSubscriberID`
- Serializes the data inside the method, rather than requiring callers
  to do so
2023-01-27 15:11:48 -08:00
Max Radermacher
489c05b058
Clean up system contact fetch completion block 2023-01-26 12:06:05 -08:00
Evan Hahn
227f05e932 Clean up "set subscriber ID" request
This change should have no user impact.

This changes the "set subscriber ID" request in the following ways:

- Adds tests
- Converts it to Swift
- Renames `setSubscriptionIDRequest` to `setSubscriberID`
- Serializes the data inside the method, rather than requiring callers
  to do so

Tested this with automated tests and manually starting a subscription in
staging.
2023-01-26 13:45:25 -06:00
Max Radermacher
1f4a6d8587 Consolidate adding system contacts to whitelist 2023-01-26 10:55:58 -08:00
Max Radermacher
72f006d6ef
Remove OWSContactsManager’s “is registered” check 2023-01-26 10:55:24 -08:00
Evan Hahn
35c314bde5
Clean up donation configuration request
This change should have no user impact.

This changes a few things about
`OWSRequestFactory.donationConfigurationRequest()`:

- Adds tests
- Converts it to Swift
- Renames it to `donationConfiguration()`
- Makes it an unauthenticated request

I'm most concerned about that last thing, because it's a behavior
change. However, I think this is safe because:

1. I tested it in a simulator and it works

2. [Android appears to do the same thing][0]

3. A normal `curl` works just fine:

   ```
   curl --insecure 'https://chat.signal.org/v1/subscription/configuration'
   ```

[0]: 657c5d2bce/libsignal/service/src/main/java/org/whispersystems/signalservice/internal/push/PushServiceSocket.java (L1074)
2023-01-25 13:10:22 -06:00
Max Radermacher
0dc492fec5
Use common logic when creating web sockets 2023-01-24 14:01:34 -08:00
Evan Hahn
43cea3fa7c Remove unused parameter from subscription method
This change should have no user impact.

This argument was never used so we can remove it.

I also fixed a doc comment. It wasn't exactly wrong, but it wasn't
parsed as intended.
2023-01-21 16:13:41 -06:00
Evan Hahn
bdbb13e03f
Donations: enqueue storage syncs outside database writes
This change should have no user impact except a *very* small speedup.

Previously, we were inconsistent in this file. Now, we always call
`recordPendingLocalAccountUpdates()` outside of a write transaction.
2023-01-20 18:27:21 -08:00
Harry
df97cad708
Show a notification when being logged out via 403 from chat server
* Don't fail debug builds after locking the account and failing config lookup

* Show (no-op) notification when deregistered

* Show re-registration when tapping the push notification

* Remove asserts that can (and should) fail when deregistered

* run genstrings
2023-01-19 15:00:01 -08:00
Evan Hahn
ac3e0a67c1 Fix compilation errors for PayPal code
We merged 6e97ff3c8f and
bcbf52101e in rapid succession, which
caused compilation errors.

This fixes those.
2023-01-18 17:49:30 -06:00
Sasha Weiss
bcbf52101e
PayPal recurring donations
Co-Authored-By: Evan Hahn <evanhahn@signal.org>
2023-01-18 14:48:50 -08:00
Evan Hahn
6e97ff3c8f
Gifting: add PayPal support 2023-01-18 16:38:57 -06:00
Harry
e29ae33fed
Better past missed call handling in call disposition
* Mark previous call events read when a later call event is responded to

* Clear missed call notifications when a future call is actioned on any device

* Do two queries for TSCall updates
2023-01-17 16:05:55 -08:00
Evan Hahn
aa8bb0d892
Remove unnecessary throws from Stripe method
`Stripe.confirmPaymentIntent` was marked `throws` unnecessarily. This
removes it to simplify the code slightly.
2023-01-17 13:57:32 -06:00
Max Radermacher
e454eea2da
Refactor, optimize, and test setContactsMaps 2023-01-13 13:56:39 -08:00
Evan Hahn
3bcbd60d86
Skip onboarding permissions screen if unnecessary
We ask users for contact and notification permissions during
registration.

If the user abandons registration after approving or denying these
requests, we don't need to show them the permissions screen again, as
it'll just show an "Allow Permissions" button that advances to the next
screen.

This also cleans up some of the methods. Not strictly related, but it
felt like a good time to rename some methods and clean up some logging
(especially because we're making changes here).
2023-01-12 16:42:13 -06:00
Max Radermacher
1311d3f665
Refactor contact access code
Split it based on whether the purpose is “editing” or “sharing”. If
we’re editing, it generally means we have full access to contacts, and
that we’ve checked which of the contacts are registered on Signal. If
we’re “sharing”, we don’t care whether or not they’re registered.

If we’re “sharing”, we check whether or not we’ve prompted for the
contacts permission yet. If not, we’ll show the prompt.

If we’re “editing”, we assume we’ve already prompted (which is already
the case today), so `.notDetermined` isn’t a possible state.

Other things to note:

- The `supportsContactEditing` was always true, so it’s been removed.

- The error when contacts access isn’t allowed is now shown more
  consistently. Previously, it was sometimes shown in response to
  initializing a view controller.

- Some RecipientPickerViewController code was moved from Obj-C to Swift.
  This is probably useful on its own, but it’ll also make it easier to
  build some new UI in subsequent commits.
2023-01-12 09:55:30 -08:00
Evan Hahn
f2c218edca
Use new copy for in-chat gift messages
This required plumbing the other person's "short name", which is the
most significant code change.
2023-01-11 14:18:48 -06:00
Max Radermacher
751f551e79 Don’t use serviceIdentifier for Contacts 2023-01-09 12:01:34 -08:00
Evan Hahn
4e2575c92a Add more logging for orphan data cleaner 2023-01-04 16:51:24 -08:00
Max Radermacher
d7c52b6ad0
Fix bugs marking SignalRecipients as registered
Previously, low-trust SignalRecipients wouldn’t be marked as registered
unless they were newly-created. Now, they are marked as registered in
places where they should be (eg, successfully sending a message or
fetching a pre key means that the device exists).

As part of this change, SignalRecipients are unregistered by default,
though most call sites still mark them as registered immediately, so the
behavior in practice will be identical. There are a few places (such as
ensureAccountId) which will no longer mark new values as registered.

Finally, creating a new SignalRecipient would also update Storage
Service, even if that recipient was created in response to a storage
service update. Now, recipients updated as part of storage service
operations won’t immediately trigger another storage service update.
2023-01-03 13:23:33 -08:00