Commit Graph

7872 Commits

Author SHA1 Message Date
Max Radermacher
da3042efe9 Remove old KBS enclaves 2022-07-22 10:21:28 -07:00
Sasha Weiss
33cfe52529
Fix violations of nsobject_prefer_isequal 2022-07-21 16:00:42 -05:00
Max Radermacher
8cd4cb07e0 Temporarily disable gift receiving in beta 2022-07-21 13:54:34 -07:00
Evan Hahn
00c8a5dfc4
Remove unused group invite link remote config flag
_I recommend reviewing this with whitespace changes disabled._

`RemoteConfig.groupsV2InviteLinks` has been fully enabled for awhile
now. This removes it, and everything that depended on it. Even let us
remove a couple of strings!
2022-07-20 08:59:53 -05:00
Evan Hahn
028d97c2cb
Use remote config for gift badges
This removes `FeatureFlags.giftBadgeReceiving` and
`FeatureFlags.giftBadgeSending`, replacing them with
`RemoteConfig.canReceiveGiftBadges` and
`RemoteConfig.canSendGiftBadges`.
2022-07-20 08:50:58 -05:00
Evan Hahn
f3c5ad92b1 Remove unused isGroupInviteLink method 2022-07-19 16:48:45 -05:00
Max Radermacher
e4e21cab8c Fix outage detector error when there’s no network
If DNS resolution fails, then it’s expected that there won’t be any
addresses. Fail gracefully in this case.

If DNS resolution succeeds and provides a non-nil but empty list of
addresses, report an error. This shouldn’t happen.
2022-07-19 11:48:58 -07:00
Sasha Weiss
543d29a13b
Include banned members in comparing and rendering group memberships 2022-07-18 16:00:39 -07:00
Sasha Weiss
8ad360e71d
DRY out GroupUpdateCopy construction 2022-07-18 15:03:21 -07:00
Sasha Weiss (Signal)
9f6f4f1b5c
Remove correct request-denied-because-banned error from behind a feature flag 2022-07-18 11:18:35 -07:00
Sasha Weiss (Signal)
42e9608c73
Remove user from local group on request-to-join denied 2022-07-18 11:17:58 -07:00
Max Radermacher
2911f64c3a Remove impossible code path from populateAssets
We can rely on the compiler to ensure we have a `BadgeAssets` value.
2022-07-15 18:39:07 -07:00
Max Radermacher
0d002ce02d Consider duration when comparing ProfileBadges 2022-07-15 18:38:57 -07:00
Nora Trapp
c2d9787cf7 PR Feedback 2022-07-15 15:05:03 -07:00
Nora Trapp
b67069e251 Add the editing of private stories 2022-07-15 15:05:03 -07:00
Nora Trapp
2ab53b2b14 Sync story distribution lists 2022-07-15 15:05:03 -07:00
Sasha Weiss (Signal)
9334ed3077
Ban and unban users as part of add/remove/deny group actions 2022-07-15 09:41:19 -07:00
Sasha Weiss (Signal)
31b5eda509
Be more precise about group updates 2022-07-13 16:08:00 -07:00
Max Radermacher
85a4389859 Fix typo: Adddress → Address 2022-07-13 12:13:12 -07:00
Max Radermacher
2bde76e85d Persist outgoing gift open status
Also send viewed receipts to linked devices when opening them, and
handle viewed receipts when other devices open them.
2022-07-12 14:34:02 -07:00
Sasha Weiss (Signal)
98151dfd0d
Don't need transactions to build group models 2022-07-12 10:23:12 -07:00
Max Radermacher
47e75ab251 Put @objc on the line before let variables
This fixes our violations of [SwiftLint's `attributes` rule][0].

[0]: https://realm.github.io/SwiftLint/attributes.html
2022-07-11 16:40:48 -07:00
george-signal
80565fb43f
Revert "Remove GRDB's memory management. (#4521)" (#4546)
This reverts commit a202f6204e.

It also uses the new facility in GRDB to disable
automatic memory management.

For context see:
https://github.com/groue/GRDB.swift/pull/1253
2022-07-11 14:37:29 -07:00
Nora Trapp
4aae9b4eb1 Allow configuring who can view 'My Story' 2022-07-11 10:23:06 -07:00
Evan Hahn
bf8fd72fba
Improve Accept-Language header value, fixing registration bug
Some users [are unable to register][1] because the server [returns a 400
error][2] if passed an invalid `Accept-Language` header.

This commit helps prevent two possible error modes:

- Filters out invalid language tags. Some users reported a "Workshopx"
  language, which the server would reject because it's syntactically
  invalid. Deleting this language (at the OS level) let them register.
- If no languages are valid, we should send `*` instead of the empty
  string. There's no evidence that this happened in practice.

In addition, this commit:

- Adds tests.
- Sends a maximum of 10 languages instead of 6.
- Omits the `q` value when it's 1 because [that's the default][3].
- Marginally improves performance by iterating lazily.

[1]: https://github.com/signalapp/Signal-iOS/issues/5261
[2]: bf6d3aa324/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java (L271-L275)
[3]: https://www.rfc-editor.org/rfc/rfc9110.html#section-12.4.2

Co-authored-by: Nora Trapp <nora@signal.org>
2022-07-11 12:20:24 -05:00
Sasha Weiss (Signal)
ac341fdbbc
DRY out V2 group updates 2022-07-08 15:47:45 -07:00
Evan Hahn
64462ac1b0 Save a receipt when you send someone a badge
This commit:

1. Adds a new donation receipt type: gifts.
2. Saves receipts when sending someone a gift.

The first part was the main challenge. Previously, donation receipts had
logic like this (pseudocode):

     def getReceiptType(self):
       if self.subscriptionLevel:
         return "subscription"
       else:
         return "one-time"

Now, we explicitly encode the type and have logic to handle "legacy"
receipts that don't have a type encoded.
2022-07-08 13:17:30 -05:00
Max Radermacher
ed63a2aeac
Remove trailing comma
This fixes our violation of [SwiftLint's `trailing_comma` rule][0].

[0]: https://realm.github.io/SwiftLint/trailing_comma.html
2022-07-08 08:39:47 -05:00
Evan Hahn
951f5c3708 Remove trailing whitespace
This is a whitespace-only change that fixes a SwiftLint violation.
2022-07-07 17:39:05 -07:00
Evan Hahn
57c47ced2c Fix operator_whitespace SwiftLint violations
This fixes violations of [SwiftLint's `operator_whitespace` rule][0].
This is a whitespace-only change.

[0]: https://realm.github.io/SwiftLint/operator_whitespace.html
2022-07-07 17:38:38 -07:00
Evan Hahn
e25772183d Prefer foo != nil to _ = foo
This fixes our violations of [SwiftLint's `unused_optional_binding`
rule][0].

[0]: https://realm.github.io/SwiftLint/unused_optional_binding.html
2022-07-07 11:09:00 -07:00
Max Radermacher
369118b045 Add support for replying to gift messages 2022-07-07 10:49:20 -07:00
Max Radermacher
ea0986b676 Parse gift badges on incoming sync messages
This allows outgoing gift messages from other devices to be shown.
2022-07-07 10:46:50 -07:00
Max Radermacher
4fb4c29c80 Don’t coalesce viewed receipts 2022-07-07 10:46:37 -07:00
george-signal
a202f6204e
Remove GRDB's memory management. (#4521)
This disgusting hack removes GRDB's notification
center observers, which prevents it from calling
`DatabasePool.releaseMemory()`.

`releaseMemory` is harmful because it places all
future reads behind a dispatch barrier. The effect
is that even very short reads block on any db
reads that precede the barrier. Some of those can
be very slow, such as orphan message handling.

The practical effect of this barrier is that the
main thread gets stuck on what should be a very
quick operation, such as loading your own avatar
data. iOS can kill the app with 8badf00d.

This change is a temporary workaround. A proper
solution has been added to a PR that I sent to
GRDB, which you can see here:

https://github.com/groue/GRDB.swift/pull/1253

Once that is accepted upstream we should update
GRDB and revert this commit.

This change should fix IOS-2474 and doubtless many
other issues.
2022-07-06 13:27:13 -07:00
Max Radermacher
10469e29f5 Remove unused descriptionFor… methods
This are unused since things got refactored in ec66f3b21e. It
appears as though `contentDescription` is just called directly rather
than calling these wrappers.
2022-07-06 12:52:58 -07:00
Max Radermacher
09fd1a39d2
Send viewed receipts when redeeming gift badges 2022-07-06 12:39:41 -07:00
Evan Hahn
f5556d1857
Use durable job for sending badge gifts
Previously, sending a gift badge was not a durable operation, which
meant that crashes/failures could cause users to have their payment
methods charged without actually sending the badge.

Now, the flow is split up into two steps: non-durable parts before the
charge is attempted, and durable parts afterward.

The high-level flow is:

1. Prepare the payment, which involves a couple of repeatable network
   requests.
2. Enqueue a job with the prepared payment, that:
   1. Charges the payment method (idempotently)
   2. Requests a receipt credential (idempotently)
   3. Enqueues a gift message, and optionally a text message
3. When the job completes, open the conversation in the UI.
2022-07-01 17:10:31 -05:00
Max Radermacher
f7f66d6436
Add support for redeeming gift badges 2022-07-01 14:07:24 -07:00
Max Radermacher
7bef47f356
Use serial queue for SDSTransactable.asyncWrite
The database writes are ultimately serial, so there’s little benefit to
scheduling each of these on its own queue. If another slow-ish write is
already happening, there’s a chance that we may see thread explosion,
with many threads waiting to write to the database.
2022-06-30 08:38:54 -07:00
Sasha Weiss (Signal)
86d9b8ea0a
Remove args always passed as nil that were later unused anyway 2022-06-29 09:19:02 -07:00
Max Radermacher
c9fcee9cc3 Clean up incoming reaction processing 2022-06-27 11:10:26 -07:00
Max Radermacher
4976462238 Add missing fields to sync message descriptions 2022-06-27 09:03:47 -07:00
Max Radermacher
11d08f101f
Fix crash when deleting messages from the future
The subtraction operation produces a negative value and causes a crash
in Swift. Allow deleting these messages to match Android’s behavior.
2022-06-27 09:02:04 -07:00
Evan Hahn
d0c7de494a Computed accessors shold always be in the same order
`get`, then `set`. This fixes violations of [SwiftLint's
`computed_accessors_order` rule][0].

A very mechanical change.

[0]: https://realm.github.io/SwiftLint/computed_accessors_order.html
2022-06-24 09:35:07 -07:00
Nora Trapp
477f312c1e Send and receive sync transcripts for story messages 2022-06-24 00:35:31 -04:00
Nora Trapp
b13c7dbfdb Don't include yourself in private story recipients 2022-06-24 00:35:31 -04:00
george-signal
e528ea8824
Add source device to manifest record
* Populate the source device in manifests we create.
* Log the source device in manifests we fetch.
2022-06-23 17:50:44 -07:00
Max Radermacher
e303428216 Don’t allow “Delete for Everyone” for Gift Badges 2022-06-23 10:17:53 -07:00
Max Radermacher
da16b7c392 Convert TSMessageTest to Swift 2022-06-23 10:17:53 -07:00