Commit Graph

151 Commits

Author SHA1 Message Date
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
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
Evan Hahn
349681ff85
Attempt to recover corrupted databases
If a user's database is corrupted, we now try to fix it. I recommend
reviewing `DatabaseRecovery` to see how this works, and
`DatabaseRecoveryViewController` for the bulk of the UI.
2022-10-06 16:42:19 -05:00
Nora Trapp
c8dc629351 Show active group stories in the conversation picker 2022-09-22 14:53:29 -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
Phil Larson
00466c7a18 Remove extra commas when running sds_codegen.sh 2022-08-01 15:47:24 -05: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
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
16aa421d3e More Python 3 script fixes 2022-03-24 10:28:27 -05:00
Evan Hahn
c254811765 Remove unnecessary coding: utf-8 heading from Python scripts
Python 3 uses UTF-8 for source files by default. This removes the
unnecessary `coding: utf-8` declaration comment from all files.
2022-03-21 14:43:45 -05:00
Evan Hahn
1101db6a29 Upgrade scripts to Python 3
Python 2 was [removed from macOS in 12.3][0]. This change:

- Automatically converts many files with [2to3][1]
- Manually updates all [shebangs][2] to use `python3` instead of
  versionless `python` or `python2.7`
- Manually applies a few fixes, many of which were noted by 2to3
- Manually undoes a few fixes that were automatically done by 2to3

[0]: https://www.macrumors.com/2022/01/28/apple-removing-python-2-in-macos-12-3/
[1]: https://docs.python.org/3/library/2to3.html
[2]: https://en.wikipedia.org/wiki/Shebang_(Unix)
2022-03-21 12:58:33 -05:00
Dimitris Apostolou
62724cf0be Fix typos 2022-03-18 11:31:06 -07:00
Jordan Rose
15d13517fa Add SDSCursor protocol, for common functionality across cursors 2022-03-07 15:01:39 -08:00
Jordan Rose
61232780ee Don't reindex conversations on every model change
Every single message updates a TSThread model, but only a change in a
member's profile name or phone number, or a change to a group's model,
can update the indexing information. Turn 'shouldBeIndexedForFTS' into
a tri-state 'FTSIndexMode' with options 'never', 'manualUpdates', and
'always', and use 'manualUpdates' for TSThreads. Then explicitly
reindex on any of the changes listed above.
2022-02-01 15:05:34 -08:00
Michelle Linington
e3d18733da Bump copyright 2022-01-28 13:23:47 -08:00
Matthew Chen
9963df1f23 Reduce statics. 2021-11-02 10:36:25 -03:00
Michelle Linington
77b7ea5c40 Fix a whole bunch of warnings 2021-10-21 21:11:26 -07:00
Ehren Kret
3d768ffe3d Update copyright dates in SDS codegen 2021-09-24 10:30:09 -03:00
Michelle Linington
c7444cb01d Remove isHidden column, use recordType instead 2021-08-26 20:57:06 -07:00
Matthew Chen
10778e915c Improve handling of db corruption. 2021-05-03 15:00:33 -03:00
Matthew Chen
a00d14ddc4 Payments: Models 2021-04-06 13:57:06 -03:00
Nora Trapp
63da30f617 Store mute as millisecond timestamp 2021-03-27 12:13:20 -07:00
Matthew Chen
86b8eb08b8 Remove YapDatabase.
Apply asset from design.

Fix rebase breakage.
2021-03-25 11:41:16 -03:00
Matthew Chen
111338b59d Rewrite conversation view. 2020-12-10 12:44:13 -03:00
Nora Trapp
6f963c7ba5 Add mention notification settings 2020-08-04 14:09:06 -07:00
Matthew Chen
2a72d563ae Respond to CR. 2020-06-18 12:22:14 -03:00
Matthew Chen
c6d5a52f82 Rework SDS extensions to support deep copies and cache lifecycle. 2020-06-18 12:05:07 -03:00
Matthew Chen
b37c2bc713 Rework SDS extensions to support deep copies and cache lifecycle. 2020-06-18 12:05:07 -03:00
Matthew Chen
0891ce52e1 Copy model read cache values. Add deepCopy method to all models. 2020-06-11 13:22:16 -03:00
Ehren Kret
5cd2bd0fe4 Update all sds python shebang lines to 2.7 2020-04-14 08:52:34 -07:00
Matthew Chen
2d41ad42b4 Fix build warnings around initializers. 2020-04-08 16:05:54 -03:00
Matthew Chen
02f853a8dc Clean up code generation. 2020-04-02 13:31:14 -03:00
Michael Kirk
904b333924 codegen handles "id" type 2020-01-23 11:55:48 -07:00
Nora Trapp
14c8f4175e Add Reaction Model 2019-11-14 13:22:47 -08:00
Matthew Chen
5d787da830 Update code generation to ensure consistent property ordering. 2019-11-05 10:59:58 -03:00
Matthew Chen
179131c615 Update code generation to ensure consistent property ordering. 2019-11-05 10:45:16 -03:00
Matthew Chen
af1a74b01d Update code generation to ensure consistent property ordering. 2019-11-05 10:42:07 -03:00
Matthew Chen
471a54cc64 Update code generation to ensure consistent property ordering. 2019-11-05 10:15:07 -03:00
Michael Kirk
be0190f060 update templates 2019-11-04 14:06:54 -08:00
Matthew Chen
553a74b685 Further refine interaction writes. 2019-10-17 10:32:21 -03:00
Matthew Chen
156efd575c Revert "streamline interaction writes" refinements. 2019-10-17 10:32:21 -03:00
Matthew Chen
f5bc78696a Fix "record id v. sort id" conflicts. 2019-10-16 16:17:47 -03:00
Matthew Chen
54783c5e40 Fix typo in the "streamline interaction writes" changes. 2019-10-16 14:17:06 -03:00
Matthew Chen
b4c0fc5776 Respond to CR. 2019-10-15 11:05:15 -03:00
Matthew Chen
508b371294 Streamline interaction writes. 2019-10-15 11:01:08 -03:00
Matthew Chen
06e310d391 Rework thread mapping updates. 2019-10-11 09:31:35 -03:00
Michael Kirk
a00c1eb8d1 codegen id source 2019-09-20 16:25:55 -07:00
Michael Kirk
ca0179a1f6 fix indent 2019-09-20 16:25:55 -07:00
Matthew Chen
232f65618e Respond to CR. 2019-09-18 09:07:29 -03:00
Matthew Chen
464df8016b Respond to CR. 2019-09-18 09:07:28 -03:00