Commit Graph

415 Commits

Author SHA1 Message Date
Sasha Weiss
8bd39bf8d5
Consolidate network error methods 2023-07-26 17:23:40 -07:00
Max Radermacher
17a2fb4093
Rename ServiceId -> UntypedServiceId 2023-07-26 16:56:19 -05:00
Jordan Rose
5d183bf9cc Groups: one last fix to prefer 'userId' field over 'presentation'
In the past, certain group change actions only contained the
"presentation" of a ProfileKeyCredential rather than separate 'userId'
and 'profileKey' fields, but this has long been corrected. Most of
these are now handled using the HasAciAndProfileKey protocol, but this
one was missed because it doesn't need the profile key (and shouldn't
waste time decrypting it).
2023-07-13 16:19:11 -07:00
Max Radermacher
ca3b018734
Add & use DisappearingMessagesConfigurationStore 2023-06-05 11:00:38 -05:00
Igor Solomennikov
f65d8e267d
Remove ObjC cruft from some classes. 2023-06-02 21:36:36 -07:00
Harry
4580b9ee66
Don't rely on TSAccountManager global state to load groups from storageService 2023-06-02 09:15:52 -07:00
Sasha Weiss
2845d60e13
Remove lots of GV1-related code 2023-06-01 11:47:43 -07:00
Sasha Weiss
3ac8917bc6
Skip sending group update messages for PNI invite declines 2023-05-30 10:59:07 -07:00
Sasha Weiss
e70dab1a68
Remove entrypoints for GV1 -> GV2 migration 2023-05-30 08:50:11 -07:00
Sasha Weiss
9d16dd49e0
Support PNI invites in groups 2023-05-23 15:40:58 -07:00
Igor Solomennikov
7790837eb5
Remove unnecessary "@objc" in SignalMessaging. 2023-05-16 16:41:49 -07:00
Sasha Weiss
eff9291c89
Make sure to apply group model options when creating a thread 2023-05-05 11:43:51 -07:00
Sasha Weiss
3c5cefa07c
Clean up GroupMembership 2023-04-21 12:09:14 -07:00
Harry
290f83f8ab
Don't require pni used exclusively for logging 2023-04-19 18:22:04 -07:00
Max Radermacher
a8511014cb
Use LocalIdentifiers in Storage Service 2023-04-14 10:20:58 -07:00
Max Radermacher
b4c77035d9
Swiftify registered url handling
Co-authored-by: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com>
2023-04-10 13:37:46 -07:00
Sasha Weiss
e46307f989
Fall back to snapshot if group change proto has incompatible revision 2023-03-28 12:10:26 -07:00
Harry
a146e18aaf
Set up account state and exit registration
* Go to chat list view after registration

* sync system contacts during registration

* Use explicit local credentials for storage service operations during registration

* fix tests

* Quick hack to get through double pin confirmation

* Finishing touches

* lint

* fix build

* reload phone number discoverability after storage service sync

* fix tests again

* Take chat auth on account and contact record initializers

* Change around branches for clarity in OWSUserProfile

* pr comments

* Split ChatServiceAuth into the same and AuthedAccount

* fix tests

* merge woes
2023-03-09 21:54:51 -08:00
Max Radermacher
898fd2c4d5
Clean up queue names 2023-02-27 14:16:09 -08:00
Max Radermacher
59593c3c97
Add ServiceId & E164 types
* Use the new E164 type in a few places
* Use the new ServiceId type in a few places
2023-02-21 23:13:46 -08:00
Max Radermacher
c13ebc7482
Consolidate storage service code 2023-02-10 17:58:51 -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
Sasha Weiss
70d018a55d
.redundantChange should not be considered retryable 2023-02-07 12:57:51 -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
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
Max Radermacher
3e129edfcd Limit scope of undiscoverable gv2 phone numbers
If we’ve recently discovered that a phone number can’t be discovered,
there isn’t much benefit to checking again.

However, for other parts of the migration flow, we still want to
consider such users. For example, sometimes we want to require all users
to have a UUID to perform a migration. Before this change, we might
return a false positive after performing a CDS lookup since we wouldn’t
check whether or not recently undiscoverable users have a UUID.

In another case, we’re intentionally excluding users without UUIDs. In
this case, the end result is the same whether we drop them during the
first pass or the second pass, but the intent is more clear if we drop
all such users during the second pass.

Lastly, we want to fetch profiles even for undiscoverable users, even
though this operation is likely to fail.
2022-10-24 10:21:05 -07:00
Max Radermacher
66a6b428bb Remove internal-only profile key merging code
This is no longer necessary.
2022-10-17 09:27:55 -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
56bfcf3d72
Remove redundant fetches during gv2 migration
The `attemptToMigrateByCreatingOnService` method has a single caller,
and that caller also calls `tryToPrepareMembersForMigration` first. The
former is called when `migrationMode`’s `canMigrateToService` is true,
and the latter does a CDS lookup & profile key fetches if
`migrationMode`’s `isOnlyUpdatingIfAlreadyMigrated` is false; these two
conditions are true in the same situations. As a result, these CDS
lookups and profile key fetches aren’t necessary.

(This also removes an extra `firstly` block. I’d recommend ignoring
whitespace while reviewing the change.)
2022-10-12 10:17:26 -07:00
Nora Trapp
b962b752cb Don't auto-migrate groups on app launch 2022-09-29 09:35:00 -07:00
Nora Trapp
6930ffe2fa Remove old group capabilities 2022-09-29 09:35:00 -07:00
Sasha Weiss
ac97aeba92
Migrate to using ExpiredProfileKeyCredentials 2022-09-26 14:33:57 -07:00
Sasha Weiss
bb03be620e
Use "modern" proto fields instead of presentation for incoming group changes 2022-09-20 10:44:42 -07:00
Sasha Weiss
fb1a4979d4
Remove guard around bannedAtTimestamp 2022-09-14 13:36:19 -07:00
Sasha Weiss
edc9b13ba3
Use a dedicated error to recover from conflicts when updating a group on the service 2022-09-13 15:28:51 -07:00
Sasha Weiss
640cb03a79
Do not retry for GroupsV2Error.conflictingChange 2022-09-13 11:31:03 -07:00
Nora Trapp
ad34089ffe Sync group stories with storage service 2022-09-12 12:00:14 -07:00
Sasha Weiss
74852a3ebd
Merge almost-identical profile key fetch methods 2022-09-09 16:21:09 -07:00
Sasha Weiss
f80ed7964a
Only recover from errors in performServiceRequestAttempt 2022-09-09 09:47:57 -07:00
Sasha Weiss
f37a0040ad
Replace AuthCredential with AuthCredentialWithPni 2022-09-07 15:39:50 -07:00
Sasha Weiss
4085771309
Centralize force-casts in a VersionedProfilesSwift dependency 2022-09-07 12:43:09 -07:00
Sasha Weiss
569cdb2aad
Durable jobs for leaving groups 2022-08-26 13:13:23 -07:00
Sasha Weiss
11e2729c49
Auto-leave groups when added by a blocked contact 2022-08-25 16:20:15 -07:00
Sasha Weiss
24d3d0e68d
Remove requiredRevision arg from updateExistingGroupOnService, and make it private 2022-08-25 12:41:55 -07:00
Sasha Weiss
56b9b2c139
Wait for group updates before doing profile key updates 2022-08-25 11:54:01 -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
Harry
2950667ac9
Split OWSURLSession into a protocol and implementation
* Split OWSURLSession into a protocol and implementation

* Add OWSURLSessionMock

* Rename from basename + impl to protocol + basename

* add simple init for mock session

* nits from pr comments

* pr comments 2
2022-08-24 13:33:27 -07:00
Sasha Weiss
7146a02821
Serialize group updates using OWSOperation 2022-08-17 13:18:31 -07:00
Sasha Weiss
c5f21a2e53
Allow a bannedAtTimestamp of 0 for incoming banned members 2022-08-17 12:52:48 -07:00