Commit Graph

597 Commits

Author SHA1 Message Date
Sasha Weiss
be4b132ea6
Rename StorageServiceManagerProtocol 2023-03-23 09:29:38 -07:00
Evan Hahn
a77b45c6de Remove Dependencies from the three launch jobs
This change should have no user impact.

`FailedMessagesJob`, `IncompleteCallsJob`, and
`FailedAttachmentDownloadsJob` used to inherit from `Dependencies`. Now,
they explicitly take their one dependency: a database.

I also made a few methods private because they didn't need to be
exposed.
2023-03-20 11:01:29 -05:00
Harry
5ad17c4f2d
Support change number in registration coordinator
* Factor out RegistrationCoordinatorLoader

* Add PNI change number state to regcoordinatorloader

* Don't exit change number flow once we start a pni operation

* Add ChangePhoneNumberPniManager to reg coordinator dependencies

* add params required for pni to change number registration mode

* change number from regcoordinator

* rename ChangePhoneNumber -> LegacyChangePhoneNumber

* remove pni change number support from LegacyChangePhoneNumber

* remove codable conformance from pni change number manager's pending state

* Update ts account manager state when finalizing change number

* Add message processor deps to reg coordinator

* addAsyncCompletion on dbv2 write transactions

* Suspend message processing while doing a reg coordinator change number

* hook up change number

* Add handler-free message processing suspension method

* odds and ends

* minor cleanup

* slight refactor to finalize change phone number in the export function

* Put wait for message processing + suspend onto messageProcessor

* kick of prekey refresh after pni change number finalize transaction ends

* nit
2023-03-17 17:55:06 -07:00
Sasha Weiss
8047472f68
Rename SubscriptionManagerProtocol 2023-03-14 17:44:38 -07:00
Pete Walters
3e3e0e5acf
Add manager to periodically validate usernames 2023-03-14 09:56:08 -05:00
Sasha Weiss
cd67e81baa
Wire up PNI change-number to ChangePhoneNumber 2023-03-09 17:37:37 -08:00
Max Radermacher
218663e430
Fix when ExitShareExtension gets called 2023-02-24 00:55:42 -08:00
Sasha Weiss
e5f1af6c2e
Support lookup-by-username 2023-02-08 10:16:57 -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
0dc492fec5
Use common logic when creating web sockets 2023-01-24 14:01:34 -08:00
Igor Solomennikov
41b1469f7a
Convert OWSAudioPlayer to swift and lose 'OWS' prefix.
Also rename OWSAudioSession to AudioSession for consistency with everything else.
2022-12-06 16:00:58 -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
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
Sasha Weiss
1cf1872771
Add LocalUserLeaveGroupJobQueue to SSKEnvironment 2022-11-02 10:53:21 -07:00
Sasha Weiss
1cb90e245f
Fetch and persist remote megaphones 2022-10-26 15:03:08 -07:00
Jordan Rose
73b2570e4b Un-nest immediately-invoked block 2022-10-25 10:40:55 -07:00
Max Radermacher
1b5303c22c Remove unused BulkUUIDLookup 2022-10-25 00:41:24 -07:00
Max Radermacher
5af7880c39 Remove redundant checks for the main app
All of these use `runNowOrWhenMainAppDidBecomeReadyAsync`, and that only
runs the block in the main app, so there’s no need to skip the block if
we’re in an extension.
2022-10-17 12:42:42 -07:00
Evan Hahn
370ff654e7
Change license to AGPL
Change license to AGPL

This commit:

- Updates the `LICENSE` file

- Start every file with something like:

      // Copyright YEAR_FIRST_PUBLISHED Signal Messenger, LLC
      // SPDX-License-Identifier: AGPL-3.0-only

---

First, I removed existing license headers with this Ruby 3.1.2 script:

    require 'set'

    EXTENSIONS_TO_CHECK = Set['.h', '.hpp', '.cpp', '.m', '.mm', '.pch', '.swift']

    same = 0
    different = 0

    all_files = `git ls-files`.lines.map { |line| line.strip }
    all_files.each do |relative_path|
      if relative_path == 'Pods'
        next
      end

      unless EXTENSIONS_TO_CHECK.include? File.extname(relative_path)
        next
      end

      path = File.expand_path(relative_path)

      contents = File.read(path)
      new_contents = contents.sub(/\/\/\n\/\/  Copyright .*\n\/\/\n\n/, '')

      if contents == new_contents
        same += 1
      else
        different += 1
      end

      File.write(path, new_contents)
    end

    puts "updated #{different} file(s), left #{same} untouched"

I'm sure this script could be improved, but it worked well enough.

Then, I created `Scripts/lint/lint-license-headers` and ran it to auto-
fix a lot of files. This changed the mode of some files, but I think
that's actually desirable. For example,
`SignalServiceKit/src/Util/AppContext.m` previously had a mode of
`0755/-rwxr-xr-x`, and it's now `0644/-rw-r--r--`.

Then I fixed some stragglers and updated the precommit script.

See [a similar change in the Desktop app][0].

[0]: 8bfaf598af
2022-10-13 08:25:37 -05:00
Max Radermacher
974b643234
Reduce likelihood of flaky test failures 2022-10-07 09:36:04 -07:00
Sasha Weiss
7fb1da0cec
Migrate ExperienceUpgrade models to SDSCodableModel 2022-10-04 08:52:03 -07:00
Evan Hahn
11c2cf0813
Add basic test for database migration
_This change should have no user impact._

This adds a basic test for database migration, and makes the necessary
changes to make that possible.
2022-09-22 17:24:40 +00:00
Harry
7ee39eef63
Add SystemStoryManager
* Add OnboardingStoryManager

* mark onboarding story viewed

* Add tests and fix issues that came up from testing

* up test timeout for slower CI

* rename SystemStoryManager and put into dependency injecton container

* Use viewed state on StoryMessage itself. Have SystemStoryManager observe app lifecyle events to automatically manage the onboarding story

* use iOS assets which are now in s3

* todo cleanup

* increment timestamp for uniqueness

* pr comments

* change literal delimiter

* Add ChainedPromise utility, tests, and use in SystemStoryManager

* discretionarily observe app backgrounding in SystemStoryManager

* renaming from PR comments
2022-08-30 14:49:59 -07:00
Harry
33e26b6c4c
Migrate OWSSignalService from objc to swift, and split it into a protocol and implementation
* Split OWSSignalService into a swift protocol and implementation, migrated from objc

* Put OWSSignalService under SSKEnvironment and use mock in mock environment

* Rename from basename + impl to protocol + basename

* extend mock functionality a bit

* pr feedback
2022-08-24 14:36:52 -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
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
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
George Nachman
22c1cb8a22 Fetch phone numbers in a batch.
This is the first meaty part of optimizing
fetching display names.

Some contacts fall back to phone numbers as their
display names. This PR fetches them in a single
SQL query via
`OWSContactsManager.phoneNumbers(for:, transaction)`.

To achieve this, this PR introduces
`GRDBSignalAccountFinder.signalAccounts(for:,transaction:)`
to fetch many accounts at once.

In order to fetch many accounts at once, we need
to be able to fetch many values from a
ModelReadCache at once. So this PR introduces
`ModelReadCache.readValues(for:,transaction:)` and
`ModelReadCache.getValues(for:,transaction:,returnNilOnCacheMiss:)`.

Existing methods that operate on a single value
were refactored to use the batch methods.

This PR adds tests for this functionality, which
necessitated changing the visibility of various
private symbols and also improving the fake
profile manager to make it more configurable.

There's also a tiny optimization for Refinery to
avoid calling a closure that has no work to do.
This helps elide do-nothing SQL queries that would
otherwise have been introduced.
2022-03-17 12:46:33 -07:00
Martin Böttcher
000c4c282b Merge branch 'master' into martin/IOS-2234 2022-03-17 09:09:37 +01:00
Jordan Rose
7448b377fb Parameterize the 1:1 stores by identity (ACI or PNI)
This allows two stores to coexist in the database. Note that
everything *using* the stores will still always use the ACI stores at
this point.
2022-03-16 14:31:06 -07:00
Jordan Rose
2e39dab9b2 Support two SignalProtocolStores in SSKEnvironment
'sessionStore', 'preKeyStore', and 'signedPreKeyStore' are no longer
directly accessible; you have to go through
'signalProtocolStore(for:)' instead. This commit mechanically changes
all use sites to use `signalProtocolStore(for: .aci)`, with the
understanding that they will need cleanup in the future.

This is not enough to actually support multiple stores; they still
store in the database under the same keys. That's coming in the next
commit.
2022-03-16 14:31:06 -07:00
Martin Böttcher
8f9be31ba3 replaced NSLocalizedStringFromAppBundle with OWSLocalizedString 2022-03-08 10:17:25 +01:00
Martin Böttcher
c0adfbfb32 NSLocalizedString is replaced by NSLocalizedStringFromAppBundle (reading strings from the bundle of the main app) for all source files called by an app extension and the localizable files are removed for the app extension targets. 2022-03-07 13:29:06 +01:00
Jordan Rose
2f710ecc87 Log statistics about the SDSKeyValueStore on internal app launch
(without blocking launch, of course)

This should help us identify which SDSKeyValueStore collections might
be better promoted to full tables.
2022-03-04 16:29:27 -08:00
Michelle Linington
259cf01376 Lint 2022-03-04 14:16:29 -08:00
Michelle Linington
05ea13c8c9 LightweightCallManager will now post NSE group call alerts 2022-03-04 14:16:29 -08:00
Michelle Linington
62e804da5f Plumbing 2022-03-04 14:16:29 -08:00
Michelle Linington
1b4460748c Additional avatar logging 2022-02-25 17:28:08 -08:00
Michelle Linington
91aaffe16b Lint 2022-01-31 11:00:13 -08:00
Michelle Linington
06a83d065c Improves performance of launch jobs
Randall hit an issue where his device would take a few seconds to start
up. His logs indicate that his device is spending time running
LaunchJobs.

The first change here is to make sure we explicitly set the launch job
work at an ultra-high priority. This is okay, since we don't actually
present UI until after we finish these jobs. Running this work at
UserInteractive is appropriate since it quite literally prevents the
user from interacting with the app. There's also no other time-sensitive
UI work we need to be doing (like running animations) that we could be
contending with.

The second change is to add a bit more logging that allows us to monitor
the amount of work these jobs are doing. This will allow us to see if
these jobs are performing an excessive amount of work.

Finally, I moved these LaunchJobs to Swift. Mostly because the ObjC
implementations were block based. The additional code was going to
indent things further and our linter aggressiely indents blocks to begin
with. Moving this to Swift is much more readable.
2022-01-31 11:00:13 -08:00
Jordan Rose
a31100f0f5 Fix copyrights 2022-01-26 09:50:56 -08:00
Jordan Rose
01518551eb Import SignalMetadataKit wholesale into SignalServiceKit
The only modifications are those necessary to build as part of SSK.
The follow-up commits will clean that up a bit.
2022-01-26 09:50:55 -08:00
Nora Trapp
64b399f3e3 Fix badge expiry 2021-12-17 13:54:20 -08:00
Matthew Chen
fc749b4d72 Change phone number. 2021-11-19 14:28:18 -03:00
Matthew Chen
c0c72ef3fb Introduce WebSocketFactory. 2021-11-03 19:48:48 -07:00
Matthew Chen
539dff09e4 Move MobileCoin SDK to SignalUI. 2021-11-02 14:26:03 -03:00
Matthew Chen
9211ac8fa3 Move MobileCoin SDK to SignalUI. 2021-11-02 14:26:03 -03:00
Matthew Chen
ac83129534 Move MobileCoin SDK to SignalUI. 2021-11-02 14:26:02 -03:00
Matthew Chen
079bb08067 Move MobileCoin SDK to SignalUI. 2021-11-02 14:26:02 -03:00
Matthew Chen
3d59efc2cd Add PhoneNumberUtil singleton. 2021-10-22 19:06:14 -03:00