Commit Graph

4454 Commits

Author SHA1 Message Date
Igor Solomennikov
7f4a5f3f7b Merge branch igor/media-editor-updates. 2022-07-06 14:54:26 -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
5a0719c8cc Fix notification comment typo; avoid forced unwrap 2022-07-01 09:49:26 -07:00
Max Radermacher
46cacb177e Ignore peek call errors in staging 2022-06-29 14:32:19 -05: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
807ea6e034
Simplify …BadgeIds.contains(_:)
There’s no need to use `allCases` -- we can accomplish the same thing
using the automatically-provided `init(rawValue:)` initializer.
2022-06-28 17:15:14 -07:00
Max Radermacher
a8e25ac3b2 Ignore checkpointing errors on launch
These aren’t fatal, so they shouldn’t present the “failed to launch UI”
to the user. This restores the behavior from before 4e535fa7ef.
2022-06-24 22:27:01 -05:00
Max Radermacher
c84d3988c6 Remove redundant Storage Service assertion
If there aren’t any elements in the array, the `owsFailDebug` a few
lines down will trigger and report the same condition.
2022-06-24 14:10:18 -07: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
Sasha Weiss (Signal)
5695809776
Prevent non-temporary-file attachments from being deleted when shared 2022-06-22 13:15:04 -07:00
Evan Hahn
f4714b1a83 Basic support for sending gift badges
If you've got the `giftBadgeSending` flag enabled, you can now send gift
badges to anyone who has the capability.

This commit doesn't complete the feature, though. It is missing:

- Proper durability and error handling (to be addressed separately)
- Saving of receipts
- A few other cleanups
2022-06-22 15:50:51 +00:00
Max Radermacher
e79f37cc01 Prefer disappearingMessagesDuration(…)
The behavior is the same, and this avoids repeating the same code.
2022-06-22 08:10:55 -07:00
Max Radermacher
c0a85b888b
Add rendering support for Gift Badges
Co-authored-by: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com>
2022-06-22 08:05:25 -07:00
Evan Hahn
a1eb9e3042 Clean up boostCreatePaymentIntent()
This makes a few small changes to `OWSRequestFactory.boostCreatePaymentIntent()`:

- Adds tests
- Rewrites the function in Swift

I made sure I could do a boost (in staging) in the simulator.
2022-06-21 17:33:28 +00:00
Nora Trapp
c174899720 Propagate blurhashes during attachment multisend 2022-06-17 15:38:30 -04:00
Nora Trapp
7bd167f815
Initial story sending support
* Little fix for context menu

* Add 'My Stories' section to stories tab

* Add new story thread types

* Show stories in conversation picker

* Support for sending stories

* Update story list when sending stories

* Add basic 'My Stories' view controller

* Initial stories settings screens

* Consolidate TSPrivateStoryThread and TSMyStoryThread into one class

* Require an explicit read transaction to initialize an outgoing message

* Fix linting

* Allow enabling group story from internal settings

* Fix tests

* PR Feedback
2022-06-10 22:28:03 -04:00
Evan Hahn
8009206c18 Respect recipient capabilities when sending gift badges
This respects the `giftBadges` capability when trying to send gift
badges. In other words, it prevents you from sending gift badges to
someone who lacks the capability.

The bulk of this change involves fetching and saving of this new
capability. The rest of the code involves showing it on the "choose
recipient" screen (and some debug screens).
2022-06-10 22:37:22 +00:00
Max Radermacher
05ed931b10 Convert boost/gift badge constants to an enum 2022-06-09 15:01:22 -07:00
Evan Hahn
e679707038 Fix SwiftLint shorthand_operator violations
The gist is:

```diff
-foo = foo + 1
+foo += 1
```

Most of the violations were in generated files, so I changed and re-ran the generator.

A few of these violations required implementing some new methods, which I added tests for.

See [the docs for this rule][0].

[0]: https://realm.github.io/SwiftLint/shorthand_operator.html
2022-06-07 14:51:57 +00:00
Evan Hahn
5dbc030359 Fix violations of SwiftLint's closure_parameter_position rule
This commit should just change whitespace.

See [the docs for this rule][0].

[0]: https://realm.github.io/SwiftLint/closure_parameter_position.html
2022-06-06 13:58:23 +00:00
Evan Hahn
24ca5abf9c Remove unneeded breaks
This fixes our violations of [the SwiftLint `unneeded_break_in_switch`
rule][0].

[0]: https://realm.github.io/SwiftLint/unneeded_break_in_switch.html
2022-06-03 17:52:28 +00:00
Evan Hahn
df9d1af923 Fix file header with duplicate license and import 2022-06-03 17:49:28 +00:00
Sasha Weiss (Signal)
0a089cb63c
Make "Keep Muted Chats Archived" option available publicly 2022-05-26 10:44:43 -04:00
Evan Hahn
d2836235af Show additional details for subscription charge failures
In c5bdf6c094, we started to show errors
when a subscription failed to renew because of a charge failure.

Now, we show additional text depending on what the charge failure was.
For example, if you had an invalid card number, we show a special string
for that.
2022-05-25 18:17:53 +00:00
Evan Hahn
083ec1ccba Fix SwiftLint is_disjoint violations
This fixes violations of [SwiftLint's `is_disjoint` rules][0], which
says that `set1.intersection(set2).isEmpty` should be replaced with
`set1.isDisjoint(with: set2)`.

I also took one additional step in a few cases: `isDisjoint` can be
called [with any `Sequence`][1], not just a `Set`. This let me remove
some conversions to `Set`. In other words:

```diff
-mySet.isDisjoint(with: Set(myArray))
+mySet.isDisjoint(with: myArray)
```

[0]: https://realm.github.io/SwiftLint/is_disjoint.html
[1]: https://developer.apple.com/documentation/swift/set/2853831-isdisjoint
2022-05-25 14:17:10 +00:00
Max Radermacher
2589f1e217
Remove GV2 rollout properties
* Remove manual groups v2 migration banner
* Remove “No UUID” subtitle when creating group
* Remove `areMigrationsBlocking`
* Remove `canManuallyMigrate`
* Remove `areManualMigrationsAggressive`
* Remove `canAutoMigrate`
* Remove `areAutoMigrationsAggressive`
2022-05-20 11:07:15 -07:00
Jordan Rose
4c8d7662a6 Add OWSIdentityManager.shouldSharePhoneNumber(with:transaction:)
When someone sends a message to your PNI, your responses (from your
ACI) must include a PNI signature, and the sealed sender certificate
you use during this period should include your phone number. This
confirms to the other user that your ACI is associated with your PNI.

This commit adds the state tracking that and ensures that both
TSOutgoingMessage and OWSUDManager check that state when building 1:1
messages and choosing certificates, respectively. Later commits will
set and clear this flag as needed.
2022-05-19 14:20:53 -07:00
Evan Hahn
baddc85564 Add first gift badge screen
This adds the first screen for badge gifting. It lets you see the gift
badge, pick the currency, and advance to the next screen.

It also adds a skeleton for the next screen, so there's somewhere to
advance to, but that screen is unfinished.

All of this is behind disabled flags, so this should have no user
impact.
2022-05-19 14:07:23 +00:00
Igor Solomennikov
8b3ea9d27d Fix typo: "Gausian" -> "Gaussian". 2022-05-17 19:25:30 -07:00
Evan Hahn
4c0e511793 Fix typos in localization string comments
I noticed a few typos in localization string comments while working on
c5bdf6c094. This fixes those.

This should have no (direct) user impact.
2022-05-16 12:26:31 -05:00
Evan Hahn
29c0ddf60e Fix violations of SwiftLint's attributes rule
_I recommend reviewing this with whitespace changes disabled._

Most of these were `@objc` being on the same line, which I fixed with [a
silly script][1]—probably could've used `sed` if I were wiser. The rest
were manual fixes.

See [the SwiftLint documentation for this rule][0].

[0]: https://realm.github.io/SwiftLint/attributes.html
[1]: https://gist.github.com/EvanHahn-Signal/d353c93fa269c82b96baca0a1086521f
2022-05-14 09:07:42 -05:00
Max Radermacher
9908dd604a Acquire a background task during launch jobs
These run after the environment has released its own background task.
2022-05-13 21:36:58 -07:00
Evan Hahn
57ea808a3c Simplify Subscription constructor
This is a followup to c5bdf6c094.
2022-05-13 14:08:32 -05:00
Evan Hahn
8721d4e2a5 Skeleton "choose gift badge" screen
It doesn't do anything yet, but an image and some text is there.

This is all behind a feature flag, so this should have no user impact.
2022-05-13 13:25:36 -05:00
Evan Hahn
c5bdf6c094 Improve subscription charge error UI
Currently, when your subscription expires due a charge failure, we
incorrectly tell you that it's due to inactivity. This fixes that, by
telling you about the charge failure.

This is a bit difficult to test on its own, so I:

- Faked out the smallest pieces I could in an effort to test states
  manually
- Created `BadgeErrorSheetState` which is pretty thoroughly tested
2022-05-12 18:28:14 -05:00
Max Radermacher
d4adfaff91
Fix protocol conformance warnings
There are some Swift-only features that are part of these protocols, so
they were split into Obj-C and Swift variants. However, the class itself
only reports conformance to the Swift variant, which leads to warnings
when using the class in Objective-C.
2022-05-09 11:44:05 -05:00
Max Radermacher
52d6b27ea2 Add nullability annotations to Environment
- Each property is checked with `OWSAssertDebug` in the initializer.
  They are also initialized in a simple way when the app is launching,
  so any that are `nil` would be noticed quickly.

- Getting the shared environment also checks it with `OWSAssertDebug`.
  In addition, it’s currently an implicitly-unwrapped optional in Swift,
  so it’d already be crashing if it’s unexpectedly nil.
2022-05-06 12:43:22 -07:00
Max Radermacher
34767e8beb Increase accepted receipt credential time to 90d
Per IOS-2387.
2022-05-03 10:20:10 -05:00
Evan Hahn
04d7bb7462 Stop using arc4random in Swift files
This removes calls to `arc4random` and `arc4random_uniform` and replaces
them with calls to `Int.random` or equivalent.

These are a little less readable, which may be [why SwiftLint doesn't
like them][0]. (SwiftLint calls them "legacy", possibly because they're
not strong random number generators, but I couldn't find a clear
explanation for this anywhere, including [the original PR][1].)

This is the kind of change that's error-prone, so I wrote [a simple
script to help avoid regressions][2]. The script runs 10,000 iterations
of the old and new RNG and compares the ranges, reporting differences.
(Some differences are likely, like the ones that involve floats; others
are very unlikely to have differences.)

`git grep arc4random | grep swift` returns no results after this change.
Same for [everything else SwiftLint checks for][3].

[0]: https://realm.github.io/SwiftLint/legacy_random.html
[1]: https://github.com/realm/SwiftLint/pull/2419
[2]: https://gist.github.com/EvanHahn-Signal/9c75c9f484f4778149cbde3eafc9b285
[3]: ea6cc50890/Source/SwiftLintFramework/Rules/Idiomatic/LegacyRandomRule.swift (L23-L27)
2022-05-03 10:19:07 -05:00
Evan Hahn
0da97a3e54 Prefer "blocklist"
This replaces the word "blacklist" with "blocklist" across the codebase.

Luckily, there was only one method (and its test) that needed renaming.
2022-04-29 18:34:19 -05:00
Michelle Linington
30cb1d5609 PR Feedback: Fix incorrect error case 2022-04-29 14:47:48 -07:00
Michelle Linington
b5c17b6c1c Improved handling of group bans 2022-04-29 14:47:48 -07:00
Max Radermacher
88a28c3457 Fix typos: Reciept → Receipt 2022-04-29 12:14:09 -07:00
Evan Hahn
929aae46eb Simplify Searcher#matches
`Searcher`'s `matches` method needed a little cleanup. It iterated over
a collection twice, when it could do with only iterating once (and could
return early).

This fixes that, which also fixes a violation of [Swiftlint's
`reduce_boolean` rule][0].

[0]: https://realm.github.io/SwiftLint/reduce_boolean.html
2022-04-29 12:56:54 -05:00
george-signal
a06c706bab
Add avatar repair. (#4091)
There was a bug that caused avatars to be
encrypted with the wrong key, causing them to be
undecryptable both by ourselves and others.

That bug (IOS-2262) was fixed in #4078.

The purpose of this PR is to replace the broken
avatars with good ones.
2022-04-29 10:14:05 -07:00
Martin Böttcher
54b743de2d
moved older stringsdict changes into new branch; minor changes (#4205)
moved older stringsdict changes into new branch
2022-04-28 17:41:43 +02:00
Igor Solomennikov
dc19eb835f Fix "the the" in comments. 2022-04-27 20:16:45 -07:00
Jordan Rose
bb29404739 Only send one PniIdentity sync message when there are many requests
PniIdentity requests get sent from linked devices every time they are
launched, and primaries that don't understand them will drop them.
However, it's possible for several such requests to end up in the
queue, and we should avoid sending several responses (it's harmless
but wasteful). Wait to send any PniIdentity sync messages until
message processing has finished.
2022-04-22 14:26:04 -07:00
Jordan Rose
bc222fdc86 Check all groups for an up-to-date profile key (at most once per week)
This is an expensive check, since it fetches the latest state of every
group we're in, but the cost of an out-of-date profile key is high.
2022-04-21 11:37:38 -07:00