Commit Graph

191 Commits

Author SHA1 Message Date
Sasha Weiss
063acc1419
Batch messageId notification cancellations 2022-09-27 14:26:44 -07:00
Sasha Weiss
698180fbb3
Index name components if available 2022-08-02 11:52:20 -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
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
Nora Trapp
e662b099dd Check if a user is stories capable when sending group replies 2022-03-31 00:37:56 -07:00
George Nachman
b66b1ab866 Batch fetch of user names.
This stacks on top of PR #4065.

This is a simple change that uses the existing
batch profile fetching to get user names.

It adds a test for OWSProfileManager.
2022-03-17 15:05:39 -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
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
George Nachman
36119e4367 Introduce Refinery to help batch DB queries.
This PR is the first in a series that will
optimize looking up full names of group members.

The biggest source of slowness when opening a
group chat is looking up the full names of group
members in the search for duplicates. It is slow
because it requires multiple db queries for each
member.

The characterstic feature of this algorithm is the
iterative process of assigning names to signal
addresses. For example, some contacts' names may
be cached. For others, their profiles must be
fetched. For those without profiles, their phone
numbers must be formatted (which requires fetching
SignalAccounts). For those without phone numbers,
their user names must be formatted.

This PR creates a class called Refinery. Its job
is to make it easy to assign values to keys
through multiple passes, where each pass may
succeed only for a subset of keys.

This is useful because we will eventually issue a
single DB query for some of these passes.
2022-03-04 10:44:07 -08:00
George Nachman
7702463524 Temporarily increase user profile cache size.
PR 2982 optimized
ConversationViewController.createGroupMembershipCollisionBannerIfNecessary`
that fetches user profiles off the main thread and
then, when that completes, uses them on the main
thread to find duplicate display names.

The optimization doesn't work for large groups.
Because `UserProfileReadCache` is backed by an
LRUCache with a maximum capacity of 32, there is
effectively no cache and profiles get fetched
twice.

The main purpose of this commit is to fix this
optimization for large groups without expanding
memory usage unnecessarily. While increasing the
LRU cache's size to 1000 (or some other arbitrary
value) would fix the problem very simply, my gut
tells me that we're going to keep running into
this problem.

Rather than pick an arbitrary "large enough"
value, this commit increases the cache size to be
just large enough for its intended purpose and to
keep it that size for just long enough to do its
job.

This commit introduces the concept of a "lease" on
a larger cache size. The cache's size is defined
as the largest of all its leases plus its
"regular" size (the size it was initialized with).
For now only the user profile cache uses it.
2022-02-11 13:20:12 -08:00
Nora Trapp
aeaf5d86d6 Don't show subscription megaphone again until your subscription has been expired for at least 2 weeks 2022-02-11 13:09:20 -08:00
Nora Trapp
9ed5e74b79 Sync additional badge info with storage service 2021-12-17 13:54:20 -08:00
Nora Trapp
64b399f3e3 Fix badge expiry 2021-12-17 13:54:20 -08:00
Eugene Bistolas
ddafbd32ff Merge branch 'release/5.26.1' 2021-11-23 11:57:03 -10:00
Nora Trapp
fc23418f9c Allow tapping badge on member action sheet 2021-11-23 12:18:28 -08:00
Matthew Chen
fc749b4d72 Change phone number. 2021-11-19 14:28:18 -03:00
Nora Trapp
18a7ad8b2c Fix badge visibility on acquisition 2021-11-17 16:05:58 -08:00
Michelle Linington
ff3d21ff0e Minor tweaks to recent badging changes
- Optionals are now SDSSwiftSerializable as long as their wrapped type
  conforms
- Avatar file writes are now performed outside of a write transaction
- Various rebase cleanup
2021-11-09 14:25:53 -08:00
Michelle Linington
a6deb98c42 Lint 2021-11-09 14:25:42 -08:00
Michelle Linington
5f6ee31e68 Most of badge fetching and persistence
Saving progress before running database codegen
2021-11-09 14:25:42 -08:00
Matthew Chen
c494fb2a44 Don't cache contacts on contacts manager. 2021-10-22 19:09:44 -03:00
Matthew Chen
3bd17e2790 Don't cache contacts on contacts manager. 2021-10-22 19:09:29 -03:00
Matthew Chen
48ab796248 Don't cache contacts on contacts manager. 2021-10-22 19:09:29 -03:00
Matthew Chen
f57de3335f Remove OWSContactsManager.allContactsMap. 2021-10-22 19:09:28 -03:00
Matthew Chen
eec119025f Don't cache signal accounts on contacts manager. 2021-10-22 19:09:28 -03:00
Matthew Chen
5d780d1589 Apply script to normalize includes and imports. 2021-10-21 09:21:10 -03:00
Michelle Linington
3a649b3636 Use server timestamp when filtering stale calls 2021-10-08 11:51:36 -07:00
Matthew Chen
eed697bddd Handle certain call messages sync. 2021-09-22 12:12:10 -07:00
Matthew Chen
692c637e80 Handle certain call messages sync. 2021-09-22 12:11:09 -07:00
Michelle Linington
155c5b6a80 PR Feedback. Remove unused return value 2021-09-21 18:44:00 -07:00
Michelle Linington
3f956130c6 Ignore call messages that won't trigger CallKit ring 2021-09-21 18:44:00 -07:00
Matthew Chen
2b502ad609 Elaborate logging around missing notifications. 2021-09-02 22:51:26 -03:00
Matthew Chen
19076056d0 Never emit invalid e164 in storage service contact records; be robust to invalid e164 incoming protos. 2021-09-01 16:33:16 -03:00
Michelle Linington
aa25a1e274 Extend error messaging to beta users 2021-08-06 10:08:26 -07:00
Michelle Linington
8364e761a6 Add notification for reporting errors to internal users 2021-07-29 19:01:13 -07:00
Michelle Linington
51f3a58a61 Message send log recording and resend responses 2021-07-21 22:58:51 -07:00
Michelle Linington
9c8b225330 PR Feedback and lint 2021-07-21 22:58:50 -07:00
Michelle Linington
6a0bfa7836 Make SignalServiceAddress optional for message building
SenderKey requires that building a message is agnostic from a single
recipient. This makes the recipient argument when building an outgoing
message optional.

Currently this is used to determine if a profile key should be appended
to the message. A different solution will be required for SenderKey
messages.
2021-07-21 22:58:50 -07:00
Nora Trapp
e65b722230 Don't perform duplicate decryption of relayed call messages 2021-07-06 13:41:36 -07:00
Nora Trapp
1bac32f750 Don't keep notifications in memory 2021-07-01 12:18:27 -07:00
Matthew Chen
f754a19156 Reduce peak memory usage in system contact fetches, and sending/receiving contact syncs. 2021-06-30 15:23:49 -03:00
Matthew Chen
c1a9694a59 Rework user profile writes. 2021-06-18 13:46:39 -03:00
Matthew Chen
6576531c9f Rework user profile writes. 2021-06-18 13:46:39 -03:00
Matthew Chen
d0befacbdb Rework user profile writes. 2021-06-18 13:46:39 -03:00
Matthew Chen
e1149c9337 Rework user profile writes. 2021-06-18 13:46:39 -03:00
Matthew Chen
c0f3b95ba0 Rework user profile writes. 2021-06-18 13:46:39 -03:00
Matthew Chen
d084fd6fa4 Rework user profile writes. 2021-06-18 13:46:38 -03:00
Matthew Chen
e192e5013d Rework user profile writes. 2021-06-18 13:46:38 -03:00
Matthew Chen
7dafc6aa3d Rework user profile writes. 2021-06-18 13:46:38 -03:00