Commit Graph

350 Commits

Author SHA1 Message Date
Sasha Weiss
1cf1872771
Add LocalUserLeaveGroupJobQueue to SSKEnvironment 2022-11-02 10:53:21 -07:00
Sasha Weiss
39f927683f
Be more conservative about when we re-upload the local profile for commitments 2022-11-02 08:54:51 -07: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
72c4dcff51 Simplify methods to populate missing UUIDs
We no longer need `isBlocking`, and we can always consider errors.
2022-10-25 00:41:24 -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
d1819186f1
Remove unnecessary tryToEnableGroupsV2 call
The only place we call this in production code ensures that all members
already support gv2. As a result, there’s no reason to try and enable
gv2 -- it’s already enabled by the time we reach this code.

There are a few places in the Debug UI that may be relying on these CDS
lookups. I’ve removed one of them since there are existing “clone as v1”
and “clone as v2” options that do nearly the same thing. In another
case, I’ve dropped a reference to a live, non-test account. The other
places in the Debug UI that use this method either construct invalid
phone numbers that will never pass a CDS lookup, or they explicitly
provide UUIDs, which would exclude them from performing a lookup.
2022-10-11 17:46:52 -07:00
Evan Hahn
1b00741b6d
Fix remaining SwiftLint failures, lint more strictly
This fixes our remaining SwiftLint violations, which were small.

It also updates the precommit script to fail if any violations are
found, even warnings. This will cause CI to fail if you include a file
that isn't SwiftLint-compatible.
2022-10-07 12:00:26 -05:00
Nora Trapp
6930ffe2fa Remove old group capabilities 2022-09-29 09:35:00 -07:00
Sasha Weiss
063acc1419
Batch messageId notification cancellations 2022-09-27 14:26:44 -07:00
Sasha Weiss
ac97aeba92
Migrate to using ExpiredProfileKeyCredentials 2022-09-26 14:33:57 -07:00
Nora Trapp
6807ad8f02 Properly drop stories from untrusted sources 2022-09-15 10:26:34 -07:00
Sasha Weiss
0d71fe2c67
Cut-paste extension to its own file 2022-09-14 15:11:25 -07:00
Sasha Weiss
28709f9b27
Remove GroupManager#GroupUpdate enum 2022-09-14 11:23:12 -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
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
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
Jordan Rose
11cf13a255 Avoid intermediate copies when using dictionary keys as collections
The non-lazy map and filter always make a new array or dictionary,
which is often consumed immediately into a Set. Using `lazy` avoids
that intermediate allocation, as well as the need to loop over the
array or dictionary a second time.

This is a micro-optimization, but several of these accessors are
accessed fairly frequently, so we might as well make them faster.
2022-08-23 10:42:11 -07:00
Max Radermacher
4e4b9ec9fd Remove unused code for creating a new group
All call sites use the `avatarData` parameter, not `avatarImage`.
2022-08-22 17:19:50 -07:00
Evan Hahn
48c3c08c10 Fix vertical_parameter_alignment SwiftLint violations
This fixes violations of [SwiftLint's `vertical_parameter_alignment`
rule][0]. This should have no user impact.

[0]: https://realm.github.io/SwiftLint/vertical_parameter_alignment.html
2022-08-18 10:37:09 -05:00
Sasha Weiss
7146a02821
Serialize group updates using OWSOperation 2022-08-17 13:18:31 -07:00
Evan Hahn
e858a0d916
Use subclass of outgoing message for group updates
Currently, group (v2) updates are just instances of `TSOutgoingMessage`.
This works, but is inconsistent with other outgoing messages, which
subclass it.

This refactor changes that to make things consistent.

I think this is a useful change on its own, but it will also make future
changes easier.
2022-08-16 14:45:51 -05:00
Evan Hahn
9c4412ef18
Remove nested compiler conditionals
This change should have no user impact.

We effectively had code like this:

    #if TESTABLE_BUILD

    foo()

    #if TESTABLE_BUILD
    bar()
    #endif

    #endif

The inner ones are unnecessary, so I removed them.
2022-08-15 09:13:51 -05:00
Sasha Weiss
43943ca621
Organize GroupV2UpdatesImpl.swift 2022-08-10 16:50:23 -07:00
Sasha Weiss
d1a455b1a2
Collapse join/cancel request events in the chat 2022-08-04 13:07:27 -07:00
Sasha Weiss
7cf14333ad
Prevent empty group updates from clobbering that a member joined via invite link
Group snapshots fetched from the service do not store the
`didJoinFromInviteLink` field on their members, and when we parse a
snapshot into a group model we hardcode this value to `false` for all
members. However, we store that field locally on a `GroupMembership`'s
`MemberStateMap` when processing an "add members" change action, as the
field is provided in the `AddMember` change action proto.

This becomes an issue, since when we refresh the group's state from the
service (which we do periodically, e.g. when opening a group for the
first time after launch) the `GroupMembership` from the group's snapshot
on the service will not match the `GroupMembership` we have locally,
even though they are from the same revision, due to mismatched
`didJoinFromInviteLink` values (hardcoded in the snapshot).
Consequently, we believed we were "updating the group model in a user-
facing way", but the only change therein was clobbering a
`didJoinFromInviteLink: true` to `...: false`, which was 1) wrong and
2) did not have a description to show.

This commit changes `GroupMembership` to ignore values for
`didJoinFromInviteLink` when comparing equality. This means that when we
parse a snapshot into a `TSGroupModel` with all those values hardcoded
to false, but otherwise identical to our local, we will no longer see it
as different from our local (and subsequently clobber our local and
generate an empty update).
2022-08-03 15:04:31 -05: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
f3c5ad92b1 Remove unused isGroupInviteLink method 2022-07-19 16:48:45 -05:00
Sasha Weiss
543d29a13b
Include banned members in comparing and rendering group memberships 2022-07-18 16:00:39 -07:00
Sasha Weiss (Signal)
42e9608c73
Remove user from local group on request-to-join denied 2022-07-18 11:17:58 -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
Sasha Weiss (Signal)
98151dfd0d
Don't need transactions to build group models 2022-07-12 10:23:12 -07:00
Sasha Weiss (Signal)
ac341fdbbc
DRY out V2 group updates 2022-07-08 15:47:45 -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
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
ddad327212 Clear invalid legacy avatars, instead of crashing
A migration (introduced in b2c0e975b6)
tries to save legacy avatars to disk. However, if that legacy avatar
data is invalid, we'd crash on launch.

A user encountered this.

Our possible solutions:

1. If legacy avatar data is invalid, just drop it.
2. If legacy avatar data is invalid, try to repair it. (For example, if
   it's too large, try to resize it.) This might not fix the user's
   issue—unfortunately, we don't know why the avatar was invalid.
3. Loosen our definition of a valid avatar. (For example, increase the
   maximum size.) This also might not fix things—we don't know how the
   avatar was invalid.

I went with the first solution.

This was difficult to test. While developing, I made a temporary button
that (1) updated a group, giving it an empty legacy avatar buffer (2)
tried to migrate it.

(Thanks to c5bd634ff1 for making this easy
to diagnose!)
2022-06-10 21:50:16 +00:00
Evan Hahn
c2e7f0ca93 Prefer implicit getters
_I recommend reviewing this with whitespace changes disabled._

This fixes violations of [SwiftLint's `implicit_getter` rule][0] by
removing explicit getters when an implicit one would do.

[0]: https://realm.github.io/SwiftLint/implicit_getter.html
2022-06-06 14:00:15 +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
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
Michelle Linington
988e6b8e14 Require transactions for the remainder of BlockingManager's interface 2022-04-08 19:01:43 -07:00
Nora Trapp
d1f95f18a7 Render story reply count and indicator 2022-03-31 00:34:32 -07:00
Evan Hahn
de105468a4 Assume everyone is GV2-capable 2022-03-22 17:11:57 -05:00
Jordan Rose
a9b9f58d0e Update clang-format with AllowShortEnumsOnASingleLine: false
And apply it to our sources.
2022-03-14 11:20:20 -07:00
Michelle Linington
c28e8b09b0 First pass at Group Link rejection
Several TODOs remain pending final server API and design
2022-03-09 22:00:18 -08:00
George Nachman
d305bc66a3 Optimize searching for verification status, redux.
Commit 451fa08c22
had some bugs and was reverted by commit
12883e5db5.

This commit brings it back along with fixes.

Specific bug fixes:

* Verification status for a group was inverted.
* The local address should not be considered for
  deciding if a group is verified.
2022-03-01 14:15:11 -08:00
Nora Trapp
b2c0e975b6 Store group avatars on disk 2022-02-09 11:56:03 -08:00