diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..4520fd1 --- /dev/null +++ b/.envrc @@ -0,0 +1,8 @@ +if [[ $(uname -s) == "Linux" && $(uname --kernel-version | grep "NixOS") ]]; then + echo "The best OS (NixOS) has been detected. Using nice tools." + if ! has nix_direnv_version || ! nix_direnv_version 3.0.0; then + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.0/direnvrc" "sha256-21TMnI2xWX7HkSTjFFri2UaohXVj854mgvWapWrxRXg=" + fi + + use flake +fi diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index dfb4b8b..0000000 --- a/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -*.pb.go linguist-generated=true -*.pb.raw binary linguist-generated=true diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md index cba1054..02ed284 100644 --- a/.github/ISSUE_TEMPLATE/bug.md +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -1,18 +1,7 @@ --- name: Bug report about: If something is definitely wrong in the bridge (rather than just a setup issue), - file a bug report. Remember to include relevant logs. Asking in the Matrix room first - is strongly recommended. -type: Bug + file a bug report. Remember to include relevant logs. +labels: bug --- - - - -### Checklist - - - -* [ ] This is an actual bug, not just a setup issue (see the [troubleshooting docs](https://docs.mau.fi/bridges/general/troubleshooting.html) or ask in the Matrix room for setup help). -* [ ] I am certain that sufficient information is included. Ask in the Matrix room first if not. -* [ ] The bug is still present on the main branch. The `!signal version` command output is: `` diff --git a/.github/ISSUE_TEMPLATE/enhancement.md b/.github/ISSUE_TEMPLATE/enhancement.md index a04fe58..264e67f 100644 --- a/.github/ISSUE_TEMPLATE/enhancement.md +++ b/.github/ISSUE_TEMPLATE/enhancement.md @@ -1,6 +1,6 @@ --- name: Enhancement request about: Submit a feature request or other suggestion -type: Feature +labels: enhancement --- diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index ebd9186..678a3e0 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -3,24 +3,18 @@ name: Go on: [push, pull_request] env: - GOTOOLCHAIN: local + LIBSIGNAL_REF: "v0.36.1" jobs: lint: runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - go-version: ["1.25", "1.26"] - name: Lint ${{ matrix.go-version == '1.26' && '(latest)' || '(old)' }} - steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v6 + uses: actions/setup-go@v5 with: - go-version: ${{ matrix.go-version }} + go-version: "1.21" cache: true - name: Install libolm @@ -33,29 +27,28 @@ jobs: export PATH="$HOME/go/bin:$PATH" - name: Run pre-commit - uses: pre-commit/action@v3.0.1 + uses: pre-commit/action@v3.0.0 test: runs-on: ubuntu-latest strategy: fail-fast: false matrix: - go-version: ["1.25", "1.26"] - name: Test ${{ matrix.go-version == '1.26' && '(latest)' || '(old)' }} + go-version: ["1.20", "1.21"] steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v6 + uses: actions/setup-go@v5 with: go-version: ${{ matrix.go-version }} cache: true - #- name: Set up gotestfmt - # uses: GoTestTools/gotestfmt-action@v2 - # with: - # token: ${{ secrets.GITHUB_TOKEN }} + - name: Set up gotestfmt + uses: GoTestTools/gotestfmt-action@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} - name: Install libolm run: sudo apt-get install libolm-dev @@ -68,5 +61,4 @@ jobs: run: | set -euo pipefail export LIBRARY_PATH=. - #go test -v -json ./... -cover | gotestfmt - go test ./... + go test -v -json ./... -cover | gotestfmt diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml deleted file mode 100644 index c15f2fa..0000000 --- a/.github/workflows/stale.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: 'Lock old issues' - -on: - schedule: - - cron: '0 12 * * *' - workflow_dispatch: - -permissions: - issues: write -# pull-requests: write -# discussions: write - -concurrency: - group: lock-threads - -jobs: - lock-stale: - runs-on: ubuntu-latest - steps: - - uses: dessant/lock-threads@v6 - id: lock - with: - issue-inactive-days: 90 - process-only: issues - - name: Log processed threads - run: | - if [ '${{ steps.lock.outputs.issues }}' ]; then - echo "Issues:" && echo '${{ steps.lock.outputs.issues }}' | jq -r '.[] | "https://github.com/\(.owner)/\(.repo)/issues/\(.issue_number)"' - fi diff --git a/.gitignore b/.gitignore index 7766014..c4d535d 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,6 @@ *.log* /mautrix-signal +/mautrix-signalgo /start /libsignal_ffi.a - -.idea diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6420bf8..6c694eb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,9 +1,10 @@ include: - project: 'mautrix/ci' - file: '/gov2-as-default.yml' + file: '/go.yml' variables: BUILDER_IMAGE: dock.mau.dev/tulir/gomuks-build-docker/signal + BINARY_NAME: mautrix-signal # 32-bit arm builds aren't supported build arm: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c9cc6a3..02c1682 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v6.0.0 + rev: v4.5.0 hooks: - id: trailing-whitespace exclude_types: [markdown] @@ -9,20 +9,10 @@ repos: - id: check-added-large-files - repo: https://github.com/tekwizely/pre-commit-golang - rev: v1.0.0-rc.4 + rev: v1.0.0-rc.1 hooks: - id: go-imports exclude: "pb\\.go$" - args: - - "-local" - - "go.mau.fi/mautrix-signal" - - "-w" - id: go-vet-mod -# - id: go-staticcheck-repo-mod + #- id: go-staticcheck-repo-mod # TODO: reenable this and fix all the problems - - - repo: https://github.com/beeper/pre-commit-go - rev: v0.4.2 - hooks: - - id: zerolog-ban-msgf - - id: zerolog-use-stringer diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bf9682..2b51415 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,282 +1,10 @@ -# v26.04 - -* Updated libsignal to v0.92.1 -* Added support for admin message deletes from Signal. -* Added support for binary service IDs in storage service. -* Fixed `private_chat_portal_meta` option not setting DM room names correctly. -* Fixed panic if user is logged out during initial chat sync. -* Fixed avatar upload failing when creating new Signal group. - -# v26.03 - -* Switched to sending binary service ID fields in outgoing messages. -* Added support for roundtripping large attachments via disk to avoid keeping - the entire file in memory during en/decryption. - -# v26.02.2 - -* Added support for more new binary service ID fields. - -# v26.02.1 - -* Updated libsignal to v0.87.5. -* Added support for new binary service ID fields that Signal 8.0 switched to. - -# v26.02 - -* Bumped minimum Go version to 1.25. -* Updated libsignal to v0.87.1. -* Added automatic recovery for the session not found error from libsignal. -* Fixed sender key state not being cleared on logout properly. - -# v26.01 - -* Updated libsignal to v0.86.12. -* Changed automatic contact list sync option to only sync every 3 days rather - than on every restart. -* Fixed sending messages to groups with no other registered members. -* Fixed sender key sends failing if some users had changed devices. -* Fixed timestamps of outgoing typing notifications in DMs. - -# v25.12 - -* Updated libsignal to v0.86.8. -* Updated Docker image to Alpine 3.23. -* Added support for dropping incoming DMs from blocked contacts on Signal. -* Added support for sender key encryption when sending to groups, which makes - sending much faster and enables sending typing notifications. -* Added support for encryption retry receipts. -* Fixed bugs with handling poll votes. -* Fixed history transfer option not showing up when pairing with Signal Android. -* Fixed nicknames being cleared not being bridged - (thanks to [@Enzime] in [#623]). - -[#623]: https://github.com/mautrix/signal/pull/623 -[@Enzime]: https://github.com/Enzime - -# v25.11 - -* Updated libsignal to v0.86.4. -* Added support for bridging invite state in groups for phone number invites. -* Added support for polls. -* Fixed PNI signature not being sent when replying to message requests. -* Fixed unnecessary repeating error notices when Signal is down. -* Fixed sticker size metadata on Matrix not matching how native Signal Desktop - renders them. - -# v25.10 - -* Switched to calendar versioning. -* Updated libsignal to v0.84.0. -* Fixed backfill creating incorrect disappearing timer change notices. - -# v0.8.7 (2025-09-16) - -* Removed legacy provisioning API and database legacy migration. - Upgrading directly from versions prior to v0.7.0 is not supported. - * If you've been using the bridge since before v0.7.0 and have prevented the - bridge from writing to the config, you must either update the config - manually or allow the bridge to update it for you **before** upgrading to - this release (i.e. run v0.8.6 once with config writing allowed). -* Updated libsignal to v0.80.3. -* Added support for `com.beeper.disappearing_timer` state event, which stores - the disappearing setting of chats and allows changing the setting from Matrix. -* Added support for nicknames in displayname templates. - * Like contact list names, nicknames are not safe to use on multi-user instances. -* Added support for creating Signal groups. -* Fixed certain types of logouts not being detected properly. - -# v0.8.6 (2025-08-16) - -* Deprecated legacy provisioning API. The `/_matrix/provision/v2` endpoints will - be deleted in the next release. -* Bumped minimum Go version to 1.24. -* Updated libsignal to v0.78.2. -* Added support for "delete to me" of chats and messages. -* Added support for latest Signal backup/transfer protocol. - -# v0.8.5 (2025-07-16) - -* Updated libsignal to v0.76.1. - -# v0.8.4 (2025-06-16) - -* Updated libsignal to v0.74.1. -* Updated Docker image to Alpine 3.22. -* Fixed avatars when using direct media. -* Fixed starting chats with non-contact users. -* Fixed Matrix media being rejected if the mime type isn't specified. - -# v0.8.3 (2025-05-16) - -* Updated libsignal to v0.72.1. -* Added initial support for direct media access. - * Note that media is only kept on the Signal servers for 45 days, after which - any direct media links will permanently stop working. -* Added buffer for decrypted events to prevent losing messages if the bridge is - stopped in the middle of event handling. -* Fixed backfilling messages in existing portals after relogining. - -# v0.8.2 (2025-04-16) - -* Updated libsignal to v0.70.0. -* Fixed panics in some cases when the bridge was under heavy load. - -# v0.8.1 (2025-03-16) - -* Added QR refreshing when logging in. -* Updated libsignal to v0.67.4. - -# v0.8.0 (2025-02-16) - -* Bumped minimum Go version to 1.23. -* Added support for history transfer. -* Updated libsignal to v0.66.2. - -# v0.7.5 (2025-01-16) - -* Added support for bridging mp4 gifs in both directions. -* Added support for signaling supported features to clients using the - `com.beeper.room_features` state event. -* Updated Signal websocket authentication method. -* Fixed some cases where websocket would get stuck after a ping timeout. - -# v0.7.4 (2024-12-16) - -* Fixed syncing server-side storage after Signal login. -* Added support for new SSRE2 method of receiving the server-side storage key. -* Updated libsignal to v0.64.1. -* Updated Docker image to Alpine 3.21. - -# v0.7.3 (2024-11-16) - -* Updated libsignal to v0.62.0. - * Note for bridges running in systemd: the new version of libsignal may be - incompatible with the `MemoryDenyWriteExecute=true` option (see [#750]). -* Added basic support for Signal's new file upload protocol. - -[#750]: https://github.com/mautrix/signal/issues/570 - -# v0.7.2 (2024-10-16) - -* Updated to libsignal v0.58.3. -* Fixed spurious decryption error notices for Signal messages when the - websocket reconnects and receives old already-bridged messages. -* Fixed signalmeow not respecting account settings for choosing sender - certificate. -* Fixed bugs in storage service decryption, which could cause issues with - missing contact names among other things. -* Fixed call start notices only working once per direct chat. - -# v0.7.1 (2024-09-16) - -* Updated to libsignal v0.57.1. -* Dropped support for unauthenticated media on Matrix. -* Added support for Matrix->Signal power level bridging - (thanks to [@maltee1] in [#531]). -* Changed voice message conversion to convert to aac instead of m4a, - because Signal iOS doesn't appear to like ffmpeg's m4a files. -* Fixed outgoing sync messages not including disappearing start timestamp, - which would cause native clients to disappear messages at the wrong time. -* Re-added notices about decryption errors. - -[#531]: https://github.com/mautrix/signal/pull/531 - -# v0.7.0 (2024-08-16) - -* Bumped minimum Go version to 1.22. -* Updated to libsignal v0.55.0. -* Rewrote bridge using bridgev2 architecture. - * It is recommended to check the config file after upgrading. If you have - prevented the bridge from writing to the config, you should update it - manually. - * Thanks to [@maltee1] for reimplementing Matrix -> Signal membership - handling in the rewrite. - * If you are still somehow using a pre-v0.5.0 versions, upgrading to v0.6.3 - is required before upgrading to v0.7.0 or higher. - -# v0.6.3 (2024-07-16) - -* Updated to libsignal v0.52.0. -* Fixed bridge losing track of user phone numbers in some cases. -* Fixed edge cases in handling new outgoing DMs started from other devices. -* Added `sync groups` command (thanks to [@maltee1] in [#490]). -* Fixed typo in location bridging example config - (thanks to [@AndrewFerr] in [#516]). - -[#490]: https://github.com/mautrix/signal/pull/490 -[#516]: https://github.com/mautrix/signal/pull/516 -[@AndrewFerr]: https://github.com/mautrix/signal/pull/516 - -# v0.6.2 (2024-06-16) - -* Updated to libsignal v0.51.0. -* Fixed voice messages not being rendered correctly in Element X. -* Fixed contact avatars not being bridged correctly even when enabled in - the bridge config. -* Implemented connector for the upcoming bridgev2 architecture. - -# v0.6.1 (2024-05-16) - -* Added support for bridging location messages from Matrix to Signal - (thanks to [@maltee1] in [#504]). - * Note that Signal doesn't support real location messages, so they're just - bridged as links. The link template is configurable. -* Fixed bridging long text messages from Signal - (thanks to [@maltee1] in [#506]). -* Improved handling of ping timeouts in Signal websocket. - -[#504]: https://github.com/mautrix/signal/pull/504 -[#506]: https://github.com/mautrix/signal/pull/506 - -# v0.6.0 (2024-04-16) - -* Updated to libsignal v0.44.0. -* Refactored bridge to support Signal's new phone number identifier (PNI) - system in order to fix starting new chats and receiving messages from new - users. - * When starting a chat with a user you haven't talked to before, the portal - room will not have a ghost user for the recipient until they accept the - message request. -* Added support for syncing existing groups on login instead of having to wait - for new messages. -* Added notices if decrypting incoming message from Signal fails. -* Added bridging of group metadata from Matrix to Signal - (thanks to [@maltee1] in [#461]). -* Added command to create new Signal group for Matrix room - (thanks to [@maltee1] in [#461] and [#491]). -* Added commands for inviting users to Signal groups by phone number - (thanks to [@maltee1] in [#495]). -* Improved handling of missed Signal group metadata changes - (thanks to [@maltee1] in [#488]). - -[#461]: https://github.com/mautrix/signal/pull/461 -[#488]: https://github.com/mautrix/signal/pull/488 -[#491]: https://github.com/mautrix/signal/pull/491 -[#495]: https://github.com/mautrix/signal/pull/495 - -# v0.5.1 (2024-03-16) - -* Updated to libsignal v0.41.0. -* Fixed sending messages to groups. -* Fixed some cases of ghost user info changing repeatedly on multi-user - instances. -* Fixed migrating SQLite databases from Python version. - -# v0.5.0 (2024-02-16) +# v0.5.0 (unreleased) * Rewrote bridge in Go. - * To migrate the bridge, simply upgrade in-place. The database and config - will be migrated automatically, although some parts of the config aren't - migrated (e.g. log config). If you prevented the bridge from writing to - the config file, you'll have to temporarily allow it or update it yourself. - * The bridge doesn't use signald anymore, all users will have to re-link the - bridge. signald can be deleted after upgrading. - * Primary device mode is no longer supported, signal-cli is recommended if - you don't want to use the official Signal mobile apps. - * Some old features are not yet supported (e.g. group management features). + * The bridge doesn't use signald anymore. + * All users will have to re-link the bridge. + * Primary device mode is no longer supported. * Renamed main branch from `master` to `main`. -* Added support for edits and message formatting. # v0.4.3 (2023-05-17) diff --git a/Dockerfile b/Dockerfile index 1acc3d2..6e6b20d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,17 @@ # -- Build libsignal (with Rust) -- -FROM rust:1-alpine AS rust-builder -RUN apk add --no-cache git make cmake protoc musl-dev g++ clang-dev protobuf-dev +FROM rust:1-alpine as rust-builder +RUN apk add --no-cache git make cmake protoc musl-dev g++ clang-dev WORKDIR /build # Copy all files needed for Rust build, and no Go files COPY pkg/libsignalgo/libsignal/. pkg/libsignalgo/libsignal/. -COPY build-rust.sh . -RUN ./build-rust.sh +ENV RUSTFLAGS="-Ctarget-feature=-crt-static" RUSTC_WRAPPER="" +RUN cd pkg/libsignalgo/libsignal/ && cargo build -p libsignal-ffi --release # -- Build mautrix-signal (with Go) -- -FROM golang:1-alpine3.23 AS go-builder -RUN apk add --no-cache git ca-certificates build-base olm-dev zlib-dev +FROM golang:1-alpine3.19 AS go-builder +RUN apk add --no-cache git ca-certificates build-base olm-dev WORKDIR /build # Copy all files needed for Go build, and no Rust files @@ -19,27 +19,25 @@ COPY *.go go.* *.yaml *.sh ./ COPY pkg/signalmeow/. pkg/signalmeow/. COPY pkg/libsignalgo/* pkg/libsignalgo/ COPY pkg/libsignalgo/resources/. pkg/libsignalgo/resources/. -COPY pkg/msgconv/. pkg/msgconv/. -COPY pkg/signalid/. pkg/signalid/. -COPY pkg/connector/. pkg/connector/. -COPY cmd/. cmd/. +COPY config/. config/. +COPY database/. database/. +COPY msgconv/. msgconv/. COPY .git .git ENV LIBRARY_PATH=. -COPY --from=rust-builder /build/pkg/libsignalgo/libsignal/target/*/libsignal_ffi.a ./ -RUN </dev/null) -X main.Commit=$$(git rev-parse HEAD) -X 'main.BuildTime=`date '+%b %_d %Y, %H:%M:%S'`'" + +clean: + rm -f ./$(LIBRARY_FILENAME) + cd $(RUST_DIR) && cargo clean + rm -f $(GO_BINARY) diff --git a/README.md b/README.md index 82e9624..4e644f5 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@ Some quick links: * Basic usage: [Authentication](https://docs.mau.fi/bridges/go/signal/authentication.html) ### Features & Roadmap -[ROADMAP.md](ROADMAP.md) contains a general overview of what is supported by the bridge. +[ROADMAP.md](https://github.com/mautrix/signal/blob/main/ROADMAP.md) +contains a general overview of what is supported by the bridge. ## Discussion Matrix room: [`#signal:maunium.net`](https://matrix.to/#/#signal:maunium.net) diff --git a/ROADMAP.md b/ROADMAP.md index 228b271..685d1aa 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,48 +1,45 @@ # Features & roadmap * Matrix → Signal - * [x] Message content + * [ ] Message content * [x] Text * [x] Formatting * [x] Mentions - * [x] Polls - * [x] Media + * [ ] Media * [x] Images * [x] Audio files * [x] Voice messages * [x] Files * [x] Gifs - * [x] Locations + * [ ] Locations * [x] Stickers * [x] Message edits * [x] Message reactions * [x] Message redactions - * [x] Group info changes - * [x] Name - * [x] Avatar - * [x] Topic + * [ ] Group info changes + * [ ] Name + * [ ] Avatar + * [ ] Topic * [ ] Membership actions * [ ] Join (accepting invites) - * [x] Invite - * [x] Leave - * [x] Kick/Ban/Unban - * [x] Group permissions + * [ ] Invite + * [ ] Leave + * [ ] Kick/Ban/Unban * [x] Typing notifications - * [x] Read receipts + * [ ] Read receipts (currently partial support, only marks last message) * [x] Delivery receipts (sent after message is bridged) * Signal → Matrix * [ ] Message content * [x] Text * [x] Formatting * [x] Mentions - * [x] Polls * [ ] Media * [x] Images * [x] Voice notes * [x] Files * [x] Gifs * [x] Stickers - * [x] Contacts + * [ ] Contacts * [ ] Payment messages * [x] Message edits * [x] Message reactions @@ -55,20 +52,20 @@ * [x] Name * [x] Avatar * [x] Topic - * [x] Membership actions - * [x] Join - * [x] Invite - * [x] Request join (via invite link, requires a client that supports knocks) - * [x] Leave - * [x] Kick/Ban/Unban - * [x] Group permissions + * [ ] Membership actions + * [ ] Join + * [ ] Invite + * [ ] Request join (via invite link, requires a client that supports knocks) + * [ ] Leave + * [ ] Kick/Ban/Unban + * [ ] Group permissions * [x] Typing notifications * [x] Read receipts * [ ] Delivery receipts (there's no good way to bridge these) * [x] Disappearing messages * Misc - * [x] Automatic portal creation - * [x] After login + * [ ] Automatic portal creation + * [ ] After login * [x] When receiving message * [x] Linking as secondary device * [ ] Registering as primary device diff --git a/build-go.sh b/build-go.sh index 54f9c6a..91123ec 100755 --- a/build-go.sh +++ b/build-go.sh @@ -1,2 +1,4 @@ #!/bin/sh -BINARY_NAME=mautrix-signal go tool maubuild "$@" +export MAUTRIX_VERSION=$(cat go.mod | grep 'maunium.net/go/mautrix ' | awk '{ print $2 }') +export GO_LDFLAGS="-s -w -X main.Tag=$(git describe --exact-match --tags 2>/dev/null) -X main.Commit=$(git rev-parse HEAD) -X 'main.BuildTime=`date '+%b %_d %Y, %H:%M:%S'`' -X 'maunium.net/go/mautrix.GoModVersion=$MAUTRIX_VERSION'" +go build -ldflags "$GO_LDFLAGS" -o mautrix-signal diff --git a/build-rust.sh b/build-rust.sh deleted file mode 100755 index d75efb3..0000000 --- a/build-rust.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -git submodule update --init -cd pkg/libsignalgo/libsignal && RUSTFLAGS="-Ctarget-feature=-crt-static" RUSTC_WRAPPER="" cargo build -p libsignal-ffi --profile=release diff --git a/build.sh b/build.sh index 3ec20a6..b17ad4f 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,4 @@ #!/bin/sh -set -e -./build-rust.sh -cp -f pkg/libsignalgo/libsignal/target/release/libsignal_ffi.a . -LIBRARY_PATH=.:$LIBRARY_PATH ./build-go.sh +git submodule init +git submodule update +make diff --git a/cmd/mautrix-signal/legacyprovision.go b/cmd/mautrix-signal/legacyprovision.go deleted file mode 100644 index c9061ac..0000000 --- a/cmd/mautrix-signal/legacyprovision.go +++ /dev/null @@ -1,147 +0,0 @@ -// mautrix-signal - A Matrix-Signal puppeting bridge. -// Copyright (C) 2024 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is istributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package main - -import ( - "encoding/json" - "fmt" - "net/http" - - "github.com/rs/zerolog" - "maunium.net/go/mautrix" - "maunium.net/go/mautrix/bridgev2" - "maunium.net/go/mautrix/id" -) - -func legacyResolveIdentifierOrStartChat(w http.ResponseWriter, r *http.Request, create bool) { - login := m.Matrix.Provisioning.GetLoginForRequest(w, r) - if login == nil { - return - } - api := login.Client.(bridgev2.IdentifierResolvingNetworkAPI) - phonenum := r.PathValue("phonenum") - resp, err := api.ResolveIdentifier(r.Context(), phonenum, create) - if err != nil { - zerolog.Ctx(r.Context()).Err(err).Msg("Failed to resolve identifier") - JSONResponse(w, http.StatusInternalServerError, &Error{ - Error: fmt.Sprintf("Failed to resolve identifier: %v", err), - ErrCode: "M_UNKNOWN", - }) - return - } else if resp == nil { - JSONResponse(w, http.StatusNotFound, &Error{ - ErrCode: mautrix.MNotFound.ErrCode, - Error: "User not found on Signal", - }) - return - } - status := http.StatusOK - apiResp := &ResolveIdentifierResponse{ - ChatID: ResolveIdentifierResponseChatID{ - UUID: string(resp.UserID), - Number: phonenum, - }, - } - if resp.Ghost != nil { - if resp.UserInfo != nil { - resp.Ghost.UpdateInfo(r.Context(), resp.UserInfo) - } - apiResp.OtherUser = &ResolveIdentifierResponseOtherUser{ - MXID: resp.Ghost.Intent.GetMXID(), - DisplayName: resp.Ghost.Name, - AvatarURL: resp.Ghost.AvatarMXC.ParseOrIgnore(), - } - } - if resp.Chat != nil { - if resp.Chat.Portal == nil { - resp.Chat.Portal, err = m.Bridge.GetPortalByKey(r.Context(), resp.Chat.PortalKey) - if err != nil { - zerolog.Ctx(r.Context()).Err(err).Msg("Failed to get portal") - JSONResponse(w, http.StatusInternalServerError, &mautrix.RespError{ - Err: "Failed to get portal", - ErrCode: "M_UNKNOWN", - }) - return - } - } - if create && resp.Chat.Portal.MXID == "" { - apiResp.JustCreated = true - status = http.StatusCreated - err = resp.Chat.Portal.CreateMatrixRoom(r.Context(), login, resp.Chat.PortalInfo) - if err != nil { - zerolog.Ctx(r.Context()).Err(err).Msg("Failed to create portal room") - JSONResponse(w, http.StatusInternalServerError, &mautrix.RespError{ - Err: "Failed to create portal room", - ErrCode: "M_UNKNOWN", - }) - return - } - } - apiResp.RoomID = resp.Chat.Portal.MXID - } - JSONResponse(w, status, &Response{ - Success: true, - Status: "ok", - ResolveIdentifierResponse: apiResp, - }) -} - -func legacyProvResolveIdentifier(w http.ResponseWriter, r *http.Request) { - legacyResolveIdentifierOrStartChat(w, r, false) -} - -func legacyProvPM(w http.ResponseWriter, r *http.Request) { - legacyResolveIdentifierOrStartChat(w, r, true) -} - -func JSONResponse(w http.ResponseWriter, status int, response any) { - w.Header().Add("Content-Type", "application/json") - w.WriteHeader(status) - _ = json.NewEncoder(w).Encode(response) -} - -type Error struct { - Success bool `json:"success"` - Error string `json:"error"` - ErrCode string `json:"errcode"` -} - -type Response struct { - Success bool `json:"success"` - Status string `json:"status"` - - // For response in ResolveIdentifier - *ResolveIdentifierResponse -} - -type ResolveIdentifierResponse struct { - RoomID id.RoomID `json:"room_id"` - ChatID ResolveIdentifierResponseChatID `json:"chat_id"` - JustCreated bool `json:"just_created"` - OtherUser *ResolveIdentifierResponseOtherUser `json:"other_user,omitempty"` -} - -type ResolveIdentifierResponseChatID struct { - UUID string `json:"uuid"` - Number string `json:"number"` -} - -type ResolveIdentifierResponseOtherUser struct { - MXID id.UserID `json:"mxid"` - DisplayName string `json:"displayname"` - AvatarURL id.ContentURI `json:"avatar_url"` -} diff --git a/cmd/mautrix-signal/main.go b/cmd/mautrix-signal/main.go deleted file mode 100644 index 6440669..0000000 --- a/cmd/mautrix-signal/main.go +++ /dev/null @@ -1,56 +0,0 @@ -// mautrix-signal - A Matrix-Signal puppeting bridge. -// Copyright (C) 2024 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package main - -import ( - "fmt" - - "maunium.net/go/mautrix/bridgev2/matrix/mxmain" - - "go.mau.fi/mautrix-signal/pkg/connector" - "go.mau.fi/mautrix-signal/pkg/signalmeow/web" -) - -// Information to find out exactly which commit the bridge was built from. -// These are filled at build time with the -X linker flag. -var ( - Tag = "unknown" - Commit = "unknown" - BuildTime = "unknown" -) - -var m = mxmain.BridgeMain{ - Name: "mautrix-signal", - URL: "https://github.com/mautrix/signal", - Description: "A Matrix-Signal puppeting bridge.", - Version: "26.04", - SemCalVer: true, - - Connector: &connector.SignalConnector{}, -} - -func main() { - web.UserAgent = fmt.Sprintf("mautrix-signal/%s %s", m.Version, web.BaseUserAgent) - m.PostStart = func() { - if m.Matrix.Provisioning != nil { - m.Matrix.Provisioning.Router.HandleFunc("GET /v2/resolve_identifier/{phonenum}", legacyProvResolveIdentifier) - m.Matrix.Provisioning.Router.HandleFunc("POST /v2/pm/{phonenum}", legacyProvPM) - } - } - m.InitVersion(Tag, Commit, BuildTime) - m.Run() -} diff --git a/commands.go b/commands.go new file mode 100644 index 0000000..e56c00a --- /dev/null +++ b/commands.go @@ -0,0 +1,558 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2023 Scott Weber +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package main + +import ( + "context" + "strings" + + "github.com/google/uuid" + "github.com/skip2/go-qrcode" + "maunium.net/go/mautrix" + "maunium.net/go/mautrix/bridge/commands" + "maunium.net/go/mautrix/event" + "maunium.net/go/mautrix/id" + + "go.mau.fi/mautrix-signal/pkg/signalmeow" +) + +var ( + HelpSectionConnectionManagement = commands.HelpSection{Name: "Connection management", Order: 11} + HelpSectionCreatingPortals = commands.HelpSection{Name: "Creating portals", Order: 15} + HelpSectionPortalManagement = commands.HelpSection{Name: "Portal management", Order: 20} + HelpSectionInvites = commands.HelpSection{Name: "Group invites", Order: 25} + HelpSectionMiscellaneous = commands.HelpSection{Name: "Miscellaneous", Order: 30} +) + +type WrappedCommandEvent struct { + *commands.Event + Bridge *SignalBridge + User *User + Portal *Portal +} + +func (br *SignalBridge) RegisterCommands() { + proc := br.CommandProcessor.(*commands.Processor) + proc.AddHandlers( + cmdPing, + cmdLogin, + cmdSetDeviceName, + cmdPM, + cmdSyncSpace, + cmdDeleteSession, + cmdSetRelay, + cmdUnsetRelay, + cmdDeletePortal, + cmdDeleteAllPortals, + cmdCleanupLostPortals, + ) +} + +func wrapCommand(handler func(*WrappedCommandEvent)) func(*commands.Event) { + return func(ce *commands.Event) { + user := ce.User.(*User) + var portal *Portal + if ce.Portal != nil { + portal = ce.Portal.(*Portal) + } + br := ce.Bridge.Child.(*SignalBridge) + handler(&WrappedCommandEvent{ce, br, user, portal}) + } +} + +var cmdSetRelay = &commands.FullHandler{ + Func: wrapCommand(fnSetRelay), + Name: "set-relay", + Help: commands.HelpMeta{ + Section: HelpSectionPortalManagement, + Description: "Relay messages in this room through your Signal account.", + }, + RequiresPortal: true, + RequiresLogin: true, +} + +func fnSetRelay(ce *WrappedCommandEvent) { + if !ce.Bridge.Config.Bridge.Relay.Enabled { + ce.Reply("Relay mode is not enabled on this instance of the bridge") + } else if ce.Bridge.Config.Bridge.Relay.AdminOnly && !ce.User.Admin { + ce.Reply("Only bridge admins are allowed to enable relay mode on this instance of the bridge") + } else { + ce.Portal.RelayUserID = ce.User.MXID + ce.Portal.Update(context.TODO()) + ce.Reply("Messages from non-logged-in users in this room will now be bridged through your Signal account") + } +} + +var cmdUnsetRelay = &commands.FullHandler{ + Func: wrapCommand(fnUnsetRelay), + Name: "unset-relay", + Help: commands.HelpMeta{ + Section: HelpSectionPortalManagement, + Description: "Stop relaying messages in this room.", + }, + RequiresPortal: true, +} + +func fnUnsetRelay(ce *WrappedCommandEvent) { + if !ce.Bridge.Config.Bridge.Relay.Enabled { + ce.Reply("Relay mode is not enabled on this instance of the bridge") + } else if ce.Bridge.Config.Bridge.Relay.AdminOnly && !ce.User.Admin { + ce.Reply("Only bridge admins are allowed to enable relay mode on this instance of the bridge") + } else { + ce.Portal.RelayUserID = "" + ce.Portal.Update(context.TODO()) + ce.Reply("Messages from non-logged-in users will no longer be bridged in this room") + } +} + +var cmdDeleteSession = &commands.FullHandler{ + Func: wrapCommand(fnDeleteSession), + Name: "delete-session", + Help: commands.HelpMeta{ + Section: HelpSectionConnectionManagement, + Description: "Disconnect from Signal, clearing sessions but keeping other data. Reconnect with `login`", + }, +} + +func fnDeleteSession(ce *WrappedCommandEvent) { + if !ce.User.SignalDevice.IsDeviceLoggedIn() { + ce.Reply("You're not logged in") + return + } + ce.User.SignalDevice.ClearKeysAndDisconnect() + ce.Reply("Disconnected from Signal") +} + +var cmdPing = &commands.FullHandler{ + Func: wrapCommand(fnPing), + Name: "ping", + Help: commands.HelpMeta{ + Section: commands.HelpSectionAuth, + Description: "Check your connection to Signal", + }, +} + +func fnPing(ce *WrappedCommandEvent) { + if ce.User.SignalID == uuid.Nil { + ce.Reply("You're not logged in") + } else if !ce.User.SignalDevice.IsDeviceLoggedIn() { + ce.Reply("You were logged in at some point, but are not anymore") + } else if !ce.User.SignalDevice.Connection.IsConnected() { + ce.Reply("You're logged into Signal, but not connected to the server") + } else { + ce.Reply("You're logged into Signal and probably connected to the server") + } +} + +var cmdSetDeviceName = &commands.FullHandler{ + Func: wrapCommand(fnSetDeviceName), + Name: "set-device-name", + Help: commands.HelpMeta{ + Section: HelpSectionConnectionManagement, + Description: "Set the name of this device in Signal", + Args: "", + }, + RequiresLogin: true, +} + +func fnSetDeviceName(ce *WrappedCommandEvent) { + if len(ce.Args) == 0 { + ce.Reply("**Usage:** `set-device-name `") + return + } + + name := strings.Join(ce.Args, " ") + err := ce.User.SignalDevice.UpdateDeviceName(name) + if err != nil { + ce.Reply("Error setting device name: %v", err) + return + } + ce.Reply("Device name updated") +} + +var cmdPM = &commands.FullHandler{ + Func: wrapCommand(fnPM), + Name: "pm", + Help: commands.HelpMeta{ + Section: HelpSectionCreatingPortals, + Description: "Open a private chat with the given phone number.", + Args: "<_international phone number_>", + }, + RequiresLogin: true, +} + +func fnPM(ce *WrappedCommandEvent) { + if len(ce.Args) == 0 { + ce.Reply("**Usage:** `pm `") + return + } + + user := ce.User + number := strings.Join(ce.Args, "") + contact, err := user.SignalDevice.ContactByE164(number) + if err != nil { + ce.Reply("Error looking up number in local contact list: %v", err) + return + } + if contact == nil { + ce.Reply("The bridge does not have the Signal ID for the number %s", number) + return + } + + portal := user.GetPortalByChatID(contact.UUID.String()) + if portal == nil { + ce.Reply("Error creating portal to %s", number) + ce.Log.Errorln("Error creating portal to", number) + return + } + if portal.MXID != "" { + ce.Reply("You already have a portal to %s at %s", number, portal.MXID) + return + } + if err := portal.CreateMatrixRoom(user, nil); err != nil { + ce.Reply("Error creating Matrix room for portal to %s", number) + ce.Log.Errorln("Error creating Matrix room for portal to %s: %s", number, err) + return + } + ce.Reply("Created portal room with and invited you to it.") +} + +var cmdSyncSpace = &commands.FullHandler{ + Func: wrapCommand(fnSyncSpace), + Name: "sync-space", + Help: commands.HelpMeta{ + Section: HelpSectionMiscellaneous, + Description: "Synchronize your personal filtering space", + }, + RequiresLogin: true, +} + +func fnSyncSpace(ce *WrappedCommandEvent) { + if !ce.Bridge.Config.Bridge.PersonalFilteringSpaces { + ce.Reply("Personal filtering spaces are not enabled on this instance of the bridge") + return + } + ctx := ce.ZLog.WithContext(context.TODO()) + dmKeys, err := ce.Bridge.DB.Portal.FindPrivateChatsNotInSpace(ctx, ce.User.SignalID) + if err != nil { + ce.ZLog.Err(err).Msg("Failed to get private chat keys") + ce.Reply("Failed to get private chat IDs from database") + return + } + count := 0 + allPortals := ce.Bridge.GetAllPortalsWithMXID() + for _, portal := range allPortals { + if portal.IsPrivateChat() { + continue + } + if ce.Bridge.StateStore.IsInRoom(portal.MXID, ce.User.MXID) && portal.addToPersonalSpace(ctx, ce.User) { + count++ + } + } + for _, key := range dmKeys { + portal := ce.Bridge.GetPortalByChatID(key) + portal.addToPersonalSpace(ctx, ce.User) + count++ + } + plural := "s" + if count == 1 { + plural = "" + } + ce.Reply("Added %d room%s to space", count, plural) +} + +var cmdLogin = &commands.FullHandler{ + Func: wrapCommand(fnLogin), + Name: "login", + Help: commands.HelpMeta{ + Section: commands.HelpSectionAuth, + Description: "Link the bridge to your Signal account as a web client.", + }, +} + +func fnLogin(ce *WrappedCommandEvent) { + //if ce.User.Session != nil { + // if ce.User.IsConnected() { + // ce.Reply("You're already logged in") + // } else { + // ce.Reply("You're already logged in. Perhaps you wanted to `reconnect`?") + // } + // return + //} + + var qrEventID id.EventID + var signalID string + var signalUsername string + + // First get the provisioning URL + provChan, err := ce.User.Login() + if err != nil { + ce.Log.Errorln("Failure logging in:", err) + ce.Reply("Failure logging in: %v", err) + return + } + + resp := <-provChan + if resp.Err != nil || resp.State == signalmeow.StateProvisioningError { + ce.Reply("Error getting provisioning URL: %v", resp.Err) + return + } + if resp.State == signalmeow.StateProvisioningURLReceived { + qrEventID = ce.User.sendQR(ce, resp.ProvisioningUrl, qrEventID) + } else { + ce.Reply("Unexpected state: %v", resp.State) + return + } + + // Next, get the results of finishing registration + resp = <-provChan + _, _ = ce.Bot.RedactEvent(ce.RoomID, qrEventID) + if resp.Err != nil || resp.State == signalmeow.StateProvisioningError { + if resp.Err != nil && strings.HasSuffix(resp.Err.Error(), " EOF") { + ce.Reply("Logging in timed out, please try again.") + } else { + ce.Reply("Error finishing registration: %v", resp.Err) + } + return + } + if resp.State == signalmeow.StateProvisioningDataReceived { + signalID = resp.ProvisioningData.AciUuid + signalUsername = resp.ProvisioningData.Number + ce.Reply("Successfully logged in!") + ce.Reply("ACI: %v, Phone Number: %v", resp.ProvisioningData.AciUuid, resp.ProvisioningData.Number) + } else { + ce.Reply("Unexpected state: %v", resp.State) + return + } + + // Finally, get the results of generating and registering prekeys + resp = <-provChan + if resp.Err != nil || resp.State == signalmeow.StateProvisioningError { + ce.Reply("Error with prekeys: %v", resp.Err) + return + } + if resp.State == signalmeow.StateProvisioningPreKeysRegistered { + ce.Reply("Successfully generated, registered and stored prekeys! 🎉") + } else { + ce.Reply("Unexpected state: %v", resp.State) + return + } + + // Update user with SignalID + if signalID != "" { + ce.User.SignalID, err = uuid.Parse(signalID) + if err != nil { + ce.Reply("Problem logging in - SignalID is not a valid UUID") + return + } + ce.User.SignalUsername = signalUsername + } else { + ce.Reply("Problem logging in - No SignalID received") + return + } + err = ce.User.Update(context.TODO()) + if err != nil { + ce.ZLog.Err(err).Msg("Failed to save user to database") + } + + // Connect to Signal + ce.User.Connect() +} + +func (user *User) sendQR(ce *WrappedCommandEvent, code string, prevEvent id.EventID) id.EventID { + url, ok := user.uploadQR(ce, code) + if !ok { + return prevEvent + } + content := event.MessageEventContent{ + MsgType: event.MsgImage, + Body: code, + URL: url.CUString(), + } + if len(prevEvent) != 0 { + content.SetEdit(prevEvent) + } + resp, err := ce.Bot.SendMessageEvent(ce.RoomID, event.EventMessage, &content) + if err != nil { + ce.Log.Errorln("Failed to send QR code to user:", err) + } else if len(prevEvent) == 0 { + prevEvent = resp.EventID + } + return prevEvent +} + +func (user *User) uploadQR(ce *WrappedCommandEvent, code string) (id.ContentURI, bool) { + qrCode, err := qrcode.Encode(code, qrcode.Low, 256) + if err != nil { + ce.Log.Errorln("Failed to encode QR code:", err) + ce.Reply("Failed to encode QR code: %v", err) + return id.ContentURI{}, false + } + + bot := user.bridge.AS.BotClient() + + resp, err := bot.UploadBytes(qrCode, "image/png") + if err != nil { + ce.Log.Errorln("Failed to upload QR code:", err) + ce.Reply("Failed to upload QR code: %v", err) + return id.ContentURI{}, false + } + return resp.ContentURI, true +} + +func canDeletePortal(portal *Portal, userID id.UserID) bool { + if len(portal.MXID) == 0 { + return false + } + + members, err := portal.MainIntent().JoinedMembers(portal.MXID) + if err != nil { + portal.log.Err(err). + Str("user_id", userID.String()). + Msg("Failed to get joined members to check if user can delete portal") + return false + } + for otherUser := range members.Joined { + _, isPuppet := portal.bridge.ParsePuppetMXID(otherUser) + if isPuppet || otherUser == portal.bridge.Bot.UserID || otherUser == userID { + continue + } + user := portal.bridge.GetUserByMXID(otherUser) + if user != nil && user.IsLoggedIn() { + return false + } + } + return true +} + +var cmdDeletePortal = &commands.FullHandler{ + Func: wrapCommand(fnDeletePortal), + Name: "delete-portal", + Help: commands.HelpMeta{ + Section: HelpSectionPortalManagement, + Description: "Delete the current portal. If the portal is used by other people, this is limited to bridge admins.", + }, + RequiresPortal: true, +} + +func fnDeletePortal(ce *WrappedCommandEvent) { + if !ce.User.Admin && !canDeletePortal(ce.Portal, ce.User.MXID) { + ce.Reply("Only bridge admins can delete portals with other Matrix users") + return + } + + ce.Portal.log.Info().Str("user_id", ce.User.MXID.String()).Msg("User requested deletion of portal") + ce.Portal.Delete() + ce.Portal.Cleanup(false) +} + +var cmdDeleteAllPortals = &commands.FullHandler{ + Func: wrapCommand(fnDeleteAllPortals), + Name: "delete-all-portals", + Help: commands.HelpMeta{ + Section: HelpSectionPortalManagement, + Description: "Delete all portals.", + }, +} + +func fnDeleteAllPortals(ce *WrappedCommandEvent) { + portals := ce.Bridge.GetAllPortalsWithMXID() + var portalsToDelete []*Portal + + if ce.User.Admin { + portalsToDelete = portals + } else { + portalsToDelete = portals[:0] + for _, portal := range portals { + if canDeletePortal(portal, ce.User.MXID) { + portalsToDelete = append(portalsToDelete, portal) + } + } + } + if len(portalsToDelete) == 0 { + ce.Reply("Didn't find any portals to delete") + return + } + + leave := func(portal *Portal) { + if len(portal.MXID) > 0 { + _, _ = portal.MainIntent().KickUser(portal.MXID, &mautrix.ReqKickUser{ + Reason: "Deleting portal", + UserID: ce.User.MXID, + }) + } + } + customPuppet := ce.Bridge.GetPuppetByCustomMXID(ce.User.MXID) + if customPuppet != nil && customPuppet.CustomIntent() != nil { + intent := customPuppet.CustomIntent() + leave = func(portal *Portal) { + if len(portal.MXID) > 0 { + _, _ = intent.LeaveRoom(portal.MXID) + _, _ = intent.ForgetRoom(portal.MXID) + } + } + } + ce.Reply("Found %d portals, deleting...", len(portalsToDelete)) + for _, portal := range portalsToDelete { + portal.Delete() + leave(portal) + } + ce.Reply("Finished deleting portal info. Now cleaning up rooms in background.") + + go func() { + for _, portal := range portalsToDelete { + portal.Cleanup(false) + } + ce.Reply("Finished background cleanup of deleted portal rooms.") + }() +} + +var cmdCleanupLostPortals = &commands.FullHandler{ + Func: wrapCommand(fnCleanupLostPortals), + Name: "cleanup-lost-portals", + Help: commands.HelpMeta{ + Section: HelpSectionPortalManagement, + Description: "Clean up portals that were discarded due to the receiver not being logged into the bridge", + }, + RequiresAdmin: true, +} + +func fnCleanupLostPortals(ce *WrappedCommandEvent) { + portals, err := ce.Bridge.DB.LostPortal.GetAll(context.TODO()) + if err != nil { + ce.Reply("Failed to get portals: %v", err) + return + } else if len(portals) == 0 { + ce.Reply("No lost portals found") + return + } + + ce.Reply("Found %d lost portals, deleting...", len(portals)) + for _, portal := range portals { + dmUUID, err := uuid.Parse(portal.ChatID) + intent := ce.Bot + if err == nil { + intent = ce.Bridge.GetPuppetBySignalID(dmUUID).DefaultIntent() + } + ce.Bridge.CleanupRoom(ce.ZLog, intent, portal.MXID, false) + err = portal.Delete(context.TODO()) + if err != nil { + ce.ZLog.Err(err).Msg("Failed to delete lost portal from database after cleanup") + } + } + ce.Reply("Finished cleaning up portals") +} diff --git a/config/bridge.go b/config/bridge.go new file mode 100644 index 0000000..b023852 --- /dev/null +++ b/config/bridge.go @@ -0,0 +1,230 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2022 Tulir Asokan +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package config + +import ( + "errors" + "fmt" + "strings" + "text/template" + "time" + + "maunium.net/go/mautrix/bridge/bridgeconfig" + "maunium.net/go/mautrix/event" + "maunium.net/go/mautrix/id" + + "go.mau.fi/mautrix-signal/pkg/signalmeow/types" +) + +type BridgeConfig struct { + UsernameTemplate string `yaml:"username_template"` + DisplaynameTemplate string `yaml:"displayname_template"` + PrivateChatPortalMeta string `yaml:"private_chat_portal_meta"` + UseContactAvatars bool `yaml:"use_contact_avatars"` + + PortalMessageBuffer int `yaml:"portal_message_buffer"` + + PersonalFilteringSpaces bool `yaml:"personal_filtering_spaces"` + BridgeNotices bool `yaml:"bridge_notices"` + DeliveryReceipts bool `yaml:"delivery_receipts"` + MessageStatusEvents bool `yaml:"message_status_events"` + MessageErrorNotices bool `yaml:"message_error_notices"` + SyncDirectChatList bool `yaml:"sync_direct_chat_list"` + ResendBridgeInfo bool `yaml:"resend_bridge_info"` + CaptionInMessage bool `yaml:"caption_in_message"` + FederateRooms bool `yaml:"federate_rooms"` + + DoublePuppetConfig bridgeconfig.DoublePuppetConfig `yaml:",inline"` + + MessageHandlingTimeout struct { + ErrorAfterStr string `yaml:"error_after"` + DeadlineStr string `yaml:"deadline"` + + ErrorAfter time.Duration `yaml:"-"` + Deadline time.Duration `yaml:"-"` + } `yaml:"message_handling_timeout"` + + CommandPrefix string `yaml:"command_prefix"` + ManagementRoomText bridgeconfig.ManagementRoomTexts `yaml:"management_room_text"` + + Encryption bridgeconfig.EncryptionConfig `yaml:"encryption"` + + Provisioning struct { + Prefix string `yaml:"prefix"` + SharedSecret string `yaml:"shared_secret"` + DebugEndpoints bool `yaml:"debug_endpoints"` + } `yaml:"provisioning"` + + Permissions bridgeconfig.PermissionConfig `yaml:"permissions"` + + Relay RelaybotConfig `yaml:"relay"` + + usernameTemplate *template.Template `yaml:"-"` + displaynameTemplate *template.Template `yaml:"-"` +} + +func (bc *BridgeConfig) GetResendBridgeInfo() bool { + return bc.ResendBridgeInfo +} + +func (bc *BridgeConfig) EnableMessageStatusEvents() bool { + return bc.MessageStatusEvents +} + +func (bc *BridgeConfig) EnableMessageErrorNotices() bool { + return bc.MessageErrorNotices +} + +func boolToInt(val bool) int { + if val { + return 1 + } + return 0 +} + +func (bc *BridgeConfig) Validate() error { + _, hasWildcard := bc.Permissions["*"] + _, hasExampleDomain := bc.Permissions["example.com"] + _, hasExampleUser := bc.Permissions["@admin:example.com"] + exampleLen := boolToInt(hasWildcard) + boolToInt(hasExampleUser) + boolToInt(hasExampleDomain) + if len(bc.Permissions) <= exampleLen { + return errors.New("bridge.permissions not configured") + } + return nil +} + +type umBridgeConfig BridgeConfig + +func (bc *BridgeConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { + err := unmarshal((*umBridgeConfig)(bc)) + if err != nil { + return err + } + + bc.usernameTemplate, err = template.New("username").Parse(bc.UsernameTemplate) + if err != nil { + return err + } else if !strings.Contains(bc.FormatUsername("1234567890"), "1234567890") { + return fmt.Errorf("username template is missing user ID placeholder") + } + bc.displaynameTemplate, err = template.New("displayname").Parse(bc.DisplaynameTemplate) + if err != nil { + return err + } + + return nil +} + +var _ bridgeconfig.BridgeConfig = (*BridgeConfig)(nil) + +func (bc BridgeConfig) GetDoublePuppetConfig() bridgeconfig.DoublePuppetConfig { + return bc.DoublePuppetConfig +} + +func (bc BridgeConfig) GetEncryptionConfig() bridgeconfig.EncryptionConfig { + return bc.Encryption +} + +func (bc BridgeConfig) GetCommandPrefix() string { + return bc.CommandPrefix +} + +func (bc BridgeConfig) GetManagementRoomTexts() bridgeconfig.ManagementRoomTexts { + return bc.ManagementRoomText +} + +func (bc BridgeConfig) FormatUsername(userID string) string { + var buffer strings.Builder + _ = bc.usernameTemplate.Execute(&buffer, userID) + return buffer.String() +} + +type DisplaynameParams struct { + ProfileName string + ContactName string + Username string + PhoneNumber string + UUID string + AboutEmoji string +} + +func (bc BridgeConfig) FormatDisplayname(contact *types.Contact) string { + var buffer strings.Builder + _ = bc.displaynameTemplate.Execute(&buffer, DisplaynameParams{ + ProfileName: contact.ProfileName, + ContactName: contact.ContactName, + //Username: contact.Username, + PhoneNumber: contact.E164, + UUID: contact.UUID.String(), + AboutEmoji: contact.ProfileAboutEmoji, + }) + return buffer.String() +} + +type RelaybotConfig struct { + Enabled bool `yaml:"enabled"` + AdminOnly bool `yaml:"admin_only"` + MessageFormats map[event.MessageType]string `yaml:"message_formats"` + messageTemplates *template.Template `yaml:"-"` +} + +type umRelaybotConfig RelaybotConfig + +func (rc *RelaybotConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { + err := unmarshal((*umRelaybotConfig)(rc)) + if err != nil { + return err + } + + rc.messageTemplates = template.New("messageTemplates") + for key, format := range rc.MessageFormats { + _, err := rc.messageTemplates.New(string(key)).Parse(format) + if err != nil { + return err + } + } + + return nil +} + +type Sender struct { + UserID string + event.MemberEventContent +} + +type formatData struct { + Sender Sender + Message string + Content *event.MessageEventContent +} + +func (rc *RelaybotConfig) FormatMessage(content *event.MessageEventContent, sender id.UserID, member event.MemberEventContent) (string, error) { + if len(member.Displayname) == 0 { + member.Displayname = sender.String() + } + member.Displayname = template.HTMLEscapeString(member.Displayname) + var output strings.Builder + err := rc.messageTemplates.ExecuteTemplate(&output, string(content.MsgType), formatData{ + Sender: Sender{ + UserID: template.HTMLEscapeString(sender.String()), + MemberEventContent: member, + }, + Content: content, + Message: content.FormattedBody, + }) + return output.String(), err +} diff --git a/pkg/signalmeow/store/upgrades/20-fix-backup-chat-columns.go b/config/config.go similarity index 50% rename from pkg/signalmeow/store/upgrades/20-fix-backup-chat-columns.go rename to config/config.go index d409fe6..de62c82 100644 --- a/pkg/signalmeow/store/upgrades/20-fix-backup-chat-columns.go +++ b/config/config.go @@ -1,5 +1,5 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2025 Tulir Asokan +// mautrix-signal - A Matrix-Signal puppeting bridge. +// Copyright (C) 2022 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -14,23 +14,31 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package upgrades +package config import ( - "context" - - "go.mau.fi/util/dbutil" + "maunium.net/go/mautrix/bridge/bridgeconfig" + "maunium.net/go/mautrix/id" ) -func init() { - Table.Register(-1, 20, 13, "Add missing columns for backup chat table", dbutil.TxnModeOn, func(ctx context.Context, db *dbutil.Database) (err error) { - var exists bool - if exists, err = db.ColumnExists(ctx, "signalmeow_backup_chat", "latest_message_id"); err == nil && !exists { - _, err = db.Exec(ctx, ` - ALTER TABLE signalmeow_backup_chat ADD COLUMN latest_message_id BIGINT; - ALTER TABLE signalmeow_backup_chat ADD COLUMN total_message_count INTEGER; - `) - } - return - }) +type Config struct { + *bridgeconfig.BaseConfig `yaml:",inline"` + + Metrics struct { + Enabled bool `yaml:"enabled"` + Listen string `yaml:"listen"` + } `yaml:"metrics"` + + Signal struct { + DeviceName string `yaml:"device_name"` + } `yaml:"signal"` + + Bridge BridgeConfig `yaml:"bridge"` +} + +func (config *Config) CanAutoDoublePuppet(userID id.UserID) bool { + _, homeserver, _ := userID.Parse() + _, hasSecret := config.Bridge.DoublePuppetConfig.SharedSecretMap[homeserver] + + return hasSecret } diff --git a/config/upgrade.go b/config/upgrade.go new file mode 100644 index 0000000..d133705 --- /dev/null +++ b/config/upgrade.go @@ -0,0 +1,157 @@ +// mautrix-signal - A Matrix-Signal puppeting bridge. +// Copyright (C) 2022 Tulir Asokan +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package config + +import ( + "net/url" + "strings" + + up "go.mau.fi/util/configupgrade" + "go.mau.fi/util/random" + "maunium.net/go/mautrix/bridge/bridgeconfig" +) + +func DoUpgrade(helper *up.Helper) { + bridgeconfig.Upgrader.DoUpgrade(helper) + + legacyDB, ok := helper.Get(up.Str, "appservice", "database") + if ok { + if strings.HasPrefix(legacyDB, "postgres") { + parsedDB, err := url.Parse(legacyDB) + if err != nil { + panic(err) + } + q := parsedDB.Query() + if parsedDB.Host == "" && !q.Has("host") { + q.Set("host", "/var/run/postgresql") + } else if !q.Has("sslmode") { + q.Set("sslmode", "disable") + } + parsedDB.RawQuery = q.Encode() + helper.Set(up.Str, parsedDB.String(), "appservice", "database", "uri") + helper.Set(up.Str, "postgres", "appservice", "database", "type") + } else { + dbPath := strings.TrimPrefix(strings.TrimPrefix(legacyDB, "sqlite:"), "///") + helper.Set(up.Str, dbPath, "appservice", "database", "uri") + helper.Set(up.Str, "sqlite3-fk-wal", "appservice", "database", "type") + } + } + if legacyDBMinSize, ok := helper.Get(up.Int, "appservice", "database_opts", "min_size"); ok { + helper.Set(up.Int, legacyDBMinSize, "appservice", "database", "max_idle_conns") + } + if legacyDBMaxSize, ok := helper.Get(up.Int, "appservice", "database_opts", "max_size"); ok { + helper.Set(up.Int, legacyDBMaxSize, "appservice", "database", "max_open_conns") + } + if legacyBotUsername, ok := helper.Get(up.Str, "appservice", "bot_username"); ok { + helper.Set(up.Str, legacyBotUsername, "appservice", "bot", "username") + } + if legacyBotDisplayname, ok := helper.Get(up.Str, "appservice", "bot_displayname"); ok { + helper.Set(up.Str, legacyBotDisplayname, "appservice", "bot", "displayname") + } + if legacyBotAvatar, ok := helper.Get(up.Str, "appservice", "bot_avatar"); ok { + helper.Set(up.Str, legacyBotAvatar, "appservice", "bot", "avatar") + } + + helper.Copy(up.Bool, "metrics", "enabled") + helper.Copy(up.Str, "metrics", "listen") + + helper.Copy(up.Str, "signal", "device_name") + + if usernameTemplate, ok := helper.Get(up.Str, "bridge", "username_template"); ok && strings.Contains(usernameTemplate, "{userid}") { + helper.Set(up.Str, strings.ReplaceAll(usernameTemplate, "{userid}", "{{.}}"), "bridge", "username_template") + } else { + helper.Copy(up.Str, "bridge", "username_template") + } + if displaynameTemplate, ok := helper.Get(up.Str, "bridge", "displayname_template"); ok && strings.Contains(displaynameTemplate, "{displayname}") { + helper.Set(up.Str, strings.ReplaceAll(displaynameTemplate, "{displayname}", `{{or .ProfileName .PhoneNumber "Unknown user"}}`), "bridge", "displayname_template") + } else { + helper.Copy(up.Str, "bridge", "displayname_template") + } + helper.Copy(up.Str, "bridge", "private_chat_portal_meta") + helper.Copy(up.Bool, "bridge", "use_contact_avatars") + helper.Copy(up.Int, "bridge", "portal_message_buffer") + helper.Copy(up.Bool, "bridge", "personal_filtering_spaces") + helper.Copy(up.Bool, "bridge", "bridge_notices") + helper.Copy(up.Bool, "bridge", "delivery_receipts") + helper.Copy(up.Bool, "bridge", "message_status_events") + helper.Copy(up.Bool, "bridge", "message_error_notices") + helper.Copy(up.Bool, "bridge", "sync_direct_chat_list") + helper.Copy(up.Bool, "bridge", "resend_bridge_info") + helper.Copy(up.Bool, "bridge", "caption_in_message") + helper.Copy(up.Bool, "bridge", "federate_rooms") + helper.Copy(up.Map, "bridge", "double_puppet_server_map") + helper.Copy(up.Bool, "bridge", "double_puppet_allow_discovery") + helper.Copy(up.Map, "bridge", "login_shared_secret_map") + helper.Copy(up.Str, "bridge", "command_prefix") + helper.Copy(up.Str, "bridge", "management_room_text", "welcome") + helper.Copy(up.Str, "bridge", "management_room_text", "welcome_connected") + helper.Copy(up.Str, "bridge", "management_room_text", "welcome_unconnected") + helper.Copy(up.Str|up.Null, "bridge", "management_room_text", "additional_help") + helper.Copy(up.Bool, "bridge", "encryption", "allow") + helper.Copy(up.Bool, "bridge", "encryption", "default") + helper.Copy(up.Bool, "bridge", "encryption", "require") + helper.Copy(up.Bool, "bridge", "encryption", "appservice") + helper.Copy(up.Bool, "bridge", "encryption", "allow_key_sharing") + helper.Copy(up.Bool, "bridge", "encryption", "delete_keys", "delete_outbound_on_ack") + helper.Copy(up.Bool, "bridge", "encryption", "delete_keys", "dont_store_outbound") + helper.Copy(up.Bool, "bridge", "encryption", "delete_keys", "ratchet_on_decrypt") + helper.Copy(up.Bool, "bridge", "encryption", "delete_keys", "delete_fully_used_on_decrypt") + helper.Copy(up.Bool, "bridge", "encryption", "delete_keys", "delete_prev_on_new_session") + helper.Copy(up.Bool, "bridge", "encryption", "delete_keys", "delete_on_device_delete") + helper.Copy(up.Bool, "bridge", "encryption", "delete_keys", "periodically_delete_expired") + helper.Copy(up.Bool, "bridge", "encryption", "delete_keys", "delete_outdated_inbound") + helper.Copy(up.Str, "bridge", "encryption", "verification_levels", "receive") + helper.Copy(up.Str, "bridge", "encryption", "verification_levels", "send") + helper.Copy(up.Str, "bridge", "encryption", "verification_levels", "share") + helper.Copy(up.Bool, "bridge", "encryption", "rotation", "enable_custom") + helper.Copy(up.Int, "bridge", "encryption", "rotation", "milliseconds") + helper.Copy(up.Int, "bridge", "encryption", "rotation", "messages") + helper.Copy(up.Bool, "bridge", "encryption", "rotation", "disable_device_change_key_rotation") + + helper.Copy(up.Str, "bridge", "provisioning", "prefix") + if secret, ok := helper.Get(up.Str, "bridge", "provisioning", "shared_secret"); !ok || secret == "generate" { + sharedSecret := random.String(64) + helper.Set(up.Str, sharedSecret, "bridge", "provisioning", "shared_secret") + } else { + helper.Copy(up.Str, "bridge", "provisioning", "shared_secret") + } + helper.Copy(up.Bool, "bridge", "provisioning", "debug_endpoints") + + helper.Copy(up.Map, "bridge", "permissions") + helper.Copy(up.Bool, "bridge", "relay", "enabled") + helper.Copy(up.Bool, "bridge", "relay", "admin_only") + helper.Copy(up.Map, "bridge", "relay", "message_formats") +} + +var SpacedBlocks = [][]string{ + {"homeserver", "software"}, + {"appservice"}, + {"appservice", "hostname"}, + {"appservice", "database"}, + {"appservice", "id"}, + {"appservice", "as_token"}, + {"metrics"}, + {"signal"}, + {"bridge"}, + {"bridge", "personal_filtering_spaces"}, + {"bridge", "command_prefix"}, + {"bridge", "management_room_text"}, + {"bridge", "encryption"}, + {"bridge", "provisioning"}, + {"bridge", "permissions"}, + {"logging"}, +} diff --git a/custompuppet.go b/custompuppet.go new file mode 100644 index 0000000..31cc119 --- /dev/null +++ b/custompuppet.go @@ -0,0 +1,97 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2023 Tulir Asokan +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package main + +import ( + "context" + "fmt" + + "maunium.net/go/mautrix/id" +) + +func (puppet *Puppet) SwitchCustomMXID(accessToken string, mxid id.UserID) error { + puppet.CustomMXID = mxid + puppet.AccessToken = accessToken + err := puppet.Update(context.TODO()) + if err != nil { + return fmt.Errorf("failed to save access token: %w", err) + } + err = puppet.StartCustomMXID(false) + if err != nil { + return err + } + // TODO leave rooms with default puppet + return nil +} + +func (puppet *Puppet) ClearCustomMXID() { + save := puppet.CustomMXID != "" || puppet.AccessToken != "" + puppet.bridge.puppetsLock.Lock() + if puppet.CustomMXID != "" && puppet.bridge.puppetsByCustomMXID[puppet.CustomMXID] == puppet { + delete(puppet.bridge.puppetsByCustomMXID, puppet.CustomMXID) + } + puppet.bridge.puppetsLock.Unlock() + puppet.CustomMXID = "" + puppet.AccessToken = "" + puppet.customIntent = nil + puppet.customUser = nil + if save { + err := puppet.Update(context.TODO()) + if err != nil { + puppet.log.Err(err).Msg("Failed to clear custom MXID") + } + } +} + +func (puppet *Puppet) StartCustomMXID(reloginOnFail bool) error { + newIntent, newAccessToken, err := puppet.bridge.DoublePuppet.Setup(puppet.CustomMXID, puppet.AccessToken, reloginOnFail) + if err != nil { + puppet.ClearCustomMXID() + return err + } + puppet.bridge.puppetsLock.Lock() + puppet.bridge.puppetsByCustomMXID[puppet.CustomMXID] = puppet + puppet.bridge.puppetsLock.Unlock() + if puppet.AccessToken != newAccessToken { + puppet.AccessToken = newAccessToken + err = puppet.Update(context.TODO()) + } + puppet.customIntent = newIntent + puppet.customUser = puppet.bridge.GetUserByMXID(puppet.CustomMXID) + return err +} + +func (user *User) tryAutomaticDoublePuppeting() { + if !user.bridge.Config.CanAutoDoublePuppet(user.MXID) { + return + } + user.log.Debug().Msg("Checking if double puppeting needs to be enabled") + puppet := user.bridge.GetPuppetBySignalID(user.SignalID) + if len(puppet.CustomMXID) > 0 { + user.log.Debug().Msg("User already has double-puppeting enabled") + // Custom puppet already enabled + return + } + puppet.CustomMXID = user.MXID + err := puppet.StartCustomMXID(true) + if err != nil { + user.log.Warn().Err(err).Msg("Failed to login with shared secret") + } else { + // TODO leave rooms with default puppet + user.log.Debug().Msg("Successfully automatically enabled custom puppet") + } +} diff --git a/database/database.go b/database/database.go new file mode 100644 index 0000000..daa365f --- /dev/null +++ b/database/database.go @@ -0,0 +1,53 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2023 Scott Weber, Tulir Asokan +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package database + +import ( + _ "embed" + + _ "github.com/lib/pq" + _ "github.com/mattn/go-sqlite3" + "go.mau.fi/util/dbutil" + + "go.mau.fi/mautrix-signal/database/upgrades" +) + +type Database struct { + *dbutil.Database + + User *UserQuery + Portal *PortalQuery + LostPortal *LostPortalQuery + Puppet *PuppetQuery + Message *MessageQuery + Reaction *ReactionQuery + DisappearingMessage *DisappearingMessageQuery +} + +func New(db *dbutil.Database) *Database { + db.UpgradeTable = upgrades.Table + return &Database{ + Database: db, + User: &UserQuery{dbutil.MakeQueryHelper(db, newUser)}, + Portal: &PortalQuery{dbutil.MakeQueryHelper(db, newPortal)}, + LostPortal: &LostPortalQuery{dbutil.MakeQueryHelper(db, newLostPortal)}, + Puppet: &PuppetQuery{dbutil.MakeQueryHelper(db, newPuppet)}, + Message: &MessageQuery{dbutil.MakeQueryHelper(db, newMessage)}, + Reaction: &ReactionQuery{dbutil.MakeQueryHelper(db, newReaction)}, + DisappearingMessage: &DisappearingMessageQuery{dbutil.MakeQueryHelper(db, newDisappearingMessage)}, + } +} diff --git a/database/disappearingmessage.go b/database/disappearingmessage.go new file mode 100644 index 0000000..b32a8ee --- /dev/null +++ b/database/disappearingmessage.go @@ -0,0 +1,125 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2023 Scott Weber, Tulir Asokan +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package database + +import ( + "context" + "database/sql" + "time" + + "go.mau.fi/util/dbutil" + "maunium.net/go/mautrix/id" +) + +const ( + getUnscheduledDisappearingMessagesForRoomQuery = ` + SELECT room_id, mxid, expiration_seconds, expiration_ts + FROM disappearing_message WHERE expiration_ts IS NULL AND room_id = $1 + ` + getExpiredDisappearingMessagesQuery = ` + SELECT room_id, mxid, expiration_seconds, expiration_ts + FROM disappearing_message WHERE expiration_ts IS NOT NULL AND expiration_ts <= $1 + ` + getNextDisappearingMessageQuery = ` + SELECT room_id, mxid, expiration_seconds, expiration_ts + FROM disappearing_message WHERE expiration_ts IS NOT NULL ORDER BY expiration_ts ASC LIMIT 1 + ` + insertDisappearingMessageQuery = ` + INSERT INTO disappearing_message (room_id, mxid, expiration_seconds, expiration_ts) VALUES ($1, $2, $3, $4) + ` + updateDisappearingMessageQuery = ` + UPDATE disappearing_message SET expiration_ts=$2 WHERE mxid=$1 + ` + deleteDisappearingMessageQuery = ` + DELETE FROM disappearing_message WHERE mxid=$1 + ` +) + +type DisappearingMessageQuery struct { + *dbutil.QueryHelper[*DisappearingMessage] +} + +type DisappearingMessage struct { + qh *dbutil.QueryHelper[*DisappearingMessage] + + RoomID id.RoomID + EventID id.EventID + ExpireIn time.Duration + ExpireAt time.Time +} + +func newDisappearingMessage(qh *dbutil.QueryHelper[*DisappearingMessage]) *DisappearingMessage { + return &DisappearingMessage{qh: qh} +} + +func (dmq *DisappearingMessageQuery) NewWithValues(roomID id.RoomID, eventID id.EventID, expireIn time.Duration, expireAt time.Time) *DisappearingMessage { + return &DisappearingMessage{ + qh: dmq.QueryHelper, + RoomID: roomID, + EventID: eventID, + ExpireIn: expireIn, + ExpireAt: expireAt, + } +} + +func (dmq *DisappearingMessageQuery) GetUnscheduledForRoom(ctx context.Context, roomID id.RoomID) ([]*DisappearingMessage, error) { + return dmq.QueryMany(ctx, getUnscheduledDisappearingMessagesForRoomQuery, roomID) +} + +func (dmq *DisappearingMessageQuery) GetExpiredMessages(ctx context.Context) ([]*DisappearingMessage, error) { + return dmq.QueryMany(ctx, getExpiredDisappearingMessagesQuery, time.Now().Unix()+1) +} + +func (dmq *DisappearingMessageQuery) GetNextScheduledMessage(ctx context.Context) (*DisappearingMessage, error) { + return dmq.QueryOne(ctx, getNextDisappearingMessageQuery) +} + +func (msg *DisappearingMessage) Scan(row dbutil.Scannable) (*DisappearingMessage, error) { + var expireIn int64 + var expireAt sql.NullInt64 + err := row.Scan(&msg.RoomID, &msg.EventID, &expireIn, &expireAt) + if err != nil { + return nil, err + } + msg.ExpireIn = time.Duration(expireIn) * time.Second + if expireAt.Valid { + msg.ExpireAt = time.Unix(expireAt.Int64, 0) + } + return msg, nil +} + +func (msg *DisappearingMessage) sqlVariables() []any { + var expireAt sql.NullInt64 + if !msg.ExpireAt.IsZero() { + expireAt.Valid = true + expireAt.Int64 = msg.ExpireAt.Unix() + } + return []any{msg.RoomID, msg.EventID, int64(msg.ExpireIn.Seconds()), expireAt} +} + +func (msg *DisappearingMessage) Insert(ctx context.Context) error { + return msg.qh.Exec(ctx, insertDisappearingMessageQuery, msg.sqlVariables()...) +} + +func (msg *DisappearingMessage) StartExpirationTimer(ctx context.Context) error { + msg.ExpireAt = time.Now().Add(msg.ExpireIn) + return msg.qh.Exec(ctx, updateDisappearingMessageQuery, msg.EventID, msg.ExpireAt.Unix()) +} + +func (msg *DisappearingMessage) Delete(ctx context.Context) error { + return msg.qh.Exec(ctx, deleteDisappearingMessageQuery, msg.EventID) +} diff --git a/database/lostportal.go b/database/lostportal.go new file mode 100644 index 0000000..29779b8 --- /dev/null +++ b/database/lostportal.go @@ -0,0 +1,58 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2023 Tulir Asokan +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package database + +import ( + "context" + + "go.mau.fi/util/dbutil" + "maunium.net/go/mautrix/id" +) + +const ( + getLostPortalsQuery = `SELECT chat_id, receiver, mxid FROM lost_portals` + deleteLostPortalQuery = `DELETE FROM lost_portals WHERE mxid=$1` +) + +type LostPortalQuery struct { + *dbutil.QueryHelper[*LostPortal] +} + +func (lpq *LostPortalQuery) GetAll(ctx context.Context) ([]*LostPortal, error) { + return lpq.QueryMany(ctx, getLostPortalsQuery) +} + +type LostPortal struct { + qh *dbutil.QueryHelper[*LostPortal] + + ChatID string + Receiver string + MXID id.RoomID +} + +func newLostPortal(qh *dbutil.QueryHelper[*LostPortal]) *LostPortal { + return &LostPortal{qh: qh} +} + +func (l *LostPortal) Scan(row dbutil.Scannable) (*LostPortal, error) { + err := row.Scan(&l.ChatID, &l.Receiver, &l.MXID) + return l, err +} + +func (l *LostPortal) Delete(ctx context.Context) error { + return l.qh.Exec(ctx, deleteLostPortalQuery, l.MXID) +} diff --git a/database/message.go b/database/message.go new file mode 100644 index 0000000..aa51aad --- /dev/null +++ b/database/message.go @@ -0,0 +1,170 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2023 Scott Weber, Tulir Asokan +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package database + +import ( + "context" + "fmt" + "strings" + + "github.com/google/uuid" + "github.com/lib/pq" + "go.mau.fi/util/dbutil" + "maunium.net/go/mautrix/id" +) + +const ( + getMessageByMXIDQuery = ` + SELECT sender, timestamp, part_index, signal_chat_id, signal_receiver, mxid, mx_room FROM message + WHERE mxid=$1 + ` + getMessagePartBySignalIDQuery = ` + SELECT sender, timestamp, part_index, signal_chat_id, signal_receiver, mxid, mx_room FROM message + WHERE sender=$1 AND timestamp=$2 AND part_index=$3 AND signal_receiver=$4 + ` + getLastMessagePartBySignalIDQuery = ` + SELECT sender, timestamp, part_index, signal_chat_id, signal_receiver, mxid, mx_room FROM message + WHERE sender=$1 AND timestamp=$2 AND signal_receiver=$3 + ORDER BY part_index DESC LIMIT 1 + ` + getAllMessagePartsBySignalIDQuery = ` + SELECT sender, timestamp, part_index, signal_chat_id, signal_receiver, mxid, mx_room FROM message + WHERE sender=$1 AND timestamp=$2 AND signal_receiver=$3 + ` + getMessageLastPartBySignalIDWithUnknownReceiverQuery = ` + SELECT sender, timestamp, part_index, signal_chat_id, signal_receiver, mxid, mx_room FROM message + WHERE sender=$1 AND timestamp=$2 AND (signal_receiver=$3 OR signal_receiver='00000000-0000-0000-0000-000000000000') + ORDER BY part_index DESC LIMIT 1 + ` + getManyMessagesBySignalIDQueryPostgres = ` + SELECT sender, timestamp, part_index, signal_chat_id, signal_receiver, mxid, mx_room FROM message + WHERE sender=$1 AND (signal_receiver=$2 OR signal_receiver=$3) AND timestamp=ANY($4) + ORDER BY timestamp DESC, part_index DESC + ` + getManyMessagesBySignalIDQuerySQLite = ` + SELECT sender, timestamp, part_index, signal_chat_id, signal_receiver, mxid, mx_room FROM message + WHERE sender=?1 AND (signal_receiver=?2 OR signal_receiver=?3) AND timestamp IN (?4) + ORDER BY timestamp DESC, part_index DESC + ` + getFirstBeforeQuery = ` + SELECT sender, timestamp, part_index, signal_chat_id, signal_receiver, mxid, mx_room FROM message + WHERE mx_room=$1 AND timestamp <= $2 + ORDER BY timestamp DESC + LIMIT 1 + ` + insertMessageQuery = ` + INSERT INTO message (sender, timestamp, part_index, signal_chat_id, signal_receiver, mxid, mx_room) + VALUES ($1, $2, $3, $4, $5, $6, $7) + ` + deleteMessageQuery = ` + DELETE FROM message + WHERE sender=$1 AND timestamp=$2 AND part_index=$3 AND signal_receiver=$4 + ` + updateMessageTimestampQuery = ` + UPDATE message SET timestamp=$4 WHERE sender=$1 AND timestamp=$2 AND signal_receiver=$3 + ` +) + +type MessageQuery struct { + *dbutil.QueryHelper[*Message] +} + +type Message struct { + qh *dbutil.QueryHelper[*Message] + + Sender uuid.UUID + Timestamp uint64 + PartIndex int + + SignalChatID string + SignalReceiver uuid.UUID + + MXID id.EventID + RoomID id.RoomID +} + +func newMessage(qh *dbutil.QueryHelper[*Message]) *Message { + return &Message{qh: qh} +} + +func (mq *MessageQuery) GetByMXID(ctx context.Context, mxid id.EventID) (*Message, error) { + return mq.QueryOne(ctx, getMessageByMXIDQuery, mxid) +} + +func (mq *MessageQuery) GetBySignalID(ctx context.Context, sender uuid.UUID, timestamp uint64, partIndex int, receiver uuid.UUID) (*Message, error) { + return mq.QueryOne(ctx, getMessagePartBySignalIDQuery, sender, timestamp, partIndex, receiver) +} + +func (mq *MessageQuery) GetLastPartBySignalID(ctx context.Context, sender uuid.UUID, timestamp uint64, receiver uuid.UUID) (*Message, error) { + return mq.QueryOne(ctx, getLastMessagePartBySignalIDQuery, sender, timestamp, receiver) +} + +func (mq *MessageQuery) GetAllPartsBySignalID(ctx context.Context, sender uuid.UUID, timestamp uint64, receiver uuid.UUID) ([]*Message, error) { + return mq.QueryMany(ctx, getAllMessagePartsBySignalIDQuery, sender, timestamp, receiver) +} + +func (mq *MessageQuery) GetLastPartBySignalIDWithUnknownReceiver(ctx context.Context, sender uuid.UUID, timestamp uint64, receiver uuid.UUID) (*Message, error) { + return mq.QueryOne(ctx, getMessageLastPartBySignalIDWithUnknownReceiverQuery, sender, timestamp, receiver) +} + +func (mq *MessageQuery) GetManyBySignalID(ctx context.Context, sender uuid.UUID, timestamps []uint64, receiver uuid.UUID, strictReceiver bool) ([]*Message, error) { + receiver2 := uuid.Nil + if strictReceiver { + receiver2 = receiver + } + if mq.GetDB().Dialect == dbutil.Postgres { + int64Array := make([]int64, len(timestamps)) + for i, timestamp := range timestamps { + int64Array[i] = int64(timestamp) + } + return mq.QueryMany(ctx, getManyMessagesBySignalIDQueryPostgres, sender, receiver, receiver2, pq.Array(int64Array)) + } else { + const varargIndex = 3 + arguments := make([]any, len(timestamps)+varargIndex) + placeholders := make([]string, len(timestamps)) + arguments[0] = sender + arguments[1] = receiver + arguments[2] = receiver2 + for i, timestamp := range timestamps { + arguments[i+varargIndex] = timestamp + placeholders[i] = fmt.Sprintf("?%d", i+varargIndex+1) + } + return mq.QueryMany(ctx, strings.Replace(getManyMessagesBySignalIDQuerySQLite, fmt.Sprintf("?%d", varargIndex+1), strings.Join(placeholders, ", ?"), 1), arguments...) + } +} + +func (msg *Message) Scan(row dbutil.Scannable) (*Message, error) { + return dbutil.ValueOrErr(msg, row.Scan( + &msg.Sender, &msg.Timestamp, &msg.PartIndex, &msg.SignalChatID, &msg.SignalReceiver, &msg.MXID, &msg.RoomID, + )) +} + +func (msg *Message) sqlVariables() []any { + return []any{msg.Sender, msg.Timestamp, msg.PartIndex, msg.SignalChatID, msg.SignalReceiver, msg.MXID, msg.RoomID} +} + +func (msg *Message) Insert(ctx context.Context) error { + return msg.qh.Exec(ctx, insertMessageQuery, msg.sqlVariables()...) +} + +func (msg *Message) Delete(ctx context.Context) error { + return msg.qh.Exec(ctx, deleteMessageQuery, msg.Sender, msg.Timestamp, msg.PartIndex, msg.SignalReceiver) +} + +func (msg *Message) SetTimestamp(ctx context.Context, editTime uint64) error { + return msg.qh.Exec(ctx, updateMessageTimestampQuery, msg.Sender, msg.Timestamp, msg.SignalReceiver, editTime) +} diff --git a/database/portal.go b/database/portal.go new file mode 100644 index 0000000..1068fb3 --- /dev/null +++ b/database/portal.go @@ -0,0 +1,190 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2023 Scott Weber, Tulir Asokan +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package database + +import ( + "context" + "database/sql" + + "github.com/google/uuid" + "go.mau.fi/util/dbutil" + "maunium.net/go/mautrix/id" + + "go.mau.fi/mautrix-signal/pkg/signalmeow/types" +) + +const ( + portalBaseSelect = ` + SELECT chat_id, receiver, mxid, name, topic, avatar_hash, avatar_url, name_set, avatar_set, + revision, encrypted, relay_user_id, expiration_time + FROM portal + ` + getPortalByMXIDQuery = portalBaseSelect + `WHERE mxid=$1` + getPortalByChatIDQuery = portalBaseSelect + `WHERE chat_id=$1 AND receiver=$2` + getPortalsByReceiver = portalBaseSelect + `WHERE receiver=$1` + getAllPortalsWithMXIDQuery = portalBaseSelect + `WHERE mxid IS NOT NULL` + getChatsNotInSpaceQuery = ` + SELECT chat_id FROM portal + LEFT JOIN user_portal ON portal.chat_id=user_portal.portal_chat_id AND portal.receiver=user_portal.portal_receiver + WHERE mxid<>'' AND receiver=$1 AND (user_portal.in_space=false OR user_portal.in_space IS NULL) + ` + insertPortalQuery = ` + INSERT INTO portal ( + chat_id, receiver, mxid, name, topic, avatar_hash, avatar_url, name_set, avatar_set, + revision, encrypted, relay_user_id, expiration_time + ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13) + ` + updatePortalQuery = ` + UPDATE portal SET + mxid=$3, name=$4, topic=$5, avatar_hash=$6, avatar_url=$7, name_set=$8, + avatar_set=$9, revision=$10, encrypted=$11, relay_user_id=$12, + expiration_time=$13 + WHERE chat_id=$1 AND receiver=$2 + ` + deletePortalQuery = `DELETE FROM portal WHERE chat_id=$1 AND receiver=$2` +) + +type PortalQuery struct { + *dbutil.QueryHelper[*Portal] +} + +type PortalKey struct { + ChatID string + Receiver uuid.UUID +} + +func (pk *PortalKey) UserID() uuid.UUID { + parsed, _ := uuid.Parse(pk.ChatID) + return parsed +} + +func (pk *PortalKey) GroupID() types.GroupIdentifier { + if len(pk.ChatID) == 44 { + return types.GroupIdentifier(pk.ChatID) + } + return "" +} + +func NewPortalKey(chatID string, receiver uuid.UUID) PortalKey { + return PortalKey{ + ChatID: chatID, + Receiver: receiver, + } +} + +type Portal struct { + qh *dbutil.QueryHelper[*Portal] + + PortalKey + MXID id.RoomID + Name string + Topic string + AvatarHash string + AvatarURL id.ContentURI + NameSet bool + AvatarSet bool + Revision int + Encrypted bool + RelayUserID id.UserID + ExpirationTime int +} + +func newPortal(qh *dbutil.QueryHelper[*Portal]) *Portal { + return &Portal{qh: qh} +} + +func (pq *PortalQuery) GetByMXID(ctx context.Context, mxid id.RoomID) (*Portal, error) { + return pq.QueryOne(ctx, getPortalByMXIDQuery, mxid) +} + +func (pq *PortalQuery) GetByChatID(ctx context.Context, pk PortalKey) (*Portal, error) { + return pq.QueryOne(ctx, getPortalByChatIDQuery, pk.ChatID, pk.Receiver) +} + +func (pq *PortalQuery) FindPrivateChatsOf(ctx context.Context, receiver uuid.UUID) ([]*Portal, error) { + return pq.QueryMany(ctx, getPortalsByReceiver, receiver) +} + +func (pq *PortalQuery) GetAllWithMXID(ctx context.Context) ([]*Portal, error) { + return pq.QueryMany(ctx, getAllPortalsWithMXIDQuery) +} + +func (pq *PortalQuery) FindPrivateChatsNotInSpace(ctx context.Context, receiver uuid.UUID) ([]PortalKey, error) { + rows, err := pq.GetDB().QueryContext(ctx, getChatsNotInSpaceQuery, receiver) + if err != nil { + return nil, err + } + return dbutil.NewRowIter(rows, func(rows dbutil.Rows) (key PortalKey, err error) { + err = rows.Scan(&key.ChatID) + key.Receiver = receiver + return + }).AsList() +} + +func (p *Portal) Scan(row dbutil.Scannable) (*Portal, error) { + var mxid sql.NullString + err := row.Scan( + &p.ChatID, + &p.Receiver, + &mxid, + &p.Name, + &p.Topic, + &p.AvatarHash, + &p.AvatarURL, + &p.NameSet, + &p.AvatarSet, + &p.Revision, + &p.Encrypted, + &p.RelayUserID, + &p.ExpirationTime, + ) + if err != nil { + return nil, err + } + p.MXID = id.RoomID(mxid.String) + return p, nil +} + +func (p *Portal) sqlVariables() []any { + return []any{ + p.ChatID, + p.Receiver, + dbutil.StrPtr(p.MXID), + p.Name, + p.Topic, + p.AvatarHash, + &p.AvatarURL, + p.NameSet, + p.AvatarSet, + p.Revision, + p.Encrypted, + p.RelayUserID, + p.ExpirationTime, + } +} + +func (p *Portal) Insert(ctx context.Context) error { + return p.qh.Exec(ctx, insertPortalQuery, p.sqlVariables()...) +} + +func (p *Portal) Update(ctx context.Context) error { + return p.qh.Exec(ctx, updatePortalQuery, p.sqlVariables()...) +} + +func (p *Portal) Delete(ctx context.Context) error { + return p.qh.Exec(ctx, deletePortalQuery, p.ChatID, p.Receiver) +} diff --git a/database/puppet.go b/database/puppet.go new file mode 100644 index 0000000..e6e752b --- /dev/null +++ b/database/puppet.go @@ -0,0 +1,147 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2023 Scott Weber, Tulir Asokan +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package database + +import ( + "context" + "database/sql" + + "github.com/google/uuid" + "go.mau.fi/util/dbutil" + "maunium.net/go/mautrix/id" +) + +const ( + puppetBaseSelect = ` + SELECT uuid, number, name, name_quality, avatar_hash, avatar_url, name_set, avatar_set, + contact_info_set, is_registered, custom_mxid, access_token + FROM puppet + ` + getPuppetBySignalIDQuery = puppetBaseSelect + `WHERE uuid=$1` + getPuppetByNumberQuery = puppetBaseSelect + `WHERE number=$1` + getPuppetByCustomMXIDQuery = puppetBaseSelect + `WHERE custom_mxid=$1` + getPuppetsWithCustomMXID = puppetBaseSelect + `WHERE custom_mxid<>''` + updatePuppetQuery = ` + UPDATE puppet SET + number=$2, name=$3, name_quality=$4, avatar_hash=$5, avatar_url=$6, + name_set=$7, avatar_set=$8, contact_info_set=$9, is_registered=$10, + custom_mxid=$11, access_token=$12 + WHERE uuid=$1 + ` + insertPuppetQuery = ` + INSERT INTO puppet ( + uuid, number, name, name_quality, avatar_hash, avatar_url, + name_set, avatar_set, contact_info_set, is_registered, + custom_mxid, access_token + ) + VALUES ( + $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12 + ) + ` +) + +type PuppetQuery struct { + *dbutil.QueryHelper[*Puppet] +} + +type Puppet struct { + qh *dbutil.QueryHelper[*Puppet] + + SignalID uuid.UUID + Number string + Name string + NameQuality int + AvatarHash string + AvatarURL id.ContentURI + NameSet bool + AvatarSet bool + + IsRegistered bool + + CustomMXID id.UserID + AccessToken string + ContactInfoSet bool +} + +func newPuppet(qh *dbutil.QueryHelper[*Puppet]) *Puppet { + return &Puppet{qh: qh} +} + +func (pq *PuppetQuery) GetBySignalID(ctx context.Context, signalID uuid.UUID) (*Puppet, error) { + return pq.QueryOne(ctx, getPuppetBySignalIDQuery, signalID) +} + +func (pq *PuppetQuery) GetByNumber(ctx context.Context, number string) (*Puppet, error) { + return pq.QueryOne(ctx, getPuppetByNumberQuery, number) +} + +func (pq *PuppetQuery) GetByCustomMXID(ctx context.Context, mxid id.UserID) (*Puppet, error) { + return pq.QueryOne(ctx, getPuppetByCustomMXIDQuery, mxid) +} + +func (pq *PuppetQuery) GetAllWithCustomMXID(ctx context.Context) ([]*Puppet, error) { + return pq.QueryMany(ctx, getPuppetsWithCustomMXID) +} + +func (p *Puppet) Scan(row dbutil.Scannable) (*Puppet, error) { + var number, customMXID sql.NullString + err := row.Scan( + &p.SignalID, + &number, + &p.Name, + &p.NameQuality, + &p.AvatarHash, + &p.AvatarURL, + &p.NameSet, + &p.AvatarSet, + &p.ContactInfoSet, + &p.IsRegistered, + &customMXID, + &p.AccessToken, + ) + if err != nil { + return nil, nil + } + p.Number = number.String + p.CustomMXID = id.UserID(customMXID.String) + return p, nil +} + +func (p *Puppet) sqlVariables() []any { + return []any{ + p.SignalID, + dbutil.StrPtr(p.Number), + p.Name, + p.NameQuality, + p.AvatarHash, + &p.AvatarURL, + p.NameSet, + p.AvatarSet, + p.ContactInfoSet, + p.IsRegistered, + dbutil.StrPtr(p.CustomMXID), + p.AccessToken, + } +} + +func (p *Puppet) Insert(ctx context.Context) error { + return p.qh.Exec(ctx, insertPuppetQuery, p.sqlVariables()...) +} + +func (p *Puppet) Update(ctx context.Context) error { + return p.qh.Exec(ctx, updatePuppetQuery, p.sqlVariables()...) +} diff --git a/database/reaction.go b/database/reaction.go new file mode 100644 index 0000000..fc5228e --- /dev/null +++ b/database/reaction.go @@ -0,0 +1,97 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2023 Scott Weber, Tulir Asokan +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package database + +import ( + "context" + + "github.com/google/uuid" + "go.mau.fi/util/dbutil" + "maunium.net/go/mautrix/id" +) + +const ( + getReactionByMXIDQuery = `SELECT msg_author, msg_timestamp, author, emoji, signal_chat_id, signal_receiver, mxid, mx_room FROM reaction WHERE mxid=$1` + getReactionBySignalIDQuery = `SELECT msg_author, msg_timestamp, author, emoji, signal_chat_id, signal_receiver, mxid, mx_room FROM reaction WHERE msg_author=$1 AND msg_timestamp=$2 AND author=$3 AND signal_receiver=$4` + insertReactionQuery = ` + INSERT INTO reaction (msg_author, msg_timestamp, author, emoji, signal_chat_id, signal_receiver, mxid, mx_room) + VALUES ($1, $2, $3, $4, $5, $6, $7, $8) + ` + updateReactionQuery = ` + UPDATE reaction + SET mxid=$1, emoji=$2 + WHERE msg_author=$3 AND msg_timestamp=$4 AND author=$5 AND signal_receiver=$6 + ` + deleteReactionQuery = ` + DELETE FROM reaction WHERE msg_author=$1 AND msg_timestamp=$2 AND author=$3 AND signal_receiver=$4 + ` +) + +type ReactionQuery struct { + *dbutil.QueryHelper[*Reaction] +} + +func newReaction(qh *dbutil.QueryHelper[*Reaction]) *Reaction { + return &Reaction{qh: qh} +} + +type Reaction struct { + qh *dbutil.QueryHelper[*Reaction] + + MsgAuthor uuid.UUID + MsgTimestamp uint64 + Author uuid.UUID + Emoji string + + SignalChatID string + SignalReceiver uuid.UUID + + MXID id.EventID + RoomID id.RoomID +} + +func (rq *ReactionQuery) GetByMXID(ctx context.Context, mxid id.EventID) (*Reaction, error) { + return rq.QueryOne(ctx, getReactionByMXIDQuery, mxid) +} + +func (rq *ReactionQuery) GetBySignalID(ctx context.Context, msgAuthor uuid.UUID, msgTimestamp uint64, author, signalReceiver uuid.UUID) (*Reaction, error) { + return rq.QueryOne(ctx, getReactionBySignalIDQuery, msgAuthor, msgTimestamp, author, signalReceiver) +} + +func (r *Reaction) Scan(row dbutil.Scannable) (*Reaction, error) { + return dbutil.ValueOrErr(r, row.Scan( + &r.MsgAuthor, &r.MsgTimestamp, &r.Author, &r.Emoji, &r.SignalChatID, &r.SignalReceiver, &r.MXID, &r.RoomID, + )) +} + +func (r *Reaction) sqlVariables() []any { + return []any{ + r.MsgAuthor, r.MsgTimestamp, r.Author, r.Emoji, r.SignalChatID, r.SignalReceiver, r.MXID, r.RoomID, + } +} + +func (r *Reaction) Insert(ctx context.Context) error { + return r.qh.Exec(ctx, insertReactionQuery, r.sqlVariables()...) +} + +func (r *Reaction) Update(ctx context.Context) error { + return r.qh.Exec(ctx, updateReactionQuery, r.MXID, r.Emoji, r.MsgAuthor, r.MsgTimestamp, r.Author, r.SignalReceiver) +} + +func (r *Reaction) Delete(ctx context.Context) error { + return r.qh.Exec(ctx, deleteReactionQuery, r.MsgAuthor, r.MsgTimestamp, r.Author, r.SignalReceiver) +} diff --git a/database/upgrades/00-latest.sql b/database/upgrades/00-latest.sql new file mode 100644 index 0000000..580eab6 --- /dev/null +++ b/database/upgrades/00-latest.sql @@ -0,0 +1,112 @@ +-- v0 -> v18 (compatible with v17+): Latest revision + +CREATE TABLE portal ( + chat_id TEXT NOT NULL, + receiver uuid NOT NULL, + mxid TEXT, + name TEXT NOT NULL, + topic TEXT NOT NULL, + encrypted BOOLEAN NOT NULL DEFAULT false, + avatar_hash TEXT NOT NULL, + avatar_url TEXT NOT NULL, + name_set BOOLEAN NOT NULL DEFAULT false, + avatar_set BOOLEAN NOT NULL DEFAULT false, + revision INTEGER NOT NULL DEFAULT 0, + + expiration_time BIGINT NOT NULL, + relay_user_id TEXT NOT NULL, + + PRIMARY KEY (chat_id, receiver), + CONSTRAINT portal_mxid_unique UNIQUE(mxid) +); + +CREATE TABLE puppet ( + uuid uuid PRIMARY KEY, + number TEXT UNIQUE, + name TEXT NOT NULL, + name_quality INTEGER NOT NULL, + avatar_hash TEXT NOT NULL, + avatar_url TEXT NOT NULL, + name_set BOOLEAN NOT NULL DEFAULT false, + avatar_set BOOLEAN NOT NULL DEFAULT false, + + is_registered BOOLEAN NOT NULL DEFAULT false, + contact_info_set BOOLEAN NOT NULL DEFAULT false, + + custom_mxid TEXT, + access_token TEXT NOT NULL, + + CONSTRAINT puppet_custom_mxid_unique UNIQUE(custom_mxid) +); + +CREATE TABLE "user" ( + mxid TEXT PRIMARY KEY, + uuid uuid, + phone TEXT, + + management_room TEXT, + space_room TEXT, + + CONSTRAINT user_uuid_unique UNIQUE(uuid) +); + +CREATE TABLE user_portal ( + user_mxid TEXT, + portal_chat_id TEXT, + portal_receiver uuid, + last_read_ts BIGINT NOT NULL DEFAULT 0, + in_space BOOLEAN NOT NULL DEFAULT false, + + PRIMARY KEY (user_mxid, portal_chat_id, portal_receiver), + CONSTRAINT user_portal_user_fkey FOREIGN KEY (user_mxid) + REFERENCES "user"(mxid) ON UPDATE CASCADE ON DELETE CASCADE, + CONSTRAINT user_portal_portal_fkey FOREIGN KEY (portal_chat_id, portal_receiver) + REFERENCES portal(chat_id, receiver) ON UPDATE CASCADE ON DELETE CASCADE +); + +CREATE TABLE message ( + sender uuid NOT NULL, + timestamp BIGINT NOT NULL, + part_index INTEGER NOT NULL, + + signal_chat_id TEXT NOT NULL, + signal_receiver uuid NOT NULL, + + mxid TEXT NOT NULL, + mx_room TEXT NOT NULL, + + PRIMARY KEY (sender, timestamp, part_index, signal_receiver), + CONSTRAINT message_portal_fkey FOREIGN KEY (signal_chat_id, signal_receiver) + REFERENCES portal(chat_id, receiver) ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (sender) REFERENCES puppet(uuid) ON DELETE CASCADE, + CONSTRAINT message_mxid_unique UNIQUE (mxid) +); + +CREATE TABLE reaction ( + msg_author uuid NOT NULL, + msg_timestamp BIGINT NOT NULL, + -- part_index is not used in reactions, but is required for the foreign key. + _part_index INTEGER NOT NULL DEFAULT 0, + + author uuid NOT NULL, + emoji TEXT NOT NULL, + + signal_chat_id TEXT NOT NULL, + signal_receiver uuid NOT NULL, + + mxid TEXT NOT NULL, + mx_room TEXT NOT NULL, + + PRIMARY KEY (msg_author, msg_timestamp, author, signal_receiver), + CONSTRAINT reaction_message_fkey FOREIGN KEY (msg_author, msg_timestamp, _part_index, signal_receiver) + REFERENCES message (sender, timestamp, part_index, signal_receiver) ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (author) REFERENCES puppet(uuid) ON DELETE CASCADE, + CONSTRAINT reaction_mxid_unique UNIQUE (mxid) +); + +CREATE TABLE disappearing_message ( + mxid TEXT NOT NULL PRIMARY KEY, + room_id TEXT NOT NULL, + expiration_seconds BIGINT NOT NULL, + expiration_ts BIGINT +); diff --git a/database/upgrades/13-upgrade-mx-state-store.sql b/database/upgrades/13-upgrade-mx-state-store.sql new file mode 100644 index 0000000..ec1b6c2 --- /dev/null +++ b/database/upgrades/13-upgrade-mx-state-store.sql @@ -0,0 +1,18 @@ +-- v13: Switch mx_room_state from Python to Go format +ALTER TABLE mx_room_state DROP COLUMN is_encrypted; +ALTER TABLE mx_room_state DROP COLUMN has_full_member_list; + +-- only: postgres for next 2 lines +ALTER TABLE mx_room_state ALTER COLUMN power_levels TYPE jsonb USING power_levels::jsonb; +ALTER TABLE mx_room_state ALTER COLUMN encryption TYPE jsonb USING encryption::jsonb; + +ALTER TABLE "user" ADD COLUMN management_room TEXT; + +UPDATE mx_user_profile SET displayname='' WHERE displayname IS NULL; +UPDATE mx_user_profile SET avatar_url='' WHERE avatar_url IS NULL; + +CREATE TABLE mx_registrations ( + user_id TEXT PRIMARY KEY +); + +UPDATE mx_version SET version=5; diff --git a/database/upgrades/14-remove-notice-room.sql b/database/upgrades/14-remove-notice-room.sql new file mode 100644 index 0000000..9ad0692 --- /dev/null +++ b/database/upgrades/14-remove-notice-room.sql @@ -0,0 +1,3 @@ +-- v14: Remove redundant notice_room column from users +UPDATE "user" SET management_room = COALESCE(management_room, notice_room); +ALTER TABLE "user" DROP COLUMN notice_room; diff --git a/database/upgrades/15-remove-unused-puppet-columns.sql b/database/upgrades/15-remove-unused-puppet-columns.sql new file mode 100644 index 0000000..925c3a8 --- /dev/null +++ b/database/upgrades/15-remove-unused-puppet-columns.sql @@ -0,0 +1,3 @@ +-- v15: Remove unused columns in puppet table +ALTER TABLE puppet DROP COLUMN next_batch; +ALTER TABLE puppet DROP COLUMN base_url; diff --git a/database/upgrades/16-refactor-postgres.sql b/database/upgrades/16-refactor-postgres.sql new file mode 100644 index 0000000..db2fee6 --- /dev/null +++ b/database/upgrades/16-refactor-postgres.sql @@ -0,0 +1,109 @@ +-- v16: Refactor types (Postgres) +-- only: postgres + +DROP TABLE IF EXISTS user_portal; + +-- Drop constraints so we can fix timestamps. +ALTER TABLE reaction DROP CONSTRAINT reaction_message_fkey; +ALTER TABLE message DROP CONSTRAINT message_pkey; + +-- Add part index to message and fix the hacky timestamps +ALTER TABLE message ADD COLUMN part_index INTEGER; +UPDATE message + SET timestamp=CASE WHEN timestamp > 1500000000000000 THEN timestamp / 1000 ELSE timestamp END, + part_index=CASE WHEN timestamp > 1500000000000000 THEN timestamp % 1000 ELSE 0 END; +-- If the bridge users have reacted to message parts, forget about those, not worth trying to deal with potential conflicts. +DELETE FROM reaction WHERE msg_timestamp > 1500000000000000; +ALTER TABLE message ALTER COLUMN part_index SET NOT NULL; +ALTER TABLE reaction ADD COLUMN _part_index INTEGER NOT NULL DEFAULT 0; + +-- Re-add the dropped constraints (but with part index and no chat) +ALTER TABLE message ADD PRIMARY KEY (sender, timestamp, part_index, signal_receiver); +ALTER TABLE message DROP CONSTRAINT IF EXISTS message_signal_chat_id_signal_receiver_fkey; +ALTER TABLE message DROP CONSTRAINT IF EXISTS message_signal_chat_id_fkey; +ALTER TABLE message ADD CONSTRAINT message_portal_fkey + FOREIGN KEY (signal_chat_id, signal_receiver) + REFERENCES portal (chat_id, receiver) + ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE reaction ADD CONSTRAINT reaction_message_fkey FOREIGN KEY (msg_author, msg_timestamp, _part_index, signal_receiver) + REFERENCES message (sender, timestamp, part_index, signal_receiver) ON DELETE CASCADE ON UPDATE CASCADE; +-- Also update the reaction primary key +ALTER TABLE reaction DROP CONSTRAINT reaction_pkey; +ALTER TABLE reaction ADD PRIMARY KEY (author, msg_author, msg_timestamp, signal_receiver); + +-- Change unique constraint from (mxid, mx_room) to just mxid. +ALTER TABLE message DROP CONSTRAINT message_mxid_mx_room_key; +ALTER TABLE message ADD CONSTRAINT message_mxid_unique UNIQUE (mxid); +ALTER TABLE reaction DROP CONSTRAINT reaction_mxid_mx_room_key; +ALTER TABLE reaction ADD CONSTRAINT reaction_mxid_unique UNIQUE (mxid); + +CREATE TABLE lost_portals ( + mxid TEXT PRIMARY KEY, + chat_id TEXT, + receiver TEXT +); +INSERT INTO lost_portals SELECT mxid, chat_id, receiver FROM portal WHERE mxid<>''; + +-- Make mxid column unique (requires using nulls for missing values) +UPDATE portal SET mxid=NULL WHERE mxid=''; +ALTER TABLE portal ADD CONSTRAINT portal_mxid_unique UNIQUE(mxid); +-- Delete any portals that aren't associated with logged-in users. +DELETE FROM portal WHERE receiver<>'' AND receiver NOT IN (SELECT username FROM "user" WHERE uuid IS NOT NULL); +-- Change receiver to uuid instead of phone number, also add nil uuid for groups. +UPDATE portal SET receiver=(SELECT uuid FROM "user" WHERE username=receiver LIMIT 1) WHERE receiver<>''; +UPDATE portal SET receiver='00000000-0000-0000-0000-000000000000' WHERE receiver=''; +-- Drop the foreign keys again to allow changing types (the ON UPDATE CASCADEs are needed for the above step) +ALTER TABLE message DROP CONSTRAINT message_portal_fkey; +ALTER TABLE reaction DROP CONSTRAINT reaction_message_fkey; +ALTER TABLE portal ALTER COLUMN receiver TYPE uuid USING receiver::uuid; +ALTER TABLE message ALTER COLUMN signal_receiver TYPE uuid USING signal_receiver::uuid; +ALTER TABLE reaction ALTER COLUMN signal_receiver TYPE uuid USING signal_receiver::uuid; +-- Re-add the dropped constraints again +ALTER TABLE message ADD CONSTRAINT message_portal_fkey + FOREIGN KEY (signal_chat_id, signal_receiver) + REFERENCES portal (chat_id, receiver) + ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE reaction ADD CONSTRAINT reaction_message_fkey FOREIGN KEY (msg_author, msg_timestamp, _part_index, signal_receiver) + REFERENCES message (sender, timestamp, part_index, signal_receiver) ON DELETE CASCADE ON UPDATE CASCADE; +-- Delete group v1 portal entries +DELETE FROM portal WHERE chat_id NOT LIKE '________-____-____-____-____________' AND LENGTH(chat_id) <> 44; +DELETE FROM lost_portals WHERE mxid IN (SELECT mxid FROM portal WHERE mxid<>''); + +-- Remove unnecessary nullables in portal +UPDATE portal SET name='' WHERE name IS NULL; +UPDATE portal SET topic='' WHERE topic IS NULL; +UPDATE portal SET avatar_hash='' WHERE avatar_hash IS NULL; +UPDATE portal SET avatar_url='' WHERE avatar_url IS NULL; +UPDATE portal SET expiration_time=0 WHERE expiration_time IS NULL; +UPDATE portal SET relay_user_id='' WHERE relay_user_id IS NULL; +ALTER TABLE portal ALTER COLUMN name SET NOT NULL; +ALTER TABLE portal ALTER COLUMN topic SET NOT NULL; +ALTER TABLE portal ALTER COLUMN avatar_hash SET NOT NULL; +ALTER TABLE portal ALTER COLUMN avatar_url SET NOT NULL; +ALTER TABLE portal ALTER COLUMN expiration_time SET NOT NULL; +ALTER TABLE portal ALTER COLUMN relay_user_id SET NOT NULL; + +-- Add unique constraint to custom_mxid +UPDATE puppet SET custom_mxid=NULL WHERE custom_mxid=''; +ALTER TABLE puppet ADD CONSTRAINT puppet_custom_mxid_unique UNIQUE(custom_mxid); +-- Remove unnecessary nullables in puppet +UPDATE puppet SET name='' WHERE name IS NULL; +UPDATE puppet SET avatar_hash='' WHERE avatar_hash IS NULL; +UPDATE puppet SET avatar_url='' WHERE avatar_url IS NULL; +UPDATE puppet SET access_token='' WHERE access_token IS NULL; +ALTER TABLE puppet ALTER COLUMN name SET NOT NULL; +ALTER TABLE puppet ALTER COLUMN avatar_hash SET NOT NULL; +ALTER TABLE puppet ALTER COLUMN avatar_url SET NOT NULL; +ALTER TABLE puppet ALTER COLUMN access_token SET NOT NULL; +ALTER TABLE puppet ALTER COLUMN name_quality DROP DEFAULT; + +ALTER TABLE "user" ADD CONSTRAINT user_uuid_unique UNIQUE(uuid); +ALTER TABLE "user" RENAME COLUMN username TO phone; + +-- Drop room_id from disappearing message primary key +ALTER TABLE disappearing_message DROP CONSTRAINT disappearing_message_pkey; +ALTER TABLE disappearing_message ADD PRIMARY KEY (mxid); +-- Remove unnecessary nullables in disappearing_message +ALTER TABLE disappearing_message ALTER COLUMN room_id SET NOT NULL; +UPDATE disappearing_message SET expiration_seconds=0 WHERE expiration_seconds IS NULL; +ALTER TABLE disappearing_message ALTER COLUMN expiration_seconds SET NOT NULL; diff --git a/database/upgrades/17-refactor-sqlite.sql b/database/upgrades/17-refactor-sqlite.sql new file mode 100644 index 0000000..2d1a32f --- /dev/null +++ b/database/upgrades/17-refactor-sqlite.sql @@ -0,0 +1,190 @@ +-- v17: Refactor types (SQLite) +-- transaction: off +-- only: sqlite + +-- This is separate from v16 so that postgres can run with transaction: on +-- (split upgrades by dialect don't currently allow disabling transaction in only one dialect) + +DROP TABLE IF EXISTS user_portal; + +PRAGMA foreign_keys = OFF; +BEGIN; + +CREATE TABLE message_new ( + sender uuid NOT NULL, + timestamp BIGINT NOT NULL, + part_index INTEGER NOT NULL, + + signal_chat_id TEXT NOT NULL, + signal_receiver TEXT NOT NULL, + + mxid TEXT NOT NULL, + mx_room TEXT NOT NULL, + + PRIMARY KEY (sender, timestamp, part_index, signal_receiver), + CONSTRAINT message_portal_fkey FOREIGN KEY (signal_chat_id, signal_receiver) REFERENCES portal(chat_id, receiver) ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (sender) REFERENCES puppet(uuid) ON DELETE CASCADE, + CONSTRAINT message_mxid_unique UNIQUE (mxid) +); + +CREATE TABLE reaction_new ( + msg_author uuid NOT NULL, + msg_timestamp BIGINT NOT NULL, + -- part_index is not used in reactions, but is required for the foreign key. + _part_index INTEGER NOT NULL DEFAULT 0, + + author uuid NOT NULL, + emoji TEXT NOT NULL, + + signal_chat_id TEXT NOT NULL, + signal_receiver TEXT NOT NULL, + + mxid TEXT NOT NULL, + mx_room TEXT NOT NULL, + + PRIMARY KEY (msg_author, msg_timestamp, author, signal_receiver), + CONSTRAINT reaction_message_fkey FOREIGN KEY (msg_author, msg_timestamp, _part_index, signal_receiver) + REFERENCES message (sender, timestamp, part_index, signal_receiver) ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (author) REFERENCES puppet(uuid) ON DELETE CASCADE, + CONSTRAINT reaction_mxid_unique UNIQUE (mxid) +); + + +INSERT INTO message_new +SELECT sender, + CASE WHEN timestamp > 1500000000000000 THEN timestamp / 1000 ELSE timestamp END, + CASE WHEN timestamp > 1500000000000000 THEN timestamp % 1000 ELSE 0 END, + COALESCE(signal_chat_id, ''), + COALESCE(signal_receiver, ''), + mxid, + mx_room +FROM message; + +INSERT INTO reaction_new +SELECT msg_author, + msg_timestamp, + 0, -- _part_index + author, + emoji, + COALESCE(signal_chat_id, ''), + COALESCE(signal_receiver, ''), + mxid, + mx_room +FROM reaction +WHERE msg_timestamp<1500000000000000; + +DROP TABLE message; +DROP TABLE reaction; +ALTER TABLE message_new RENAME TO message; +ALTER TABLE reaction_new RENAME TO reaction; + +PRAGMA foreign_key_check; +COMMIT; + +PRAGMA foreign_keys = ON; + +BEGIN; +CREATE TABLE lost_portals ( + mxid TEXT PRIMARY KEY, + chat_id TEXT, + receiver TEXT +); +INSERT INTO lost_portals SELECT mxid, chat_id, receiver FROM portal WHERE mxid<>''; +DELETE FROM portal WHERE receiver<>'' AND receiver NOT IN (SELECT username FROM "user" WHERE uuid<>''); +UPDATE portal SET receiver=(SELECT uuid FROM "user" WHERE username=receiver LIMIT 1) WHERE receiver<>''; +UPDATE portal SET receiver='00000000-0000-0000-0000-000000000000' WHERE receiver=''; +DELETE FROM portal WHERE chat_id NOT LIKE '________-____-____-____-____________' AND LENGTH(chat_id) <> 44; +DELETE FROM lost_portals WHERE mxid IN (SELECT mxid FROM portal WHERE mxid<>''); +COMMIT; + +PRAGMA foreign_keys = OFF; + +BEGIN; + +CREATE TABLE portal_new ( + chat_id TEXT NOT NULL, + receiver uuid NOT NULL, + mxid TEXT, + name TEXT NOT NULL, + topic TEXT NOT NULL, + encrypted BOOLEAN NOT NULL DEFAULT false, + avatar_hash TEXT NOT NULL, + avatar_url TEXT NOT NULL, + name_set BOOLEAN NOT NULL DEFAULT false, + avatar_set BOOLEAN NOT NULL DEFAULT false, + revision INTEGER NOT NULL DEFAULT 0, + + expiration_time BIGINT NOT NULL, + relay_user_id TEXT NOT NULL, + + PRIMARY KEY (chat_id, receiver), + CONSTRAINT portal_mxid_unique UNIQUE(mxid) +); + +INSERT INTO portal_new + SELECT chat_id, receiver, CASE WHEN mxid='' THEN NULL ELSE mxid END, + COALESCE(name, ''), COALESCE(topic, ''), encrypted, COALESCE(avatar_hash, ''), COALESCE(avatar_url, ''), + name_set, avatar_set, revision, COALESCE(expiration_time, 0), COALESCE(relay_user_id, '') + FROM portal; +DROP TABLE portal; +ALTER TABLE portal_new RENAME TO portal; + +CREATE TABLE puppet_new ( + uuid uuid PRIMARY KEY, + number TEXT UNIQUE, + name TEXT NOT NULL, + name_quality INTEGER NOT NULL, + avatar_hash TEXT NOT NULL, + avatar_url TEXT NOT NULL, + name_set BOOLEAN NOT NULL DEFAULT false, + avatar_set BOOLEAN NOT NULL DEFAULT false, + + is_registered BOOLEAN NOT NULL DEFAULT false, + contact_info_set BOOLEAN NOT NULL DEFAULT false, + + custom_mxid TEXT, + access_token TEXT NOT NULL, + + CONSTRAINT puppet_custom_mxid_unique UNIQUE(custom_mxid) +); + +INSERT INTO puppet_new + SELECT uuid, number, COALESCE(name, ''), COALESCE(name_quality, 0), COALESCE(avatar_hash, ''), + COALESCE(avatar_url, ''), name_set, avatar_set, is_registered, contact_info_set, + CASE WHEN custom_mxid='' THEN NULL ELSE custom_mxid END, COALESCE(access_token, '') + FROM puppet; +DROP TABLE puppet; +ALTER TABLE puppet_new RENAME TO puppet; + +CREATE TABLE user_new ( + mxid TEXT PRIMARY KEY, + uuid uuid, + phone TEXT, + + management_room TEXT, + + CONSTRAINT user_uuid_unique UNIQUE(uuid) +); + +INSERT INTO user_new + SELECT mxid, uuid, username, management_room + FROM user; +DROP TABLE user; +ALTER TABLE user_new RENAME TO user; + +CREATE TABLE disappearing_message_new ( + mxid TEXT NOT NULL PRIMARY KEY, + room_id TEXT NOT NULL, + expiration_seconds BIGINT NOT NULL, + expiration_ts BIGINT +); + +INSERT INTO disappearing_message_new + SELECT mxid, room_id, COALESCE(expiration_seconds, 0), expiration_ts + FROM disappearing_message; +DROP TABLE disappearing_message; +ALTER TABLE disappearing_message_new RENAME TO disappearing_message; + +PRAGMA foreign_key_check; +COMMIT; +PRAGMA foreign_keys = ON; diff --git a/database/upgrades/18-spaces.sql b/database/upgrades/18-spaces.sql new file mode 100644 index 0000000..24248ba --- /dev/null +++ b/database/upgrades/18-spaces.sql @@ -0,0 +1,17 @@ +-- v18 (compatible with v17+): Add columns for personal filtering space info +ALTER TABLE "user" ADD COLUMN space_room TEXT; + +DROP TABLE IF EXISTS user_portal; +CREATE TABLE user_portal ( + user_mxid TEXT, + portal_chat_id TEXT, + portal_receiver uuid, + last_read_ts BIGINT NOT NULL DEFAULT 0, + in_space BOOLEAN NOT NULL DEFAULT false, + + PRIMARY KEY (user_mxid, portal_chat_id, portal_receiver), + CONSTRAINT user_portal_user_fkey FOREIGN KEY (user_mxid) + REFERENCES "user"(mxid) ON UPDATE CASCADE ON DELETE CASCADE, + CONSTRAINT user_portal_portal_fkey FOREIGN KEY (portal_chat_id, portal_receiver) + REFERENCES portal(chat_id, receiver) ON UPDATE CASCADE ON DELETE CASCADE +); diff --git a/pkg/connector/dbmeta.go b/database/upgrades/upgrades.go similarity index 56% rename from pkg/connector/dbmeta.go rename to database/upgrades/upgrades.go index d8f644e..c99efe8 100644 --- a/pkg/connector/dbmeta.go +++ b/database/upgrades/upgrades.go @@ -1,5 +1,5 @@ // mautrix-signal - A Matrix-Signal puppeting bridge. -// Copyright (C) 2024 Tulir Asokan +// Copyright (C) 2023 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -14,28 +14,26 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package connector +package upgrades import ( - "maunium.net/go/mautrix/bridgev2/database" + "embed" + "errors" - "go.mau.fi/mautrix-signal/pkg/signalid" + "go.mau.fi/util/dbutil" ) -func (s *SignalConnector) GetDBMetaTypes() database.MetaTypes { - return database.MetaTypes{ - Portal: func() any { - return &signalid.PortalMetadata{} - }, - Ghost: func() any { - return &signalid.GhostMetadata{} - }, - Message: func() any { - return &signalid.MessageMetadata{} - }, - Reaction: nil, - UserLogin: func() any { - return &signalid.UserLoginMetadata{} - }, - } +var Table dbutil.UpgradeTable + +//go:embed *.sql +var rawUpgrades embed.FS + +func init() { + Table.Register(-1, 12, 0, "Unsupported version", false, func(tx dbutil.Execable, database *dbutil.Database) error { + return errors.New("please upgrade to mautrix-signal v0.4.3 before upgrading to a newer version") + }) + Table.Register(1, 13, 0, "Jump to version 13", false, func(tx dbutil.Execable, database *dbutil.Database) error { + return nil + }) + Table.RegisterFS(rawUpgrades) } diff --git a/database/user.go b/database/user.go new file mode 100644 index 0000000..b0340f0 --- /dev/null +++ b/database/user.go @@ -0,0 +1,116 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2023 Scott Weber, Tulir Asokan +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package database + +import ( + "context" + "database/sql" + "sync" + "time" + + "github.com/google/uuid" + "go.mau.fi/util/dbutil" + "maunium.net/go/mautrix/id" +) + +const ( + getUserByMXIDQuery = `SELECT mxid, phone, uuid, management_room, space_room FROM "user" WHERE mxid=$1` + getUserByPhoneQuery = `SELECT mxid, phone, uuid, management_room, space_room FROM "user" WHERE phone=$1` + getUserByUUIDQuery = `SELECT mxid, phone, uuid, management_room, space_room FROM "user" WHERE uuid=$1` + getAllLoggedInUsersQuery = `SELECT mxid, phone, uuid, management_room, space_room FROM "user" WHERE phone IS NOT NULL` + insertUserQuery = `INSERT INTO "user" (mxid, phone, uuid, management_room, space_room) VALUES ($1, $2, $3, $4, $5)` + updateUserQuery = `UPDATE "user" SET phone=$2, uuid=$3, management_room=$4, space_room=$5 WHERE mxid=$1` +) + +type UserQuery struct { + *dbutil.QueryHelper[*User] +} + +type User struct { + qh *dbutil.QueryHelper[*User] + + MXID id.UserID + SignalUsername string + SignalID uuid.UUID + ManagementRoom id.RoomID + SpaceRoom id.RoomID + + lastReadCache map[PortalKey]time.Time + lastReadCacheLock sync.Mutex + inSpaceCache map[PortalKey]bool + inSpaceCacheLock sync.Mutex +} + +func newUser(qh *dbutil.QueryHelper[*User]) *User { + return &User{ + qh: qh, + + lastReadCache: make(map[PortalKey]time.Time), + inSpaceCache: make(map[PortalKey]bool), + } +} + +func (uq *UserQuery) GetByMXID(ctx context.Context, mxid id.UserID) (*User, error) { + return uq.QueryOne(ctx, getUserByMXIDQuery, mxid) +} + +func (uq *UserQuery) GetByPhone(ctx context.Context, phone string) (*User, error) { + return uq.QueryOne(ctx, getUserByPhoneQuery, phone) +} + +func (uq *UserQuery) GetBySignalID(ctx context.Context, uuid uuid.UUID) (*User, error) { + return uq.QueryOne(ctx, getUserByUUIDQuery, uuid) +} + +func (uq *UserQuery) GetAllLoggedIn(ctx context.Context) ([]*User, error) { + return uq.QueryMany(ctx, getAllLoggedInUsersQuery) +} + +func (u *User) sqlVariables() []any { + var nu uuid.NullUUID + nu.UUID = u.SignalID + nu.Valid = u.SignalID != uuid.Nil + return []any{u.MXID, dbutil.StrPtr(u.SignalUsername), nu, dbutil.StrPtr(u.ManagementRoom), dbutil.StrPtr(u.SpaceRoom)} +} + +func (u *User) Insert(ctx context.Context) error { + return u.qh.Exec(ctx, insertUserQuery, u.sqlVariables()...) +} + +func (u *User) Update(ctx context.Context) error { + return u.qh.Exec(ctx, updateUserQuery, u.sqlVariables()...) +} + +func (u *User) Scan(row dbutil.Scannable) (*User, error) { + var phone, managementRoom, spaceRoom sql.NullString + var signalID uuid.NullUUID + err := row.Scan( + &u.MXID, + &phone, + &signalID, + &managementRoom, + &spaceRoom, + ) + if err != nil { + return nil, err + } + u.SignalUsername = phone.String + u.SignalID = signalID.UUID + u.ManagementRoom = id.RoomID(managementRoom.String) + u.SpaceRoom = id.RoomID(spaceRoom.String) + return u, nil +} diff --git a/database/userportal.go b/database/userportal.go new file mode 100644 index 0000000..587b052 --- /dev/null +++ b/database/userportal.go @@ -0,0 +1,121 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2023 Scott Weber, Tulir Asokan +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package database + +import ( + "context" + "database/sql" + "errors" + "time" + + "github.com/rs/zerolog" +) + +const ( + getLastReadTSQuery = `SELECT last_read_ts FROM user_portal WHERE user_mxid=$1 AND portal_chat_id=$2 AND portal_receiver=$3` + setLastReadTSQuery = ` + INSERT INTO user_portal (user_mxid, portal_chat_id, portal_receiver, last_read_ts) VALUES ($1, $2, $3, $4) + ON CONFLICT (user_mxid, portal_chat_id, portal_receiver) DO UPDATE + SET last_read_ts=excluded.last_read_ts WHERE user_portal.last_read_ts. + +package main + +import ( + "context" + "fmt" + "time" + + "github.com/rs/zerolog" + "maunium.net/go/mautrix" + "maunium.net/go/mautrix/id" + + "go.mau.fi/mautrix-signal/database" +) + +type DisappearingMessagesManager struct { + DB *database.Database + Log zerolog.Logger + Bridge *SignalBridge + checkMessagesChan chan struct{} +} + +func (dmm *DisappearingMessagesManager) ScheduleDisappearingForRoom(ctx context.Context, roomID id.RoomID) { + log := dmm.Log.With().Str("room_id", roomID.String()).Logger() + disappearingMessages, err := dmm.DB.DisappearingMessage.GetUnscheduledForRoom(ctx, roomID) + if err != nil { + log.Err(err).Msg("Failed to get unscheduled disappearing messages") + return + } + for _, disappearingMessage := range disappearingMessages { + err = disappearingMessage.StartExpirationTimer(ctx) + if err != nil { + log.Err(err).Msg("Failed to schedule disappearing message") + } else { + log.Debug(). + Str("event_id", disappearingMessage.EventID.String()). + Time("expire_at", disappearingMessage.ExpireAt). + Msg("Scheduling disappearing message") + } + } + + // Tell the disappearing messages loop to check again + dmm.checkMessagesChan <- struct{}{} +} + +func (dmm *DisappearingMessagesManager) StartDisappearingLoop(ctx context.Context) { + dmm.checkMessagesChan = make(chan struct{}, 1) + go func() { + log := dmm.Log.With().Str("action", "loop").Logger() + ctx = log.WithContext(ctx) + for { + dmm.redactExpiredMessages(ctx) + + duration := 10 * time.Minute // Check again in 10 minutes just in case + nextMsg, err := dmm.DB.DisappearingMessage.GetNextScheduledMessage(ctx) + if err != nil { + if ctx.Err() != nil { + return + } + log.Err(err).Msg("Failed to get next disappearing message") + continue + } else if nextMsg != nil { + duration = nextMsg.ExpireAt.Sub(time.Now()) + } + + select { + case <-time.After(duration): + case <-dmm.checkMessagesChan: + case <-ctx.Done(): + return + } + } + }() +} + +func (dmm *DisappearingMessagesManager) redactExpiredMessages(ctx context.Context) { + log := zerolog.Ctx(ctx) + expiredMessages, err := dmm.DB.DisappearingMessage.GetExpiredMessages(ctx) + if err != nil { + log.Err(err).Msg("Failed to get expired disappearing messages") + return + } + + for _, msg := range expiredMessages { + portal := dmm.Bridge.GetPortalByMXID(msg.RoomID) + if portal == nil { + log.Warn().Str("event_id", msg.EventID.String()).Str("room_id", msg.RoomID.String()).Msg("Failed to redact message: portal not found") + continue + } + _, err = portal.MainIntent().RedactEvent(msg.RoomID, msg.EventID, mautrix.ReqRedact{ + Reason: "Message expired", + TxnID: fmt.Sprintf("mxsg_disappear_%s", msg.EventID), + }) + if err != nil { + log.Err(err). + Str("event_id", msg.EventID.String()). + Str("room_id", msg.RoomID.String()). + Msg("Failed to redact message") + } else { + log.Err(err). + Str("event_id", msg.EventID.String()). + Str("room_id", msg.RoomID.String()). + Msg("Redacted message") + } + err = msg.Delete(ctx) + if err != nil { + log.Err(err). + Str("event_id", msg.EventID.String()). + Msg("Failed to delete disappearing message row in database") + } + } +} + +func (dmm *DisappearingMessagesManager) AddDisappearingMessage(ctx context.Context, eventID id.EventID, roomID id.RoomID, expireIn time.Duration, startTimerNow bool) { + if expireIn == 0 { + return + } + var expireAt time.Time + if startTimerNow { + expireAt = time.Now().Add(expireIn) + } + disappearingMessage := dmm.DB.DisappearingMessage.NewWithValues(roomID, eventID, expireIn, expireAt) + err := disappearingMessage.Insert(ctx) + if err != nil { + zerolog.Ctx(ctx).Err(err).Str("event_id", eventID.String()). + Msg("Failed to add disappearing message to database") + return + } + zerolog.Ctx(ctx).Debug().Str("event_id", eventID.String()). + Msg("Added disappearing message row to database") + if startTimerNow { + // Tell the disappearing messages loop to check again + dmm.checkMessagesChan <- struct{}{} + } +} diff --git a/docker-run.sh b/docker-run.sh index 5f1ec65..f4285ed 100755 --- a/docker-run.sh +++ b/docker-run.sh @@ -4,8 +4,6 @@ if [[ -z "$GID" ]]; then GID="$UID" fi -BINARY_NAME=/usr/bin/mautrix-signal - # Define functions. function fixperms { chown -R $UID:$GID /data @@ -17,7 +15,7 @@ function fixperms { } if [[ ! -f /data/config.yaml ]]; then - $BINARY_NAME -c /data/config.yaml -e + cp /opt/mautrix-signal/example-config.yaml /data/config.yaml echo "Didn't find a config file." echo "Copied default config file to /data/config.yaml" echo "Modify that config file to your liking." @@ -26,7 +24,7 @@ if [[ ! -f /data/config.yaml ]]; then fi if [[ ! -f /data/registration.yaml ]]; then - $BINARY_NAME -g -c /data/config.yaml -r /data/registration.yaml || exit $? + /usr/bin/mautrix-signal -g -c /data/config.yaml -r /data/registration.yaml || exit $? echo "Didn't find a registration file." echo "Generated one for you." echo "See https://docs.mau.fi/bridges/general/registering-appservices.html on how to use it." @@ -36,12 +34,13 @@ fi cd /data fixperms +EXE=/usr/bin/mautrix-signal DLV=/usr/bin/dlv -if [ -x "$DLV" ]; then - if [ "$DBGWAIT" != 1 ]; then +if [[ -x $DLV ]]; then + if [[ $DBGWAIT -ne 1 ]]; then NOWAIT=1 fi - BINARY_NAME="${DLV} exec ${BINARY_NAME} ${NOWAIT:+--continue --accept-multiclient} --api-version 2 --headless -l :4040" + EXE="${DLV} exec ${EXE} ${NOWAIT:+--continue --accept-multiclient} --api-version 2 --headless -l :4040" fi -exec su-exec $UID:$GID $BINARY_NAME +exec su-exec $UID:$GID $EXE diff --git a/example-config.yaml b/example-config.yaml new file mode 100644 index 0000000..af71116 --- /dev/null +++ b/example-config.yaml @@ -0,0 +1,303 @@ +# Homeserver details. +homeserver: + # The address that this appservice can use to connect to the homeserver. + address: https://matrix.example.com + # The domain of the homeserver (also known as server_name, used for MXIDs, etc). + domain: example.com + + # What software is the homeserver running? + # Standard Matrix homeservers like Synapse, Dendrite and Conduit should just use "standard" here. + software: standard + # The URL to push real-time bridge status to. + # If set, the bridge will make POST requests to this URL whenever a user's discord connection state changes. + # The bridge will use the appservice as_token to authorize requests. + status_endpoint: null + # Endpoint for reporting per-message status. + message_send_checkpoint_endpoint: null + # Does the homeserver support https://github.com/matrix-org/matrix-spec-proposals/pull/2246? + async_media: false + + # Should the bridge use a websocket for connecting to the homeserver? + # The server side is currently not documented anywhere and is only implemented by mautrix-wsproxy, + # mautrix-asmux (deprecated), and hungryserv (proprietary). + websocket: false + # How often should the websocket be pinged? Pinging will be disabled if this is zero. + ping_interval_seconds: 0 + +# Application service host/registration related details. +# Changing these values requires regeneration of the registration. +appservice: + # The address that the homeserver can use to connect to this appservice. + address: http://localhost:29328 + + # The hostname and port where this appservice should listen. + hostname: 0.0.0.0 + port: 29328 + + # Database config. + database: + # The database type. "sqlite3-fk-wal" and "postgres" are supported. + type: postgres + # The database URI. + # SQLite: A raw file path is supported, but `file:?_txlock=immediate` is recommended. + # https://github.com/mattn/go-sqlite3#connection-string + # Postgres: Connection string. For example, postgres://user:password@host/database?sslmode=disable + # To connect via Unix socket, use something like postgres:///dbname?host=/var/run/postgresql + uri: postgres://user:password@host/database?sslmode=disable + # Maximum number of connections. Mostly relevant for Postgres. + max_open_conns: 20 + max_idle_conns: 2 + # Maximum connection idle time and lifetime before they're closed. Disabled if null. + # Parsed with https://pkg.go.dev/time#ParseDuration + max_conn_idle_time: null + max_conn_lifetime: null + + # The unique ID of this appservice. + id: signal + # Appservice bot details. + bot: + # Username of the appservice bot. + username: signalbot + # Display name and avatar for bot. Set to "remove" to remove display name/avatar, leave empty + # to leave display name/avatar as-is. + displayname: Signal bridge bot + avatar: mxc://maunium.net/wPJgTQbZOtpBFmDNkiNEMDUp + + # Whether or not to receive ephemeral events via appservice transactions. + # Requires MSC2409 support (i.e. Synapse 1.22+). + ephemeral_events: true + + # Should incoming events be handled asynchronously? + # This may be necessary for large public instances with lots of messages going through. + # However, messages will not be guaranteed to be bridged in the same order they were sent in. + async_transactions: false + + # Authentication tokens for AS <-> HS communication. Autogenerated; do not modify. + as_token: "This value is generated when generating the registration" + hs_token: "This value is generated when generating the registration" + +# Prometheus config. +metrics: + # Enable prometheus metrics? + enabled: false + # IP and port where the metrics listener should be. The path is always /metrics + listen: 127.0.0.1:8000 + +signal: + # Default device name that shows up in the Signal app. + device_name: mautrix-signal + +# Bridge config +bridge: + # Localpart template of MXIDs for Signal users. + # {{.}} is replaced with the internal ID of the Signal user. + username_template: signal_{{.}} + # Displayname template for Signal users. This is also used as the room name in DMs if private_chat_portal_meta is enabled. + # {{.ProfileName}} - The Signal profile name set by the user. + # {{.ContactName}} - The name for the user from your phone's contact list. This is not safe on multi-user instances. + # {{.PhoneNumber}} - The phone number of the user. + # {{.UUID}} - The UUID of the Signal user. + # {{.AboutEmoji}} - The emoji set by the user in their profile. + displayname_template: '{{or .ProfileName .PhoneNumber "Unknown user"}}' + # Whether to explicitly set the avatar and room name for private chat portal rooms. + # If set to `default`, this will be enabled in encrypted rooms and disabled in unencrypted rooms. + # If set to `always`, all DM rooms will have explicit names and avatars set. + # If set to `never`, DM rooms will never have names and avatars set. + private_chat_portal_meta: default + # Should avatars from the user's contact list be used? This is not safe on multi-user instances. + use_contact_avatars: false + + portal_message_buffer: 128 + + # Should the bridge create a space for each logged-in user and add bridged rooms to it? + # Users who logged in before turning this on should run `!signal sync-space` to create and fill the space for the first time. + personal_filtering_spaces: false + # Should Matrix m.notice-type messages be bridged? + bridge_notices: true + # Should the bridge send a read receipt from the bridge bot when a message has been sent to Signal? + delivery_receipts: false + # Whether the bridge should send the message status as a custom com.beeper.message_send_status event. + message_status_events: false + # Whether the bridge should send error notices via m.notice events when a message fails to bridge. + message_error_notices: true + # Should the bridge update the m.direct account data event when double puppeting is enabled. + # Note that updating the m.direct event is not atomic (except with mautrix-asmux) + # and is therefore prone to race conditions. + sync_direct_chat_list: false + # Set this to true to tell the bridge to re-send m.bridge events to all rooms on the next run. + # This field will automatically be changed back to false after it, except if the config file is not writable. + resend_bridge_info: false + # Send captions in the same message as images. This will send data compatible with both MSC2530. + # This is currently not supported in most clients. + caption_in_message: false + # Whether or not created rooms should have federation enabled. + # If false, created portal rooms will never be federated. + federate_rooms: true + # Servers to always allow double puppeting from + double_puppet_server_map: + example.com: https://example.com + # Allow using double puppeting from any server with a valid client .well-known file. + double_puppet_allow_discovery: false + # Shared secrets for https://github.com/devture/matrix-synapse-shared-secret-auth + # + # If set, double puppeting will be enabled automatically for local users + # instead of users having to find an access token and run `login-matrix` + # manually. + login_shared_secret_map: + example.com: foobar + + # Maximum time for handling Matrix events. Duration strings formatted for https://pkg.go.dev/time#ParseDuration + # Null means there's no enforced timeout. + message_handling_timeout: + # Send an error message after this timeout, but keep waiting for the response until the deadline. + # This is counted from the origin_server_ts, so the warning time is consistent regardless of the source of delay. + # If the message is older than this when it reaches the bridge, the message won't be handled at all. + error_after: null + # Drop messages after this timeout. They may still go through if the message got sent to the servers. + # This is counted from the time the bridge starts handling the message. + deadline: 120s + + # The prefix for commands. Only required in non-management rooms. + command_prefix: '!signal' + # Messages sent upon joining a management room. + # Markdown is supported. The defaults are listed below. + management_room_text: + # Sent when joining a room. + welcome: "Hello, I'm a Signal bridge bot." + # Sent when joining a management room and the user is already logged in. + welcome_connected: "Use `help` for help." + # Sent when joining a management room and the user is not logged in. + welcome_unconnected: "Use `help` for help or `login` to log in." + # Optional extra text sent when joining a management room. + additional_help: "" + + # End-to-bridge encryption support options. + # + # See https://docs.mau.fi/bridges/general/end-to-bridge-encryption.html for more info. + encryption: + # Allow encryption, work in group chat rooms with e2ee enabled + allow: false + # Default to encryption, force-enable encryption in all portals the bridge creates + # This will cause the bridge bot to be in private chats for the encryption to work properly. + default: false + # Whether to use MSC2409/MSC3202 instead of /sync long polling for receiving encryption-related data. + appservice: false + # Require encryption, drop any unencrypted messages. + require: false + # Enable key sharing? If enabled, key requests for rooms where users are in will be fulfilled. + # You must use a client that supports requesting keys from other users to use this feature. + allow_key_sharing: false + # Options for deleting megolm sessions from the bridge. + delete_keys: + # Beeper-specific: delete outbound sessions when hungryserv confirms + # that the user has uploaded the key to key backup. + delete_outbound_on_ack: false + # Don't store outbound sessions in the inbound table. + dont_store_outbound: false + # Ratchet megolm sessions forward after decrypting messages. + ratchet_on_decrypt: false + # Delete fully used keys (index >= max_messages) after decrypting messages. + delete_fully_used_on_decrypt: false + # Delete previous megolm sessions from same device when receiving a new one. + delete_prev_on_new_session: false + # Delete megolm sessions received from a device when the device is deleted. + delete_on_device_delete: false + # Periodically delete megolm sessions when 2x max_age has passed since receiving the session. + periodically_delete_expired: false + # Delete inbound megolm sessions that don't have the received_at field used for + # automatic ratcheting and expired session deletion. This is meant as a migration + # to delete old keys prior to the bridge update. + delete_outdated_inbound: false + # What level of device verification should be required from users? + # + # Valid levels: + # unverified - Send keys to all device in the room. + # cross-signed-untrusted - Require valid cross-signing, but trust all cross-signing keys. + # cross-signed-tofu - Require valid cross-signing, trust cross-signing keys on first use (and reject changes). + # cross-signed-verified - Require valid cross-signing, plus a valid user signature from the bridge bot. + # Note that creating user signatures from the bridge bot is not currently possible. + # verified - Require manual per-device verification + # (currently only possible by modifying the `trust` column in the `crypto_device` database table). + verification_levels: + # Minimum level for which the bridge should send keys to when bridging messages from Signal to Matrix. + receive: unverified + # Minimum level that the bridge should accept for incoming Matrix messages. + send: unverified + # Minimum level that the bridge should require for accepting key requests. + share: cross-signed-tofu + # Options for Megolm room key rotation. These options allow you to + # configure the m.room.encryption event content. See: + # https://spec.matrix.org/v1.3/client-server-api/#mroomencryption for + # more information about that event. + rotation: + # Enable custom Megolm room key rotation settings. Note that these + # settings will only apply to rooms created after this option is + # set. + enable_custom: false + # The maximum number of milliseconds a session should be used + # before changing it. The Matrix spec recommends 604800000 (a week) + # as the default. + milliseconds: 604800000 + # The maximum number of messages that should be sent with a given a + # session before changing it. The Matrix spec recommends 100 as the + # default. + messages: 100 + + # Disable rotating keys when a user's devices change? + # You should not enable this option unless you understand all the implications. + disable_device_change_key_rotation: false + + # Settings for provisioning API + provisioning: + # Prefix for the provisioning API paths. + prefix: /_matrix/provision + # Shared secret for authentication. If set to "generate", a random secret will be generated, + # or if set to "disable", the provisioning API will be disabled. + shared_secret: generate + # Enable debug API at /debug with provisioning authentication. + debug_endpoints: false + + # Permissions for using the bridge. + # Permitted values: + # relay - Talk through the relaybot (if enabled), no access otherwise + # user - Access to use the bridge to chat with a Signal account. + # admin - User level and some additional administration tools + # Permitted keys: + # * - All Matrix users + # domain - All users on that homeserver + # mxid - Specific user + permissions: + "*": relay + "example.com": user + "@admin:example.com": admin + + # Settings for relay mode + relay: + # Whether relay mode should be allowed. If allowed, `!wa set-relay` can be used to turn any + # authenticated user into a relaybot for that chat. + enabled: false + # Should only admins be allowed to set themselves as relay users? + admin_only: true + # The formats to use when sending messages to Signal via the relaybot. + message_formats: + m.text: "{{ .Sender.Displayname }}: {{ .Message }}" + m.notice: "{{ .Sender.Displayname }}: {{ .Message }}" + m.emote: "* {{ .Sender.Displayname }} {{ .Message }}" + m.file: "{{ .Sender.Displayname }} sent a file" + m.image: "{{ .Sender.Displayname }} sent an image" + m.audio: "{{ .Sender.Displayname }} sent an audio file" + m.video: "{{ .Sender.Displayname }} sent a video" + m.location: "{{ .Sender.Displayname }} sent a location" + +# Logging config. See https://github.com/tulir/zeroconfig for details. +logging: + min_level: debug + writers: + - type: stdout + format: pretty-colored + - type: file + format: json + filename: ./logs/mautrix-signal.log + max_size: 100 + max_backups: 10 + compress: true diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..80c5341 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1703255338, + "narHash": "sha256-Z6wfYJQKmDN9xciTwU3cOiOk+NElxdZwy/FiHctCzjU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6df37dc6a77654682fe9f071c62b4242b5342e04", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..cbb2b61 --- /dev/null +++ b/flake.nix @@ -0,0 +1,33 @@ +{ + description = "mautrix-signal development environment"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + (flake-utils.lib.eachDefaultSystem (system: + let pkgs = import nixpkgs { inherit system; }; + in { + devShells.default = pkgs.mkShell { + LIBCLANG_PATH = "${pkgs.llvmPackages_11.libclang.lib}/lib"; + + buildInputs = with pkgs; [ + clang + cmake + gnumake + protobuf + rust-cbindgen + rustup + olm + + go_1_20 + go-tools + gotools + + pre-commit + ]; + }; + })); +} diff --git a/go.mod b/go.mod index 931af45..90870ea 100644 --- a/go.mod +++ b/go.mod @@ -1,52 +1,51 @@ module go.mau.fi/mautrix-signal -go 1.25.0 - -toolchain go1.26.2 - -tool go.mau.fi/util/cmd/maubuild +go 1.20 require ( - github.com/coder/websocket v1.8.14 - github.com/emersion/go-vcard v0.0.0-20241024213814-c9703dde27ff - github.com/google/uuid v1.6.0 + github.com/beeper/libserv v0.0.0-20231231163024-8eba5b0c509d + github.com/google/uuid v1.5.0 + github.com/gorilla/mux v1.8.0 + github.com/lib/pq v1.10.9 github.com/mattn/go-pointer v0.0.1 - github.com/rs/zerolog v1.35.1 - github.com/stretchr/testify v1.11.1 - github.com/tidwall/gjson v1.18.0 - go.mau.fi/util v0.9.9-0.20260511124621-9241e81bdf25 - golang.org/x/crypto v0.50.0 - golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f - golang.org/x/net v0.53.0 - golang.org/x/sync v0.20.0 - google.golang.org/protobuf v1.36.11 - gopkg.in/yaml.v3 v3.0.1 - maunium.net/go/mautrix v0.27.1-0.20260513120123-5fba7e3afae4 + github.com/mattn/go-sqlite3 v1.14.19 + github.com/prometheus/client_golang v1.18.0 + github.com/rs/zerolog v1.31.0 + github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e + github.com/stretchr/testify v1.8.4 + github.com/tidwall/gjson v1.17.0 + go.mau.fi/util v0.2.2-0.20231229201527-e01ca03301e9 + golang.org/x/crypto v0.17.0 + golang.org/x/exp v0.0.0-20231226003508-02704c960a9b + golang.org/x/net v0.19.0 + google.golang.org/protobuf v1.32.0 + maunium.net/go/maulogger/v2 v2.4.1 + maunium.net/go/mautrix v0.16.3-0.20240103125335-7c45a3d28be2 + nhooyr.io/websocket v1.8.10 ) require ( - filippo.io/edwards25519 v1.2.0 // indirect - github.com/coreos/go-systemd/v22 v22.7.0 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/coreos/go-systemd/v22 v22.5.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/kr/pretty v0.3.1 // indirect - github.com/lib/pq v1.12.3 // indirect - github.com/mattn/go-colorable v0.1.14 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-sqlite3 v1.14.44 // indirect - github.com/petermattis/goid v0.0.0-20260330135022-df67b199bc81 // indirect + github.com/gorilla/websocket v1.5.0 // indirect + github.com/kr/text v0.2.0 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect + github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/rogpeppe/go-internal v1.10.0 // indirect - github.com/rs/xid v1.6.0 // indirect - github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect - github.com/tidwall/match v1.2.0 // indirect - github.com/tidwall/pretty v1.2.1 // indirect + github.com/prometheus/client_model v0.5.0 // indirect + github.com/prometheus/common v0.45.0 // indirect + github.com/prometheus/procfs v0.12.0 // indirect + github.com/rs/xid v1.5.0 // indirect + github.com/tidwall/match v1.1.1 // indirect + github.com/tidwall/pretty v1.2.0 // indirect github.com/tidwall/sjson v1.2.5 // indirect - github.com/yuin/goldmark v1.8.2 // indirect - go.mau.fi/zeroconfig v0.2.0 // indirect - golang.org/x/mod v0.35.0 // indirect - golang.org/x/sys v0.43.0 // indirect - golang.org/x/text v0.36.0 // indirect - gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect + github.com/yuin/goldmark v1.6.0 // indirect + go.mau.fi/zeroconfig v0.1.2 // indirect + golang.org/x/sys v0.15.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect maunium.net/go/mauflag v1.0.0 // indirect ) diff --git a/go.sum b/go.sum index 2f02866..6f025c4 100644 --- a/go.sum +++ b/go.sum @@ -1,95 +1,98 @@ -filippo.io/edwards25519 v1.2.0 h1:crnVqOiS4jqYleHd9vaKZ+HKtHfllngJIiOpNpoJsjo= -filippo.io/edwards25519 v1.2.0/go.mod h1:xzAOLCNug/yB62zG1bQ8uziwrIqIuxhctzJT18Q77mc= -github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7OputlJIzU= -github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= -github.com/coder/websocket v1.8.14 h1:9L0p0iKiNOibykf283eHkKUHHrpG7f65OE3BhhO7v9g= -github.com/coder/websocket v1.8.14/go.mod h1:NX3SzP+inril6yawo5CQXx8+fk145lPDC6pumgx0mVg= -github.com/coreos/go-systemd/v22 v22.7.0 h1:LAEzFkke61DFROc7zNLX/WA2i5J8gYqe0rSj9KI28KA= -github.com/coreos/go-systemd/v22 v22.7.0/go.mod h1:xNUYtjHu2EDXbsxz1i41wouACIwT7Ybq9o0BQhMwD0w= +github.com/DATA-DOG/go-sqlmock v1.5.1 h1:FK6RCIUSfmbnI/imIICmboyQBkOckutaa6R5YYlLZyo= +github.com/beeper/libserv v0.0.0-20231231163024-8eba5b0c509d h1:CSrg1zpAEMXK3VIUx5deRT6YMMX3Kd8jDkiUmB1uoWw= +github.com/beeper/libserv v0.0.0-20231231163024-8eba5b0c509d/go.mod h1:b9FFm9y4mEm36G8ytVmS1vkNzJa0KepmcdVY+qf7qRU= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= +github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/emersion/go-vcard v0.0.0-20241024213814-c9703dde27ff h1:4N8wnS3f1hNHSmFD5zgFkWCyA4L1kCDkImPAtK7D6tg= -github.com/emersion/go-vcard v0.0.0-20241024213814-c9703dde27ff/go.mod h1:HMJKR5wlh/ziNp+sHEDV2ltblO4JD2+IdDOWtGcQBTM= -github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= -github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= +github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= +github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= +github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= -github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/lib/pq v1.12.3 h1:tTWxr2YLKwIvK90ZXEw8GP7UFHtcbTtty8zsI+YjrfQ= -github.com/lib/pq v1.12.3/go.mod h1:/p+8NSbOcwzAEI7wiMXFlgydTwcgTr3OSKMsD2BitpA= -github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= -github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= +github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-pointer v0.0.1 h1:n+XhsuGeVO6MEAp7xyEukFINEa+Quek5psIR/ylA6o0= github.com/mattn/go-pointer v0.0.1/go.mod h1:2zXcozF6qYGgmsG+SeTZz3oAbFLdD3OWqnUbNvJZAlc= -github.com/mattn/go-sqlite3 v1.14.44 h1:3VSe+xafpbzsLbdr2AWlAZk9yRHiBhTBakioXaCKTF8= -github.com/mattn/go-sqlite3 v1.14.44/go.mod h1:pjEuOr8IwzLJP2MfGeTb0A35jauH+C2kbHKBr7yXKVQ= -github.com/petermattis/goid v0.0.0-20260330135022-df67b199bc81 h1:WDsQxOJDy0N1VRAjXLpi8sCEZRSGarLWQevDxpTBRrM= -github.com/petermattis/goid v0.0.0-20260330135022-df67b199bc81/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/mattn/go-sqlite3 v1.14.19 h1:fhGleo2h1p8tVChob4I9HpmVFIAkKGpiukdrgQbWfGI= +github.com/mattn/go-sqlite3 v1.14.19/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= +github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg= +github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= +github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= +github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= +github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM= +github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY= +github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= +github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= -github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU= -github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0= -github.com/rs/zerolog v1.35.1 h1:m7xQeoiLIiV0BCEY4Hs+j2NG4Gp2o2KPKmhnnLiazKI= -github.com/rs/zerolog v1.35.1/go.mod h1:EjML9kdfa/RMA7h/6z6pYmq1ykOuA8/mjWaEvGI+jcw= +github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc= +github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A= +github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0= github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M= -github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= -github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= -github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM= +github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/match v1.2.0 h1:0pt8FlkOwjN2fPt4bIl4BoNxb98gGHN2ObFEDkrfZnM= -github.com/tidwall/match v1.2.0/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= +github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= -github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= -github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= -github.com/yuin/goldmark v1.8.2 h1:kEGpgqJXdgbkhcOgBxkC0X0PmoPG1ZyoZ117rDVp4zE= -github.com/yuin/goldmark v1.8.2/go.mod h1:ip/1k0VRfGynBgxOz0yCqHrbZXhcjxyuS66Brc7iBKg= -go.mau.fi/util v0.9.9-0.20260511124621-9241e81bdf25 h1:YPEmc+li7TF6C9AdRTcSLMb6yCHdF27/wNT7kFLIVNg= -go.mau.fi/util v0.9.9-0.20260511124621-9241e81bdf25/go.mod h1:jE9FfhbgEgAwxei6lomO9v8zdCIATcquONUu4vjRwSs= -go.mau.fi/zeroconfig v0.2.0 h1:e/OGEERqVRRKlgaro7E6bh8xXiKFSXB3eNNIud7FUjU= -go.mau.fi/zeroconfig v0.2.0/go.mod h1:J0Vn0prHNOm493oZoQ84kq83ZaNCYZnq+noI1b1eN8w= -golang.org/x/crypto v0.50.0 h1:zO47/JPrL6vsNkINmLoo/PH1gcxpls50DNogFvB5ZGI= -golang.org/x/crypto v0.50.0/go.mod h1:3muZ7vA7PBCE6xgPX7nkzzjiUq87kRItoJQM1Yo8S+Q= -golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f h1:W3F4c+6OLc6H2lb//N1q4WpJkhzJCK5J6kUi1NTVXfM= -golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f/go.mod h1:J1xhfL/vlindoeF/aINzNzt2Bket5bjo9sdOYzOsU80= -golang.org/x/mod v0.35.0 h1:Ww1D637e6Pg+Zb2KrWfHQUnH2dQRLBQyAtpr/haaJeM= -golang.org/x/mod v0.35.0/go.mod h1:+GwiRhIInF8wPm+4AoT6L0FA1QWAad3OMdTRx4tFYlU= -golang.org/x/net v0.53.0 h1:d+qAbo5L0orcWAr0a9JweQpjXF19LMXJE8Ey7hwOdUA= -golang.org/x/net v0.53.0/go.mod h1:JvMuJH7rrdiCfbeHoo3fCQU24Lf5JJwT9W3sJFulfgs= -golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4= -golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= +github.com/yuin/goldmark v1.6.0 h1:boZcn2GTjpsynOsC0iJHnBWa4Bi0qzfJjthwauItG68= +github.com/yuin/goldmark v1.6.0/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.mau.fi/util v0.2.2-0.20231229201527-e01ca03301e9 h1:sYi2qn5XYnWyHjzBj04/ZeyqMMK31qPM1l2v7aWeiA0= +go.mau.fi/util v0.2.2-0.20231229201527-e01ca03301e9/go.mod h1:9dGsBCCbZJstx16YgnVMVi3O2bOizELoKpugLD4FoGs= +go.mau.fi/zeroconfig v0.1.2 h1:DKOydWnhPMn65GbXZOafgkPm11BvFashZWLct0dGFto= +go.mau.fi/zeroconfig v0.1.2/go.mod h1:NcSJkf180JT+1IId76PcMuLTNa1CzsFFZ0nBygIQM70= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/exp v0.0.0-20231226003508-02704c960a9b h1:kLiC65FbiHWFAOu+lxwNPujcsl8VYyTYYEZnsOO1WK4= +golang.org/x/exp v0.0.0-20231226003508-02704c960a9b/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= +golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI= -golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= -golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg= -golang.org/x/text v0.36.0/go.mod h1:NIdBknypM8iqVmPiuco0Dh6P5Jcdk8lJL0CUebqK164= -google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= -google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= +google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= maunium.net/go/mauflag v1.0.0 h1:YiaRc0tEI3toYtJMRIfjP+jklH45uDHtT80nUamyD4M= maunium.net/go/mauflag v1.0.0/go.mod h1:nLivPOpTpHnpzEh8jEdSL9UqO9+/KBJFmNRlwKfkPeA= -maunium.net/go/mautrix v0.27.1-0.20260513120123-5fba7e3afae4 h1:zNC9eVAhw8FhKpM3AxNAh/iy75UEYX91uJUvqqAYlvo= -maunium.net/go/mautrix v0.27.1-0.20260513120123-5fba7e3afae4/go.mod h1:3sOGhXi3P1V6/NruTA0gujkvTypXVUraWktCuTGyDuM= +maunium.net/go/maulogger/v2 v2.4.1 h1:N7zSdd0mZkB2m2JtFUsiGTQQAdP0YeFWT7YMc80yAL8= +maunium.net/go/maulogger/v2 v2.4.1/go.mod h1:omPuYwYBILeVQobz8uO3XC8DIRuEb5rXYlQSuqrbCho= +maunium.net/go/mautrix v0.16.3-0.20240103125335-7c45a3d28be2 h1:Tgdv1P3hl6I4BDzHNl4kZ+2VrdpkBJ1F3WOyzFbyHlU= +maunium.net/go/mautrix v0.16.3-0.20240103125335-7c45a3d28be2/go.mod h1:gCgLw/4c1a8QsiOWTdUdXlt5cYdE0rJ9wLeZQKPD58Q= +nhooyr.io/websocket v1.8.10 h1:mv4p+MnGrLDcPlBoWsvPP7XCzTYMXP9F9eIGoKbgx7Q= +nhooyr.io/websocket v1.8.10/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c= diff --git a/main.go b/main.go new file mode 100644 index 0000000..2db6181 --- /dev/null +++ b/main.go @@ -0,0 +1,364 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2023 Scott Weber +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package main + +import ( + "context" + _ "embed" + "fmt" + "os" + "sync" + + "github.com/google/uuid" + "github.com/rs/zerolog" + "go.mau.fi/util/configupgrade" + "go.mau.fi/util/dbutil" + "maunium.net/go/mautrix" + "maunium.net/go/mautrix/bridge" + "maunium.net/go/mautrix/bridge/commands" + "maunium.net/go/mautrix/event" + "maunium.net/go/mautrix/format" + "maunium.net/go/mautrix/id" + + "go.mau.fi/mautrix-signal/config" + "go.mau.fi/mautrix-signal/database" + "go.mau.fi/mautrix-signal/msgconv/matrixfmt" + "go.mau.fi/mautrix-signal/msgconv/signalfmt" + "go.mau.fi/mautrix-signal/pkg/signalmeow" +) + +//go:embed example-config.yaml +var ExampleConfig string + +// Information to find out exactly which commit the bridge was built from. +// These are filled at build time with the -X linker flag. +var ( + Tag = "unknown" + Commit = "unknown" + BuildTime = "unknown" +) + +type SignalBridge struct { + bridge.Bridge + + Config *config.Config + DB *database.Database + Metrics *MetricsHandler + MeowStore *signalmeow.StoreContainer + + provisioning *ProvisioningAPI + + usersByMXID map[id.UserID]*User + usersBySignalID map[uuid.UUID]*User + usersLock sync.Mutex + + managementRooms map[id.RoomID]*User + managementRoomsLock sync.Mutex + + portalsByMXID map[id.RoomID]*Portal + portalsByID map[database.PortalKey]*Portal + portalsLock sync.Mutex + + puppets map[uuid.UUID]*Puppet + puppetsByCustomMXID map[id.UserID]*Puppet + puppetsByNumber map[string]*Puppet + puppetsLock sync.Mutex + + disappearingMessagesManager *DisappearingMessagesManager +} + +var _ bridge.ChildOverride = (*SignalBridge)(nil) + +func (br *SignalBridge) GetExampleConfig() string { + return ExampleConfig +} + +func (br *SignalBridge) GetConfigPtr() interface{} { + br.Config = &config.Config{ + BaseConfig: &br.Bridge.Config, + } + br.Config.BaseConfig.Bridge = &br.Config.Bridge + return br.Config +} + +func (br *SignalBridge) Init() { + br.CommandProcessor = commands.NewProcessor(&br.Bridge) + br.RegisterCommands() + + signalmeow.SetLogger(br.ZLog.With().Str("component", "signalmeow").Logger()) + + br.DB = database.New(br.Bridge.DB) + br.MeowStore = signalmeow.NewStore(br.Bridge.DB, dbutil.ZeroLogger(br.ZLog.With().Str("db_section", "signalmeow").Logger())) + + ss := br.Config.Bridge.Provisioning.SharedSecret + if len(ss) > 0 && ss != "disable" { + br.provisioning = &ProvisioningAPI{bridge: br, log: br.ZLog.With().Str("component", "provisioning").Logger()} + } + br.disappearingMessagesManager = &DisappearingMessagesManager{ + DB: br.DB, + Log: br.ZLog.With().Str("component", "disappearing messages").Logger(), + Bridge: br, + } + + br.Metrics = NewMetricsHandler(br.Config.Metrics.Listen, br.Log.Sub("Metrics"), br.DB) + br.MatrixHandler.TrackEventDuration = br.Metrics.TrackMatrixEvent + + signalFormatParams = &signalfmt.FormatParams{ + GetUserInfo: func(u uuid.UUID) signalfmt.UserInfo { + puppet := br.GetPuppetBySignalID(u) + if puppet == nil { + return signalfmt.UserInfo{} + } + user := br.GetUserBySignalID(u) + if user != nil { + return signalfmt.UserInfo{ + MXID: user.MXID, + Name: puppet.Name, + } + } + return signalfmt.UserInfo{ + MXID: puppet.MXID, + Name: puppet.Name, + } + }, + } + matrixFormatParams = &matrixfmt.HTMLParser{ + GetUUIDFromMXID: func(userID id.UserID) uuid.UUID { + parsed, ok := br.ParsePuppetMXID(userID) + if ok { + return parsed + } + // TODO only get if exists + user := br.GetUserByMXID(userID) + if user != nil && user.SignalID != uuid.Nil { + return user.SignalID + } + return uuid.Nil + }, + } +} + +func (br *SignalBridge) logLostPortals(ctx context.Context) { + lostPortals, err := br.DB.LostPortal.GetAll(ctx) + if err != nil { + br.ZLog.Err(err).Msg("Failed to get lost portals") + return + } else if len(lostPortals) == 0 { + return + } + lostCountByReceiver := make(map[string]int) + for _, lost := range lostPortals { + lostCountByReceiver[lost.Receiver]++ + } + br.ZLog.Warn(). + Any("count_by_receiver", lostCountByReceiver). + Msg("Some portals were discarded due to the receiver not being logged into the bridge anymore. " + + "Use `!signal cleanup-lost-portals` to remove them from the database. " + + "Alternatively, you can re-insert the data into the portal table with the appropriate receiver column to restore the portals.") +} + +func (br *SignalBridge) Start() { + go br.logLostPortals(context.TODO()) + err := br.MeowStore.Upgrade() + if err != nil { + br.Log.Fatalln("Failed to upgrade signalmeow database: %v", err) + os.Exit(15) + } + if br.provisioning != nil { + br.Log.Debugln("Initializing provisioning API") + br.provisioning.Init() + } + go br.StartUsers() + if br.Config.Metrics.Enabled { + go br.Metrics.Start() + } + go br.disappearingMessagesManager.StartDisappearingLoop(context.TODO()) +} + +func (br *SignalBridge) Stop() { + br.Metrics.Stop() + for _, user := range br.usersByMXID { + br.Log.Debugln("Disconnecting", user.MXID) + user.Disconnect() + } +} + +func (br *SignalBridge) GetIPortal(mxid id.RoomID) bridge.Portal { + p := br.GetPortalByMXID(mxid) + if p == nil { + return nil + } + return p +} + +func (br *SignalBridge) GetIUser(mxid id.UserID, create bool) bridge.User { + p := br.GetUserByMXID(mxid) + if p == nil { + return nil + } + return p +} + +func (br *SignalBridge) IsGhost(mxid id.UserID) bool { + _, isGhost := br.ParsePuppetMXID(mxid) + return isGhost +} + +func (br *SignalBridge) GetIGhost(mxid id.UserID) bridge.Ghost { + p := br.GetPuppetByMXID(mxid) + if p == nil { + return nil + } + return p +} + +func (br *SignalBridge) CreatePrivatePortal(roomID id.RoomID, brInviter bridge.User, brGhost bridge.Ghost) { + inviter := brInviter.(*User) + puppet := brGhost.(*Puppet) + + log := br.ZLog.With(). + Str("action", "create private portal"). + Str("target_room_id", roomID.String()). + Str("inviter_mxid", brInviter.GetMXID().String()). + Str("invitee_uuid", puppet.SignalID.String()). + Logger() + log.Debug().Msg("Creating private chat portal") + + key := database.NewPortalKey(puppet.SignalID.String(), inviter.SignalID) + portal := br.GetPortalByChatID(key) + ctx := log.WithContext(context.TODO()) + + if len(portal.MXID) == 0 { + br.createPrivatePortalFromInvite(ctx, roomID, inviter, puppet, portal) + return + } + log.Debug(). + Str("existing_room_id", portal.MXID.String()). + Msg("Existing private chat portal found, trying to invite user") + + ok := portal.ensureUserInvited(inviter) + if !ok { + log.Warn().Msg("Failed to invite user to existing private chat portal. Redirecting portal to new room") + br.createPrivatePortalFromInvite(ctx, roomID, inviter, puppet, portal) + return + } + intent := puppet.DefaultIntent() + errorMessage := fmt.Sprintf("You already have a private chat portal with me at [%[1]s](https://matrix.to/#/%[1]s)", portal.MXID) + errorContent := format.RenderMarkdown(errorMessage, true, false) + _, _ = intent.SendMessageEvent(roomID, event.EventMessage, errorContent) + log.Debug().Msg("Leaving ghost from private chat room after accepting invite because we already have a chat with the user") + _, _ = intent.LeaveRoom(roomID) +} + +func (br *SignalBridge) createPrivatePortalFromInvite(ctx context.Context, roomID id.RoomID, inviter *User, puppet *Puppet, portal *Portal) { + log := zerolog.Ctx(ctx) + log.Debug().Msg("Creating private portal from invite") + + // Check if room is already encrypted + var existingEncryption event.EncryptionEventContent + var encryptionEnabled bool + err := portal.MainIntent().StateEvent(roomID, event.StateEncryption, "", &existingEncryption) + if err != nil { + log.Err(err).Msg("Failed to check if encryption is enabled in private chat room") + } else { + encryptionEnabled = existingEncryption.Algorithm == id.AlgorithmMegolmV1 + } + portal.MXID = roomID + br.portalsLock.Lock() + br.portalsByMXID[portal.MXID] = portal + br.portalsLock.Unlock() + intent := puppet.DefaultIntent() + + if br.Config.Bridge.Encryption.Default || encryptionEnabled { + log.Debug().Msg("Adding bridge bot to new private chat portal as encryption is enabled") + _, err = intent.InviteUser(roomID, &mautrix.ReqInviteUser{UserID: br.Bot.UserID}) + if err != nil { + log.Err(err).Msg("Failed to invite bridge bot to enable e2be") + } + err = br.Bot.EnsureJoined(roomID) + if err != nil { + log.Err(err).Msg("Failed to join as bridge bot to enable e2be") + } + if !encryptionEnabled { + _, err = intent.SendStateEvent(roomID, event.StateEncryption, "", portal.getEncryptionEventContent()) + if err != nil { + log.Err(err).Msg("Failed to enable e2be") + } + } + br.AS.StateStore.SetMembership(roomID, inviter.MXID, event.MembershipJoin) + br.AS.StateStore.SetMembership(roomID, puppet.MXID, event.MembershipJoin) + br.AS.StateStore.SetMembership(roomID, br.Bot.UserID, event.MembershipJoin) + portal.Encrypted = true + } + //portal.Topic = PrivateChatTopic + _, _ = portal.MainIntent().SetRoomTopic(portal.MXID, portal.Topic) + if portal.shouldSetDMRoomMetadata() { + portal.Name = puppet.Name + portal.AvatarURL = puppet.AvatarURL + portal.AvatarHash = puppet.AvatarHash + portal.AvatarSet = puppet.AvatarSet + _, err = portal.MainIntent().SetRoomName(portal.MXID, portal.Name) + portal.NameSet = err == nil + _, err = portal.MainIntent().SetRoomAvatar(portal.MXID, portal.AvatarURL) + portal.AvatarSet = err == nil + } + err = portal.Update(ctx) + if err != nil { + log.Err(err).Msg("Failed to update portal in database") + } + portal.UpdateBridgeInfo() + _, _ = intent.SendNotice(roomID, "Private chat portal created") + log.Info().Msg("Created private chat portal after invite") +} + +func main() { + br := &SignalBridge{ + usersByMXID: make(map[id.UserID]*User), + usersBySignalID: make(map[uuid.UUID]*User), + + managementRooms: make(map[id.RoomID]*User), + + portalsByMXID: make(map[id.RoomID]*Portal), + portalsByID: make(map[database.PortalKey]*Portal), + + puppets: make(map[uuid.UUID]*Puppet), + puppetsByCustomMXID: make(map[id.UserID]*Puppet), + puppetsByNumber: make(map[string]*Puppet), + } + br.Bridge = bridge.Bridge{ + Name: "mautrix-signal", + URL: "https://github.com/mautrix/signal", + Description: "A Matrix-Signal puppeting bridge.", + Version: "0.4.99", + ProtocolName: "Signal", + BeeperServiceName: "signal", + BeeperNetworkName: "signal", + + CryptoPickleKey: "mautrix.bridge.e2ee", + + ConfigUpgrader: &configupgrade.StructUpgrader{ + SimpleUpgrader: configupgrade.SimpleUpgrader(config.DoUpgrade), + Blocks: config.SpacedBlocks, + Base: ExampleConfig, + }, + + Child: br, + } + br.InitVersion(Tag, Commit, BuildTime) + + br.Main() +} diff --git a/messagetracking.go b/messagetracking.go new file mode 100644 index 0000000..eb3ece1 --- /dev/null +++ b/messagetracking.go @@ -0,0 +1,308 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2023 Scott Weber +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package main + +import ( + "context" + "errors" + "fmt" + "sync" + "time" + + "github.com/rs/zerolog" + "maunium.net/go/mautrix" + "maunium.net/go/mautrix/bridge/status" + "maunium.net/go/mautrix/event" + "maunium.net/go/mautrix/id" + + "go.mau.fi/mautrix-signal/msgconv" +) + +var ( + errUserNotConnected = errors.New("you are not connected to Signal") + errDifferentUser = errors.New("user is not the recipient of this private chat portal") + errUserNotLoggedIn = errors.New("user is not logged in and chat has no relay bot") + errRelaybotNotLoggedIn = errors.New("neither user nor relay bot of chat are logged in") + errMNoticeDisabled = errors.New("bridging m.notice messages is disabled") + errUnexpectedParsedContentType = errors.New("unexpected parsed content type") + + errRedactionTargetNotFound = errors.New("redaction target message was not found") + errRedactionTargetSentBySomeoneElse = errors.New("redaction target message was sent by someone else") + errUnreactTargetSentBySomeoneElse = errors.New("redaction target reaction was sent by someone else") + errReactionTargetNotFound = errors.New("reaction target message not found") + errEditUnknownTarget = errors.New("unknown edit target message") + errFailedToGetEditTarget = errors.New("failed to get edit target message") + errEditDifferentSender = errors.New("can't edit message sent by another user") + errEditTooOld = errors.New("message is too old to be edited") + + errMessageTakingLong = errors.New("bridging the message is taking longer than usual") + errTimeoutBeforeHandling = errors.New("message timed out before handling was started") +) + +func errorToStatusReason(err error) (reason event.MessageStatusReason, status event.MessageStatus, isCertain, sendNotice bool, humanMessage string) { + switch { + case errors.Is(err, errUnexpectedParsedContentType), + errors.Is(err, msgconv.ErrUnsupportedMsgType), + errors.Is(err, msgconv.ErrInvalidGeoURI): + return event.MessageStatusUnsupported, event.MessageStatusFail, true, true, "" + case errors.Is(err, errMNoticeDisabled): + return event.MessageStatusUnsupported, event.MessageStatusFail, true, false, "" + case errors.Is(err, errEditDifferentSender), + errors.Is(err, errEditTooOld), + errors.Is(err, errEditUnknownTarget): + return event.MessageStatusUnsupported, event.MessageStatusFail, true, true, err.Error() + case errors.Is(err, errTimeoutBeforeHandling): + return event.MessageStatusTooOld, event.MessageStatusRetriable, true, true, "the message was too old when it reached the bridge, so it was not handled" + case errors.Is(err, context.DeadlineExceeded): + return event.MessageStatusTooOld, event.MessageStatusRetriable, false, true, "handling the message took too long and was cancelled" + case errors.Is(err, errMessageTakingLong): + return event.MessageStatusTooOld, event.MessageStatusPending, false, true, err.Error() + case errors.Is(err, errRedactionTargetNotFound), + errors.Is(err, errReactionTargetNotFound), + errors.Is(err, errRedactionTargetSentBySomeoneElse), + errors.Is(err, errUnreactTargetSentBySomeoneElse): + return event.MessageStatusGenericError, event.MessageStatusFail, true, false, "" + case errors.Is(err, errUserNotConnected): + return event.MessageStatusGenericError, event.MessageStatusRetriable, true, true, "" + case errors.Is(err, errUserNotLoggedIn), + errors.Is(err, errDifferentUser), + errors.Is(err, errRelaybotNotLoggedIn): + return event.MessageStatusGenericError, event.MessageStatusRetriable, true, false, "" + default: + return event.MessageStatusGenericError, event.MessageStatusRetriable, false, true, "" + } +} + +func (portal *Portal) sendErrorMessage(evt *event.Event, err error, confirmed bool, editID id.EventID) id.EventID { + if !portal.bridge.Config.Bridge.MessageErrorNotices { + return "" + } + certainty := "may not have been" + if confirmed { + certainty = "was not" + } + var msgType string + switch evt.Type { + case event.EventMessage: + msgType = "message" + case event.EventReaction: + msgType = "reaction" + case event.EventRedaction: + msgType = "redaction" + //case TypeMSC3381PollResponse, TypeMSC3381V2PollResponse: + // msgType = "poll response" + //case TypeMSC3381PollStart: + // msgType = "poll start" + default: + msgType = "unknown event" + } + msg := fmt.Sprintf("\u26a0 Your %s %s bridged: %v", msgType, certainty, err) + if errors.Is(err, errMessageTakingLong) { + msg = fmt.Sprintf("\u26a0 Bridging your %s is taking longer than usual", msgType) + } + content := &event.MessageEventContent{ + MsgType: event.MsgNotice, + Body: msg, + } + if editID != "" { + content.SetEdit(editID) + } else { + content.SetReply(evt) + } + resp, err := portal.sendMainIntentMessage(content) + if err != nil { + portal.log.Err(err).Msg("Failed to send bridging error message") + return "" + } + return resp.EventID +} + +func (portal *Portal) sendStatusEvent(evtID, lastRetry id.EventID, err error, deliveredTo *[]id.UserID) { + if !portal.bridge.Config.Bridge.MessageStatusEvents { + return + } + if lastRetry == evtID { + lastRetry = "" + } + intent := portal.bridge.Bot + if !portal.Encrypted { + // Bridge bot isn't present in unencrypted DMs + intent = portal.MainIntent() + } + content := event.BeeperMessageStatusEventContent{ + Network: portal.getBridgeInfoStateKey(), + RelatesTo: event.RelatesTo{ + Type: event.RelReference, + EventID: evtID, + }, + DeliveredToUsers: deliveredTo, + LastRetry: lastRetry, + } + if err == nil { + content.Status = event.MessageStatusSuccess + } else { + content.Reason, content.Status, _, _, content.Message = errorToStatusReason(err) + content.Error = err.Error() + } + _, err = intent.SendMessageEvent(portal.MXID, event.BeeperMessageStatus, &content) + if err != nil { + portal.log.Err(err).Msg("Failed to send message status event") + } +} + +func (portal *Portal) sendDeliveryReceipt(eventID id.EventID) { + if portal.bridge.Config.Bridge.DeliveryReceipts { + err := portal.bridge.Bot.SendReceipt(portal.MXID, eventID, event.ReceiptTypeRead, nil) + if err != nil { + portal.log.Debug().Err(err).Stringer("event_id", eventID).Msg("Failed to send delivery receipt") + } + } +} + +func (portal *Portal) sendMessageMetrics(evt *event.Event, err error, part string, ms *metricSender) { + log := portal.log.With(). + Str("handling_step", part). + Str("event_type", evt.Type.String()). + Stringer("event_id", evt.ID). + Stringer("sender", evt.Sender). + Logger() + if evt.Type == event.EventRedaction { + log = log.With().Str("redacts", evt.Redacts.String()).Logger() + } + + origEvtID := evt.ID + if retryMeta := evt.Content.AsMessage().MessageSendRetry; retryMeta != nil { + origEvtID = retryMeta.OriginalEventID + } + if err != nil { + logEvt := portal.log.Error() + if part == "Ignoring" { + logEvt = portal.log.Debug() + } + logEvt.Err(err).Msg("Sending message metrics for event") + reason, statusCode, isCertain, sendNotice, _ := errorToStatusReason(err) + checkpointStatus := status.ReasonToCheckpointStatus(reason, statusCode) + portal.bridge.SendMessageCheckpoint(evt, status.MsgStepRemote, err, checkpointStatus, ms.getRetryNum()) + if sendNotice { + ms.setNoticeID(portal.sendErrorMessage(evt, err, isCertain, ms.getNoticeID())) + } + portal.sendStatusEvent(origEvtID, evt.ID, err, nil) + } else { + portal.log.Debug().Msg("Sending metrics for successfully handled Matrix event") + portal.sendDeliveryReceipt(evt.ID) + portal.bridge.SendMessageSuccessCheckpoint(evt, status.MsgStepRemote, ms.getRetryNum()) + var deliveredTo *[]id.UserID + if portal.IsPrivateChat() { + deliveredTo = &[]id.UserID{} + } + portal.sendStatusEvent(origEvtID, evt.ID, nil, deliveredTo) + if prevNotice := ms.popNoticeID(); prevNotice != "" { + _, _ = portal.MainIntent().RedactEvent(portal.MXID, prevNotice, mautrix.ReqRedact{ + Reason: "error resolved", + }) + } + } + if ms != nil { + portal.log.Debug().Object("timings", ms.timings).Msg("Timings for event") + } +} + +type messageTimings struct { + initReceive time.Duration + decrypt time.Duration + implicitRR time.Duration + portalQueue time.Duration + totalReceive time.Duration + + preproc time.Duration + convert time.Duration + totalSend time.Duration +} + +func niceRound(dur time.Duration) time.Duration { + switch { + case dur < time.Millisecond: + return dur + case dur < time.Second: + return dur.Round(100 * time.Microsecond) + default: + return dur.Round(time.Millisecond) + } +} + +func (mt *messageTimings) MarshalZerologObject(evt *zerolog.Event) { + evt. + Dict("bridge", zerolog.Dict(). + Str("init_receive", niceRound(mt.initReceive).String()). + Str("decrypt", niceRound(mt.decrypt).String()). + Str("queue", niceRound(mt.portalQueue).String()). + Str("total_hs_to_portal", niceRound(mt.totalReceive).String())). + Dict("portal", zerolog.Dict(). + Str("implicit_rr", niceRound(mt.implicitRR).String()). + Str("preproc", niceRound(mt.preproc).String()). + Str("convert", niceRound(mt.convert).String()). + Str("total_send", niceRound(mt.totalSend).String())) +} + +type metricSender struct { + portal *Portal + previousNotice id.EventID + lock sync.Mutex + completed bool + retryNum int + timings *messageTimings +} + +func (ms *metricSender) getRetryNum() int { + if ms != nil { + return ms.retryNum + } + return 0 +} + +func (ms *metricSender) getNoticeID() id.EventID { + if ms == nil { + return "" + } + return ms.previousNotice +} + +func (ms *metricSender) popNoticeID() id.EventID { + if ms == nil { + return "" + } + evtID := ms.previousNotice + ms.previousNotice = "" + return evtID +} + +func (ms *metricSender) setNoticeID(evtID id.EventID) { + if ms != nil && ms.previousNotice == "" { + ms.previousNotice = evtID + } +} + +func (ms *metricSender) sendMessageMetrics(evt *event.Event, err error, part string, completed bool) { + ms.lock.Lock() + defer ms.lock.Unlock() + if !completed && ms.completed { + return + } + ms.portal.sendMessageMetrics(evt, err, part, ms) + ms.retryNum++ + ms.completed = completed +} diff --git a/metrics.go b/metrics.go new file mode 100644 index 0000000..da18836 --- /dev/null +++ b/metrics.go @@ -0,0 +1,315 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2023 Element +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package main + +import ( + "context" + "net/http" + "runtime/debug" + "strconv" + "sync" + "time" + + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/promauto" + "github.com/prometheus/client_golang/prometheus/promhttp" + log "maunium.net/go/maulogger/v2" + "maunium.net/go/mautrix/event" + "maunium.net/go/mautrix/id" + + "go.mau.fi/mautrix-signal/database" +) + +type MetricsHandler struct { + db *database.Database + server *http.Server + log log.Logger + + running bool + ctx context.Context + stopRecorder func() + + matrixEventHandling *prometheus.HistogramVec + signalMessageAge prometheus.Histogram + signalMessageHandling *prometheus.HistogramVec + countCollection prometheus.Histogram + disconnections *prometheus.CounterVec + incomingRetryReceipts *prometheus.CounterVec + connectionFailures *prometheus.CounterVec + puppetCount prometheus.Gauge + userCount prometheus.Gauge + messageCount prometheus.Gauge + portalCount *prometheus.GaugeVec + encryptedGroupCount prometheus.Gauge + encryptedPrivateCount prometheus.Gauge + unencryptedGroupCount prometheus.Gauge + unencryptedPrivateCount prometheus.Gauge + + connected prometheus.Gauge + connectedState map[string]bool + connectedStateLock sync.Mutex + loggedIn prometheus.Gauge + loggedInState map[string]bool + loggedInStateLock sync.Mutex +} + +func NewMetricsHandler(address string, log log.Logger, db *database.Database) *MetricsHandler { + portalCount := promauto.NewGaugeVec(prometheus.GaugeOpts{ + Name: "bridge_portals_total", + Help: "Number of portal rooms on Matrix", + }, []string{"type", "encrypted"}) + return &MetricsHandler{ + db: db, + server: &http.Server{Addr: address, Handler: promhttp.Handler()}, + log: log, + running: false, + + matrixEventHandling: promauto.NewHistogramVec(prometheus.HistogramOpts{ + Name: "matrix_event", + Help: "Time spent processing Matrix events", + }, []string{"event_type"}), + signalMessageAge: promauto.NewHistogram(prometheus.HistogramOpts{ + Name: "remote_event_age", + Help: "Age of messages received from Signal", + Buckets: []float64{1, 2, 3, 5, 7.5, 10, 20, 30, 60}, + }), + signalMessageHandling: promauto.NewHistogramVec(prometheus.HistogramOpts{ + Name: "remote_event", + Help: "Time spent processing Signal messages", + }, []string{"message_type"}), + countCollection: promauto.NewHistogram(prometheus.HistogramOpts{ + Name: "bridge_count_collection", + Help: "Time spent collecting the bridge_*_total metrics", + }), + disconnections: promauto.NewCounterVec(prometheus.CounterOpts{ + Name: "bridge_disconnections", + Help: "Number of times a Matrix user has been disconnected from Signal", + }, []string{"user_id"}), + connectionFailures: promauto.NewCounterVec(prometheus.CounterOpts{ + Name: "bridge_connection_failures", + Help: "Number of times a connection has failed to Signal", + }, []string{"reason"}), + incomingRetryReceipts: promauto.NewCounterVec(prometheus.CounterOpts{ + Name: "bridge_incoming_retry_receipts", + Help: "Number of times a remote Signal user has requested a retry from the bridge. retry_count = 5 is usually the last attempt (and very likely means a failed message)", + }, []string{"retry_count", "message_found"}), + puppetCount: promauto.NewGauge(prometheus.GaugeOpts{ + Name: "bridge_puppets_total", + Help: "Number of Signal users bridged into Matrix", + }), + userCount: promauto.NewGauge(prometheus.GaugeOpts{ + Name: "bridge_users_total", + Help: "Number of Matrix users using the bridge", + }), + messageCount: promauto.NewGauge(prometheus.GaugeOpts{ + Name: "bridge_messages_total", + Help: "Number of messages bridged", + }), + portalCount: portalCount, + encryptedGroupCount: portalCount.With(prometheus.Labels{"type": "group", "encrypted": "true"}), + encryptedPrivateCount: portalCount.With(prometheus.Labels{"type": "private", "encrypted": "true"}), + unencryptedGroupCount: portalCount.With(prometheus.Labels{"type": "group", "encrypted": "false"}), + unencryptedPrivateCount: portalCount.With(prometheus.Labels{"type": "private", "encrypted": "false"}), + + loggedIn: promauto.NewGauge(prometheus.GaugeOpts{ + Name: "bridge_logged_in", + Help: "Bridge users logged into Signal", + }), + loggedInState: make(map[string]bool), + connected: promauto.NewGauge(prometheus.GaugeOpts{ + Name: "bridge_connected", + Help: "Bridge users connected to Signal", + }), + connectedState: make(map[string]bool), + } +} + +func noop() {} + +func (mh *MetricsHandler) TrackMatrixEvent(eventType event.Type) func() { + if !mh.running { + return noop + } + start := time.Now() + return func() { + duration := time.Now().Sub(start) + mh.matrixEventHandling. + With(prometheus.Labels{"event_type": eventType.Type}). + Observe(duration.Seconds()) + } +} + +func (mh *MetricsHandler) TrackSignalMessage(timestamp time.Time, messageType string) func() { + if !mh.running { + return noop + } + + start := time.Now() + return func() { + duration := time.Now().Sub(start) + mh.signalMessageHandling. + With(prometheus.Labels{"message_type": messageType}). + Observe(duration.Seconds()) + mh.signalMessageAge.Observe(time.Now().Sub(timestamp).Seconds()) + } +} + +func (mh *MetricsHandler) TrackDisconnection(userID id.UserID) { + if !mh.running { + return + } + mh.disconnections.With(prometheus.Labels{"user_id": string(userID)}).Inc() +} + +func (mh *MetricsHandler) TrackConnectionFailure(reason string) { + if !mh.running { + return + } + mh.connectionFailures.With(prometheus.Labels{"reason": reason}).Inc() +} + +func (mh *MetricsHandler) TrackRetryReceipt(count int, found bool) { + if !mh.running { + return + } + mh.incomingRetryReceipts.With(prometheus.Labels{ + "retry_count": strconv.Itoa(count), + "message_found": strconv.FormatBool(found), + }).Inc() +} + +func (mh *MetricsHandler) TrackLoginState(signalID string, loggedIn bool) { + if !mh.running { + return + } + mh.loggedInStateLock.Lock() + defer mh.loggedInStateLock.Unlock() + currentVal, ok := mh.loggedInState[signalID] + if !ok || currentVal != loggedIn { + mh.loggedInState[signalID] = loggedIn + if loggedIn { + mh.loggedIn.Inc() + } else { + mh.loggedIn.Dec() + } + } +} + +func (mh *MetricsHandler) TrackConnectionState(signalID string, connected bool) { + if !mh.running { + return + } + mh.connectedStateLock.Lock() + defer mh.connectedStateLock.Unlock() + currentVal, ok := mh.connectedState[signalID] + if !ok || currentVal != connected { + mh.connectedState[signalID] = connected + if connected { + mh.connected.Inc() + } else { + mh.connected.Dec() + } + } +} + +func (mh *MetricsHandler) updateStats() { + start := time.Now() + var puppetCount int + err := mh.db.QueryRowContext(mh.ctx, "SELECT COUNT(*) FROM puppet").Scan(&puppetCount) + if err != nil { + mh.log.Warnln("Failed to scan number of puppets:", err) + } else { + mh.puppetCount.Set(float64(puppetCount)) + } + + var userCount int + err = mh.db.QueryRowContext(mh.ctx, `SELECT COUNT(*) FROM "user"`).Scan(&userCount) + if err != nil { + mh.log.Warnln("Failed to scan number of users:", err) + } else { + mh.userCount.Set(float64(userCount)) + } + + var messageCount int + err = mh.db.QueryRowContext(mh.ctx, "SELECT COUNT(*) FROM message").Scan(&messageCount) + if err != nil { + mh.log.Warnln("Failed to scan number of messages:", err) + } else { + mh.messageCount.Set(float64(messageCount)) + } + + var encryptedGroupCount, encryptedPrivateCount, unencryptedGroupCount, unencryptedPrivateCount int + // TODO Use a more precise way to check if a chat_id is a UUID. + // It should also be compatible with both SQLite & Postgres. + err = mh.db.QueryRowContext(mh.ctx, ` + SELECT + COUNT(CASE WHEN chat_id NOT LIKE '%-%-%-%-%' AND encrypted THEN 1 END) AS encrypted_group_portals, + COUNT(CASE WHEN chat_id LIKE '%-%-%-%-%' AND encrypted THEN 1 END) AS encrypted_private_portals, + COUNT(CASE WHEN chat_id NOT LIKE '%-%-%-%-%' AND NOT encrypted THEN 1 END) AS unencrypted_group_portals, + COUNT(CASE WHEN chat_id LIKE '%-%-%-%-%' AND NOT encrypted THEN 1 END) AS unencrypted_private_portals + FROM portal WHERE mxid<>'' + `).Scan(&encryptedGroupCount, &encryptedPrivateCount, &unencryptedGroupCount, &unencryptedPrivateCount) + if err != nil { + mh.log.Warnln("Failed to scan number of portals:", err) + } else { + mh.encryptedGroupCount.Set(float64(encryptedGroupCount)) + mh.encryptedPrivateCount.Set(float64(encryptedPrivateCount)) + mh.unencryptedGroupCount.Set(float64(unencryptedGroupCount)) + mh.unencryptedPrivateCount.Set(float64(encryptedPrivateCount)) + } + mh.countCollection.Observe(time.Now().Sub(start).Seconds()) +} + +func (mh *MetricsHandler) startUpdatingStats() { + defer func() { + err := recover() + if err != nil { + mh.log.Fatalfln("Panic in metric updater: %v\n%s", err, string(debug.Stack())) + } + }() + ticker := time.Tick(10 * time.Second) + for { + mh.updateStats() + select { + case <-mh.ctx.Done(): + return + case <-ticker: + } + } +} + +func (mh *MetricsHandler) Start() { + mh.running = true + mh.ctx, mh.stopRecorder = context.WithCancel(context.Background()) + go mh.startUpdatingStats() + err := mh.server.ListenAndServe() + mh.running = false + if err != nil && err != http.ErrServerClosed { + mh.log.Fatalln("Error in metrics listener:", err) + } +} + +func (mh *MetricsHandler) Stop() { + if !mh.running { + return + } + mh.stopRecorder() + err := mh.server.Close() + if err != nil { + mh.log.Errorln("Error closing metrics listener:", err) + } +} diff --git a/pkg/msgconv/from-matrix.go b/msgconv/from-matrix.go similarity index 51% rename from pkg/msgconv/from-matrix.go rename to msgconv/from-matrix.go index a334afd..d0b0f83 100644 --- a/pkg/msgconv/from-matrix.go +++ b/msgconv/from-matrix.go @@ -18,67 +18,51 @@ package msgconv import ( "context" + "errors" "fmt" - "net/http" - "strings" + "time" "github.com/rs/zerolog" + "go.mau.fi/util/exerrors" "go.mau.fi/util/exmime" "go.mau.fi/util/ffmpeg" "go.mau.fi/util/variationselector" "golang.org/x/exp/constraints" "google.golang.org/protobuf/proto" - "maunium.net/go/mautrix/bridgev2" - "maunium.net/go/mautrix/bridgev2/database" "maunium.net/go/mautrix/event" - "go.mau.fi/mautrix-signal/pkg/msgconv/matrixfmt" - "go.mau.fi/mautrix-signal/pkg/signalid" + "go.mau.fi/mautrix-signal/msgconv/matrixfmt" "go.mau.fi/mautrix-signal/pkg/signalmeow" signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" ) -func (mc *MessageConverter) ToSignal( - ctx context.Context, - client *signalmeow.Client, - portal *bridgev2.Portal, - evt *event.Event, - content *event.MessageEventContent, - relaybotFormatted bool, - replyTo *database.Message, -) (*signalpb.DataMessage, error) { - ctx = context.WithValue(ctx, contextKeyClient, client) - ctx = context.WithValue(ctx, contextKeyPortal, portal) +var ( + ErrUnsupportedMsgType = errors.New("unsupported msgtype") + ErrMediaDownloadFailed = errors.New("failed to download media") + ErrMediaDecryptFailed = errors.New("failed to decrypt media") + ErrMediaConvertFailed = errors.New("failed to convert") + ErrMediaUploadFailed = errors.New("failed to upload media") + ErrInvalidGeoURI = errors.New("invalid `geo:` URI in message") +) + +func (mc *MessageConverter) ToSignal(ctx context.Context, evt *event.Event, content *event.MessageEventContent, relaybotFormatted bool) (*signalpb.DataMessage, error) { if evt.Type == event.EventSticker { content.MsgType = event.MessageType(event.EventSticker.Type) } + // Matrix timestamps can be faked, but if the user is using their own Signal account, faking timestamps is their problem. + ts := uint64(evt.Timestamp) + // However, when relaying, timestamps shouldn't be trusted because anyone can send a message with any timestamp. + if relaybotFormatted { + ts = uint64(time.Now().UnixMilli()) + } dm := &signalpb.DataMessage{ - Preview: mc.convertURLPreviewToSignal(ctx, content), + Timestamp: &ts, + Quote: mc.GetSignalReply(ctx, content), + Preview: mc.convertURLPreviewToSignal(ctx, evt), } - if replyTo != nil { - authorACI, messageID, err := signalid.ParseMessageID(replyTo.ID) - if err == nil { - dm.Quote = &signalpb.DataMessage_Quote{ - Id: proto.Uint64(messageID), - AuthorAciBinary: authorACI[:], - Type: signalpb.DataMessage_Quote_NORMAL.Enum(), - } - if replyTo.Metadata.(*signalid.MessageMetadata).ContainsAttachments { - dm.Quote.Attachments = make([]*signalpb.DataMessage_Quote_QuotedAttachment, 1) - } - } - } - if content.BeeperDisappearingTimer != nil { - dm.ExpireTimer = proto.Uint32(uint32(content.BeeperDisappearingTimer.Timer.Seconds())) - } else if portal.Disappear.Timer > 0 { - dm.ExpireTimer = proto.Uint32(uint32(portal.Disappear.Timer.Seconds())) - } - if dm.ExpireTimer != nil && *dm.ExpireTimer != 0 { - timerVersion := portal.Metadata.(*signalid.PortalMetadata).ExpirationTimerVersion - if timerVersion > 0 { - dm.ExpireTimerVersion = &timerVersion - } + if expirationTime := mc.GetData(ctx).ExpirationTime; expirationTime != 0 { + dm.ExpireTimer = proto.Uint32(uint32(expirationTime)) } if content.MsgType == event.MsgEmote && !relaybotFormatted { content.Body = "/me " + content.Body @@ -86,7 +70,7 @@ func (mc *MessageConverter) ToSignal( content.FormattedBody = "/me " + content.FormattedBody } } - body, bodyRanges := matrixfmt.Parse(ctx, mc.MatrixFmtParams, content) + body, bodyRanges := matrixfmt.Parse(mc.MatrixFmtParams, content) switch content.MsgType { case event.MsgText, event.MsgNotice, event.MsgEmote: dm.Body = proto.String(body) @@ -110,34 +94,26 @@ func (mc *MessageConverter) ToSignal( return nil, fmt.Errorf("failed to convert sticker: %w", err) } att.Flags = proto.Uint32(uint32(signalpb.AttachmentPointer_BORDERLESS)) + var emoji *string + // TODO check for single grapheme cluster? + if len([]rune(content.Body)) == 1 { + emoji = proto.String(variationselector.Remove(content.Body)) + } + dm.Sticker = &signalpb.DataMessage_Sticker{ + // Signal iOS validates that pack id/key are of the correct length. + // Android is fine with any non-nil values (like a zero-length byte string). + PackId: make([]byte, 16), + PackKey: make([]byte, 32), + StickerId: proto.Uint32(0), - dm.Sticker = ParseStickerMeta(content.Info.BridgedSticker) - if dm.Sticker == nil { - var emoji *string - // TODO check for single grapheme cluster? - if len([]rune(content.Body)) == 1 { - emoji = proto.String(variationselector.Remove(content.Body)) - } - dm.Sticker = &signalpb.DataMessage_Sticker{ - // Signal iOS validates that pack id/key are of the correct length. - // Android is fine with any non-nil values (like a zero-length byte string). - PackId: make([]byte, 16), - PackKey: make([]byte, 32), - StickerId: proto.Uint32(0), - Emoji: emoji, - } + Data: att, + Emoji: emoji, } - dm.Sticker.Data = att case event.MsgLocation: - lat, lon, err := parseGeoURI(content.GeoURI) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Invalid geo URI") - return nil, err - } - locationString := fmt.Sprintf(mc.LocationFormat, lat, lon) - dm.Body = &locationString + // TODO implement + fallthrough default: - return nil, fmt.Errorf("%w %s", bridgev2.ErrUnsupportedMessageType, content.MsgType) + return nil, fmt.Errorf("%w %s", ErrUnsupportedMsgType, content.MsgType) } return dm, nil } @@ -151,36 +127,44 @@ func maybeInt[T constraints.Integer](v T) *T { func (mc *MessageConverter) convertFileToSignal(ctx context.Context, evt *event.Event, content *event.MessageEventContent) (*signalpb.AttachmentPointer, error) { log := zerolog.Ctx(ctx) - data, err := mc.Bridge.Bot.DownloadMedia(ctx, content.URL, content.File) + mxc := content.URL + if content.File != nil { + mxc = content.File.URL + } + data, err := mc.DownloadMatrixMedia(ctx, mxc) if err != nil { - return nil, fmt.Errorf("%w: %w", bridgev2.ErrMediaDownloadFailed, err) + return nil, exerrors.NewDualError(ErrMediaDownloadFailed, err) + } + if content.File != nil { + err = content.File.DecryptInPlace(data) + if err != nil { + return nil, exerrors.NewDualError(ErrMediaDecryptFailed, err) + } } fileName := content.Body if content.FileName != "" { fileName = content.FileName } + _, isVoice := evt.Content.Raw["org.matrix.msc3245.voice"] mime := content.GetInfo().MimeType - if mime == "" { - mime = http.DetectContentType(data) - } - if content.MSC3245Voice != nil && mime != "audio/aac" && ffmpeg.Supported() { - data, err = ffmpeg.ConvertBytes(ctx, data, ".aac", []string{}, []string{"-c:a", "aac"}, mime) + if isVoice { + data, err = ffmpeg.ConvertBytes(ctx, data, ".m4a", []string{}, []string{"-c:a", "aac"}, mime) if err != nil { return nil, err } mime = "audio/aac" - fileName += ".aac" - } else if evt.Type == event.EventSticker { + fileName += ".m4a" + } else if evt.Type == event.EventSticker && mime != "image/webp" && mime != "image/png" && mime != "image/apng" { switch mime { case "image/webp", "image/png", "image/apng": // allowed case "image/gif": - if !ffmpeg.Supported() { + if !mc.ConvertGIFToAPNG { return nil, fmt.Errorf("converting gif stickers is not supported") } data, err = ffmpeg.ConvertBytes(ctx, data, ".apng", []string{}, []string{}, mime) if err != nil { - return nil, fmt.Errorf("%w (gif to apng): %w", bridgev2.ErrMediaConvertFailed, err) + return nil, fmt.Errorf("%w gif to apng: %w", ErrMediaConvertFailed, err) } fileName += ".apng" mime = "image/apng" @@ -188,17 +172,14 @@ func (mc *MessageConverter) convertFileToSignal(ctx context.Context, evt *event. return nil, fmt.Errorf("unsupported content type for sticker %s", mime) } } - att, err := getClient(ctx).UploadAttachment(ctx, data) + att, err := signalmeow.UploadAttachment(ctx, mc.GetClient(ctx), data) if err != nil { log.Err(err).Msg("Failed to upload file") - return nil, fmt.Errorf("%w: %w", bridgev2.ErrMediaReuploadFailed, err) + return nil, exerrors.NewDualError(ErrMediaUploadFailed, err) } - if content.MSC3245Voice != nil && mime == "audio/aac" { + if isVoice { att.Flags = proto.Uint32(uint32(signalpb.AttachmentPointer_VOICE_MESSAGE)) } - if content.Info.MauGIF { - att.Flags = proto.Uint32(uint32(signalpb.AttachmentPointer_GIF)) - } att.ContentType = proto.String(mime) att.FileName = &fileName att.Height = maybeInt(uint32(content.Info.Height)) @@ -210,20 +191,3 @@ func (mc *MessageConverter) convertFileToSignal(ctx context.Context, evt *event. } return att, nil } - -func parseGeoURI(uri string) (lat, long string, err error) { - if !strings.HasPrefix(uri, "geo:") { - err = fmt.Errorf("uri doesn't have geo: prefix") - return - } - // Remove geo: prefix and anything after ; - coordinates := strings.Split(strings.TrimPrefix(uri, "geo:"), ";")[0] - splitCoordinates := strings.Split(coordinates, ",") - if len(splitCoordinates) != 2 { - err = fmt.Errorf("didn't find exactly two numbers separated by a comma") - } else { - lat = splitCoordinates[0] - long = splitCoordinates[1] - } - return -} diff --git a/msgconv/from-signal.go b/msgconv/from-signal.go new file mode 100644 index 0000000..a963444 --- /dev/null +++ b/msgconv/from-signal.go @@ -0,0 +1,360 @@ +// mautrix-signal - A Matrix-Signal puppeting bridge. +// Copyright (C) 2024 Tulir Asokan +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package msgconv + +import ( + "context" + "fmt" + "net/http" + "strings" + "time" + + "github.com/rs/zerolog" + "go.mau.fi/util/exfmt" + "go.mau.fi/util/exmime" + "go.mau.fi/util/ffmpeg" + "golang.org/x/exp/slices" + "maunium.net/go/mautrix/crypto/attachment" + "maunium.net/go/mautrix/event" + + "go.mau.fi/mautrix-signal/msgconv/signalfmt" + "go.mau.fi/mautrix-signal/pkg/signalmeow" + signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" +) + +type ConvertedMessage struct { + Parts []*ConvertedMessagePart + Timestamp uint64 + DisappearIn uint32 +} + +func (cm *ConvertedMessage) MergeCaption() { + if len(cm.Parts) != 2 || cm.Parts[1].Content.MsgType != event.MsgText { + return + } + switch cm.Parts[0].Content.MsgType { + case event.MsgImage, event.MsgVideo, event.MsgAudio, event.MsgFile: + default: + return + } + mediaContent := cm.Parts[0].Content + textContent := cm.Parts[1].Content + mediaContent.FileName = mediaContent.Body + mediaContent.Body = textContent.Body + mediaContent.Format = textContent.Format + mediaContent.FormattedBody = textContent.FormattedBody + cm.Parts = cm.Parts[:1] +} + +type ConvertedMessagePart struct { + Type event.Type + Content *event.MessageEventContent + Extra map[string]any +} + +func calculateLength(dm *signalpb.DataMessage) int { + if dm.GetFlags()&uint32(signalpb.DataMessage_EXPIRATION_TIMER_UPDATE) != 0 { + return 1 + } + if dm.Sticker != nil { + return 1 + } + length := len(dm.Attachments) + len(dm.Contact) + if dm.Body != nil { + length++ + } + if dm.Payment != nil { + length++ + } + if dm.GiftBadge != nil { + length++ + } + if length == 0 && dm.GetRequiredProtocolVersion() > uint32(signalpb.DataMessage_CURRENT) { + length = 1 + } + return length +} + +func CanConvertSignal(dm *signalpb.DataMessage) bool { + return calculateLength(dm) > 0 +} + +func (mc *MessageConverter) ToMatrix(ctx context.Context, dm *signalpb.DataMessage) *ConvertedMessage { + cm := &ConvertedMessage{ + Timestamp: dm.GetTimestamp(), + DisappearIn: dm.GetExpireTimer(), + Parts: make([]*ConvertedMessagePart, 0, calculateLength(dm)), + } + if dm.GetFlags()&uint32(signalpb.DataMessage_EXPIRATION_TIMER_UPDATE) != 0 { + cm.Parts = append(cm.Parts, mc.convertDisappearingTimerChangeToMatrix(ctx, dm)) + // Don't disappear disappearing timer changes + cm.DisappearIn = 0 + // Don't allow any other parts in a disappearing timer change message + return cm + } + if dm.Sticker != nil { + cm.Parts = append(cm.Parts, mc.convertStickerToMatrix(ctx, dm.Sticker)) + // Don't allow any other parts in a sticker message + return cm + } + for i, att := range dm.GetAttachments() { + cm.Parts = append(cm.Parts, mc.convertAttachmentToMatrix(ctx, i, att)) + } + for _, contact := range dm.GetContact() { + cm.Parts = append(cm.Parts, mc.convertContactToMatrix(ctx, contact)) + } + if dm.Payment != nil { + cm.Parts = append(cm.Parts, mc.convertPaymentToMatrix(ctx, dm.Payment)) + } + if dm.GiftBadge != nil { + cm.Parts = append(cm.Parts, mc.convertGiftBadgeToMatrix(ctx, dm.GiftBadge)) + } + if dm.Body != nil { + cm.Parts = append(cm.Parts, mc.convertTextToMatrix(ctx, dm)) + } + if len(cm.Parts) == 0 && dm.GetRequiredProtocolVersion() > uint32(signalpb.DataMessage_CURRENT) { + cm.Parts = append(cm.Parts, &ConvertedMessagePart{ + Type: event.EventMessage, + Content: &event.MessageEventContent{ + MsgType: event.MsgNotice, + Body: "The bridge does not support this message type yet.", + }, + }) + } + replyTo, sender := mc.GetMatrixReply(ctx, dm.Quote) + for _, part := range cm.Parts { + if part.Content.Mentions == nil { + part.Content.Mentions = &event.Mentions{} + } + if replyTo != "" { + part.Content.RelatesTo = (&event.RelatesTo{}).SetReplyTo(replyTo) + if !slices.Contains(part.Content.Mentions.UserIDs, sender) { + part.Content.Mentions.UserIDs = append(part.Content.Mentions.UserIDs, sender) + } + } + } + return cm +} + +func (mc *MessageConverter) convertDisappearingTimerChangeToMatrix(ctx context.Context, dm *signalpb.DataMessage) *ConvertedMessagePart { + part := &ConvertedMessagePart{ + Type: event.EventMessage, + Content: &event.MessageEventContent{ + MsgType: event.MsgNotice, + Body: fmt.Sprintf("Disappearing messages set to %s", exfmt.Duration(time.Duration(dm.GetExpireTimer())*time.Second)), + }, + } + if dm.GetExpireTimer() == 0 { + part.Content.Body = "Disappearing messages disabled" + } + portal := mc.GetData(ctx) + portal.ExpirationTime = int(dm.GetExpireTimer()) + err := portal.Update(ctx) + if err != nil { + zerolog.Ctx(ctx).Err(err).Msg("Failed to update portal disappearing timer in database") + } + return part +} + +func (mc *MessageConverter) convertTextToMatrix(ctx context.Context, dm *signalpb.DataMessage) *ConvertedMessagePart { + content := signalfmt.Parse(dm.GetBody(), dm.GetBodyRanges(), mc.SignalFmtParams) + extra := map[string]any{} + if len(dm.Preview) > 0 { + extra["com.beeper.linkpreviews"] = mc.convertURLPreviewsToBeeper(ctx, dm.Preview) + } + return &ConvertedMessagePart{ + Type: event.EventMessage, + Content: content, + Extra: extra, + } +} + +func (mc *MessageConverter) convertPaymentToMatrix(ctx context.Context, payment *signalpb.DataMessage_Payment) *ConvertedMessagePart { + return &ConvertedMessagePart{ + Type: event.EventMessage, + Content: &event.MessageEventContent{ + MsgType: event.MsgNotice, + Body: "Payments are not yet supported", + }, + Extra: map[string]any{ + "fi.mau.signal.payment": payment, + }, + } +} + +func (mc *MessageConverter) convertGiftBadgeToMatrix(ctx context.Context, giftBadge *signalpb.DataMessage_GiftBadge) *ConvertedMessagePart { + return &ConvertedMessagePart{ + Type: event.EventMessage, + Content: &event.MessageEventContent{ + MsgType: event.MsgNotice, + Body: "Gift badges are not yet supported", + }, + Extra: map[string]any{ + "fi.mau.signal.gift_badge": giftBadge, + }, + } +} + +func (mc *MessageConverter) convertContactToMatrix(ctx context.Context, contact *signalpb.DataMessage_Contact) *ConvertedMessagePart { + return &ConvertedMessagePart{ + Type: event.EventMessage, + Content: &event.MessageEventContent{ + MsgType: event.MsgNotice, + Body: "Contact messages are not yet supported", + }, + Extra: map[string]any{ + "fi.mau.signal.contact": contact, + }, + } +} + +func (mc *MessageConverter) convertAttachmentToMatrix(ctx context.Context, index int, att *signalpb.AttachmentPointer) *ConvertedMessagePart { + part, err := mc.reuploadAttachment(ctx, att) + if err != nil { + zerolog.Ctx(ctx).Err(err).Int("attachment_index", index).Msg("Failed to handle attachment") + return &ConvertedMessagePart{ + Type: event.EventMessage, + Content: &event.MessageEventContent{ + MsgType: event.MsgNotice, + Body: fmt.Sprintf("Failed to handle attachment %s: %v", att.GetFileName(), err), + }, + } + } + return part +} + +func (mc *MessageConverter) convertStickerToMatrix(ctx context.Context, sticker *signalpb.DataMessage_Sticker) *ConvertedMessagePart { + converted, err := mc.reuploadAttachment(ctx, sticker.GetData()) + if err != nil { + zerolog.Ctx(ctx).Err(err).Msg("Failed to handle sticker") + return &ConvertedMessagePart{ + Type: event.EventMessage, + Content: &event.MessageEventContent{ + MsgType: event.MsgNotice, + Body: fmt.Sprintf("Failed to handle sticker: %v", err), + }, + } + } + // Signal stickers are 512x512, so tell Matrix clients to render them as 256x256 + if converted.Content.Info.Width == 512 && converted.Content.Info.Height == 512 { + converted.Content.Info.Width = 256 + converted.Content.Info.Height = 256 + } + converted.Content.Body = sticker.GetEmoji() + converted.Type = event.EventSticker + converted.Content.MsgType = "" + // TODO fetch full pack metadata like the old bridge did? + converted.Extra["fi.mau.signal.sticker"] = map[string]any{ + "id": sticker.GetStickerId(), + "emoji": sticker.GetEmoji(), + "pack": map[string]any{ + "id": sticker.GetPackId(), + "key": sticker.GetPackKey(), + }, + } + // Hack for bad clients like Element X which don't support encrypted stickers. + // This requires thumbnail_file to be set (which is done in reuploadAttachment). + // It works because Element X supports encrypted thumbnails on stickers, + // so just add an empty url field to pass validation. + // TODO remove once ruma fixes https://github.com/matrix-org/matrix-spec/issues/1667 + if converted.Content.File != nil { + converted.Extra["url"] = "" + } + return converted +} + +func (mc *MessageConverter) reuploadAttachment(ctx context.Context, att *signalpb.AttachmentPointer) (*ConvertedMessagePart, error) { + data, err := signalmeow.DownloadAttachment(ctx, att) + if err != nil { + return nil, fmt.Errorf("failed to download attachment: %w", err) + } + mimeType := att.GetContentType() + if mimeType == "" { + mimeType = http.DetectContentType(data) + } + fileName := att.GetFileName() + extra := map[string]any{} + if mc.ConvertVoiceMessages && att.GetFlags()&uint32(signalpb.AttachmentPointer_VOICE_MESSAGE) != 0 { + data, err = ffmpeg.ConvertBytes(ctx, data, ".ogg", []string{}, []string{"-c:a", "libopus"}, mimeType) + if err != nil { + return nil, fmt.Errorf("failed to convert audio to ogg/opus: %w", err) + } + fileName += ".ogg" + mimeType = "audio/ogg" + extra["org.matrix.msc3245.voice"] = map[string]any{} + extra["org.matrix.msc1767.audio"] = map[string]any{} + } + var file *event.EncryptedFileInfo + uploadMime := mimeType + uploadFileName := fileName + if mc.GetData(ctx).Encrypted { + file = &event.EncryptedFileInfo{ + EncryptedFile: *attachment.NewEncryptedFile(), + URL: "", + } + file.EncryptInPlace(data) + uploadMime = "application/octet-stream" + uploadFileName = "" + } + mxc, err := mc.UploadMatrixMedia(ctx, data, uploadFileName, uploadMime) + if err != nil { + return nil, err + } + content := &event.MessageEventContent{ + Body: fileName, + Info: &event.FileInfo{ + MimeType: mimeType, + Width: int(att.GetWidth()), + Height: int(att.GetHeight()), + Size: len(data), + }, + } + if att.GetBlurHash() != "" { + content.Info.Blurhash = att.GetBlurHash() + content.Info.AnoaBlurhash = att.GetBlurHash() + } + switch strings.Split(mimeType, "/")[0] { + case "image": + content.MsgType = event.MsgImage + case "video": + content.MsgType = event.MsgVideo + case "audio": + content.MsgType = event.MsgAudio + default: + content.MsgType = event.MsgFile + } + if content.Body == "" { + content.Body = strings.TrimPrefix(string(content.MsgType), "m.") + exmime.ExtensionFromMimetype(mimeType) + } + if file != nil { + file.URL = mxc + content.File = file + } else { + content.URL = mxc + } + // Hack for bad clients like Element iOS as well as stickers on Element X Android/iOS + // TODO remove once Element iOS is deprecated? + infoCopy := *content.Info + content.Info.ThumbnailInfo = &infoCopy + content.Info.ThumbnailURL = content.URL + content.Info.ThumbnailFile = content.File + return &ConvertedMessagePart{ + Type: event.EventMessage, + Content: content, + Extra: extra, + }, nil +} diff --git a/pkg/msgconv/matrixfmt/convert.go b/msgconv/matrixfmt/convert.go similarity index 82% rename from pkg/msgconv/matrixfmt/convert.go rename to msgconv/matrixfmt/convert.go index 5318735..8e20e52 100644 --- a/pkg/msgconv/matrixfmt/convert.go +++ b/msgconv/matrixfmt/convert.go @@ -17,20 +17,18 @@ package matrixfmt import ( - "context" - "maunium.net/go/mautrix/event" signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" ) -func Parse(ctx context.Context, parser *HTMLParser, content *event.MessageEventContent) (string, []*signalpb.BodyRange) { +func Parse(parser *HTMLParser, content *event.MessageEventContent) (string, []*signalpb.BodyRange) { if content.Format != event.FormatHTML { return content.Body, nil } - parseCtx := NewContext(ctx) - parseCtx.AllowedMentions = content.Mentions - parsed := parser.Parse(content.FormattedBody, parseCtx) + ctx := NewContext() + ctx.AllowedMentions = content.Mentions + parsed := parser.Parse(content.FormattedBody, ctx) if parsed == nil { return "", nil } diff --git a/pkg/msgconv/matrixfmt/convert_test.go b/msgconv/matrixfmt/convert_test.go similarity index 80% rename from pkg/msgconv/matrixfmt/convert_test.go rename to msgconv/matrixfmt/convert_test.go index 1ade316..0ee2514 100644 --- a/pkg/msgconv/matrixfmt/convert_test.go +++ b/msgconv/matrixfmt/convert_test.go @@ -1,7 +1,6 @@ package matrixfmt_test import ( - "context" "fmt" "testing" @@ -10,12 +9,12 @@ import ( "maunium.net/go/mautrix/event" "maunium.net/go/mautrix/id" - "go.mau.fi/mautrix-signal/pkg/msgconv/matrixfmt" - "go.mau.fi/mautrix-signal/pkg/msgconv/signalfmt" + "go.mau.fi/mautrix-signal/msgconv/matrixfmt" + "go.mau.fi/mautrix-signal/msgconv/signalfmt" ) var formatParams = &matrixfmt.HTMLParser{ - GetUUIDFromMXID: func(_ context.Context, id id.UserID) uuid.UUID { + GetUUIDFromMXID: func(id id.UserID) uuid.UUID { if id.Homeserver() == "signal" { return uuid.MustParse(id.Localpart()) } @@ -24,7 +23,7 @@ var formatParams = &matrixfmt.HTMLParser{ } func TestParse_Empty(t *testing.T) { - text, entities := matrixfmt.Parse(context.TODO(), formatParams, &event.MessageEventContent{ + text, entities := matrixfmt.Parse(formatParams, &event.MessageEventContent{ MsgType: event.MsgText, Body: "", }) @@ -33,7 +32,7 @@ func TestParse_Empty(t *testing.T) { } func TestParse_EmptyHTML(t *testing.T) { - text, entities := matrixfmt.Parse(context.TODO(), formatParams, &event.MessageEventContent{ + text, entities := matrixfmt.Parse(formatParams, &event.MessageEventContent{ MsgType: event.MsgText, Body: "", Format: event.FormatHTML, @@ -44,7 +43,7 @@ func TestParse_EmptyHTML(t *testing.T) { } func TestParse_Plaintext(t *testing.T) { - text, entities := matrixfmt.Parse(context.TODO(), formatParams, &event.MessageEventContent{ + text, entities := matrixfmt.Parse(formatParams, &event.MessageEventContent{ MsgType: event.MsgText, Body: "Hello world!", }) @@ -65,13 +64,6 @@ func TestParse_HTML(t *testing.T) { Length: 5, Value: signalfmt.StyleBold, }}}, - {name: "UnnecessaryWhitespace", in: " Hello , World!", out: "Hello, World!", ent: signalfmt.BodyRangeList{{ - Start: 0, - Length: 5, - Value: signalfmt.StyleBold, - }}}, - {name: "UnnecessaryWhitespaceParagraph", in: "

Hello

", out: "Hello"}, - {name: "EmptyParagraph", in: "

Hello

", out: "Hello"}, { name: "MultiBasic", in: "Hello, World!", @@ -160,7 +152,7 @@ func TestParse_HTML(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { fmt.Println("--------------------------------------------------------------------------------") - parsed := formatParams.Parse(test.in, matrixfmt.NewContext(context.TODO())) + parsed := formatParams.Parse(test.in, matrixfmt.NewContext()) assert.Equal(t, test.out, parsed.String.String()) assert.Equal(t, test.ent, parsed.Entities) }) diff --git a/pkg/msgconv/matrixfmt/html.go b/msgconv/matrixfmt/html.go similarity index 96% rename from pkg/msgconv/matrixfmt/html.go rename to msgconv/matrixfmt/html.go index 958ccc3..074caff 100644 --- a/pkg/msgconv/matrixfmt/html.go +++ b/msgconv/matrixfmt/html.go @@ -1,19 +1,18 @@ package matrixfmt import ( - "context" "fmt" "math" - "slices" "strconv" "strings" "github.com/google/uuid" + "golang.org/x/exp/slices" "golang.org/x/net/html" "maunium.net/go/mautrix/event" "maunium.net/go/mautrix/id" - "go.mau.fi/mautrix-signal/pkg/msgconv/signalfmt" + "go.mau.fi/mautrix-signal/msgconv/signalfmt" ) type EntityString struct { @@ -81,26 +80,22 @@ func (es *EntityString) TrimSpace() *EntityString { return nil } DebugLog("TRIMSPACE %q %+v\n", es.String, es.Entities) - cutStart := 0 - for ; cutStart < len(es.String); cutStart++ { + var cutEnd, cutStart int + for cutStart = 0; cutStart < len(es.String); cutStart++ { switch es.String[cutStart] { case '\t', '\n', '\v', '\f', '\r', ' ', 0x85, 0xA0: continue } break } - cutEnd := len(es.String) - for ; cutEnd > cutStart; cutEnd-- { - switch es.String[cutEnd-1] { + for cutEnd = len(es.String) - 1; cutEnd >= 0; cutEnd-- { + switch es.String[cutEnd] { case '\t', '\n', '\v', '\f', '\r', ' ', 0x85, 0xA0: continue } break } - if cutEnd == cutStart { - DebugLog(" -> EMPTY\n") - return NewEntityString("") - } + cutEnd++ if cutStart == 0 && cutEnd == len(es.String) { DebugLog(" -> NOOP\n") return es @@ -206,15 +201,13 @@ func (ts TagStack) Has(tag string) bool { } type Context struct { - Ctx context.Context AllowedMentions *event.Mentions TagStack TagStack PreserveWhitespace bool } -func NewContext(ctx context.Context) Context { +func NewContext() Context { return Context{ - Ctx: ctx, TagStack: make(TagStack, 0, 4), } } @@ -231,7 +224,7 @@ func (ctx Context) WithWhitespace() Context { // HTMLParser is a somewhat customizable Matrix HTML parser. type HTMLParser struct { - GetUUIDFromMXID func(context.Context, id.UserID) uuid.UUID + GetUUIDFromMXID func(id.UserID) uuid.UUID } // TaggedString is a string that also contains a HTML tag. @@ -285,6 +278,7 @@ func (parser *HTMLParser) listToString(node *html.Node, ctx Context) *EntityStri continue } var prefix string + // TODO make bullets and numbering configurable if ordered { indexPadding := indentLength - Digits(counter) if indexPadding < 0 { @@ -362,7 +356,7 @@ func (parser *HTMLParser) linkToString(node *html.Node, ctx Context) *EntityStri // Mention not allowed, use name as-is return str } - u := parser.GetUUIDFromMXID(ctx.Ctx, mxid) + u := parser.GetUUIDFromMXID(mxid) if u == uuid.Nil { // Don't include the link for mentions of non-Signal users, the name is enough return str diff --git a/msgconv/msgconv.go b/msgconv/msgconv.go new file mode 100644 index 0000000..d22f402 --- /dev/null +++ b/msgconv/msgconv.go @@ -0,0 +1,62 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2024 Tulir Asokan +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package msgconv + +import ( + "context" + + "github.com/google/uuid" + "maunium.net/go/mautrix/event" + "maunium.net/go/mautrix/id" + + "go.mau.fi/mautrix-signal/database" + "go.mau.fi/mautrix-signal/msgconv/matrixfmt" + "go.mau.fi/mautrix-signal/msgconv/signalfmt" + "go.mau.fi/mautrix-signal/pkg/signalmeow" + signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" +) + +type PortalMethods interface { + UploadMatrixMedia(ctx context.Context, data []byte, fileName, contentType string) (id.ContentURIString, error) + DownloadMatrixMedia(ctx context.Context, uri id.ContentURIString) ([]byte, error) + GetMatrixReply(ctx context.Context, msg *signalpb.DataMessage_Quote) (replyTo id.EventID, replyTargetSender id.UserID) + GetSignalReply(ctx context.Context, content *event.MessageEventContent) *signalpb.DataMessage_Quote + + GetClient(ctx context.Context) *signalmeow.Device + + GetData(ctx context.Context) *database.Portal +} + +type ExtendedPortalMethods interface { + QueueFileTransfer(ctx context.Context, msgTS uint64, fileName string, ap *signalpb.AttachmentPointer) (id.ContentURIString, error) +} + +type MessageConverter struct { + PortalMethods + + SignalFmtParams *signalfmt.FormatParams + MatrixFmtParams *matrixfmt.HTMLParser + + ConvertVoiceMessages bool + ConvertGIFToAPNG bool + MaxFileSize int64 + AsyncFiles bool +} + +func (mc *MessageConverter) IsPrivateChat(ctx context.Context) bool { + return mc.GetData(ctx).UserID() != uuid.Nil +} diff --git a/pkg/msgconv/signalfmt/convert.go b/msgconv/signalfmt/convert.go similarity index 80% rename from pkg/msgconv/signalfmt/convert.go rename to msgconv/signalfmt/convert.go index 412af36..317374d 100644 --- a/pkg/msgconv/signalfmt/convert.go +++ b/msgconv/signalfmt/convert.go @@ -17,14 +17,12 @@ package signalfmt import ( - "context" "html" - "slices" "strings" "github.com/google/uuid" - "github.com/rs/zerolog" "golang.org/x/exp/maps" + "golang.org/x/exp/slices" "maunium.net/go/mautrix/event" "maunium.net/go/mautrix/id" @@ -37,7 +35,7 @@ type UserInfo struct { } type FormatParams struct { - GetUserInfo func(ctx context.Context, uuid uuid.UUID) UserInfo + GetUserInfo func(uuid uuid.UUID) UserInfo } type formatContext struct { @@ -51,7 +49,7 @@ func (ctx formatContext) TextToHTML(text string) string { return event.TextToHTML(text) } -func Parse(ctx context.Context, message string, ranges []*signalpb.BodyRange, params *FormatParams) *event.MessageEventContent { +func Parse(message string, ranges []*signalpb.BodyRange, params *FormatParams) *event.MessageEventContent { content := &event.MessageEventContent{ MsgType: event.MsgText, Body: message, @@ -86,27 +84,15 @@ func Parse(ctx context.Context, message string, ranges []*signalpb.BodyRange, pa Start: int(*r.Start), Length: int(*r.Length), }.TruncateEnd(maxLength) - var mentionACI uuid.UUID switch rv := r.GetAssociatedValue().(type) { case *signalpb.BodyRange_Style_: br.Value = Style(rv.Style) case *signalpb.BodyRange_MentionAci: - var err error - mentionACI, err = uuid.Parse(rv.MentionAci) + parsed, err := uuid.Parse(rv.MentionAci) if err != nil { continue } - case *signalpb.BodyRange_MentionAciBinary: - if len(rv.MentionAciBinary) != 16 { - continue - } - mentionACI = uuid.UUID(rv.MentionAciBinary) - default: - zerolog.Ctx(ctx).Warn().Type("value_type", rv).Msg("Unsupported body range type") - continue - } - if mentionACI != uuid.Nil { - userInfo := params.GetUserInfo(ctx, mentionACI) + userInfo := params.GetUserInfo(parsed) if userInfo.MXID == "" { continue } @@ -115,7 +101,7 @@ func Parse(ctx context.Context, message string, ranges []*signalpb.BodyRange, pa // Maybe use NewUTF16String and do index replacements for the plaintext body too, // or just replace the plaintext body by parsing the generated HTML. content.Body = strings.Replace(content.Body, "\uFFFC", userInfo.Name, 1) - br.Value = Mention{UserInfo: userInfo, UUID: mentionACI} + br.Value = Mention{UserInfo: userInfo, UUID: parsed} } lrt.Add(br) } diff --git a/pkg/msgconv/signalfmt/convert_test.go b/msgconv/signalfmt/convert_test.go similarity index 96% rename from pkg/msgconv/signalfmt/convert_test.go rename to msgconv/signalfmt/convert_test.go index eb65542..eaed12d 100644 --- a/pkg/msgconv/signalfmt/convert_test.go +++ b/msgconv/signalfmt/convert_test.go @@ -17,7 +17,6 @@ package signalfmt_test import ( - "context" "testing" "github.com/google/uuid" @@ -26,7 +25,7 @@ import ( "maunium.net/go/mautrix/event" "maunium.net/go/mautrix/id" - "go.mau.fi/mautrix-signal/pkg/msgconv/signalfmt" + "go.mau.fi/mautrix-signal/msgconv/signalfmt" signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" ) @@ -34,7 +33,7 @@ var realUser = uuid.New() func TestParse(t *testing.T) { formatParams := &signalfmt.FormatParams{ - GetUserInfo: func(ctx context.Context, uuid uuid.UUID) signalfmt.UserInfo { + GetUserInfo: func(uuid uuid.UUID) signalfmt.UserInfo { if uuid == realUser { return signalfmt.UserInfo{ MXID: "@test:example.com", @@ -169,7 +168,7 @@ func TestParse(t *testing.T) { } for _, test := range tests { t.Run(test.name, func(t *testing.T) { - parsed := signalfmt.Parse(context.TODO(), test.ins, test.ine, formatParams) + parsed := signalfmt.Parse(test.ins, test.ine, formatParams) assert.Equal(t, test.body, parsed.Body) assert.Equal(t, test.html, parsed.FormattedBody) }) diff --git a/pkg/msgconv/signalfmt/html.go b/msgconv/signalfmt/html.go similarity index 100% rename from pkg/msgconv/signalfmt/html.go rename to msgconv/signalfmt/html.go diff --git a/pkg/msgconv/signalfmt/tags.go b/msgconv/signalfmt/tags.go similarity index 96% rename from pkg/msgconv/signalfmt/tags.go rename to msgconv/signalfmt/tags.go index b273e0e..043bb43 100644 --- a/pkg/msgconv/signalfmt/tags.go +++ b/msgconv/signalfmt/tags.go @@ -40,8 +40,8 @@ func (m Mention) String() string { } func (m Mention) Proto() signalpb.BodyRangeAssociatedValue { - return &signalpb.BodyRange_MentionAciBinary{ - MentionAciBinary: m.UUID[:], + return &signalpb.BodyRange_MentionAci{ + MentionAci: m.UUID.String(), } } diff --git a/pkg/msgconv/signalfmt/tree.go b/msgconv/signalfmt/tree.go similarity index 100% rename from pkg/msgconv/signalfmt/tree.go rename to msgconv/signalfmt/tree.go diff --git a/msgconv/urlpreview.go b/msgconv/urlpreview.go new file mode 100644 index 0000000..2a14442 --- /dev/null +++ b/msgconv/urlpreview.go @@ -0,0 +1,143 @@ +// mautrix-signal - A Matrix-Signal puppeting bridge. +// Copyright (C) 2024 Tulir Asokan +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package msgconv + +import ( + "context" + "encoding/json" + "regexp" + "time" + + "github.com/rs/zerolog" + "github.com/tidwall/gjson" + "google.golang.org/protobuf/proto" + + "maunium.net/go/mautrix" + "maunium.net/go/mautrix/event" + + "go.mau.fi/mautrix-signal/pkg/signalmeow" + signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" +) + +type BeeperLinkPreview struct { + mautrix.RespPreviewURL + MatchedURL string `json:"matched_url"` + ImageEncryption *event.EncryptedFileInfo `json:"beeper:image:encryption,omitempty"` +} + +func (mc *MessageConverter) convertURLPreviewsToBeeper(ctx context.Context, preview []*signalpb.Preview) []*BeeperLinkPreview { + output := make([]*BeeperLinkPreview, len(preview)) + for i, p := range preview { + output[i] = mc.convertURLPreviewToBeeper(ctx, p) + } + return output +} + +func (mc *MessageConverter) convertURLPreviewToBeeper(ctx context.Context, preview *signalpb.Preview) *BeeperLinkPreview { + output := &BeeperLinkPreview{ + MatchedURL: preview.GetUrl(), + RespPreviewURL: mautrix.RespPreviewURL{ + CanonicalURL: preview.GetUrl(), + Title: preview.GetTitle(), + Description: preview.GetDescription(), + }, + } + if preview.Image != nil { + msg, err := mc.reuploadAttachment(ctx, preview.Image) + if err != nil { + zerolog.Ctx(ctx).Err(err).Msg("Failed to reupload link preview image") + } else { + output.ImageURL = msg.Content.URL + output.ImageEncryption = msg.Content.File + output.ImageType = msg.Content.Info.MimeType + output.ImageSize = msg.Content.Info.Size + output.ImageHeight = msg.Content.Info.Height + output.ImageWidth = msg.Content.Info.Width + } + } + return output +} + +var URLRegex = regexp.MustCompile(`https?://[^\s/_*]+(?:/\S*)?`) + +func (mc *MessageConverter) convertURLPreviewToSignal(ctx context.Context, evt *event.Event) []*signalpb.Preview { + var previews []*BeeperLinkPreview + + log := zerolog.Ctx(ctx) + rawPreview := gjson.GetBytes(evt.Content.VeryRaw, `com\.beeper\.linkpreviews`) + if rawPreview.Exists() && rawPreview.IsArray() { + if err := json.Unmarshal([]byte(rawPreview.Raw), &previews); err != nil || len(previews) == 0 { + return nil + } + } /* else if portal.bridge.Config.Bridge.URLPreviews { + if matchedURL := URLRegex.FindString(evt.Content.AsMessage().Body); len(matchedURL) == 0 { + return nil + } else if parsed, err := url.Parse(matchedURL); err != nil { + return nil + } else if parsed.Host, err = idna.ToASCII(parsed.Host); err != nil { + return nil + } else if mxPreview, err := portal.MainIntent().GetURLPreview(parsed.String()); err != nil { + log.Err(err).Str("matched_url", matchedURL).Msg("Failed to fetch preview for URL found in message") + return nil + } else { + previews = []*BeeperLinkPreview{{ + RespPreviewURL: *mxPreview, + MatchedURL: matchedURL, + }} + } + }*/ + if len(previews) == 0 { + return nil + } + output := make([]*signalpb.Preview, len(previews)) + for i, preview := range previews { + output[i] = &signalpb.Preview{ + Url: proto.String(preview.MatchedURL), + Title: proto.String(preview.Title), + Description: proto.String(preview.Description), + Date: proto.Uint64(uint64(time.Now().UnixMilli())), + } + imageMXC := preview.ImageURL + if preview.ImageEncryption != nil { + imageMXC = preview.ImageEncryption.URL + } + if imageMXC != "" { + data, err := mc.DownloadMatrixMedia(ctx, imageMXC) + if err != nil { + log.Err(err).Int("preview_index", i).Msg("Failed to download URL preview image") + continue + } + if preview.ImageEncryption != nil { + err = preview.ImageEncryption.DecryptInPlace(data) + if err != nil { + log.Err(err).Int("preview_index", i).Msg("Failed to decrypt URL preview image") + continue + } + } + uploaded, err := signalmeow.UploadAttachment(ctx, mc.GetClient(ctx), data) + if err != nil { + log.Err(err).Int("preview_index", i).Msg("Failed to reupload URL preview image") + continue + } + uploaded.ContentType = proto.String(preview.ImageType) + uploaded.Width = proto.Uint32(uint32(preview.ImageWidth)) + uploaded.Height = proto.Uint32(uint32(preview.ImageHeight)) + output[i].Image = uploaded + } + } + return output +} diff --git a/pkg/connector/backfill.go b/pkg/connector/backfill.go deleted file mode 100644 index b7b2a23..0000000 --- a/pkg/connector/backfill.go +++ /dev/null @@ -1,207 +0,0 @@ -// mautrix-signal - A Matrix-Signal puppeting bridge. -// Copyright (C) 2025 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package connector - -import ( - "context" - "fmt" - "slices" - "time" - - "github.com/google/uuid" - "github.com/rs/zerolog" - "go.mau.fi/util/ptr" - "maunium.net/go/mautrix/bridgev2" - "maunium.net/go/mautrix/bridgev2/networkid" - - "go.mau.fi/mautrix-signal/pkg/msgconv" - "go.mau.fi/mautrix-signal/pkg/signalid" - "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf/backuppb" - "go.mau.fi/mautrix-signal/pkg/signalmeow/store" -) - -var _ bridgev2.BackfillingNetworkAPI = (*SignalClient)(nil) - -func tryCastUUID(b []byte) uuid.UUID { - if len(b) == 16 { - return uuid.UUID(b) - } - return uuid.Nil -} - -func (s *SignalClient) FetchMessages(ctx context.Context, params bridgev2.FetchMessagesParams) (*bridgev2.FetchMessagesResponse, error) { - if !s.IsLoggedIn() { - return nil, bridgev2.ErrNotLoggedIn - } - userID, groupID, err := signalid.ParsePortalID(params.Portal.ID) - if err != nil { - return nil, fmt.Errorf("failed to parse portal ID: %w", err) - } - var chat *store.BackupChat - if groupID != "" { - chat, err = s.Client.Store.BackupStore.GetBackupChatByGroupID(ctx, groupID) - } else { - chat, err = s.Client.Store.BackupStore.GetBackupChatByUserID(ctx, userID) - } - if err != nil { - return nil, fmt.Errorf("failed to get chat: %w", err) - } else if chat == nil { - zerolog.Ctx(ctx).Debug().Msg("Chat not found, returning nil response for backfill") - return nil, nil - } - var anchorTS time.Time - if params.AnchorMessage != nil { - anchorTS = params.AnchorMessage.Timestamp - } - minTS := anchorTS - items, err := s.Client.Store.BackupStore.GetBackupChatItems(ctx, chat.Id, anchorTS, params.Forward, params.Count) - if err != nil { - return nil, fmt.Errorf("failed to get chat items: %w", err) - } - if len(items) > 0 { - minTS = time.UnixMilli(int64(items[0].DateSent)) - } - // GetBackupChatItems returns in reverse chronological order, so flip the list - slices.Reverse(items) - var firstDirectionfulProcessed bool - var isRead bool - convertedMessages := make([]*bridgev2.BackfillMessage, 0, len(items)) - attMap := make(msgconv.AttachmentMap) - recipientMap := make(map[uint64]*backuppb.Recipient) - getRecipientACI := func(id uint64) (uuid.UUID, error) { - recipient, ok := recipientMap[id] - if !ok { - recipient, err = s.Client.Store.BackupStore.GetBackupRecipient(ctx, id) - if err != nil { - return uuid.Nil, fmt.Errorf("failed to get recipient %d: %w", id, err) - } else if len(recipient.GetContact().GetAci()) != 16 && recipient.GetSelf() == nil { - zerolog.Ctx(ctx).Warn(). - Uint64("recipient_id", id). - Type("recipient_type", recipient.GetDestination()). - Msg("ACI not found for recipient") - } - recipientMap[id] = recipient - } - - switch dest := recipient.Destination.(type) { - case *backuppb.Recipient_Self: - return s.Client.Store.ACI, nil - case *backuppb.Recipient_Contact: - if len(dest.Contact.GetAci()) == 16 { - return uuid.UUID(dest.Contact.GetAci()), nil - } - } - return uuid.Nil, nil - } - var prevStreamOrder int64 - findNextStreamOrder := func(i int) int64 { - for ; i < len(items); i++ { - inc, ok := items[i].DirectionalDetails.(*backuppb.ChatItem_Incoming) - if ok { - return int64(inc.Incoming.GetDateServerSent()) - } - } - return time.Now().UnixMilli() - } - for i, item := range items { - var streamOrder int64 - switch dt := item.DirectionalDetails.(type) { - case *backuppb.ChatItem_Incoming: - streamOrder = int64(dt.Incoming.GetDateServerSent()) - prevStreamOrder = streamOrder - if !firstDirectionfulProcessed { - firstDirectionfulProcessed = true - isRead = dt.Incoming.Read - } - case *backuppb.ChatItem_Outgoing: - streamOrder = int64(item.GetDateSent()) - // Ensure stream order is higher than previous incoming item, but lower than next incoming item - streamOrder = min(streamOrder, findNextStreamOrder(i+1)-1) - streamOrder = max(streamOrder, prevStreamOrder+1) - - if !firstDirectionfulProcessed { - firstDirectionfulProcessed = true - isRead = true - } - } - if len(attMap) > 0 { - clear(attMap) - } - senderACI, err := getRecipientACI(item.AuthorId) - if err != nil { - return nil, err - } else if senderACI == uuid.Nil { - continue - } - dm, reactions := msgconv.BackupToDataMessage(item, attMap) - if dm == nil { - continue - } - cm := s.Main.MsgConv.ToMatrix(ctx, s.Client, params.Portal, senderACI, s.Main.Bridge.Bot, dm, attMap) - convertedReactions := make([]*bridgev2.BackfillReaction, 0, len(reactions)) - for _, reaction := range reactions { - reactionSenderACI, err := getRecipientACI(reaction.AuthorId) - if err != nil { - return nil, err - } else if reactionSenderACI == uuid.Nil { - continue - } - convertedReactions = append(convertedReactions, &bridgev2.BackfillReaction{ - TargetPart: ptr.Ptr(networkid.PartID("")), - Timestamp: time.UnixMilli(int64(reaction.SentTimestamp)), - Sender: s.makeEventSender(reactionSenderACI), - Emoji: reaction.GetEmoji(), - }) - } - msgID := signalid.MakeMessageID(senderACI, item.DateSent) - convertedMessages = append(convertedMessages, &bridgev2.BackfillMessage{ - ConvertedMessage: cm, - Sender: s.makeEventSender(senderACI), - ID: msgID, - TxnID: networkid.TransactionID(msgID), - Timestamp: time.UnixMilli(int64(item.DateSent)), - StreamOrder: streamOrder, - Reactions: convertedReactions, - }) - } - return &bridgev2.FetchMessagesResponse{ - Messages: convertedMessages, - HasMore: len(items) >= params.Count, - Forward: params.Forward, - MarkRead: isRead, - ApproxTotalCount: chat.TotalMessages, - CompleteCallback: func() { - // When reaching the last backwards backfill batch, delete the chat from the backup store. - // If backwards backfilling isn't enabled, delete immediately after the first backfill request. - if (!params.Forward && len(items) < params.Count) || !s.Main.Bridge.Config.Backfill.Queue.AnyEnabled() { - err := s.Client.Store.BackupStore.DeleteBackupChat(ctx, chat.Id) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to delete chat from backup store") - } else { - zerolog.Ctx(ctx).Debug().Msg("Deleted chat from backup store as backfill seems finished") - } - } else { - err := s.Client.Store.BackupStore.DeleteBackupChatItems(ctx, chat.Id, minTS) - if err != nil { - zerolog.Ctx(ctx).Err(err).Time("min_ts", minTS).Msg("Failed to delete messages from backup store") - } else { - zerolog.Ctx(ctx).Debug().Time("min_ts", minTS).Msg("Deleted messages from backup store") - } - } - }, - }, nil -} diff --git a/pkg/connector/capabilities.go b/pkg/connector/capabilities.go deleted file mode 100644 index 5eab6a8..0000000 --- a/pkg/connector/capabilities.go +++ /dev/null @@ -1,241 +0,0 @@ -// mautrix-signal - A Matrix-Signal puppeting bridge. -// Copyright (C) 2025 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package connector - -import ( - "context" - "time" - - "go.mau.fi/util/ffmpeg" - "go.mau.fi/util/jsontime" - "go.mau.fi/util/ptr" - - "maunium.net/go/mautrix/bridgev2" - "maunium.net/go/mautrix/bridgev2/database" - "maunium.net/go/mautrix/bridgev2/networkid" - "maunium.net/go/mautrix/event" -) - -func supportedIfFFmpeg() event.CapabilitySupportLevel { - if ffmpeg.Supported() { - return event.CapLevelPartialSupport - } - return event.CapLevelRejected -} - -func capID() string { - base := "fi.mau.signal.capabilities.2026_05_12" - if ffmpeg.Supported() { - return base + "+ffmpeg" - } - return base -} - -const MaxFileSize = 100 * 1024 * 1024 -const MaxTextLength = 2000 - -var signalCaps = &event.RoomFeatures{ - ID: capID(), - - Formatting: map[event.FormattingFeature]event.CapabilitySupportLevel{ - // Features that Signal supports natively - event.FmtBold: event.CapLevelFullySupported, - event.FmtItalic: event.CapLevelFullySupported, - event.FmtStrikethrough: event.CapLevelFullySupported, - event.FmtSpoiler: event.CapLevelFullySupported, - event.FmtInlineCode: event.CapLevelFullySupported, - event.FmtCodeBlock: event.CapLevelFullySupported, - event.FmtUserLink: event.CapLevelFullySupported, - - // Features that aren't supported on Signal, but are converted into a markdown-like representation - event.FmtBlockquote: event.CapLevelPartialSupport, - event.FmtInlineLink: event.CapLevelPartialSupport, - event.FmtUnorderedList: event.CapLevelPartialSupport, - event.FmtOrderedList: event.CapLevelPartialSupport, - event.FmtListStart: event.CapLevelPartialSupport, - event.FmtHeaders: event.CapLevelPartialSupport, - }, - File: map[event.CapabilityMsgType]*event.FileFeatures{ - event.MsgImage: { - MimeTypes: map[string]event.CapabilitySupportLevel{ - "image/gif": event.CapLevelFullySupported, - "image/png": event.CapLevelFullySupported, - "image/jpeg": event.CapLevelFullySupported, - "image/webp": event.CapLevelFullySupported, - "image/bmp": event.CapLevelFullySupported, - }, - MaxWidth: 4096, - MaxHeight: 4096, - MaxSize: MaxFileSize, - Caption: event.CapLevelFullySupported, - MaxCaptionLength: MaxTextLength, - }, - event.MsgVideo: { - MimeTypes: map[string]event.CapabilitySupportLevel{ - "video/mp4": event.CapLevelFullySupported, - "video/ogg": event.CapLevelFullySupported, - "video/webm": event.CapLevelFullySupported, - }, - MaxSize: MaxFileSize, - Caption: event.CapLevelFullySupported, - MaxCaptionLength: MaxTextLength, - }, - event.MsgAudio: { - MimeTypes: map[string]event.CapabilitySupportLevel{ - "audio/aac": event.CapLevelFullySupported, - "audio/mpeg": event.CapLevelFullySupported, - }, - MaxSize: MaxFileSize, - }, - event.MsgFile: { - MimeTypes: map[string]event.CapabilitySupportLevel{ - "*/*": event.CapLevelFullySupported, - }, - MaxSize: MaxFileSize, - Caption: event.CapLevelFullySupported, - MaxCaptionLength: MaxTextLength, - }, - event.CapMsgSticker: { - MimeTypes: map[string]event.CapabilitySupportLevel{ - // Signal clients will only render static webp, so apng is preferred - "image/webp": event.CapLevelPartialSupport, - "image/png": event.CapLevelFullySupported, - "image/apng": event.CapLevelFullySupported, - "image/gif": supportedIfFFmpeg(), - }, - Caption: event.CapLevelDropped, - MaxSize: MaxFileSize, - }, - event.CapMsgVoice: { - MimeTypes: map[string]event.CapabilitySupportLevel{ - "audio/aac": event.CapLevelFullySupported, - "audio/ogg": supportedIfFFmpeg(), - }, - Caption: event.CapLevelDropped, - MaxSize: MaxFileSize, - MaxDuration: ptr.Ptr(jsontime.S(1 * time.Hour)), - }, - event.CapMsgGIF: { - MimeTypes: map[string]event.CapabilitySupportLevel{ - "image/gif": event.CapLevelFullySupported, - "video/mp4": event.CapLevelFullySupported, - }, - Caption: event.CapLevelFullySupported, - MaxSize: MaxFileSize, - }, - }, - State: event.StateFeatureMap{ - event.StateRoomName.Type: {Level: event.CapLevelFullySupported}, - event.StateRoomAvatar.Type: {Level: event.CapLevelFullySupported}, - event.StateTopic.Type: {Level: event.CapLevelFullySupported}, - event.StateBeeperDisappearingTimer.Type: {Level: event.CapLevelFullySupported}, - }, - MemberActions: event.MemberFeatureMap{ - event.MemberActionInvite: event.CapLevelFullySupported, - event.MemberActionRevokeInvite: event.CapLevelFullySupported, - event.MemberActionLeave: event.CapLevelFullySupported, - event.MemberActionBan: event.CapLevelFullySupported, - event.MemberActionKick: event.CapLevelFullySupported, - }, - MaxTextLength: MaxTextLength, // TODO support arbitrary sized text messages with files - LocationMessage: event.CapLevelPartialSupport, - Poll: event.CapLevelRejected, - Thread: event.CapLevelUnsupported, - Reply: event.CapLevelFullySupported, - Edit: event.CapLevelFullySupported, - EditMaxCount: 10, - EditMaxAge: ptr.Ptr(jsontime.S(24 * time.Hour)), - Delete: event.CapLevelFullySupported, - DeleteForMe: false, - DeleteMaxAge: ptr.Ptr(jsontime.S(24 * time.Hour)), - DisappearingTimer: signalDisappearingCap, - - Reaction: event.CapLevelFullySupported, - ReactionCount: 1, - AllowedReactions: nil, - CustomEmojiReactions: false, - ReadReceipts: true, - TypingNotifications: true, - - DeleteChat: true, - MessageRequest: &event.MessageRequestFeatures{ - AcceptWithMessage: event.CapLevelPartialSupport, - AcceptWithButton: event.CapLevelFullySupported, - }, -} - -var signalDisappearingCap = &event.DisappearingTimerCapability{ - Types: []event.DisappearingType{event.DisappearingTypeAfterRead}, -} - -var signalCapsNoteToSelf *event.RoomFeatures -var signalCapsDM *event.RoomFeatures - -func init() { - signalCapsDM = ptr.Clone(signalCaps) - signalCapsDM.ID = capID() + "+dm" - signalCapsDM.MemberActions = nil - signalCapsDM.State = event.StateFeatureMap{ - event.StateBeeperDisappearingTimer.Type: {Level: event.CapLevelFullySupported}, - } - signalCapsNoteToSelf = ptr.Clone(signalCapsDM) - signalCapsNoteToSelf.EditMaxAge = nil - signalCapsNoteToSelf.DeleteMaxAge = nil - signalCapsNoteToSelf.ID = capID() + "+note_to_self" -} - -func (s *SignalClient) GetCapabilities(ctx context.Context, portal *bridgev2.Portal) *event.RoomFeatures { - if portal.Receiver == s.UserLogin.ID && portal.ID == networkid.PortalID(s.UserLogin.ID) { - return signalCapsNoteToSelf - } else if portal.RoomType == database.RoomTypeDM { - return signalCapsDM - } - return signalCaps -} - -var signalGeneralCaps = &bridgev2.NetworkGeneralCapabilities{ - DisappearingMessages: true, - AggressiveUpdateInfo: true, - ImplicitReadReceipts: true, - Provisioning: bridgev2.ProvisioningCapabilities{ - ImagePackImport: true, - ResolveIdentifier: bridgev2.ResolveIdentifierCapabilities{ - CreateDM: true, - LookupPhone: true, - LookupUsername: false, // TODO implement - ContactList: true, - }, - GroupCreation: map[string]bridgev2.GroupTypeCapabilities{ - "group": { - TypeDescription: "a group chat", - - Name: bridgev2.GroupFieldCapability{Allowed: true, Required: true, MaxLength: 32}, - Avatar: bridgev2.GroupFieldCapability{Allowed: true}, - Disappear: bridgev2.GroupFieldCapability{Allowed: true, DisappearSettings: signalDisappearingCap}, - Participants: bridgev2.GroupFieldCapability{Allowed: true}, - }, - }, - }, -} - -func (s *SignalConnector) GetCapabilities() *bridgev2.NetworkGeneralCapabilities { - return signalGeneralCaps -} - -func (s *SignalConnector) GetBridgeInfoVersion() (info, capabilities int) { - return 1, 8 -} diff --git a/pkg/connector/chatinfo.go b/pkg/connector/chatinfo.go deleted file mode 100644 index 0d48c45..0000000 --- a/pkg/connector/chatinfo.go +++ /dev/null @@ -1,495 +0,0 @@ -// mautrix-signal - A Matrix-Signal puppeting bridge. -// Copyright (C) 2024 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package connector - -import ( - "context" - "crypto/sha256" - "fmt" - "strconv" - "strings" - "time" - - "github.com/google/uuid" - "github.com/rs/zerolog" - "go.mau.fi/util/ptr" - "maunium.net/go/mautrix" - "maunium.net/go/mautrix/bridgev2" - "maunium.net/go/mautrix/bridgev2/database" - "maunium.net/go/mautrix/bridgev2/networkid" - "maunium.net/go/mautrix/event" - "maunium.net/go/mautrix/id" - - "go.mau.fi/mautrix-signal/pkg/libsignalgo" - "go.mau.fi/mautrix-signal/pkg/signalid" - "go.mau.fi/mautrix-signal/pkg/signalmeow" - "go.mau.fi/mautrix-signal/pkg/signalmeow/store" - "go.mau.fi/mautrix-signal/pkg/signalmeow/types" -) - -var ( - _ bridgev2.IdentifierResolvingNetworkAPI = (*SignalClient)(nil) - _ bridgev2.GroupCreatingNetworkAPI = (*SignalClient)(nil) - _ bridgev2.ContactListingNetworkAPI = (*SignalClient)(nil) - _ bridgev2.GhostDMCreatingNetworkAPI = (*SignalClient)(nil) -) - -var _ bridgev2.IdentifierValidatingNetwork = (*SignalConnector)(nil) - -const PrivateChatTopic = "Signal private chat" -const NoteToSelfName = "Signal Note to Self" - -func (s *SignalClient) GetUserInfoWithRefreshAfter(ctx context.Context, ghost *bridgev2.Ghost, refreshAfter time.Duration) (*bridgev2.UserInfo, error) { - userID, err := signalid.ParseUserIDAsServiceID(ghost.ID) - if err != nil { - return nil, err - } - if ghost.Name != "" && s.Main.Bridge.Background { - // Don't do unnecessary fetches in background mode - return nil, nil - } - var contact *types.Recipient - if userID.Type == libsignalgo.ServiceIDTypePNI { - contact, err = s.Client.Store.RecipientStore.LoadAndUpdateRecipient(ctx, uuid.Nil, userID.UUID, nil) - } else { - contact, err = s.Client.ContactByACIWithRefreshAfter(ctx, userID.UUID, refreshAfter) - } - if err != nil { - return nil, err - } - meta := ghost.Metadata.(*signalid.GhostMetadata) - if userID.Type != libsignalgo.ServiceIDTypePNI && (!s.Main.Config.UseOutdatedProfiles && meta.ProfileFetchedAt.After(contact.Profile.FetchedAt)) { - return nil, nil - } - return s.contactToUserInfo(ctx, contact) -} - -func (s *SignalClient) GetUserInfo(ctx context.Context, ghost *bridgev2.Ghost) (*bridgev2.UserInfo, error) { - return s.GetUserInfoWithRefreshAfter(ctx, ghost, signalmeow.DefaultProfileRefreshAfter) -} - -func (s *SignalClient) GetChatInfo(ctx context.Context, portal *bridgev2.Portal) (*bridgev2.ChatInfo, error) { - userID, groupID, err := signalid.ParsePortalID(portal.ID) - if err != nil { - return nil, fmt.Errorf("failed to parse portal id: %w", err) - } - if groupID != "" { - return s.getGroupInfo(ctx, groupID, 0, nil) - } else { - aci, pni := userID.ToACIAndPNI() - contact, err := s.Client.Store.RecipientStore.LoadAndUpdateRecipient(ctx, aci, pni, nil) - if err != nil { - return nil, err - } - return s.makeCreateDMResponse(ctx, contact, nil).PortalInfo, nil - } -} - -func (s *SignalClient) contactToUserInfo(ctx context.Context, contact *types.Recipient) (*bridgev2.UserInfo, error) { - isBot := false - ui := &bridgev2.UserInfo{ - IsBot: &isBot, - Identifiers: []string{}, - ExtraUpdates: func(ctx context.Context, ghost *bridgev2.Ghost) (changed bool) { - meta := ghost.Metadata.(*signalid.GhostMetadata) - if meta.ProfileFetchedAt.Before(contact.Profile.FetchedAt) { - changed = meta.ProfileFetchedAt.IsZero() && !contact.Profile.FetchedAt.IsZero() - meta.ProfileFetchedAt.Time = contact.Profile.FetchedAt - } - return false - }, - } - if contact.E164 != "" { - ui.Identifiers = append(ui.Identifiers, "tel:"+contact.E164) - } - name := s.Main.Config.FormatDisplayname(contact) - ui.Name = &name - if s.Main.Config.UseContactAvatars && contact.ContactAvatar.Hash != "" { - ui.Avatar = &bridgev2.Avatar{ - ID: networkid.AvatarID("hash:" + contact.ContactAvatar.Hash), - Get: func(ctx context.Context) ([]byte, error) { - if contact.ContactAvatar.Image == nil { - return nil, fmt.Errorf("contact avatar not available") - } - return contact.ContactAvatar.Image, nil - }, - } - } else if contact.Profile.AvatarPath == "clear" { - ui.Avatar = &bridgev2.Avatar{ - ID: "", - Remove: true, - } - } else if contact.Profile.AvatarPath != "" { - ui.Avatar = &bridgev2.Avatar{ - ID: makeAvatarPathID(contact.Profile.AvatarPath), - } - - if s.Main.MsgConv.DirectMedia { - userID, err := signalid.ParseUserLoginID(s.UserLogin.ID) - if err != nil { - return nil, fmt.Errorf("failed to parse user login ID: %w", err) - } - mediaID, err := signalid.DirectMediaProfileAvatar{ - UserID: userID, - ContactID: contact.ACI, - ProfileAvatarPath: contact.Profile.AvatarPath, - }.AsMediaID() - if err != nil { - return nil, err - } - ui.Avatar.MXC, err = s.Main.Bridge.Matrix.GenerateContentURI(ctx, mediaID) - if err != nil { - return nil, err - } - ui.Avatar.Hash = signalid.HashMediaID(mediaID) - } else { - ui.Avatar.Get = func(ctx context.Context) ([]byte, error) { - return s.Client.DownloadUserAvatar(ctx, contact.Profile.AvatarPath, contact.Profile.Key) - } - } - } - return ui, nil -} - -func (s *SignalConnector) ValidateUserID(id networkid.UserID) bool { - _, err := signalid.ParseUserIDAsServiceID(id) - return err == nil -} - -func (s *SignalClient) CreateChatWithGhost(ctx context.Context, ghost *bridgev2.Ghost) (*bridgev2.CreateChatResponse, error) { - parsedID, err := signalid.ParseUserIDAsServiceID(ghost.ID) - if err != nil { - return nil, err - } - resp, err := s.ResolveIdentifier(ctx, parsedID.String(), true) - if err != nil { - return nil, err - } else if resp == nil { - return nil, nil - } - resultID, err := signalid.ParseUserIDAsServiceID(resp.UserID) - if err != nil { - return nil, fmt.Errorf("failed to parse result user ID: %w", err) - } - if parsedID.Type == libsignalgo.ServiceIDTypePNI { - if resultID.Type == libsignalgo.ServiceIDTypeACI && !resultID.IsEmpty() { - resp.Chat.DMRedirectedTo = resp.UserID - } else { - resp.Chat.DMRedirectedTo = bridgev2.SpecialValueDMRedirectedToBot - } - } - return resp.Chat, nil -} - -func (s *SignalClient) ResolveIdentifier(ctx context.Context, number string, _ bool) (*bridgev2.ResolveIdentifierResponse, error) { - var aci, pni uuid.UUID - var e164Number uint64 - var recipient *types.Recipient - serviceID, err := signalid.ParseUserIDAsServiceID(networkid.UserID(number)) - if err != nil { - number, err = bridgev2.CleanPhoneNumber(number) - if err != nil { - return nil, bridgev2.WrapRespErr(err, mautrix.MInvalidParam) - } - e164Number, err = strconv.ParseUint(strings.TrimPrefix(number, "+"), 10, 64) - if err != nil { - return nil, bridgev2.WrapRespErr(fmt.Errorf("error parsing phone number: %w", err), mautrix.MInvalidParam) - } - e164String := fmt.Sprintf("+%d", e164Number) - if recipient, err = s.Client.ContactByE164(ctx, e164String); err != nil { - return nil, fmt.Errorf("error looking up number in local contact list: %w", err) - } else if recipient != nil && (recipient.ACI == uuid.Nil || !s.Client.Store.RecipientStore.IsUnregistered(ctx, libsignalgo.NewACIServiceID(recipient.ACI))) { - aci = recipient.ACI - pni = recipient.PNI - } else if resp, err := s.Client.LookupPhone(ctx, e164Number); err != nil { - return nil, fmt.Errorf("error looking up number on server: %w", err) - } else { - aci = resp[e164Number].ACI - pni = resp[e164Number].PNI - if aci == uuid.Nil && pni == uuid.Nil { - return nil, nil - } - recipient, err = s.Client.Store.RecipientStore.UpdateRecipientE164(ctx, aci, pni, e164String) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to save recipient entry after looking up phone") - } - aci, pni = recipient.ACI, recipient.PNI - if aci != uuid.Nil { - s.Client.Store.RecipientStore.MarkUnregistered(ctx, libsignalgo.NewACIServiceID(aci), false) - } - } - } else { - aci, pni = serviceID.ToACIAndPNI() - recipient, err = s.Client.Store.RecipientStore.LoadAndUpdateRecipient(ctx, aci, pni, nil) - if err != nil { - return nil, fmt.Errorf("error loading recipient: %w", err) - } - } - zerolog.Ctx(ctx).Debug(). - Uint64("e164", e164Number). - Stringer("aci", aci). - Stringer("pni", pni). - Msg("Found resolve identifier target user") - - userInfo, err := s.contactToUserInfo(ctx, recipient) - if err != nil { - return nil, fmt.Errorf("failed to convert contact: %w", err) - } - - var userID networkid.UserID - if aci != uuid.Nil { - userID = signalid.MakeUserID(aci) - } else { - userID = signalid.MakeUserIDFromServiceID(libsignalgo.NewPNIServiceID(pni)) - } - // createChat is a no-op: chats don't need to be created, and we always return chat info - resp := &bridgev2.ResolveIdentifierResponse{ - UserID: userID, - UserInfo: userInfo, - Chat: s.makeCreateDMResponse(ctx, recipient, nil), - } - resp.Ghost, err = s.Main.Bridge.GetGhostByID(ctx, resp.UserID) - if err != nil { - return nil, fmt.Errorf("failed to get ghost: %w", err) - } - return resp, nil -} - -func (s *SignalClient) CreateGroup(ctx context.Context, params *bridgev2.GroupCreateParams) (*bridgev2.CreateChatResponse, error) { - group := &signalmeow.Group{ - Title: ptr.Val(params.Name).Name, - Members: make([]*signalmeow.GroupMember, 1, len(params.Participants)+1), - Description: ptr.Val(params.Topic).Topic, - AnnouncementsOnly: false, - DisappearingMessagesDuration: uint32(ptr.Val(params.Disappear).Timer.Seconds()), - AccessControl: &signalmeow.GroupAccessControl{ - Members: signalmeow.AccessControl_MEMBER, - AddFromInviteLink: signalmeow.AccessControl_UNSATISFIABLE, - Attributes: signalmeow.AccessControl_ADMINISTRATOR, - }, - } - var pl *event.PowerLevelsEventContent - // TODO actually get PLs - if pl != nil { - if pl.EventsDefault > pl.UsersDefault { - group.AnnouncementsOnly = true - } - if pl.Invite() > pl.UsersDefault { - group.AccessControl.Members = signalmeow.AccessControl_ADMINISTRATOR - } - if pl.GetEventLevel(event.StateRoomName) <= pl.UsersDefault { - group.AccessControl.Attributes = signalmeow.AccessControl_MEMBER - } - } - group.Members[0] = &signalmeow.GroupMember{ - ACI: s.Client.Store.ACI, - Role: signalmeow.GroupMember_ADMINISTRATOR, - } - currentTS := uint64(time.Now().UnixMilli()) - for _, member := range params.Participants { - userID, err := signalid.ParseUserIDAsServiceID(member) - if err != nil { - return nil, fmt.Errorf("invalid user ID %q: %w", member, err) - } - if userID.Type == libsignalgo.ServiceIDTypeACI { - group.Members = append(group.Members, &signalmeow.GroupMember{ - ACI: userID.UUID, - Role: signalmeow.GroupMember_DEFAULT, // TODO set proper role from power levels - }) - } else if userID.Type == libsignalgo.ServiceIDTypePNI { - // TODO check if this is correct - group.PendingMembers = append(group.PendingMembers, &signalmeow.PendingMember{ - ServiceID: userID, - Role: signalmeow.GroupMember_DEFAULT, - AddedByUserID: s.Client.Store.ACI, - Timestamp: currentTS, - }) - } - } - _, err := signalmeow.PrepareGroupCreation(group) - if err != nil { - return nil, fmt.Errorf("failed to prepare group creation: %w", err) - } - var avatarBytes []byte - var avatarMXC id.ContentURIString - if params.Avatar != nil && params.Avatar.URL != "" { - avatarMXC = params.Avatar.URL - avatarBytes, err = s.Main.Bridge.Bot.DownloadMedia(ctx, params.Avatar.URL, nil) - if err != nil { - return nil, fmt.Errorf("failed to download avatar: %w", err) - } - group.AvatarPath, err = s.Client.UploadGroupAvatar(ctx, avatarBytes, group.GroupIdentifier, group.GroupMasterKey) - if err != nil { - return nil, fmt.Errorf("failed to upload avatar: %w", err) - } - } - portal, err := s.Main.Bridge.GetPortalByKey(ctx, s.makePortalKey(string(group.GroupIdentifier))) - if err != nil { - return nil, fmt.Errorf("failed to get portal: %w", err) - } - if params.RoomID != "" { - err = portal.UpdateMatrixRoomID(ctx, params.RoomID, bridgev2.UpdateMatrixRoomIDParams{SyncDBMetadata: func() { - portal.Name = group.Title - portal.NameSet = true - portal.Topic = group.Description - portal.TopicSet = true - portal.AvatarHash = sha256.Sum256(avatarBytes) - portal.AvatarSet = true - portal.AvatarMXC = avatarMXC - portal.AvatarID = makeAvatarPathID(group.AvatarPath) - if group.DisappearingMessagesDuration > 0 { - portal.Disappear = database.DisappearingSetting{ - Type: event.DisappearingTypeAfterRead, - Timer: time.Duration(group.DisappearingMessagesDuration) * time.Second, - } - } - }}) - if err != nil { - return nil, fmt.Errorf("failed to set portal room ID: %w", err) - } - } - resp, err := s.Client.CreateGroup(ctx, group) - if err != nil { - return nil, fmt.Errorf("failed to create group: %w", err) - } - if params.RoomID != "" { - // UpdateMatrixRoomID could do this for us if we passed ChatInfoSource to it, - // but we only want to do it after the group is successfully created - portal.UpdateBridgeInfo(ctx) - portal.UpdateCapabilities(ctx, s.UserLogin, true) - } - wrappedInfo, err := s.wrapGroupInfo(ctx, resp, nil) - if err != nil { - return nil, fmt.Errorf("failed to wrap group info for sync: %w", err) - } - return &bridgev2.CreateChatResponse{ - PortalKey: portal.PortalKey, - Portal: portal, - PortalInfo: wrappedInfo, - }, nil -} - -func (s *SignalClient) GetContactList(ctx context.Context) ([]*bridgev2.ResolveIdentifierResponse, error) { - recipients, err := s.Client.Store.RecipientStore.LoadAllContacts(ctx) - if err != nil { - return nil, err - } - resp := make([]*bridgev2.ResolveIdentifierResponse, len(recipients)) - for i, recipient := range recipients { - userInfo, err := s.contactToUserInfo(ctx, recipient) - if err != nil { - return nil, fmt.Errorf("failed to convert contact: %w", err) - } - recipientResp := &bridgev2.ResolveIdentifierResponse{ - UserInfo: userInfo, - Chat: s.makeCreateDMResponse(ctx, recipient, nil), - } - if recipient.ACI != uuid.Nil { - recipientResp.UserID = signalid.MakeUserID(recipient.ACI) - ghost, err := s.Main.Bridge.GetGhostByID(ctx, recipientResp.UserID) - if err != nil { - return nil, fmt.Errorf("failed to get ghost for %s: %w", recipient.ACI, err) - } - recipientResp.Ghost = ghost - } else { - recipientResp.UserID = signalid.MakeUserIDFromServiceID(libsignalgo.NewPNIServiceID(recipient.PNI)) - } - resp[i] = recipientResp - } - return resp, nil -} - -func (s *SignalClient) makeCreateDMResponse(ctx context.Context, recipient *types.Recipient, backupChat *store.BackupChat) *bridgev2.CreateChatResponse { - namePtr := bridgev2.DefaultChatName - topic := PrivateChatTopic - selfUser := s.makeEventSender(s.Client.Store.ACI) - members := &bridgev2.ChatMemberList{ - IsFull: true, - MemberMap: map[networkid.UserID]bridgev2.ChatMember{ - selfUser.Sender: { - EventSender: selfUser, - Membership: event.MembershipJoin, - PowerLevel: &moderatorPL, - }, - }, - PowerLevels: &bridgev2.PowerLevelOverrides{ - Events: map[event.Type]int{ - event.StateRoomName: 0, - event.StateTopic: 0, - event.StateRoomAvatar: 0, - event.StateBeeperDisappearingTimer: 0, - }, - }, - } - if s.Main.Config.NumberInTopic && recipient.E164 != "" { - topic = fmt.Sprintf("%s with %s", PrivateChatTopic, recipient.E164) - } - var serviceID libsignalgo.ServiceID - var avatar *bridgev2.Avatar - if recipient.ACI == uuid.Nil { - namePtr = ptr.Ptr(s.Main.Config.FormatDisplayname(recipient)) - serviceID = libsignalgo.NewPNIServiceID(recipient.PNI) - } else { - if backupChat == nil { - var err error - backupChat, err = s.Client.Store.BackupStore.GetBackupChatByUserID(ctx, libsignalgo.NewACIServiceID(recipient.ACI)) - if err != nil { - zerolog.Ctx(ctx).Warn().Err(err).Msg("Failed to get backup chat for recipient") - } - } - members.OtherUserID = signalid.MakeUserID(recipient.ACI) - if recipient.ACI == s.Client.Store.ACI { - namePtr = ptr.Ptr(NoteToSelfName) - avatar = &bridgev2.Avatar{ - ID: networkid.AvatarID(s.Main.Config.NoteToSelfAvatar), - Remove: len(s.Main.Config.NoteToSelfAvatar) == 0, - MXC: s.Main.Config.NoteToSelfAvatar, - Hash: sha256.Sum256([]byte(s.Main.Config.NoteToSelfAvatar)), - } - } else { - // The other user is only present if their ACI is known - recipientUser := s.makeEventSender(recipient.ACI) - members.MemberMap[recipientUser.Sender] = bridgev2.ChatMember{ - EventSender: recipientUser, - Membership: event.MembershipJoin, - PowerLevel: &moderatorPL, - } - } - serviceID = libsignalgo.NewACIServiceID(recipient.ACI) - } - return &bridgev2.CreateChatResponse{ - PortalKey: s.makeDMPortalKey(serviceID), - PortalInfo: &bridgev2.ChatInfo{ - Name: namePtr, - Avatar: avatar, - Topic: &topic, - Members: members, - Type: ptr.Ptr(database.RoomTypeDM), - - MessageRequest: ptr.Ptr(recipient.ACI != uuid.Nil && recipient.ProbablyMessageRequest()), - CanBackfill: backupChat != nil, - ExtraUpdates: updatePortalSyncMeta, - }, - } -} - -func makeAvatarPathID(avatarPath string) networkid.AvatarID { - if avatarPath == "" { - return "" - } - return networkid.AvatarID("path:" + avatarPath) -} diff --git a/pkg/connector/chatsync.go b/pkg/connector/chatsync.go deleted file mode 100644 index 636cad7..0000000 --- a/pkg/connector/chatsync.go +++ /dev/null @@ -1,180 +0,0 @@ -// mautrix-signal - A Matrix-Signal puppeting bridge. -// Copyright (C) 2025 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package connector - -import ( - "context" - "encoding/base64" - "time" - - "github.com/google/uuid" - "github.com/rs/zerolog" - "maunium.net/go/mautrix/bridgev2" - "maunium.net/go/mautrix/bridgev2/simplevent" - - "go.mau.fi/mautrix-signal/pkg/libsignalgo" - "go.mau.fi/mautrix-signal/pkg/signalid" - "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf/backuppb" - "go.mau.fi/mautrix-signal/pkg/signalmeow/types" -) - -func (s *SignalClient) stopChatSync() { - if cancel := s.cancelChatSync.Swap(nil); cancel != nil { - (*cancel)() - } -} - -func (s *SignalClient) syncChats(ctx context.Context, cancel context.CancelFunc) { - defer cancel() - - if s.UserLogin.Metadata.(*signalid.UserLoginMetadata).ChatsSynced { - return - } - - if s.Client.Store.EphemeralBackupKey != nil { - zerolog.Ctx(ctx).Info().Msg("Fetching transfer archive before syncing chats") - meta, err := s.Client.WaitForTransfer(ctx) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to request transfer archive") - return - } else if meta.Error != "" { - zerolog.Ctx(ctx).Error().Str("error_type", meta.Error).Msg("Transfer archive request was rejected") - s.UserLogin.Metadata.(*signalid.UserLoginMetadata).ChatsSynced = true - err = s.UserLogin.Save(ctx) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to save user login metadata after transfer archive request was rejected") - } - return - } - err = s.Client.FetchAndProcessTransfer(ctx, meta) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to fetch and process transfer archive") - return - } - zerolog.Ctx(ctx).Info().Msg("Transfer archive fetched and processed, syncing chats") - } - chats, err := s.Client.Store.BackupStore.GetBackupChats(ctx) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to get chats from backup store") - return - } - zerolog.Ctx(ctx).Info().Int("chat_count", len(chats)).Msg("Fetched chats to sync from database") - for _, chat := range chats { - if ctx.Err() != nil { - zerolog.Ctx(ctx).Debug(). - AnErr("ctx_err", ctx.Err()). - Msg("Context cancelled while syncing chats, stopping") - return - } - recipient, err := s.Client.Store.BackupStore.GetBackupRecipient(ctx, chat.RecipientId) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to get recipient for chat") - continue - } else if recipient == nil { - zerolog.Ctx(ctx).Warn(). - Uint64("backup_chat_id", chat.Id). - Uint64("backup_recipient_id", chat.RecipientId). - Msg("No recipient found for chat") - continue - } - resyncEvt := &simplevent.ChatResync{ - EventMeta: simplevent.EventMeta{ - Type: bridgev2.RemoteEventChatResync, - LogContext: func(c zerolog.Context) zerolog.Context { - return c. - Int("message_count", chat.TotalMessages). - Uint64("backup_chat_id", chat.Id). - Uint64("backup_recipient_id", chat.RecipientId) - }, - CreatePortal: true, - }, - LatestMessageTS: time.UnixMilli(int64(chat.LatestMessageID)), - } - switch dest := recipient.Destination.(type) { - case *backuppb.Recipient_Contact: - aci := tryCastUUID(dest.Contact.GetAci()) - pni := tryCastUUID(dest.Contact.GetPni()) - if chat.TotalMessages == 0 { - zerolog.Ctx(ctx).Debug(). - Stringer("aci", aci). - Stringer("pni", pni). - Uint64("e164", dest.Contact.GetE164()). - Msg("Skipping direct chat with no messages and deleting data") - err = s.Client.Store.BackupStore.DeleteBackupChat(ctx, chat.Id) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to delete chat from backup store") - } - continue - } - processedRecipient, err := s.Client.Store.RecipientStore.LoadAndUpdateRecipient(ctx, aci, pni, nil) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to get full recipient data") - continue - } - dmInfo := s.makeCreateDMResponse(ctx, processedRecipient, chat) - resyncEvt.PortalKey = dmInfo.PortalKey - resyncEvt.ChatInfo = dmInfo.PortalInfo - case *backuppb.Recipient_Self: - processedRecipient, err := s.Client.Store.RecipientStore.LoadAndUpdateRecipient(ctx, s.Client.Store.ACI, uuid.Nil, nil) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to get full recipient data") - continue - } - dmInfo := s.makeCreateDMResponse(ctx, processedRecipient, chat) - resyncEvt.PortalKey = dmInfo.PortalKey - resyncEvt.ChatInfo = dmInfo.PortalInfo - case *backuppb.Recipient_Group: - if len(dest.Group.MasterKey) != libsignalgo.GroupMasterKeyLength { - continue - } - rawGroupID, err := libsignalgo.GroupMasterKey(dest.Group.MasterKey).GroupIdentifier() - if err != nil { - zerolog.Ctx(ctx).Err(err). - Uint64("recipient_id", recipient.Id). - Msg("Failed to get group identifier from master key") - continue - } - groupID := types.GroupIdentifier(base64.StdEncoding.EncodeToString(rawGroupID[:])) - groupInfo, err := s.getGroupInfo(ctx, groupID, dest.Group.GetSnapshot().GetVersion(), chat) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to get full group info") - continue - } - resyncEvt.PortalKey = s.makePortalKey(string(groupID)) - resyncEvt.ChatInfo = groupInfo - default: - zerolog.Ctx(ctx).Debug(). - Type("destination_type", dest). - Uint64("backup_chat_id", chat.Id). - Uint64("backup_recipient_id", chat.RecipientId). - Msg("Ignoring and deleting chat with unsupported destination type") - err = s.Client.Store.BackupStore.DeleteBackupChat(ctx, chat.Id) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to delete chat from backup store") - } - continue - } - if !s.UserLogin.QueueRemoteEvent(resyncEvt).Success { - return - } - } - s.UserLogin.Metadata.(*signalid.UserLoginMetadata).ChatsSynced = true - err = s.UserLogin.Save(ctx) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to save user login metadata after syncing chats") - } -} diff --git a/pkg/connector/client.go b/pkg/connector/client.go deleted file mode 100644 index 4fcf188..0000000 --- a/pkg/connector/client.go +++ /dev/null @@ -1,365 +0,0 @@ -// mautrix-signal - A Matrix-Signal puppeting bridge. -// Copyright (C) 2024 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package connector - -import ( - "context" - "fmt" - "sync/atomic" - "time" - - "github.com/rs/zerolog" - "go.mau.fi/util/exsync" - "maunium.net/go/mautrix/bridgev2" - "maunium.net/go/mautrix/bridgev2/networkid" - "maunium.net/go/mautrix/bridgev2/status" - "maunium.net/go/mautrix/event" - - "go.mau.fi/mautrix-signal/pkg/signalid" - "go.mau.fi/mautrix-signal/pkg/signalmeow" - "go.mau.fi/mautrix-signal/pkg/signalmeow/web" -) - -type SignalClient struct { - Main *SignalConnector - UserLogin *bridgev2.UserLogin - Client *signalmeow.Client - Ghost *bridgev2.Ghost - - queueEmptyWaiter *exsync.Event - cancelChatSync atomic.Pointer[context.CancelFunc] -} - -var ( - _ bridgev2.NetworkAPI = (*SignalClient)(nil) - _ bridgev2.BackgroundSyncingNetworkAPI = (*SignalClient)(nil) - _ bridgev2.StickerImportingNetworkAPI = (*SignalClient)(nil) -) - -var pushCfg = &bridgev2.PushConfig{ - FCM: &bridgev2.FCMPushConfig{ - // https://github.com/signalapp/Signal-Android/blob/main/app/src/main/res/values/firebase_messaging.xml#L4 - SenderID: "312334754206", - }, - APNs: &bridgev2.APNsPushConfig{ - BundleID: "org.whispersystems.signal", - }, -} - -func (s *SignalClient) GetPushConfigs() *bridgev2.PushConfig { - return pushCfg -} - -func (s *SignalClient) RegisterPushNotifications(ctx context.Context, pushType bridgev2.PushType, token string) error { - if s.Client == nil { - return bridgev2.ErrNotLoggedIn - } - switch pushType { - case bridgev2.PushTypeFCM: - return s.Client.RegisterFCM(ctx, token) - case bridgev2.PushTypeAPNs: - return s.Client.RegisterAPNs(ctx, token) - default: - return fmt.Errorf("unsupported push type: %s", pushType) - } -} - -func (s *SignalClient) DownloadImagePack(ctx context.Context, url string) (*bridgev2.ImportedImagePack, error) { - return s.Main.MsgConv.DownloadImagePack(ctx, url) -} - -func (s *SignalClient) ListImagePacks(ctx context.Context) ([]*event.ImagePackMetadata, error) { - return []*event.ImagePackMetadata{}, nil -} - -func (s *SignalClient) LogoutRemote(ctx context.Context) { - if s.Client == nil { - return - } - s.stopChatSync() - err := s.Client.Unlink(ctx) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to unlink device") - } - err = s.Client.StopReceiveLoops() - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to stop receive loops for logout") - } - err = s.Main.Store.DeleteDevice(context.TODO(), &s.Client.Store.DeviceData) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to delete device from store") - } -} - -func (s *SignalClient) IsThisUser(_ context.Context, userID networkid.UserID) bool { - if s.Client == nil { - return false - } - return userID == signalid.MakeUserID(s.Client.Store.ACI) -} - -func (s *SignalClient) bridgeStateLoop(statusChan <-chan signalmeow.SignalConnectionStatus) { - var peekedConnectionStatus signalmeow.SignalConnectionStatus - for { - var connectionStatus signalmeow.SignalConnectionStatus - if peekedConnectionStatus.Event != signalmeow.SignalConnectionEventNone { - s.UserLogin.Log.Debug(). - Stringer("peeked_connection_status_event", peekedConnectionStatus.Event). - Msg("Using peeked connectionStatus event") - connectionStatus = peekedConnectionStatus - peekedConnectionStatus = signalmeow.SignalConnectionStatus{} - } else { - var ok bool - connectionStatus, ok = <-statusChan - if !ok { - s.UserLogin.Log.Debug().Msg("statusChan channel closed") - return - } - } - - err := connectionStatus.Err - switch connectionStatus.Event { - case signalmeow.SignalConnectionEventConnected: - s.UserLogin.Log.Debug().Msg("Sending Connected BridgeState") - s.UserLogin.BridgeState.Send(status.BridgeState{StateEvent: status.StateConnected}) - - case signalmeow.SignalConnectionEventDisconnected: - s.UserLogin.Log.Debug().Msg("Received SignalConnectionEventDisconnected") - - // Debounce: wait 7s before sending TransientDisconnect, in case we get a reconnect - // We should wait until the next message comes in, or 7 seconds has passed. - // - If a disconnected event comes in, just loop again, unless it's been more than 7 seconds. - // - If a non-disconnected event comes in, store it in peekedConnectionStatus, - // break out of this loop and go back to the top of the goroutine to handle it in the switch. - // - If 7 seconds passes without any non-disconnect messages, send the TransientDisconnect. - // (Why 7 seconds? It was 5 at first, but websockets min retry is 5 seconds, - // so it would send TransientDisconnect right before reconnecting. 7 seems to work well.) - debounceTimer := time.NewTimer(7 * time.Second) - PeekLoop: - for { - var ok bool - select { - case peekedConnectionStatus, ok = <-statusChan: - // Handle channel closing - if !ok { - s.UserLogin.Log.Debug().Msg("connectionStatus channel closed") - return - } - // If it's another Disconnected event, just keep looping - if peekedConnectionStatus.Event == signalmeow.SignalConnectionEventDisconnected { - peekedConnectionStatus = signalmeow.SignalConnectionStatus{} - continue - } - // If it's a non-disconnect event, break out of the PeekLoop and handle it in the switch - break PeekLoop - case <-debounceTimer.C: - // Time is up, so break out of the loop and send the TransientDisconnect - break PeekLoop - } - } - // We're out of the PeekLoop, so either we got a non-disconnect event, or it's been 7 seconds (or both). - // We want to send TransientDisconnect if it's been 7 seconds, but not if the latest event was something - // other than Disconnected - if !debounceTimer.Stop() { // If the timer has already expired - // Send TransientDisconnect only if the latest event is a disconnect or no event - // (peekedConnectionStatus could be something else if the timer and the event race) - if peekedConnectionStatus.Event == signalmeow.SignalConnectionEventDisconnected || - peekedConnectionStatus.Event == signalmeow.SignalConnectionEventNone { - s.UserLogin.Log.Debug().Msg("Sending TransientDisconnect BridgeState") - if err == nil { - s.UserLogin.BridgeState.Send(status.BridgeState{StateEvent: status.StateTransientDisconnect}) - } else { - s.UserLogin.BridgeState.Send(status.BridgeState{StateEvent: status.StateTransientDisconnect, Error: "unknown-websocket-error", Message: err.Error()}) - } - } - } - - case signalmeow.SignalConnectionEventLoggedOut: - s.stopChatSync() - s.UserLogin.Log.Debug().Msg("Sending BadCredentials BridgeState") - if err == nil { - s.UserLogin.BridgeState.Send(status.BridgeState{StateEvent: status.StateBadCredentials, Message: "You have been logged out of Signal, please reconnect"}) - } else { - s.UserLogin.BridgeState.Send(status.BridgeState{StateEvent: status.StateBadCredentials, Message: err.Error()}) - } - err = s.Client.ClearKeysAndDisconnect(context.TODO()) - if err != nil { - s.UserLogin.Log.Error().Err(err).Msg("Failed to clear keys and disconnect") - } - - case signalmeow.SignalConnectionEventError: - s.UserLogin.Log.Debug().Msg("Sending TransientDisconnect BridgeState") - s.UserLogin.BridgeState.Send(status.BridgeState{StateEvent: status.StateTransientDisconnect, Error: "unknown-websocket-error", Message: err.Error()}) - - case signalmeow.SignalConnectionEventFatalError: - s.UserLogin.Log.Debug().Msg("Sending UnknownError BridgeState") - s.UserLogin.BridgeState.Send(status.BridgeState{StateEvent: status.StateUnknownError, Error: "unknown-websocket-error", Message: err.Error()}) - - case signalmeow.SignalConnectionCleanShutdown: - if s.Client.IsLoggedIn() { - s.UserLogin.Log.Debug().Msg("Clean Shutdown - sending no BridgeState") - } else { - s.UserLogin.Log.Debug().Msg("Clean Shutdown, but logged out - Sending BadCredentials BridgeState") - s.UserLogin.BridgeState.Send(status.BridgeState{StateEvent: status.StateBadCredentials, Message: "You have been logged out of Signal, please reconnect"}) - } - } - } -} - -func (s *SignalClient) Connect(ctx context.Context) { - if s.Client == nil { - s.UserLogin.BridgeState.Send(status.BridgeState{StateEvent: status.StateBadCredentials, Message: "You're not logged into Signal"}) - return - } - s.updateRemoteProfile(ctx, false) - s.tryConnect(ctx, 0, true) -} - -func (s *SignalClient) ConnectBackground(ctx context.Context, _ *bridgev2.ConnectBackgroundParams) error { - s.queueEmptyWaiter.Clear() - ch, unauthCh, err := s.Client.StartWebsockets(ctx) - if err != nil { - return err - } - defer s.Disconnect() - log := zerolog.Ctx(ctx) - queueEmpty := s.queueEmptyWaiter.GetChan() - didConnect := false - for { - select { - case status := <-ch: - switch status.Event { - case web.SignalWebsocketConnectionEventConnected: - log.Info().Msg("Authed websocket connected") - didConnect = true - case web.SignalWebsocketConnectionEventDisconnected: - log.Err(status.Err).Msg("Authed websocket disconnected") - case web.SignalWebsocketConnectionEventLoggedOut: - log.Err(status.Err).Msg("Authed websocket logged out") - return fmt.Errorf("authed websocket logged out: %w", status.Err) - case web.SignalWebsocketConnectionEventError, web.SignalWebsocketConnectionEventFatalError: - log.Err(status.Err).Msg("Authed websocket error") - return fmt.Errorf("authed websocket errored: %w", status.Err) - case web.SignalWebsocketConnectionEventCleanShutdown: - log.Info().Msg("Authed websocket clean shutdown") - } - case status := <-unauthCh: - switch status.Event { - case web.SignalWebsocketConnectionEventConnected: - log.Info().Msg("Unauthed websocket connected") - case web.SignalWebsocketConnectionEventDisconnected: - log.Err(status.Err).Msg("Unauthed websocket disconnected") - case web.SignalWebsocketConnectionEventLoggedOut: - log.Err(status.Err).Msg("Unauthed websocket logged out") - case web.SignalWebsocketConnectionEventError, web.SignalWebsocketConnectionEventFatalError: - log.Err(status.Err).Msg("Unauthed websocket error") - case web.SignalWebsocketConnectionEventCleanShutdown: - log.Info().Msg("Unauthed websocket clean shutdown") - } - case <-ctx.Done(): - log.Warn().Msg("Context finished before queue empty event") - if didConnect { - // Don't propagate timeout errors if the connection was successful at least once - return nil - } - return ctx.Err() - case <-queueEmpty: - log.Info().Msg("Received queue empty event") - return nil - } - } -} - -func (s *SignalClient) Disconnect() { - if s.Client == nil { - return - } - s.stopChatSync() - err := s.Client.StopReceiveLoops() - if err != nil { - s.UserLogin.Log.Err(err).Msg("Failed to stop receive loops") - } -} - -func (s *SignalClient) postLoginConnect() { - ctx := s.UserLogin.Log.WithContext(s.Main.Bridge.BackgroundCtx) - s.tryConnect(ctx, 0, false) -} - -func (s *SignalClient) tryConnect(ctx context.Context, retryCount int, noLoginSync bool) { - if ctx.Err() != nil { - zerolog.Ctx(ctx).Debug(). - Int("retry_count", retryCount). - AnErr("ctx_err", ctx.Err()). - Msg("Context is canceled, not trying to connect") - return - } - if retryCount == 0 { - s.UserLogin.BridgeState.Send(status.BridgeState{StateEvent: status.StateConnecting}) - } - ch, err := s.Client.StartReceiveLoops(ctx) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to start receive loops") - s.UserLogin.BridgeState.Send(status.BridgeState{StateEvent: status.StateTransientDisconnect, Error: "unknown-websocket-error", Message: err.Error()}) - retryInSeconds := 2 << retryCount - if retryInSeconds > 150 { - retryInSeconds = 150 - } - zerolog.Ctx(ctx).Debug().Int("retry_in_seconds", retryInSeconds).Msg("Sleeping and retrying connection") - select { - case <-time.After(time.Duration(retryInSeconds) * time.Second): - case <-ctx.Done(): - zerolog.Ctx(ctx).Info().Msg("Context canceled, exit tryConnect") - return - } - s.tryConnect(ctx, retryCount+1, noLoginSync) - return - } - syncCtx, cancel := context.WithCancel(ctx) - if oldCancel := s.cancelChatSync.Swap(&cancel); oldCancel != nil { - (*oldCancel)() - } - go s.bridgeStateLoop(ch) - if noLoginSync { - go s.syncChats(syncCtx, cancel) - } else { - // TODO it would be more proper to only connect after syncing, - // but currently syncing will fetch group info online, so it has to be connected. - if s.Client.Store.EphemeralBackupKey != nil { - go func() { - if s.Client.Store.MasterKey != nil { - s.Client.SyncStorage(ctx) - } else { - s.UserLogin.Log.Warn().Msg("No master key for storage sync before backup sync") - } - s.syncChats(syncCtx, cancel) - }() - } else { - cancel() - if s.Client.Store.MasterKey != nil { - go s.Client.SyncStorage(ctx) - } - } - } -} - -func (s *SignalClient) IsLoggedIn() bool { - if s.Client == nil { - return false - } - return s.Client.IsLoggedIn() -} diff --git a/pkg/connector/commands.go b/pkg/connector/commands.go deleted file mode 100644 index 0be2370..0000000 --- a/pkg/connector/commands.go +++ /dev/null @@ -1,73 +0,0 @@ -// mautrix-signal - A Matrix-Signal puppeting bridge. -// Copyright (C) 2025 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package connector - -import ( - "errors" - - "maunium.net/go/mautrix/bridgev2" - "maunium.net/go/mautrix/bridgev2/commands" - "maunium.net/go/mautrix/bridgev2/networkid" - - "go.mau.fi/mautrix-signal/pkg/signalid" -) - -var CmdDiscardSenderKey = &commands.FullHandler{ - Func: fnDiscardSenderKey, - Name: "discard-sender-key", - Help: commands.HelpMeta{ - Section: commands.HelpSectionChats, - Description: "Discard the Signal-side sender key in the current group", - Args: "[_login ID_]", - }, - RequiresPortal: true, - RequiresLogin: true, -} - -func fnDiscardSenderKey(ce *commands.Event) { - _, groupID, _ := signalid.ParsePortalID(ce.Portal.ID) - if groupID == "" { - ce.Reply("This command can only be used in group chat portals") - return - } - var login *bridgev2.UserLogin - if len(ce.Args) > 0 { - login = ce.Bridge.GetCachedUserLoginByID(networkid.UserLoginID(ce.Args[0])) - if login == nil || login.UserMXID != ce.User.MXID { - ce.Reply("Login not found") - return - } - } else { - var err error - login, _, err = ce.Portal.FindPreferredLogin(ce.Ctx, ce.User, false) - if errors.Is(err, bridgev2.ErrNotLoggedIn) { - ce.Reply("You're not logged in in this portal") - return - } else if err != nil { - ce.Log.Err(err).Msg("Failed to find preferred login for portal") - ce.Reply("Failed to find preferred login for portal") - return - } - } - distributionID, err := login.Client.(*SignalClient).Client.ResetSenderKey(ce.Ctx, groupID) - if err != nil { - ce.Log.Err(err).Msg("Failed to reset sender key") - ce.Reply("Failed to reset sender key") - } else { - ce.Reply("Reset sender key with distribution ID %s", distributionID) - } -} diff --git a/pkg/connector/config.go b/pkg/connector/config.go deleted file mode 100644 index 232571f..0000000 --- a/pkg/connector/config.go +++ /dev/null @@ -1,112 +0,0 @@ -// mautrix-signal - A Matrix-Signal puppeting bridge. -// Copyright (C) 2024 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package connector - -import ( - _ "embed" - "strings" - "text/template" - - up "go.mau.fi/util/configupgrade" - "gopkg.in/yaml.v3" - - "maunium.net/go/mautrix/id" - - "go.mau.fi/mautrix-signal/pkg/signalmeow/types" -) - -//go:embed example-config.yaml -var ExampleConfig string - -type SignalConfig struct { - DisplaynameTemplate string `yaml:"displayname_template"` - UseContactAvatars bool `yaml:"use_contact_avatars"` - SyncContactsOnStartup bool `yaml:"sync_contacts_on_startup"` - UseOutdatedProfiles bool `yaml:"use_outdated_profiles"` - NumberInTopic bool `yaml:"number_in_topic"` - DeviceName string `yaml:"device_name"` - NoteToSelfAvatar id.ContentURIString `yaml:"note_to_self_avatar"` - LocationFormat string `yaml:"location_format"` - DisappearViewOnce bool `yaml:"disappear_view_once"` - ExtEvPolls bool `yaml:"extev_polls"` - - displaynameTemplate *template.Template `yaml:"-"` -} - -type umConfig SignalConfig - -func (c *SignalConfig) UnmarshalYAML(node *yaml.Node) error { - err := node.Decode((*umConfig)(c)) - if err != nil { - return err - } - return c.PostProcess() -} - -func (c *SignalConfig) PostProcess() error { - var err error - c.displaynameTemplate, err = template.New("displayname").Parse(c.DisplaynameTemplate) - return err -} - -type DisplaynameParams struct { - ProfileName string - ContactName string - Nickname string - Username string - PhoneNumber string - UUID string - ACI string - PNI string - AboutEmoji string -} - -func (c *SignalConfig) FormatDisplayname(contact *types.Recipient) string { - var nameBuf strings.Builder - err := c.displaynameTemplate.Execute(&nameBuf, &DisplaynameParams{ - ProfileName: contact.Profile.Name, - ContactName: contact.ContactName, - Nickname: contact.Nickname, - Username: "", - PhoneNumber: contact.E164, - UUID: contact.ACI.String(), - ACI: contact.ACI.String(), - PNI: contact.PNI.String(), - AboutEmoji: contact.Profile.AboutEmoji, - }) - if err != nil { - panic(err) - } - return nameBuf.String() -} - -func upgradeConfig(helper up.Helper) { - helper.Copy(up.Str, "displayname_template") - helper.Copy(up.Bool, "use_contact_avatars") - helper.Copy(up.Bool, "sync_contacts_on_startup") - helper.Copy(up.Bool, "use_outdated_profiles") - helper.Copy(up.Bool, "number_in_topic") - helper.Copy(up.Str, "device_name") - helper.Copy(up.Str, "note_to_self_avatar") - helper.Copy(up.Str, "location_format") - helper.Copy(up.Bool, "disappear_view_once") - helper.Copy(up.Bool, "extev_polls") -} - -func (s *SignalConnector) GetConfig() (string, any, up.Upgrader) { - return ExampleConfig, &s.Config, up.SimpleUpgrader(upgradeConfig) -} diff --git a/pkg/connector/connector.go b/pkg/connector/connector.go deleted file mode 100644 index 0343d02..0000000 --- a/pkg/connector/connector.go +++ /dev/null @@ -1,137 +0,0 @@ -// mautrix-signal - A Matrix-Signal puppeting bridge. -// Copyright (C) 2024 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package connector - -import ( - "context" - "fmt" - "strconv" - "time" - - "github.com/google/uuid" - "go.mau.fi/util/dbutil" - "go.mau.fi/util/exhttp" - "go.mau.fi/util/exsync" - "maunium.net/go/mautrix/bridgev2" - "maunium.net/go/mautrix/bridgev2/commands" - "maunium.net/go/mautrix/bridgev2/networkid" - "maunium.net/go/mautrix/event" - "maunium.net/go/mautrix/id" - - "go.mau.fi/mautrix-signal/pkg/msgconv" - "go.mau.fi/mautrix-signal/pkg/signalid" - "go.mau.fi/mautrix-signal/pkg/signalmeow" - "go.mau.fi/mautrix-signal/pkg/signalmeow/store" - "go.mau.fi/mautrix-signal/pkg/signalmeow/web" -) - -type SignalConnector struct { - MsgConv *msgconv.MessageConverter - Store *store.Container - Bridge *bridgev2.Bridge - Config SignalConfig -} - -var _ bridgev2.NetworkConnector = (*SignalConnector)(nil) -var _ bridgev2.MaxFileSizeingNetwork = (*SignalConnector)(nil) -var _ bridgev2.TransactionIDGeneratingNetwork = (*SignalConnector)(nil) - -func (s *SignalConnector) GetName() bridgev2.BridgeName { - return bridgev2.BridgeName{ - DisplayName: "Signal", - NetworkURL: "https://signal.org", - NetworkIcon: "mxc://maunium.net/wPJgTQbZOtpBFmDNkiNEMDUp", - NetworkID: "signal", - BeeperBridgeType: "signal", - DefaultPort: 29328, - } -} - -func (s *SignalConnector) Init(bridge *bridgev2.Bridge) { - s.Store = store.NewStore(bridge.DB.Database, dbutil.ZeroLogger(bridge.Log.With().Str("db_section", "signalmeow").Logger())) - s.Bridge = bridge - s.MsgConv = msgconv.NewMessageConverter(bridge) - s.MsgConv.LocationFormat = s.Config.LocationFormat - s.MsgConv.DisappearViewOnce = s.Config.DisappearViewOnce - s.MsgConv.ExtEvPolls = s.Config.ExtEvPolls - bridge.Commands.(*commands.Processor).AddHandlers(CmdDiscardSenderKey) -} - -func (s *SignalConnector) SetMaxFileSize(maxSize int64) { - s.MsgConv.MaxFileSize = maxSize -} - -func (s *SignalConnector) Start(ctx context.Context) error { - s.ResetHTTPTransport() - err := s.Store.Upgrade(ctx) - if err != nil { - return bridgev2.DBUpgradeError{Err: err, Section: "signalmeow"} - } - return nil -} - -func (s *SignalConnector) ResetHTTPTransport() { - settings := exhttp.SensibleClientSettings - hs, ok := s.Bridge.Matrix.(bridgev2.MatrixConnectorWithHTTPSettings) - if ok { - settings = hs.GetHTTPClientSettings() - } - oldClient := web.SignalHTTPClient - web.SignalHTTPClient = settings.WithTLSConfig(web.SignalTLSConfig).Compile() - oldClient.CloseIdleConnections() -} - -func (s *SignalConnector) ResetNetworkConnections() { - for _, login := range s.Bridge.GetAllCachedUserLogins() { - c := login.Client.(*SignalClient) - if c.Client != nil { - c.Client.ForceReconnect() - } - } -} - -func (s *SignalConnector) LoadUserLogin(ctx context.Context, login *bridgev2.UserLogin) error { - aci, err := uuid.Parse(string(login.ID)) - if err != nil { - return fmt.Errorf("failed to parse user login ID: %w", err) - } - device, err := s.Store.DeviceByACI(ctx, aci) - if err != nil { - return fmt.Errorf("failed to get device from store: %w", err) - } - sc := &SignalClient{ - Main: s, - UserLogin: login, - - queueEmptyWaiter: exsync.NewEvent(), - } - if device != nil { - sc.Client = signalmeow.NewClient( - device, - sc.UserLogin.Log.With().Str("component", "signalmeow").Logger(), - sc.handleSignalEvent, - ) - sc.Client.SyncContactsOnConnect = s.Config.SyncContactsOnStartup && - time.Since(login.Metadata.(*signalid.UserLoginMetadata).LastContactSync.Time) > 3*24*time.Hour - } - login.Client = sc - return nil -} - -func (s *SignalConnector) GenerateTransactionID(userID id.UserID, roomID id.RoomID, eventType event.Type) networkid.RawTransactionID { - return networkid.RawTransactionID(strconv.FormatInt(time.Now().UnixMilli(), 10)) -} diff --git a/pkg/connector/directmedia.go b/pkg/connector/directmedia.go deleted file mode 100644 index 05e2a07..0000000 --- a/pkg/connector/directmedia.go +++ /dev/null @@ -1,130 +0,0 @@ -package connector - -import ( - "context" - "encoding/base64" - "fmt" - "os" - - "maunium.net/go/mautrix/bridgev2" - "maunium.net/go/mautrix/bridgev2/networkid" - "maunium.net/go/mautrix/mediaproxy" - - "go.mau.fi/mautrix-signal/pkg/signalid" - "go.mau.fi/mautrix-signal/pkg/signalmeow" - "go.mau.fi/mautrix-signal/pkg/signalmeow/types" -) - -var _ bridgev2.DirectMediableNetwork = (*SignalConnector)(nil) - -func (s *SignalConnector) SetUseDirectMedia() { - s.MsgConv.DirectMedia = true -} - -func (s *SignalConnector) Download(ctx context.Context, mediaID networkid.MediaID, params map[string]string) (mediaproxy.GetMediaResponse, error) { - log := s.Bridge.Log.With().Str("component", "direct download").Logger() - - info, err := signalid.ParseDirectMediaInfo(mediaID) - if err != nil { - return nil, fmt.Errorf("failed to parse direct media id: %w", err) - } - - var rawDataResp []byte - switch info := info.(type) { - case *signalid.DirectMediaAttachment: - log.Info(). - Uint64("cdn_id", info.CDNID). - Str("cdn_key", info.CDNKey). - Uint32("cdn_number", info.CDNNumber). - Int("key_len", len(info.Key)). - Int("digest_len", len(info.Digest)). - Bool("plaintext_digest", info.PlaintextDigest). - Uint32("size", info.Size). - Msg("Direct downloading attachment") - - return &mediaproxy.GetMediaResponseFile{ - Callback: func(w *os.File) (*mediaproxy.FileMeta, error) { - _, err := signalmeow.DownloadAttachment( - ctx, info.CDNID, info.CDNKey, info.CDNNumber, info.Key, info.Digest, info.PlaintextDigest, info.Size, w, - ) - if err != nil { - return nil, err - } - return &mediaproxy.FileMeta{}, nil - }, - }, nil - case *signalid.DirectMediaGroupAvatar: - log.Info(). - Stringer("user_id", info.UserID). - Hex("group_id", info.GroupID[:]). - Str("group_avatar_path", info.GroupAvatarPath). - Msg("Direct downloading group avatar") - - groupID := types.GroupIdentifier(base64.StdEncoding.EncodeToString(info.GroupID[:])) - - userLogin, err := s.Bridge.GetExistingUserLoginByID(ctx, signalid.MakeUserLoginID(info.UserID)) - if err != nil { - return nil, fmt.Errorf("failed to get user login: %w", err) - } else if userLogin == nil { - return nil, bridgev2.ErrNotLoggedIn - } - - client := userLogin.Client.(*SignalClient) - - groupMasterKey, err := client.Client.Store.GroupStore.MasterKeyFromGroupIdentifier(ctx, groupID) - if err != nil { - return nil, fmt.Errorf("failed to to get group master key: %w", err) - } - - rawDataResp, err = client.Client.DownloadGroupAvatar(ctx, info.GroupAvatarPath, groupMasterKey) - if err != nil { - log.Err(err).Msg("Direct download failed") - return nil, err - } - case *signalid.DirectMediaProfileAvatar: - log.Info(). - Stringer("user_id", info.UserID). - Stringer("contact_id", info.ContactID). - Str("profile_avatar_path", info.ProfileAvatarPath). - Msg("Direct downloading profile avatar") - - userLogin, err := s.Bridge.GetExistingUserLoginByID(ctx, signalid.MakeUserLoginID(info.UserID)) - if err != nil { - return nil, fmt.Errorf("failed to get user login: %w", err) - } else if userLogin == nil { - return nil, bridgev2.ErrNotLoggedIn - } - - client := userLogin.Client.(*SignalClient) - - profileKey, err := client.Client.Store.RecipientStore.LoadProfileKey(ctx, info.ContactID) - if err != nil { - return nil, fmt.Errorf("failed to get contact: %w", err) - } else if profileKey == nil { - return nil, fmt.Errorf("profile key not found") - } - - rawDataResp, err = client.Client.DownloadUserAvatar(ctx, info.ProfileAvatarPath, *profileKey) - if err != nil { - log.Err(err).Msg("Direct download failed") - return nil, err - } - case *signalid.DirectMediaSticker: - log.Info(). - Hex("pack_id", info.PackID). - Uint32("sticker_id", info.StickerID). - Msg("Direct downloading sticker") - - rawDataResp, err = signalmeow.DownloadStickerPackItem(ctx, info.PackID, info.PackKey, info.StickerID) - if err != nil { - log.Err(err).Msg("Direct download failed") - return nil, err - } - default: - return nil, fmt.Errorf("no downloader for direct media type: %T", info) - } - if rawDataResp == nil { - return nil, fmt.Errorf("unexpected fallthrough with no data") - } - return mediaproxy.GetMediaResponseRawData(rawDataResp), nil -} diff --git a/pkg/connector/example-config.yaml b/pkg/connector/example-config.yaml deleted file mode 100644 index 25fe035..0000000 --- a/pkg/connector/example-config.yaml +++ /dev/null @@ -1,28 +0,0 @@ -# Displayname template for Signal users. -# {{.ProfileName}} - The Signal profile name set by the user. -# {{.ContactName}} - The name for the user from your phone's contact list. This is not safe on multi-user instances. -# {{.Nickname}} - The nickname set for the user in the native Signal app. This is not safe on multi-user instances. -# {{.PhoneNumber}} - The phone number of the user. -# {{.UUID}} - The UUID of the Signal user. -# {{.AboutEmoji}} - The emoji set by the user in their profile. -displayname_template: '{{or .ProfileName .PhoneNumber "Unknown user"}}' -# Should avatars from the user's contact list be used? This is not safe on multi-user instances. -use_contact_avatars: false -# Should the bridge request the user's contact list from the phone on startup? -sync_contacts_on_startup: true -# Should the bridge sync ghost user info even if profile fetching fails? This is not safe on multi-user instances. -use_outdated_profiles: false -# Should the Signal user's phone number be included in the room topic in private chat portal rooms? -number_in_topic: true -# Default device name that shows up in the Signal app. -device_name: mautrix-signal -# Avatar image for the Note to Self room. -note_to_self_avatar: mxc://maunium.net/REBIVrqjZwmaWpssCZpBlmlL -# Format for generating URLs from location messages for sending to Signal. -# Google Maps: 'https://www.google.com/maps/place/%[1]s,%[2]s' -# OpenStreetMap: 'https://www.openstreetmap.org/?mlat=%[1]s&mlon=%[2]s' -location_format: 'https://www.google.com/maps/place/%[1]s,%[2]s' -# Should view-once messages disappear shortly after sending a read receipt on Matrix? -disappear_view_once: false -# Should polls be sent using unstable MSC3381 event types? -extev_polls: false diff --git a/pkg/connector/groupinfo.go b/pkg/connector/groupinfo.go deleted file mode 100644 index d958463..0000000 --- a/pkg/connector/groupinfo.go +++ /dev/null @@ -1,441 +0,0 @@ -// mautrix-signal - A Matrix-Signal puppeting bridge. -// Copyright (C) 2024 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package connector - -import ( - "context" - "fmt" - "time" - - "github.com/google/uuid" - "github.com/rs/zerolog" - "go.mau.fi/util/jsontime" - "go.mau.fi/util/ptr" - "maunium.net/go/mautrix/bridgev2" - "maunium.net/go/mautrix/bridgev2/database" - "maunium.net/go/mautrix/bridgev2/networkid" - "maunium.net/go/mautrix/event" - - "go.mau.fi/mautrix-signal/pkg/libsignalgo" - "go.mau.fi/mautrix-signal/pkg/signalid" - "go.mau.fi/mautrix-signal/pkg/signalmeow" - "go.mau.fi/mautrix-signal/pkg/signalmeow/store" - "go.mau.fi/mautrix-signal/pkg/signalmeow/types" -) - -var defaultPL = 0 -var moderatorPL = 50 - -func roleToPL(role signalmeow.GroupMemberRole) *int { - switch role { - case signalmeow.GroupMember_ADMINISTRATOR: - return &moderatorPL - case signalmeow.GroupMember_DEFAULT: - fallthrough - default: - return &defaultPL - } -} - -func applyAnnouncementsOnly(plc *bridgev2.PowerLevelOverrides, announcementsOnly bool) { - if announcementsOnly { - plc.EventsDefault = &moderatorPL - } else { - plc.EventsDefault = &defaultPL - } -} - -func applyAttributesAccess(plc *bridgev2.PowerLevelOverrides, attributeAccess signalmeow.AccessControl) { - attributePL := defaultPL - if attributeAccess == signalmeow.AccessControl_ADMINISTRATOR { - attributePL = moderatorPL - } - plc.Events[event.StateRoomName] = attributePL - plc.Events[event.StateRoomAvatar] = attributePL - plc.Events[event.StateTopic] = attributePL - plc.Events[event.StateBeeperDisappearingTimer] = attributePL -} - -func applyMembersAccess(plc *bridgev2.PowerLevelOverrides, memberAccess signalmeow.AccessControl) { - if memberAccess == signalmeow.AccessControl_ADMINISTRATOR { - plc.Invite = &moderatorPL - } else { - plc.Invite = &defaultPL - } -} - -func inviteLinkToJoinRule(inviteLinkAccess signalmeow.AccessControl) event.JoinRule { - switch inviteLinkAccess { - case signalmeow.AccessControl_UNSATISFIABLE: - return event.JoinRuleInvite - case signalmeow.AccessControl_ADMINISTRATOR: - return event.JoinRuleKnock - case signalmeow.AccessControl_ANY: - // TODO allow public portals? - publicPortals := false - if publicPortals { - return event.JoinRulePublic - } else { - return event.JoinRuleKnock - } - default: - return event.JoinRuleInvite - } -} - -func (s *SignalClient) getGroupInfo(ctx context.Context, groupID types.GroupIdentifier, minRevision uint32, backupChat *store.BackupChat) (*bridgev2.ChatInfo, error) { - groupInfo, _, err := s.Client.RetrieveGroupByID(ctx, groupID, minRevision) - if err != nil { - return nil, fmt.Errorf("failed to retrieve group by id: %w", err) - } - return s.wrapGroupInfo(ctx, groupInfo, backupChat) -} - -func (s *SignalClient) wrapGroupInfo(ctx context.Context, groupInfo *signalmeow.Group, backupChat *store.BackupChat) (*bridgev2.ChatInfo, error) { - members := &bridgev2.ChatMemberList{ - IsFull: true, - MemberMap: make(map[networkid.UserID]bridgev2.ChatMember, len(groupInfo.Members)+len(groupInfo.PendingMembers)+len(groupInfo.RequestingMembers)+len(groupInfo.BannedMembers)), - PowerLevels: &bridgev2.PowerLevelOverrides{ - Events: map[event.Type]int{ - event.StatePowerLevels: moderatorPL, - }, - }, - ExcludeChangesFromTimeline: true, - } - applyAnnouncementsOnly(members.PowerLevels, groupInfo.AnnouncementsOnly) - joinRule := event.JoinRuleInvite - if groupInfo.AccessControl != nil { - applyAttributesAccess(members.PowerLevels, groupInfo.AccessControl.Attributes) - applyMembersAccess(members.PowerLevels, groupInfo.AccessControl.Members) - joinRule = inviteLinkToJoinRule(groupInfo.AccessControl.AddFromInviteLink) - } - for _, member := range groupInfo.RequestingMembers { - members.MemberMap.Set(bridgev2.ChatMember{ - EventSender: s.makeEventSender(member.ACI), - Membership: event.MembershipKnock, - }) - } - for _, member := range groupInfo.PendingMembers { - s.addChatMemberWithACIQuery(ctx, members.MemberMap, member.ServiceID, bridgev2.ChatMember{ - PowerLevel: roleToPL(member.Role), - Membership: event.MembershipInvite, - MemberSender: s.makeEventSender(member.AddedByUserID), - }) - } - for _, member := range groupInfo.Members { - members.MemberMap.Set(bridgev2.ChatMember{ - EventSender: s.makeEventSender(member.ACI), - PowerLevel: roleToPL(member.Role), - Membership: event.MembershipJoin, - }) - } - for _, member := range groupInfo.BannedMembers { - s.addChatMemberWithACIQuery(ctx, members.MemberMap, member.ServiceID, bridgev2.ChatMember{ - Membership: event.MembershipBan, - }) - } - if backupChat == nil { - var err error - // TODO allow using backup chat for data too instead of asking server? - backupChat, err = s.Client.Store.BackupStore.GetBackupChatByGroupID(ctx, groupInfo.GroupIdentifier) - if err != nil { - zerolog.Ctx(ctx).Warn().Err(err).Msg("Failed to get backup chat for group") - } - } - avatar, err := s.makeGroupAvatar(ctx, groupInfo.GroupIdentifier, &groupInfo.AvatarPath, groupInfo.GroupMasterKey) - if err != nil { - return nil, fmt.Errorf("failed to make group avatar: %w", err) - } - return &bridgev2.ChatInfo{ - Name: &groupInfo.Title, - Topic: &groupInfo.Description, - Avatar: avatar, - Disappear: &database.DisappearingSetting{ - Type: event.DisappearingTypeAfterRead, - Timer: time.Duration(groupInfo.DisappearingMessagesDuration) * time.Second, - }, - Members: members, - Type: ptr.Ptr(database.RoomTypeDefault), - JoinRule: &event.JoinRulesEventContent{JoinRule: joinRule}, - ExtraUpdates: bridgev2.MergeExtraUpdaters(makeRevisionUpdater(groupInfo.Revision), updatePortalSyncMeta), - CanBackfill: backupChat != nil, - - ExcludeChangesFromTimeline: true, - }, nil -} - -func addMemberToMap(mc map[networkid.UserID]bridgev2.ChatMember, member bridgev2.ChatMember) { - mc[member.EventSender.Sender] = member -} - -func updatePortalSyncMeta(ctx context.Context, portal *bridgev2.Portal) bool { - meta := portal.Metadata.(*signalid.PortalMetadata) - meta.LastSync = jsontime.UnixNow() - return true -} - -func (s *SignalClient) makeGroupAvatar(ctx context.Context, groupID types.GroupIdentifier, path *string, groupMasterKey types.SerializedGroupMasterKey) (*bridgev2.Avatar, error) { - if path == nil { - return nil, nil - } - avatar := &bridgev2.Avatar{ - ID: makeAvatarPathID(*path), - Remove: *path == "", - } - if s.Main.MsgConv.DirectMedia { - userID, err := signalid.ParseUserLoginID(s.UserLogin.ID) - if err != nil { - return nil, fmt.Errorf("failed to parse user login ID: %w", err) - } - groupIDBytes, err := groupID.Bytes() - if err != nil { - return nil, fmt.Errorf("failed to get group id bytes: %w", err) - } - mediaID, err := signalid.DirectMediaGroupAvatar{ - UserID: userID, - GroupID: groupIDBytes, - GroupAvatarPath: *path, - }.AsMediaID() - if err != nil { - return nil, err - } - avatar.MXC, err = s.Main.Bridge.Matrix.GenerateContentURI(ctx, mediaID) - if err != nil { - return nil, err - } - avatar.Hash = signalid.HashMediaID(mediaID) - } else { - avatar.Get = func(ctx context.Context) ([]byte, error) { - return s.Client.DownloadGroupAvatar(ctx, *path, groupMasterKey) - } - } - return avatar, nil -} - -func makeRevisionUpdater(rev uint32) func(ctx context.Context, portal *bridgev2.Portal) bool { - return func(ctx context.Context, portal *bridgev2.Portal) bool { - meta := portal.Metadata.(*signalid.PortalMetadata) - if meta.Revision < rev { - meta.Revision = rev - return true - } - return false - } -} - -func (s *SignalClient) groupChangeToChatInfoChange(ctx context.Context, groupID types.GroupIdentifier, rev uint32, groupChange *signalmeow.GroupChange) (*bridgev2.ChatInfoChange, error) { - avatar, err := s.makeGroupAvatar(ctx, groupID, groupChange.ModifyAvatar, groupChange.GroupMasterKey) - if err != nil { - return nil, err - } - ic := &bridgev2.ChatInfoChange{ - ChatInfo: &bridgev2.ChatInfo{ - ExtraUpdates: makeRevisionUpdater(rev), - Name: groupChange.ModifyTitle, - Topic: groupChange.ModifyDescription, - Avatar: avatar, - }, - } - if groupChange.ModifyDisappearingMessagesDuration != nil { - ic.ChatInfo.Disappear = &database.DisappearingSetting{ - Type: event.DisappearingTypeAfterRead, - Timer: time.Duration(*groupChange.ModifyDisappearingMessagesDuration) * time.Second, - } - } - - var pls *bridgev2.PowerLevelOverrides - if groupChange.ModifyAnnouncementsOnly != nil || - groupChange.ModifyAttributesAccess != nil || - groupChange.ModifyMemberAccess != nil { - pls = &bridgev2.PowerLevelOverrides{Events: make(map[event.Type]int)} - if groupChange.ModifyAnnouncementsOnly != nil { - applyAnnouncementsOnly(pls, *groupChange.ModifyAnnouncementsOnly) - } - if groupChange.ModifyAttributesAccess != nil { - applyAttributesAccess(pls, *groupChange.ModifyAttributesAccess) - } - if groupChange.ModifyMemberAccess != nil { - applyMembersAccess(pls, *groupChange.ModifyMemberAccess) - } - } - if groupChange.ModifyAddFromInviteLinkAccess != nil { - ic.ChatInfo.JoinRule = &event.JoinRulesEventContent{ - JoinRule: inviteLinkToJoinRule(*groupChange.ModifyAddFromInviteLinkAccess), - } - } - mc := make(bridgev2.ChatMemberMap) - for _, member := range groupChange.AddPendingMembers { - s.addChatMemberWithACIQuery(ctx, mc, member.ServiceID, bridgev2.ChatMember{ - PowerLevel: roleToPL(member.Role), - Membership: event.MembershipInvite, - PrevMembership: event.MembershipLeave, - MemberSender: s.makeEventSender(member.AddedByUserID), - }) - } - for _, member := range groupChange.AddRequestingMembers { - mc.Set(bridgev2.ChatMember{ - EventSender: s.makeEventSender(member.ACI), - Membership: event.MembershipKnock, - }) - } - for _, memberServiceID := range groupChange.DeletePendingMembers { - s.addChatMemberWithACIQuery(ctx, mc, *memberServiceID, bridgev2.ChatMember{ - Membership: event.MembershipLeave, - PrevMembership: event.MembershipInvite, - }) - } - for _, memberACI := range groupChange.DeleteRequestingMembers { - mc.Set(bridgev2.ChatMember{ - EventSender: s.makeEventSender(*memberACI), - Membership: event.MembershipLeave, - PrevMembership: event.MembershipKnock, - }) - } - for _, memberACI := range groupChange.DeleteMembers { - mc.Set(bridgev2.ChatMember{ - EventSender: s.makeEventSender(*memberACI), - Membership: event.MembershipLeave, - PrevMembership: event.MembershipJoin, - }) - } - for _, memberServiceID := range groupChange.DeleteBannedMembers { - s.addChatMemberWithACIQuery(ctx, mc, *memberServiceID, bridgev2.ChatMember{ - Membership: event.MembershipLeave, - PrevMembership: event.MembershipBan, - }) - } - for _, member := range groupChange.AddBannedMembers { - s.addChatMemberWithACIQuery(ctx, mc, member.ServiceID, bridgev2.ChatMember{ - Membership: event.MembershipBan, - }) - } - for _, member := range groupChange.PromotePendingMembers { - mc.Set(bridgev2.ChatMember{ - EventSender: s.makeEventSender(member.ACI), - Membership: event.MembershipJoin, - PrevMembership: event.MembershipInvite, - }) - } - for _, member := range groupChange.PromotePendingPniAciMembers { - mc.Set(bridgev2.ChatMember{ - EventSender: s.makeEventSender(member.ACI), - Membership: event.MembershipJoin, - }) - mc.Set(bridgev2.ChatMember{ - EventSender: s.makePNIEventSender(member.PNI), - Membership: event.MembershipLeave, - PrevMembership: event.MembershipInvite, - MemberEventExtra: map[string]any{ - "com.beeper.exclude_from_timeline": true, - }, - }) - } - for _, member := range groupChange.PromoteRequestingMembers { - mc.Set(bridgev2.ChatMember{ - EventSender: s.makeEventSender(member.ACI), - Membership: event.MembershipJoin, - PrevMembership: event.MembershipKnock, - }) - } - for _, member := range groupChange.AddMembers { - mc.Set(bridgev2.ChatMember{ - EventSender: s.makeEventSender(member.ACI), - PowerLevel: roleToPL(member.Role), - Membership: event.MembershipJoin, - }) - } - for _, member := range groupChange.ModifyMemberRoles { - mc.Set(bridgev2.ChatMember{ - EventSender: s.makeEventSender(member.ACI), - PowerLevel: roleToPL(member.Role), - Membership: event.MembershipJoin, - }) - } - if len(mc) > 0 || pls != nil { - ic.MemberChanges = &bridgev2.ChatMemberList{MemberMap: mc, PowerLevels: pls} - } - return ic, nil -} - -func (s *SignalClient) addChatMemberWithACIQuery( - ctx context.Context, mc bridgev2.ChatMemberMap, serviceID libsignalgo.ServiceID, member bridgev2.ChatMember, -) { - member.EventSender = s.makeEventSenderFromServiceID(serviceID) - mc.Set(member) - if aci := s.tryResolvePNItoLoggedInACI(ctx, serviceID); aci != nil { - member.EventSender = s.makeEventSender(*aci) - mc.Add(member) - } -} - -func (s *SignalClient) tryResolvePNItoLoggedInACI(ctx context.Context, serviceID libsignalgo.ServiceID) *uuid.UUID { - if serviceID.Type != libsignalgo.ServiceIDTypePNI { - return nil - } else if serviceID.UUID == s.Client.Store.PNI { - return &s.Client.Store.ACI - } else if s.Main.Bridge.Config.SplitPortals { - // When split portals is enabled, we don't care about anyone else's logins - return nil - } else if device, err := s.Client.Store.DeviceStore.DeviceByPNI(ctx, serviceID.UUID); err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to get ACI for PNI") - return nil - } else if device == nil { - return nil - } else { - return &device.ACI - } -} - -func (s *SignalClient) catchUpGroup(ctx context.Context, portal *bridgev2.Portal, fromRevision, toRevision uint32, ts uint64) { - if fromRevision >= toRevision { - return - } - log := zerolog.Ctx(ctx).With(). - Str("action", "catch up group changes"). - Uint32("from_revision", fromRevision). - Uint32("to_revision", toRevision). - Logger() - if fromRevision == 0 { - log.Info().Msg("Syncing full group info") - info, err := s.getGroupInfo(ctx, types.GroupIdentifier(portal.ID), toRevision, nil) - if err != nil { - log.Err(err).Msg("Failed to get group info") - } else { - portal.UpdateInfo(ctx, info, s.UserLogin, nil, time.Time{}) - } - } else { - log.Info().Msg("Syncing missed group changes") - groupChanges, err := s.Client.GetGroupHistoryPage(ctx, types.GroupIdentifier(portal.ID), fromRevision, false) - if err != nil { - log.Err(err).Msg("Failed to get group history page") - s.catchUpGroup(ctx, portal, 0, toRevision, ts) - return - } - for _, gc := range groupChanges { - log.Debug().Uint32("current_rev", gc.GroupChange.Revision).Msg("Processing group change") - chatInfoChange, err := s.groupChangeToChatInfoChange(ctx, types.GroupIdentifier(portal.ID), gc.GroupChange.Revision, gc.GroupChange) - if err != nil { - log.Err(err).Msg("Failed to convert group info") - } else { - portal.ProcessChatInfoChange(ctx, s.makeEventSenderFromServiceID(gc.GroupChange.SourceServiceID), s.UserLogin, chatInfoChange, time.UnixMilli(int64(ts))) - } - if gc.GroupChange.Revision == toRevision { - break - } - } - } -} diff --git a/pkg/connector/handlematrix.go b/pkg/connector/handlematrix.go deleted file mode 100644 index 7bcb214..0000000 --- a/pkg/connector/handlematrix.go +++ /dev/null @@ -1,912 +0,0 @@ -// mautrix-signal - A Matrix-Signal puppeting bridge. -// Copyright (C) 2024 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package connector - -import ( - "context" - "crypto/sha256" - "errors" - "fmt" - "slices" - "strconv" - "time" - - "github.com/google/uuid" - "github.com/rs/zerolog" - "go.mau.fi/util/ptr" - "go.mau.fi/util/variationselector" - "google.golang.org/protobuf/proto" - "maunium.net/go/mautrix/bridgev2" - "maunium.net/go/mautrix/bridgev2/database" - "maunium.net/go/mautrix/bridgev2/networkid" - "maunium.net/go/mautrix/bridgev2/simplevent" - "maunium.net/go/mautrix/event" - - "go.mau.fi/mautrix-signal/pkg/libsignalgo" - "go.mau.fi/mautrix-signal/pkg/signalid" - "go.mau.fi/mautrix-signal/pkg/signalmeow" - signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" -) - -var ( - _ bridgev2.EditHandlingNetworkAPI = (*SignalClient)(nil) - _ bridgev2.ReactionHandlingNetworkAPI = (*SignalClient)(nil) - _ bridgev2.RedactionHandlingNetworkAPI = (*SignalClient)(nil) - _ bridgev2.ReadReceiptHandlingNetworkAPI = (*SignalClient)(nil) - _ bridgev2.TypingHandlingNetworkAPI = (*SignalClient)(nil) - _ bridgev2.RoomNameHandlingNetworkAPI = (*SignalClient)(nil) - _ bridgev2.RoomAvatarHandlingNetworkAPI = (*SignalClient)(nil) - _ bridgev2.RoomTopicHandlingNetworkAPI = (*SignalClient)(nil) - _ bridgev2.ChatViewingNetworkAPI = (*SignalClient)(nil) - _ bridgev2.DisappearTimerChangingNetworkAPI = (*SignalClient)(nil) - _ bridgev2.DeleteChatHandlingNetworkAPI = (*SignalClient)(nil) - _ bridgev2.PollHandlingNetworkAPI = (*SignalClient)(nil) - _ bridgev2.MessageRequestAcceptingNetworkAPI = (*SignalClient)(nil) -) - -func (s *SignalClient) sendMessage(ctx context.Context, portalID networkid.PortalID, content *signalpb.Content) error { - userID, groupID, err := signalid.ParsePortalID(portalID) - if err != nil { - return err - } - if groupID != "" { - result, err := s.Client.SendGroupMessage(ctx, groupID, content) - if err != nil { - return err - } - totalRecipients := len(result.FailedToSendTo) + len(result.SuccessfullySentTo) - log := zerolog.Ctx(ctx).With(). - Int("total_recipients", totalRecipients). - Int("failed_to_send_to_count", len(result.FailedToSendTo)). - Int("successfully_sent_to_count", len(result.SuccessfullySentTo)). - Logger() - if len(result.SuccessfullySentTo) == 0 && len(result.FailedToSendTo) == 0 { - log.Debug().Msg("No successes or failures - Probably sent to myself") - } else if len(result.SuccessfullySentTo) == 0 { - log.Error().Msg("Failed to send event to all members of Signal group") - return errors.New("failed to send to any members of Signal group") - } else if len(result.SuccessfullySentTo) < totalRecipients { - if len(result.FailedToSendTo) > 0 { - log.Warn().Msg("Failed to send event to some members of Signal group") - } else { - log.Warn().Msg("Only sent event to some members of Signal group") - } - } else { - log.Debug().Msg("Sent event to all members of Signal group") - } - return nil - } else { - res := s.Client.SendMessage(ctx, userID, content) - if !res.WasSuccessful { - return res.Error - } - return nil - } -} - -func getTimestampForEvent(txnID networkid.RawTransactionID, evt *event.Event, origSender *bridgev2.OrigSender) uint64 { - if origSender != nil { - // Relaybot messages are never allowed to set the timestamp - return uint64(time.Now().UnixMilli()) - } - if len(txnID) > 0 { - parsed, err := strconv.ParseUint(string(txnID), 10, 64) - if err == nil { - return parsed - } - } - return uint64(evt.Timestamp) -} - -func (s *SignalClient) HandleMatrixMessage(ctx context.Context, msg *bridgev2.MatrixMessage) (message *bridgev2.MatrixMessageResponse, err error) { - converted, err := s.Main.MsgConv.ToSignal( - ctx, s.Client, msg.Portal, msg.Event, msg.Content, msg.OrigSender != nil, msg.ReplyTo, - ) - if err != nil { - return nil, err - } - return s.doSendMessage(ctx, msg, converted, &signalid.MessageMetadata{ - ContainsAttachments: len(converted.Attachments) > 0, - }) -} - -func (s *SignalClient) doSendMessage( - ctx context.Context, - msg *bridgev2.MatrixMessage, - converted *signalpb.DataMessage, - meta *signalid.MessageMetadata, -) (*bridgev2.MatrixMessageResponse, error) { - ts := getTimestampForEvent(msg.InputTransactionID, msg.Event, msg.OrigSender) - converted.Timestamp = &ts - if meta == nil { - meta = &signalid.MessageMetadata{} - } - msgID := signalid.MakeMessageID(s.Client.Store.ACI, ts) - msg.AddPendingToIgnore(networkid.TransactionID(msgID)) - err := s.sendMessage(ctx, msg.Portal.ID, signalmeow.WrapDataMessage(converted)) - if err != nil { - return nil, bridgev2.WrapErrorInStatus(err).WithSendNotice(true) - } - dbMsg := &database.Message{ - ID: msgID, - SenderID: signalid.MakeUserID(s.Client.Store.ACI), - Timestamp: time.UnixMilli(int64(ts)), - Metadata: meta, - } - return &bridgev2.MatrixMessageResponse{ - DB: dbMsg, - RemovePending: networkid.TransactionID(msgID), - }, nil -} - -func (s *SignalClient) HandleMatrixEdit(ctx context.Context, msg *bridgev2.MatrixEdit) error { - _, targetSentTimestamp, err := signalid.ParseMessageID(msg.EditTarget.ID) - if err != nil { - return fmt.Errorf("failed to parse target message ID: %w", err) - } else if msg.EditTarget.SenderID != signalid.MakeUserID(s.Client.Store.ACI) { - return fmt.Errorf("cannot edit other people's messages") - } - var replyTo *database.Message - if msg.EditTarget.ReplyTo.MessageID != "" { - replyTo, err = s.Main.Bridge.DB.Message.GetFirstOrSpecificPartByID(ctx, msg.Portal.Receiver, msg.EditTarget.ReplyTo) - if err != nil { - return fmt.Errorf("failed to get message reply target: %w", err) - } - } - converted, err := s.Main.MsgConv.ToSignal(ctx, s.Client, msg.Portal, msg.Event, msg.Content, msg.OrigSender != nil, replyTo) - if err != nil { - return err - } - ts := getTimestampForEvent(msg.InputTransactionID, msg.Event, msg.OrigSender) - converted.Timestamp = &ts - err = s.sendMessage(ctx, msg.Portal.ID, signalmeow.WrapEditMessage(&signalpb.EditMessage{ - TargetSentTimestamp: proto.Uint64(targetSentTimestamp), - DataMessage: converted, - })) - if err != nil { - return bridgev2.WrapErrorInStatus(err).WithSendNotice(true) - } - msg.EditTarget.ID = signalid.MakeMessageID(s.Client.Store.ACI, ts) - msg.EditTarget.Metadata = &signalid.MessageMetadata{ContainsAttachments: len(converted.Attachments) > 0} - msg.EditTarget.EditCount++ - return nil -} - -func (s *SignalClient) PreHandleMatrixReaction(ctx context.Context, msg *bridgev2.MatrixReaction) (bridgev2.MatrixReactionPreResponse, error) { - return bridgev2.MatrixReactionPreResponse{ - SenderID: signalid.MakeUserID(s.Client.Store.ACI), - EmojiID: "", - Emoji: variationselector.FullyQualify(msg.Content.RelatesTo.Key), - }, nil -} - -func (s *SignalClient) HandleMatrixReaction(ctx context.Context, msg *bridgev2.MatrixReaction) (reaction *database.Reaction, err error) { - targetAuthorACI, targetSentTimestamp, err := signalid.ParseMessageID(msg.TargetMessage.ID) - if err != nil { - return nil, fmt.Errorf("failed to parse target message ID: %w", err) - } - ts := getTimestampForEvent(msg.InputTransactionID, msg.Event, msg.OrigSender) - err = s.sendMessage(ctx, msg.Portal.ID, signalmeow.WrapDataMessage(&signalpb.DataMessage{ - Timestamp: proto.Uint64(ts), - RequiredProtocolVersion: proto.Uint32(uint32(signalpb.DataMessage_REACTIONS)), - Reaction: &signalpb.DataMessage_Reaction{ - Emoji: proto.String(msg.PreHandleResp.Emoji), - Remove: proto.Bool(false), - TargetAuthorAciBinary: targetAuthorACI[:], - TargetSentTimestamp: proto.Uint64(targetSentTimestamp), - }, - })) - if err != nil { - return nil, err - } - return &database.Reaction{}, nil -} - -func (s *SignalClient) HandleMatrixReactionRemove(ctx context.Context, msg *bridgev2.MatrixReactionRemove) error { - targetAuthorACI, targetSentTimestamp, err := signalid.ParseMessageID(msg.TargetReaction.MessageID) - if err != nil { - return fmt.Errorf("failed to parse target message ID: %w", err) - } - ts := getTimestampForEvent(msg.InputTransactionID, msg.Event, msg.OrigSender) - err = s.sendMessage(ctx, msg.Portal.ID, signalmeow.WrapDataMessage(&signalpb.DataMessage{ - Timestamp: proto.Uint64(ts), - RequiredProtocolVersion: proto.Uint32(uint32(signalpb.DataMessage_REACTIONS)), - Reaction: &signalpb.DataMessage_Reaction{ - Emoji: proto.String(msg.TargetReaction.Emoji), - Remove: proto.Bool(true), - TargetAuthorAciBinary: targetAuthorACI[:], - TargetSentTimestamp: proto.Uint64(targetSentTimestamp), - }, - })) - if err != nil { - return err - } - return nil -} - -func (s *SignalClient) HandleMatrixMessageRemove(ctx context.Context, msg *bridgev2.MatrixMessageRemove) error { - _, targetSentTimestamp, err := signalid.ParseMessageID(msg.TargetMessage.ID) - if err != nil { - return fmt.Errorf("failed to parse target message ID: %w", err) - } else if msg.TargetMessage.SenderID != signalid.MakeUserID(s.Client.Store.ACI) { - return fmt.Errorf("cannot delete other people's messages") - } - ts := getTimestampForEvent(msg.InputTransactionID, msg.Event, msg.OrigSender) - err = s.sendMessage(ctx, msg.Portal.ID, signalmeow.WrapDataMessage(&signalpb.DataMessage{ - Timestamp: proto.Uint64(ts), - Delete: &signalpb.DataMessage_Delete{ - TargetSentTimestamp: proto.Uint64(targetSentTimestamp), - }, - })) - if err != nil { - return err - } - return nil -} - -func (s *SignalClient) HandleMatrixReadReceipt(ctx context.Context, receipt *bridgev2.MatrixReadReceipt) error { - if !receipt.ReadUpTo.After(receipt.LastRead) { - return nil - } - if receipt.LastRead.IsZero() { - receipt.LastRead = receipt.ReadUpTo.Add(-5 * time.Second) - } - dbMessages, err := s.Main.Bridge.DB.Message.GetMessagesBetweenTimeQuery(ctx, receipt.Portal.PortalKey, receipt.LastRead, receipt.ReadUpTo) - if err != nil { - return fmt.Errorf("failed to get messages to mark as read: %w", err) - } else if len(dbMessages) == 0 { - return nil - } - messagesToRead := map[uuid.UUID][]uint64{} - for _, msg := range dbMessages { - userID, timestamp, err := signalid.ParseMessageID(msg.ID) - if err != nil { - continue - } - messagesToRead[userID] = append(messagesToRead[userID], timestamp) - } - zerolog.Ctx(ctx).Debug(). - Any("targets", messagesToRead). - Msg("Collected read receipt target messages") - - // TODO send sync message manually containing all read receipts instead of a separate message for each recipient - - for destination, messages := range messagesToRead { - // Don't send read receipts for own messages - if destination == s.Client.Store.ACI { - continue - } - // Don't use portal.sendSignalMessage because we're sending this straight to - // who sent the original message, not the portal's ChatID - ctx, cancel := context.WithTimeout(ctx, 10*time.Second) - result := s.Client.SendMessage(ctx, libsignalgo.NewACIServiceID(destination), signalmeow.ReadReceptMessageForTimestamps(messages)) - cancel() - if !result.WasSuccessful { - zerolog.Ctx(ctx).Err(result.Error). - Stringer("destination", destination). - Uints64("message_ids", messages). - Msg("Failed to send read receipt to Signal") - } else { - zerolog.Ctx(ctx).Debug(). - Stringer("destination", destination). - Uints64("message_ids", messages). - Msg("Sent read receipt to Signal") - } - } - return nil -} - -func (s *SignalClient) HandleMatrixTyping(ctx context.Context, typing *bridgev2.MatrixTyping) error { - userID, groupID, err := signalid.ParsePortalID(typing.Portal.ID) - if err != nil { - return err - } - typingMessage := signalmeow.TypingMessage(typing.IsTyping) - if !userID.IsEmpty() && userID.Type == libsignalgo.ServiceIDTypeACI { - result := s.Client.SendMessage(ctx, userID, typingMessage) - if !result.WasSuccessful { - return result.Error - } - } else if groupID != "" { - _, err = s.Client.SendGroupMessage(ctx, groupID, typingMessage) - if err != nil { - return err - } - } - return nil -} - -func (s *SignalClient) handleMatrixRoomMeta(ctx context.Context, portal *bridgev2.Portal, gc *signalmeow.GroupChange, postUpdatePortal func()) (bool, error) { - _, groupID, err := signalid.ParsePortalID(portal.ID) - if err != nil || groupID == "" { - return false, err - } - gc.Revision = portal.Metadata.(*signalid.PortalMetadata).Revision + 1 - revision, err := s.Client.UpdateGroup(ctx, gc, groupID) - if err != nil { - return false, err - } - if gc.ModifyTitle != nil { - portal.Name = *gc.ModifyTitle - portal.NameSet = true - } - if gc.ModifyDescription != nil { - portal.Topic = *gc.ModifyDescription - portal.TopicSet = true - } - if gc.ModifyAvatar != nil { - portal.AvatarID = makeAvatarPathID(*gc.ModifyAvatar) - portal.AvatarSet = true - } - if postUpdatePortal != nil { - postUpdatePortal() - } - portal.Metadata.(*signalid.PortalMetadata).Revision = revision - return true, nil -} - -func (s *SignalClient) HandleMatrixRoomName(ctx context.Context, msg *bridgev2.MatrixRoomName) (bool, error) { - return s.handleMatrixRoomMeta(ctx, msg.Portal, &signalmeow.GroupChange{ - ModifyTitle: &msg.Content.Name, - }, nil) -} - -func (s *SignalClient) HandleMatrixRoomAvatar(ctx context.Context, msg *bridgev2.MatrixRoomAvatar) (bool, error) { - _, groupID, err := signalid.ParsePortalID(msg.Portal.ID) - if err != nil || groupID == "" { - return false, err - } - var avatarPath string - var avatarHash [32]byte - if msg.Content.URL != "" { - data, err := s.Main.Bridge.Bot.DownloadMedia(ctx, msg.Content.URL, nil) - if err != nil { - return false, fmt.Errorf("failed to download avatar: %w", err) - } - avatarHash = sha256.Sum256(data) - avatarPath, err = s.Client.UploadGroupAvatar(ctx, data, groupID, "") - if err != nil { - return false, fmt.Errorf("failed to reupload avatar: %w", err) - } - } - return s.handleMatrixRoomMeta(ctx, msg.Portal, &signalmeow.GroupChange{ - ModifyAvatar: &avatarPath, - }, func() { - msg.Portal.AvatarMXC = msg.Content.URL - msg.Portal.AvatarHash = avatarHash - }) -} - -func (s *SignalClient) HandleMatrixRoomTopic(ctx context.Context, msg *bridgev2.MatrixRoomTopic) (bool, error) { - return s.handleMatrixRoomMeta(ctx, msg.Portal, &signalmeow.GroupChange{ - ModifyDescription: &msg.Content.Topic, - }, nil) -} - -func (s *SignalClient) HandleMatrixMembership(ctx context.Context, msg *bridgev2.MatrixMembershipChange) (*bridgev2.MatrixMembershipResult, error) { - if msg.Type.IsSelf && msg.OrigSender != nil { - return nil, nil - } - var targetIntent bridgev2.MatrixAPI - var targetSignalID libsignalgo.ServiceID - var err error - if msg.Portal.RoomType == database.RoomTypeDM { - switch msg.Type { - case bridgev2.Invite: - return nil, fmt.Errorf("cannot invite additional user to dm") - default: - return nil, nil - } - } - targetSignalID, err = signalid.ParseGhostOrUserLoginID(msg.Target) - if err != nil { - return nil, fmt.Errorf("failed to parse target signal id: %w", err) - } - switch target := msg.Target.(type) { - case *bridgev2.Ghost: - targetIntent = target.Intent - case *bridgev2.UserLogin: - targetIntent = target.User.DoublePuppet(ctx) - if targetIntent == nil { - ghost, err := s.Main.Bridge.GetGhostByID(ctx, networkid.UserID(target.ID)) - if err != nil { - return nil, fmt.Errorf("failed to get ghost for user: %w", err) - } - targetIntent = ghost.Intent - } - default: - return nil, fmt.Errorf("cannot get target intent: unknown type: %T", target) - } - log := zerolog.Ctx(ctx).With(). - Str("From Membership", string(msg.Type.From)). - Str("To Membership", string(msg.Type.To)). - Logger() - gc := &signalmeow.GroupChange{} - role := signalmeow.GroupMember_DEFAULT - if msg.Type.To == event.MembershipInvite || msg.Type == bridgev2.AcceptKnock { - levels, err := msg.Portal.Bridge.Matrix.GetPowerLevels(ctx, msg.Portal.MXID) - if err != nil { - log.Err(err).Msg("Couldn't get power levels") - if levels.GetUserLevel(targetIntent.GetMXID()) >= moderatorPL { - role = signalmeow.GroupMember_ADMINISTRATOR - } - } - } - switch msg.Type { - case bridgev2.AcceptInvite: - if targetSignalID.Type != libsignalgo.ServiceIDTypeACI { - return nil, fmt.Errorf("can't accept invite for non-ACI service ID") - } - gc.PromotePendingMembers = []*signalmeow.PromotePendingMember{{ - ACI: targetSignalID.UUID, - }} - case bridgev2.RevokeInvite, bridgev2.RejectInvite: - gc.DeletePendingMembers = []*libsignalgo.ServiceID{&targetSignalID} - case bridgev2.Leave, bridgev2.Kick: - if targetSignalID.Type != libsignalgo.ServiceIDTypeACI { - return nil, fmt.Errorf("can't kick non-ACI service ID") - } - gc.DeleteMembers = []*uuid.UUID{&targetSignalID.UUID} - case bridgev2.Invite: - if targetSignalID.Type == libsignalgo.ServiceIDTypeACI { - gc.AddMembers = []*signalmeow.AddMember{{ - GroupMember: signalmeow.GroupMember{ - ACI: targetSignalID.UUID, - Role: role, - }, - }} - } else { - gc.AddPendingMembers = []*signalmeow.PendingMember{{ - ServiceID: targetSignalID, - Role: role, - AddedByUserID: s.Client.Store.ACI, - Timestamp: uint64(msg.Event.Timestamp), - }} - } - // TODO: joining and knocking requires a way to obtain the invite link - // because the joining/knocking member doesn't have the GroupMasterKey yet - // case bridgev2.Join: - // gc.AddMembers = []*signalmeow.AddMember{{ - // GroupMember: signalmeow.GroupMember{ - // ACI: targetSignalID, - // Role: role, - // }, - // JoinFromInviteLink: true, - // }} - // case bridgev2.Knock: - // gc.AddRequestingMembers = []*signalmeow.RequestingMember{{ - // ACI: targetSignalID, - // Timestamp: uint64(time.Now().UnixMilli()), - // }} - case bridgev2.AcceptKnock: - if targetSignalID.Type != libsignalgo.ServiceIDTypeACI { - return nil, fmt.Errorf("can't accept knock from non-ACI service ID") - } - gc.PromoteRequestingMembers = []*signalmeow.RoleMember{{ - ACI: targetSignalID.UUID, - Role: role, - }} - case bridgev2.RetractKnock, bridgev2.RejectKnock: - if targetSignalID.Type != libsignalgo.ServiceIDTypeACI { - return nil, fmt.Errorf("can't reject knock from non-ACI service ID") - } - gc.DeleteRequestingMembers = []*uuid.UUID{&targetSignalID.UUID} - case bridgev2.BanKnocked, bridgev2.BanInvited, bridgev2.BanJoined, bridgev2.BanLeft: - gc.AddBannedMembers = []*signalmeow.BannedMember{{ - ServiceID: targetSignalID, - Timestamp: uint64(time.Now().UnixMilli()), - }} - switch msg.Type { - case bridgev2.BanJoined: - if targetSignalID.Type != libsignalgo.ServiceIDTypeACI { - return nil, fmt.Errorf("can't ban joined non-ACI service ID") - } - gc.DeleteMembers = []*uuid.UUID{&targetSignalID.UUID} - case bridgev2.BanInvited: - gc.DeletePendingMembers = []*libsignalgo.ServiceID{&targetSignalID} - case bridgev2.BanKnocked: - if targetSignalID.Type != libsignalgo.ServiceIDTypeACI { - return nil, fmt.Errorf("can't ban knocked non-ACI service ID") - } - gc.DeleteRequestingMembers = []*uuid.UUID{&targetSignalID.UUID} - } - case bridgev2.Unban: - gc.DeleteBannedMembers = []*libsignalgo.ServiceID{&targetSignalID} - default: - return nil, fmt.Errorf("unsupported membership change: %s -> %s", msg.Type.From, msg.Type.To) - } - _, groupID, err := signalid.ParsePortalID(msg.Portal.ID) - if err != nil || groupID == "" { - return nil, err - } - gc.Revision = msg.Portal.Metadata.(*signalid.PortalMetadata).Revision + 1 - revision, err := s.Client.UpdateGroup(ctx, gc, groupID) - if err != nil { - return nil, err - } - if msg.Type == bridgev2.Invite && targetSignalID.Type != libsignalgo.ServiceIDTypePNI { - err = targetIntent.EnsureJoined(ctx, msg.Portal.MXID) - if err != nil { - return nil, err - } - } - msg.Portal.Metadata.(*signalid.PortalMetadata).Revision = revision - return nil, nil -} - -func plToRole(pl int) signalmeow.GroupMemberRole { - if pl >= moderatorPL { - return signalmeow.GroupMember_ADMINISTRATOR - } else { - return signalmeow.GroupMember_DEFAULT - } -} - -func plToAccessControl(pl int) *signalmeow.AccessControl { - var accessControl signalmeow.AccessControl - if pl >= moderatorPL { - accessControl = signalmeow.AccessControl_ADMINISTRATOR - } else { - accessControl = signalmeow.AccessControl_MEMBER - } - return &accessControl -} - -func hasAdminChanged(plc *bridgev2.SinglePowerLevelChange) bool { - if plc == nil { - return false - } - return (plc.NewLevel < moderatorPL) != (plc.OrigLevel < moderatorPL) -} - -func (s *SignalClient) HandleMatrixPowerLevels(ctx context.Context, msg *bridgev2.MatrixPowerLevelChange) (bool, error) { - if msg.Portal.RoomType == database.RoomTypeDM { - return false, nil - } - gc := &signalmeow.GroupChange{} - for _, plc := range msg.Users { - if !hasAdminChanged(&plc.SinglePowerLevelChange) { - continue - } - serviceID, err := signalid.ParseGhostOrUserLoginID(plc.Target) - if err != nil || serviceID.Type != libsignalgo.ServiceIDTypeACI { - continue - } - gc.ModifyMemberRoles = append(gc.ModifyMemberRoles, &signalmeow.RoleMember{ - ACI: serviceID.UUID, - Role: plToRole(plc.NewLevel), - }) - } - if hasAdminChanged(msg.EventsDefault) { - announcementsOnly := msg.EventsDefault.NewLevel >= moderatorPL - gc.ModifyAnnouncementsOnly = &announcementsOnly - } - if hasAdminChanged(msg.StateDefault) { - gc.ModifyAttributesAccess = plToAccessControl(msg.StateDefault.NewLevel) - } - if hasAdminChanged(msg.Invite) { - gc.ModifyMemberAccess = plToAccessControl(msg.Invite.NewLevel) - } - _, groupID, err := signalid.ParsePortalID(msg.Portal.ID) - if err != nil || groupID == "" { - return false, err - } - revision, err := s.Client.UpdateGroup(ctx, gc, groupID) - if err != nil { - return false, err - } - msg.Portal.Metadata.(*signalid.PortalMetadata).Revision = revision - return true, nil -} - -func (s *SignalClient) HandleMatrixViewingChat(ctx context.Context, msg *bridgev2.MatrixViewingChat) error { - if msg.Portal == nil { - return nil - } - - // Sync the other users ghost in DMs - if msg.Portal.OtherUserID != "" { - ghost, err := s.Main.Bridge.GetExistingGhostByID(ctx, msg.Portal.OtherUserID) - if err != nil { - return fmt.Errorf("failed to get ghost for sync: %w", err) - } else if ghost == nil { - zerolog.Ctx(ctx).Warn(). - Str("other_user_id", string(msg.Portal.OtherUserID)). - Msg("No ghost found for other user in portal") - } else { - meta := ghost.Metadata.(*signalid.GhostMetadata) - if meta.ProfileFetchedAt.Time.Add(5 * time.Minute).Before(time.Now()) { - // Reset, but don't save, portal last sync time for immediate sync now - meta.ProfileFetchedAt.Time = time.Time{} - info, err := s.GetUserInfoWithRefreshAfter(ctx, ghost, 5*time.Minute) - if err != nil { - return fmt.Errorf("failed to get user info: %w", err) - } - ghost.UpdateInfo(ctx, info) - } - } - } - - // always resync the portal if its stale - portalMeta := msg.Portal.Metadata.(*signalid.PortalMetadata) - if portalMeta.LastSync.Add(24 * time.Hour).Before(time.Now()) { - s.UserLogin.QueueRemoteEvent(&simplevent.ChatResync{ - EventMeta: simplevent.EventMeta{ - Type: bridgev2.RemoteEventChatResync, - PortalKey: msg.Portal.PortalKey, - }, - GetChatInfoFunc: s.GetChatInfo, - }) - } - - return nil -} - -func (s *SignalClient) HandleMatrixDisappearingTimer(ctx context.Context, msg *bridgev2.MatrixDisappearingTimer) (bool, error) { - if msg.Content.Type != event.DisappearingTypeAfterRead && msg.Content.Timer.Duration != 0 { - return false, fmt.Errorf("unsupported disappearing timer type: %s", msg.Content.Type) - } - userID, groupID, err := signalid.ParsePortalID(msg.Portal.ID) - if err != nil { - return false, err - } - newSetting := database.DisappearingSetting{ - Type: event.DisappearingTypeAfterRead, - Timer: msg.Content.Timer.Duration, - } - if newSetting.Timer == 0 { - newSetting.Type = event.DisappearingTypeNone - } - if groupID != "" { - return s.handleMatrixRoomMeta(ctx, msg.Portal, &signalmeow.GroupChange{ - ModifyDisappearingMessagesDuration: ptr.Ptr(uint32(msg.Content.Timer.Seconds())), - }, func() { - msg.Portal.Disappear = newSetting - }) - } else { - ts := getTimestampForEvent(msg.InputTransactionID, msg.Event, msg.OrigSender) - res := s.Client.SendMessage(ctx, userID, signalmeow.WrapDataMessage(&signalpb.DataMessage{ - Timestamp: ptr.Ptr(ts), - Flags: ptr.Ptr(uint32(signalpb.DataMessage_EXPIRATION_TIMER_UPDATE)), - ExpireTimer: ptr.Ptr(uint32(msg.Content.Timer.Seconds())), - })) - if !res.WasSuccessful { - return false, res.Error - } - msg.Portal.Disappear = newSetting - return true, nil - } -} - -func (s *SignalClient) HandleMatrixDeleteChat(ctx context.Context, msg *bridgev2.MatrixDeleteChat) error { - userID, groupID, err := signalid.ParsePortalID(msg.Portal.ID) - if err != nil { - return fmt.Errorf("failed to parse portal ID: %w", err) - } - - if msg.Content.FromMessageRequest { - // TODO block and delete support? - err = s.syncMessageRequestResponse(ctx, msg.Portal, signalpb.SyncMessage_MessageRequestResponse_DELETE) - if err != nil { - return fmt.Errorf("failed to send message request delete sync: %w", err) - } - } - - // Build ConversationIdentifier based on portal type - var conversationID *signalpb.ConversationIdentifier - if groupID == "" { - conversationID = &signalpb.ConversationIdentifier{ - Identifier: &signalpb.ConversationIdentifier_ThreadServiceIdBinary{ - ThreadServiceIdBinary: userID.Bytes(), - }, - } - } else { - gid, err := groupID.Bytes() - if err != nil { - return fmt.Errorf("failed to parse group ID: %w", err) - } - conversationID = &signalpb.ConversationIdentifier{ - Identifier: &signalpb.ConversationIdentifier_ThreadGroupId{ - ThreadGroupId: gid[:], - }, - } - } - - // Retrieve most recent messages from the portal - var mostRecentMessages []*signalpb.AddressableMessage - dbMessages, err := s.Main.Bridge.DB.Message.GetMessagesBetweenTimeQuery( - ctx, - msg.Portal.PortalKey, - time.Now().Add(-30*24*time.Hour), // Last 30 days - time.Now(), - ) - if err != nil { - zerolog.Ctx(ctx).Warn().Err(err).Msg("Failed to get recent messages for conversation delete") - } else if len(dbMessages) > 0 { - // Limit to the 5 most recent messages overall - limit := 5 - startIdx := 0 - if len(dbMessages) > limit { - startIdx = len(dbMessages) - limit - } - - // Create AddressableMessage for most recent messages - for _, dbMsg := range dbMessages[startIdx:] { - senderACI, timestamp, err := signalid.ParseMessageID(dbMsg.ID) - if err != nil { - continue - } - - mostRecentMessages = append(mostRecentMessages, &signalpb.AddressableMessage{ - Author: &signalpb.AddressableMessage_AuthorServiceIdBinary{ - AuthorServiceIdBinary: senderACI[:], - }, - SentTimestamp: proto.Uint64(timestamp), - }) - } - } - - recipientID := s.Client.Store.ACIServiceID() - // Send DeleteForMe sync message to self - result := s.Client.SendMessage(ctx, recipientID, signalmeow.WrapSyncMessage(&signalpb.SyncMessage{ - Content: &signalpb.SyncMessage_DeleteForMe_{ - DeleteForMe: &signalpb.SyncMessage_DeleteForMe{ - ConversationDeletes: []*signalpb.SyncMessage_DeleteForMe_ConversationDelete{{ - Conversation: conversationID, - MostRecentMessages: mostRecentMessages, - IsFullDelete: proto.Bool(true), - }}, - }, - }, - })) - - zerolog.Ctx(ctx).Debug(). - Str("portal_id", string(msg.Portal.ID)). - Int("recent_messages_count", len(mostRecentMessages)). - Msg("Sent conversation deletion to Signal") - - if !result.WasSuccessful { - return fmt.Errorf("failed to send delete conversation sync message: %w %s %s", result.Error, userID, groupID) - } - - return nil -} - -func (s *SignalClient) HandleMatrixPollStart(ctx context.Context, msg *bridgev2.MatrixPollStart) (*bridgev2.MatrixMessageResponse, error) { - optionNames := make([]string, len(msg.Content.PollStart.Answers)) - optionIDs := make([]string, len(msg.Content.PollStart.Answers)) - for i, option := range msg.Content.PollStart.Answers { - optionNames[i] = option.Text - optionIDs[i] = option.ID - } - converted := &signalpb.DataMessage{ - PollCreate: &signalpb.DataMessage_PollCreate{ - Question: ptr.Ptr(msg.Content.PollStart.Question.Text), - AllowMultiple: ptr.Ptr(msg.Content.PollStart.MaxSelections != 1), - Options: optionNames, - }, - RequiredProtocolVersion: ptr.Ptr(uint32(signalpb.DataMessage_POLLS)), - } - return s.doSendMessage(ctx, &msg.MatrixMessage, converted, &signalid.MessageMetadata{ - MatrixPollOptionIDs: optionIDs, - }) -} - -func (s *SignalClient) HandleMatrixPollVote(ctx context.Context, msg *bridgev2.MatrixPollVote) (*bridgev2.MatrixMessageResponse, error) { - senderACI, msgTS, err := signalid.ParseMessageID(msg.VoteTo.ID) - if err != nil { - return nil, err - } - mxOptions := msg.VoteTo.Metadata.(*signalid.MessageMetadata).MatrixPollOptionIDs - optionIndexes := make([]uint32, len(msg.Content.Response.Answers)) - for i, answer := range msg.Content.Response.Answers { - if idx := slices.Index(mxOptions, answer); idx >= 0 { - optionIndexes[i] = uint32(idx) - } else if idx, err = strconv.Atoi(answer); err == nil && idx >= 0 { - optionIndexes[i] = uint32(idx) - } else { - return nil, fmt.Errorf("unknown poll answer ID: %s", answer) - } - } - converted := &signalpb.DataMessage{ - PollVote: &signalpb.DataMessage_PollVote{ - TargetAuthorAciBinary: senderACI[:], - TargetSentTimestamp: &msgTS, - OptionIndexes: optionIndexes, - VoteCount: proto.Uint32(1), // TODO - }, - RequiredProtocolVersion: proto.Uint32(0), - } - return s.doSendMessage(ctx, &msg.MatrixMessage, converted, nil) -} - -func (s *SignalClient) syncMessageRequestResponse( - ctx context.Context, - portal *bridgev2.Portal, - respType signalpb.SyncMessage_MessageRequestResponse_Type, -) error { - userID, groupID, err := signalid.ParsePortalID(portal.ID) - if err != nil { - return err - } - accept := &signalpb.SyncMessage_MessageRequestResponse{ - Type: respType.Enum(), - } - if groupID != "" { - gidBytes, err := groupID.Bytes() - if err != nil { - return fmt.Errorf("failed to parse group ID: %w", err) - } - accept.GroupId = gidBytes[:] - } else if userID.Type == libsignalgo.ServiceIDTypeACI { - accept.ThreadAciBinary = userID.UUID[:] - } else { - return fmt.Errorf("invalid portal ID for message request response: %s", portal.ID) - } - res := s.Client.SendMessage(ctx, libsignalgo.NewACIServiceID(s.Client.Store.ACI), signalmeow.WrapSyncMessage(&signalpb.SyncMessage{ - Content: &signalpb.SyncMessage_MessageRequestResponse_{ - MessageRequestResponse: accept, - }, - })) - if !res.WasSuccessful { - return res.Error - } - return nil -} - -func (s *SignalClient) HandleMatrixAcceptMessageRequest(ctx context.Context, msg *bridgev2.MatrixAcceptMessageRequest) error { - userID, _, err := signalid.ParsePortalID(msg.Portal.ID) - if err != nil { - return err - } - err = s.syncMessageRequestResponse(ctx, msg.Portal, signalpb.SyncMessage_MessageRequestResponse_ACCEPT) - if err != nil { - return fmt.Errorf("failed to sync message request acceptance: %w", err) - } - if userID.Type == libsignalgo.ServiceIDTypeACI { - profileKey, err := s.Client.ProfileKeyForSignalID(ctx, s.Client.Store.ACI) - if err != nil { - return fmt.Errorf("failed to get own profile key: %w", err) - } - var pniSig *signalpb.PniSignatureMessage - if s.Client.Store.AccountRecord.GetPhoneNumberSharingMode() == signalpb.AccountRecord_EVERYBODY { - sig, err := s.Client.Store.PNIIdentityKeyPair.SignAlternateIdentity(s.Client.Store.ACIIdentityKeyPair.GetIdentityKey()) - if err != nil { - return fmt.Errorf("failed to generate PNI signature: %w", err) - } - pniSig = &signalpb.PniSignatureMessage{ - Pni: s.Client.Store.PNI[:], - Signature: sig, - } - } - res := s.Client.SendMessage(ctx, userID, &signalpb.Content{ - Content: &signalpb.Content_DataMessage{DataMessage: &signalpb.DataMessage{ - Flags: proto.Uint32(uint32(signalpb.DataMessage_PROFILE_KEY_UPDATE)), - ProfileKey: profileKey.Slice(), - Timestamp: proto.Uint64(getTimestampForEvent(msg.InputTransactionID, msg.Event, msg.OrigSender)), - - RequiredProtocolVersion: proto.Uint32(0), - }}, - PniSignatureMessage: pniSig, - }) - if !res.WasSuccessful { - return fmt.Errorf("failed to share profile key to accept message request: %w", res.Error) - } - // TODO send read receipts too? - } - return nil -} diff --git a/pkg/connector/handlesignal.go b/pkg/connector/handlesignal.go deleted file mode 100644 index 329b2cf..0000000 --- a/pkg/connector/handlesignal.go +++ /dev/null @@ -1,809 +0,0 @@ -// mautrix-signal - A Matrix-Signal puppeting bridge. -// Copyright (C) 2024 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package connector - -import ( - "context" - "encoding/base64" - "fmt" - "strings" - "time" - - "github.com/google/uuid" - "github.com/rs/zerolog" - "go.mau.fi/util/exzerolog" - "go.mau.fi/util/jsontime" - "go.mau.fi/util/ptr" - "maunium.net/go/mautrix/bridgev2" - "maunium.net/go/mautrix/bridgev2/database" - "maunium.net/go/mautrix/bridgev2/networkid" - "maunium.net/go/mautrix/bridgev2/simplevent" - "maunium.net/go/mautrix/bridgev2/status" - "maunium.net/go/mautrix/event" - - "go.mau.fi/mautrix-signal/pkg/libsignalgo" - "go.mau.fi/mautrix-signal/pkg/signalid" - "go.mau.fi/mautrix-signal/pkg/signalmeow" - "go.mau.fi/mautrix-signal/pkg/signalmeow/events" - signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" - "go.mau.fi/mautrix-signal/pkg/signalmeow/types" -) - -func (s *SignalClient) handleSignalEvent(rawEvt events.SignalEvent) bool { - switch evt := rawEvt.(type) { - case *events.ChatEvent: - return s.Main.Bridge.QueueRemoteEvent(s.UserLogin, &Bv2ChatEvent{ChatEvent: evt, s: s}).Success - case *events.DecryptionError: - return s.Main.Bridge.QueueRemoteEvent(s.UserLogin, s.wrapDecryptionError(evt)).Success - case *events.Receipt: - return s.handleSignalReceipt(evt) - case *events.ReadSelf: - return s.handleSignalReadSelf(evt) - case *events.DeleteForMe: - return s.handleSignalDeleteForMe(evt) - case *events.MessageRequestResponse: - return s.handleSignalMessageRequestResponse(evt) - case *events.Call: - return s.Main.Bridge.QueueRemoteEvent(s.UserLogin, s.wrapCallEvent(evt)).Success - case *events.ContactList: - s.handleSignalContactList(evt) - case *events.ACIFound: - s.handleSignalACIFound(evt) - case *events.QueueEmpty: - s.queueEmptyWaiter.Set() - case *events.LoggedOut: - s.UserLogin.BridgeState.Send(status.BridgeState{StateEvent: status.StateBadCredentials, Message: evt.Error.Error()}) - default: - s.UserLogin.Log.Warn().Type("event_type", evt).Msg("Unrecognized signalmeow event type") - } - return true -} - -func (s *SignalClient) wrapCallEvent(evt *events.Call) bridgev2.RemoteMessage { - return &simplevent.Message[*events.Call]{ - EventMeta: simplevent.EventMeta{ - Type: bridgev2.RemoteEventMessage, - LogContext: func(c zerolog.Context) zerolog.Context { - c = c.Stringer("sender_id", evt.Info.Sender) - c = c.Uint64("message_ts", evt.Timestamp) - return c - }, - PortalKey: s.makePortalKey(evt.Info.ChatID), - CreatePortal: true, - Sender: s.makeEventSender(evt.Info.Sender), - Timestamp: time.UnixMilli(int64(evt.Timestamp)), - }, - Data: evt, - ID: signalid.MakeMessageID(evt.Info.Sender, evt.Timestamp), - - ConvertMessageFunc: convertCallEvent, - } -} - -func convertCallEvent(ctx context.Context, portal *bridgev2.Portal, intent bridgev2.MatrixAPI, data *events.Call) (*bridgev2.ConvertedMessage, error) { - content := &event.MessageEventContent{ - MsgType: event.MsgNotice, - } - if data.IsRinging { - content.Body = "Incoming call" - if userID, _, _ := signalid.ParsePortalID(portal.ID); !userID.IsEmpty() { - content.MsgType = event.MsgText - } - content.BeeperActionMessage = &event.BeeperActionMessage{ - Type: event.BeeperActionMessageCall, - } - } else { - content.Body = "Call ended" - } - return &bridgev2.ConvertedMessage{ - Parts: []*bridgev2.ConvertedMessagePart{{ - Type: event.EventMessage, - Content: content, - }}, - }, nil -} - -func (s *SignalClient) wrapDecryptionError(evt *events.DecryptionError) bridgev2.RemoteMessage { - return &simplevent.Message[*events.DecryptionError]{ - EventMeta: simplevent.EventMeta{ - Type: bridgev2.RemoteEventMessage, - LogContext: func(c zerolog.Context) zerolog.Context { - c = c.Stringer("sender_id", evt.Sender) - c = c.Uint64("message_ts", evt.Timestamp) - return c - }, - PortalKey: s.makePortalKey(evt.Sender.String()), - CreatePortal: true, - Sender: s.makeEventSender(evt.Sender), - Timestamp: time.UnixMilli(int64(evt.Timestamp)), - StreamOrder: int64(evt.Timestamp), - }, - Data: evt, - // TODO use main message id and edit it if it later becomes decryptable? - ID: "decrypterr|" + signalid.MakeMessageID(evt.Sender, evt.Timestamp), - - ConvertMessageFunc: convertDecryptionError, - } -} - -func convertDecryptionError(_ context.Context, _ *bridgev2.Portal, _ bridgev2.MatrixAPI, _ *events.DecryptionError) (*bridgev2.ConvertedMessage, error) { - return &bridgev2.ConvertedMessage{ - Parts: []*bridgev2.ConvertedMessagePart{{ - Type: event.EventMessage, - Content: &event.MessageEventContent{ - MsgType: event.MsgNotice, - Body: "Message couldn't be decrypted. It may have been in this chat or a group chat. Please check your Signal app.", - }, - }}, - }, nil -} - -type Bv2ChatEvent struct { - *events.ChatEvent - s *SignalClient -} - -var ( - _ bridgev2.RemoteMessage = (*Bv2ChatEvent)(nil) - _ bridgev2.RemoteEdit = (*Bv2ChatEvent)(nil) - _ bridgev2.RemoteEventWithTimestamp = (*Bv2ChatEvent)(nil) - _ bridgev2.RemoteReaction = (*Bv2ChatEvent)(nil) - _ bridgev2.RemoteReactionRemove = (*Bv2ChatEvent)(nil) - _ bridgev2.RemoteMessageRemove = (*Bv2ChatEvent)(nil) - _ bridgev2.RemoteTyping = (*Bv2ChatEvent)(nil) - _ bridgev2.RemotePreHandler = (*Bv2ChatEvent)(nil) - _ bridgev2.RemoteChatInfoChange = (*Bv2ChatEvent)(nil) - _ bridgev2.RemoteEventWithStreamOrder = (*Bv2ChatEvent)(nil) -) - -func (evt *Bv2ChatEvent) GetType() bridgev2.RemoteEventType { - switch innerEvt := evt.Event.(type) { - case *signalpb.DataMessage: - switch { - case innerEvt.Body != nil, innerEvt.Attachments != nil, innerEvt.Contact != nil, innerEvt.Sticker != nil, - innerEvt.Payment != nil, innerEvt.GiftBadge != nil, innerEvt.PollCreate != nil, innerEvt.PollVote != nil, - innerEvt.GetRequiredProtocolVersion() > uint32(signalpb.DataMessage_CURRENT), - innerEvt.GetFlags()&uint32(signalpb.DataMessage_EXPIRATION_TIMER_UPDATE) != 0: - return bridgev2.RemoteEventMessage - case innerEvt.Reaction != nil: - if innerEvt.Reaction.GetRemove() { - return bridgev2.RemoteEventReactionRemove - } - return bridgev2.RemoteEventReaction - case innerEvt.Delete != nil, innerEvt.AdminDelete != nil: - return bridgev2.RemoteEventMessageRemove - case innerEvt.GetGroupV2().GetGroupChange() != nil: - return bridgev2.RemoteEventChatInfoChange - } - case *signalpb.EditMessage: - return bridgev2.RemoteEventEdit - case *signalpb.TypingMessage: - return bridgev2.RemoteEventTyping - } - return bridgev2.RemoteEventUnknown -} - -func (evt *Bv2ChatEvent) GetChatInfoChange(ctx context.Context) (*bridgev2.ChatInfoChange, error) { - dm, _ := evt.Event.(*signalpb.DataMessage) - gv2 := dm.GetGroupV2() - if gv2 == nil || gv2.GroupChange == nil { - return nil, fmt.Errorf("GetChatInfoChange() called for non-GroupChange event") - } - groupChange, err := evt.s.Client.DecryptGroupChange(ctx, gv2) - if err != nil { - return nil, fmt.Errorf("failed to decrypt group change: %w", err) - } - // XXX: is this ID compatible with types.GroupIdentifier? - return evt.s.groupChangeToChatInfoChange(ctx, types.GroupIdentifier(evt.Info.ChatID), gv2.GetRevision(), groupChange) -} - -func (evt *Bv2ChatEvent) PreHandle(ctx context.Context, portal *bridgev2.Portal) { - dataMsg, ok := evt.Event.(*signalpb.DataMessage) - if !ok || dataMsg.GroupV2 == nil { - return - } - portalRev := portal.Metadata.(*signalid.PortalMetadata).Revision - if evt.Info.GroupRevision > portalRev { - toRevision := evt.Info.GroupRevision - if dataMsg.GetGroupV2().GetGroupChange() != nil { - toRevision-- - } - evt.s.catchUpGroup(ctx, portal, portalRev, toRevision, dataMsg.GetTimestamp()) - } -} - -func (evt *Bv2ChatEvent) GetTimeout() time.Duration { - if evt.Event.(*signalpb.TypingMessage).GetAction() == signalpb.TypingMessage_STARTED { - return 15 * time.Second - } else { - return 0 - } -} - -func (evt *Bv2ChatEvent) GetPortalKey() networkid.PortalKey { - return evt.s.makePortalKey(evt.Info.ChatID) -} - -func (evt *Bv2ChatEvent) ShouldCreatePortal() bool { - return evt.GetType() == bridgev2.RemoteEventMessage || evt.GetType() == bridgev2.RemoteEventChatInfoChange -} - -func (evt *Bv2ChatEvent) AddLogContext(c zerolog.Context) zerolog.Context { - c = c.Stringer("sender_id", evt.Info.Sender) - switch innerEvt := evt.Event.(type) { - case *signalpb.DataMessage: - c = c.Uint64("message_ts", innerEvt.GetTimestamp()) - switch { - case innerEvt.Reaction != nil: - c = c.Uint64("reaction_target_ts", innerEvt.Reaction.GetTargetSentTimestamp()) - case innerEvt.Delete != nil: - c = c.Uint64("delete_target_ts", innerEvt.Delete.GetTargetSentTimestamp()) - } - case *signalpb.EditMessage: - c = c. - Uint64("edit_target_ts", innerEvt.GetTargetSentTimestamp()). - Uint64("edit_ts", innerEvt.GetDataMessage().GetTimestamp()) - } - return c -} - -func (evt *Bv2ChatEvent) GetSender() bridgev2.EventSender { - return evt.s.makeEventSender(evt.Info.Sender) -} - -func (evt *Bv2ChatEvent) GetID() networkid.MessageID { - ts := evt.getDataMsgTimestamp() - if ts == 0 { - return "" - } - return signalid.MakeMessageID(evt.Info.Sender, ts) -} - -func (evt *Bv2ChatEvent) getDataMsgTimestamp() uint64 { - switch innerEvt := evt.Event.(type) { - case *signalpb.DataMessage: - return innerEvt.GetTimestamp() - case *signalpb.EditMessage: - return innerEvt.GetDataMessage().GetTimestamp() - default: - return 0 - } -} - -func (evt *Bv2ChatEvent) GetTimestamp() time.Time { - ts := evt.getDataMsgTimestamp() - if ts == 0 { - return time.Now() - } - return time.UnixMilli(int64(ts)) -} - -func (evt *Bv2ChatEvent) GetTargetMessage() networkid.MessageID { - var targetAuthorACI uuid.UUID - var targetSentTS uint64 - switch innerEvt := evt.Event.(type) { - case *signalpb.DataMessage: - switch { - case innerEvt.Reaction != nil: - targetAuthorACI, _ = signalmeow.ParseStringOrBinaryUUID(innerEvt.Reaction.GetTargetAuthorAci(), innerEvt.Reaction.GetTargetAuthorAciBinary()) - targetSentTS = innerEvt.Reaction.GetTargetSentTimestamp() - case innerEvt.Delete != nil: - targetSentTS = innerEvt.Delete.GetTargetSentTimestamp() - case innerEvt.AdminDelete != nil: - if len(innerEvt.AdminDelete.GetTargetAuthorAciBinary()) == 16 { - targetAuthorACI = uuid.UUID(innerEvt.AdminDelete.GetTargetAuthorAciBinary()) - } - targetSentTS = innerEvt.AdminDelete.GetTargetSentTimestamp() - default: - return "" - } - case *signalpb.EditMessage: - targetSentTS = innerEvt.GetTargetSentTimestamp() - default: - return "" - } - if targetAuthorACI == uuid.Nil { - targetAuthorACI = evt.Info.Sender - } - return signalid.MakeMessageID(targetAuthorACI, targetSentTS) -} - -func (evt *Bv2ChatEvent) GetReactionEmoji() (string, networkid.EmojiID) { - dataMsg, ok := evt.Event.(*signalpb.DataMessage) - if !ok || dataMsg.Reaction == nil { - panic(fmt.Errorf("GetReactionEmoji() called for non-reaction event")) - } - return dataMsg.GetReaction().GetEmoji(), "" -} - -func (evt *Bv2ChatEvent) GetRemovedEmojiID() networkid.EmojiID { - return "" -} - -func (evt *Bv2ChatEvent) ConvertMessage(ctx context.Context, portal *bridgev2.Portal, intent bridgev2.MatrixAPI) (*bridgev2.ConvertedMessage, error) { - dataMsg, ok := evt.Event.(*signalpb.DataMessage) - if !ok { - return nil, fmt.Errorf("ConvertMessage() called for non-DataMessage event") - } - converted := evt.s.Main.MsgConv.ToMatrix(ctx, evt.s.Client, portal, evt.Info.Sender, intent, dataMsg, nil) - if converted.Disappear.Type != "" { - evtTS := evt.GetTimestamp() - if !dataMsg.GetIsViewOnce() { - portal.UpdateDisappearingSetting(ctx, converted.Disappear, bridgev2.UpdateDisappearingSettingOpts{ - Sender: intent, - Timestamp: evtTS, - Implicit: true, - Save: true, - SendNotice: true, - }) - } - if evt.Info.Sender == evt.s.Client.Store.ACI { - converted.Disappear.DisappearAt = evtTS.Add(converted.Disappear.Timer) - } - } - return converted, nil -} - -func (evt *Bv2ChatEvent) ConvertEdit(ctx context.Context, portal *bridgev2.Portal, intent bridgev2.MatrixAPI, existing []*database.Message) (*bridgev2.ConvertedEdit, error) { - editMsg, ok := evt.Event.(*signalpb.EditMessage) - if !ok { - return nil, fmt.Errorf("ConvertEdit() called for non-EditMessage event") - } - // TODO tell converter about existing parts to avoid reupload? - converted := evt.s.Main.MsgConv.ToMatrix(ctx, evt.s.Client, portal, evt.Info.Sender, intent, editMsg.GetDataMessage(), nil) - // TODO can anything other than the text be edited? - editPart := converted.Parts[len(converted.Parts)-1].ToEditPart(existing[len(existing)-1]) - editPart.Part.EditCount++ - editPart.Part.ID = signalid.MakeMessageID(evt.Info.Sender, editMsg.GetDataMessage().GetTimestamp()) - return &bridgev2.ConvertedEdit{ - ModifiedParts: []*bridgev2.ConvertedEditPart{editPart}, - }, nil -} - -func (evt *Bv2ChatEvent) GetStreamOrder() int64 { - return int64(evt.Info.ServerTimestamp) -} - -type Bv2Receipt struct { - Type signalpb.ReceiptMessage_Type - Chat networkid.PortalKey - Sender bridgev2.EventSender - - LastTS time.Time - LastID networkid.MessageID - IDs []networkid.MessageID -} - -func (b *Bv2Receipt) GetType() bridgev2.RemoteEventType { - switch b.Type { - case signalpb.ReceiptMessage_READ: - return bridgev2.RemoteEventReadReceipt - case signalpb.ReceiptMessage_DELIVERY: - return bridgev2.RemoteEventDeliveryReceipt - default: - return bridgev2.RemoteEventUnknown - } -} - -func (b *Bv2Receipt) GetPortalKey() networkid.PortalKey { - return b.Chat -} - -func (b *Bv2Receipt) AddLogContext(c zerolog.Context) zerolog.Context { - return c. - Str("sender_id", string(b.Sender.Sender)). - Stringer("receipt_type", b.Type). - Array("message_ids", exzerolog.ArrayOfStrs(b.IDs)) -} - -func (b *Bv2Receipt) GetSender() bridgev2.EventSender { - return b.Sender -} - -func (b *Bv2Receipt) GetLastReceiptTarget() networkid.MessageID { - return b.LastID -} - -func (b *Bv2Receipt) GetReceiptTargets() []networkid.MessageID { - return b.IDs -} - -func (b *Bv2Receipt) GetReadUpTo() time.Time { - return time.Time{} -} - -var _ bridgev2.RemoteReadReceipt = (*Bv2Receipt)(nil) - -func convertReceipts[T any](ctx context.Context, input []T, getMessageFunc func(ctx context.Context, msgID T) (*database.Message, error)) map[networkid.PortalKey]*Bv2Receipt { - log := zerolog.Ctx(ctx) - receipts := make(map[networkid.PortalKey]*Bv2Receipt) - for _, msgID := range input { - msg, err := getMessageFunc(ctx, msgID) - if err != nil { - log.Err(err).Any("message_id", msgID).Msg("Failed to get target message for receipt") - } else if msg == nil { - log.Debug().Any("message_id", msgID).Msg("Got receipt for unknown message") - } else { - receiptEvt, ok := receipts[msg.Room] - if !ok { - receiptEvt = &Bv2Receipt{Chat: msg.Room} - receipts[msg.Room] = receiptEvt - } - receiptEvt.IDs = append(receiptEvt.IDs, msg.ID) - if receiptEvt.LastTS.Before(msg.Timestamp) { - receiptEvt.LastTS = msg.Timestamp - receiptEvt.LastID = msg.ID - } - } - } - return receipts -} - -func (s *SignalClient) dispatchReceipts(sender uuid.UUID, receiptType signalpb.ReceiptMessage_Type, receipts map[networkid.PortalKey]*Bv2Receipt) bool { - evtSender := s.makeEventSender(sender) - for chat, receiptEvt := range receipts { - receiptEvt.Chat = chat - receiptEvt.Sender = evtSender - receiptEvt.Type = receiptType - if !s.Main.Bridge.QueueRemoteEvent(s.UserLogin, receiptEvt).Success { - return false - } - } - return true -} - -func (s *SignalClient) handleSignalReceipt(evt *events.Receipt) bool { - log := s.UserLogin.Log.With(). - Str("action", "handle signal receipt"). - Stringer("sender_id", evt.Sender). - Stringer("receipt_type", evt.Content.GetType()). - Logger() - ctx := log.WithContext(s.Main.Bridge.BackgroundCtx) - receipts := convertReceipts(ctx, evt.Content.Timestamp, func(ctx context.Context, msgTS uint64) (*database.Message, error) { - return s.Main.Bridge.DB.Message.GetFirstPartByID(ctx, s.UserLogin.ID, signalid.MakeMessageID(s.Client.Store.ACI, msgTS)) - }) - return s.dispatchReceipts(evt.Sender, evt.Content.GetType(), receipts) -} - -func (s *SignalClient) handleSignalReadSelf(evt *events.ReadSelf) bool { - log := s.UserLogin.Log.With(). - Str("action", "handle signal read self"). - Logger() - ctx := log.WithContext(s.Main.Bridge.BackgroundCtx) - receipts := convertReceipts(ctx, evt.Messages, func(ctx context.Context, msgInfo *signalpb.SyncMessage_Read) (*database.Message, error) { - aciUUID, err := signalmeow.ParseStringOrBinaryUUID(msgInfo.GetSenderAci(), msgInfo.GetSenderAciBinary()) - if err != nil { - return nil, err - } - return s.Main.Bridge.DB.Message.GetFirstPartByID(ctx, s.UserLogin.ID, signalid.MakeMessageID(aciUUID, msgInfo.GetTimestamp())) - }) - return s.dispatchReceipts(s.Client.Store.ACI, signalpb.ReceiptMessage_READ, receipts) -} - -func (s *SignalClient) conversationIDToPortalKey(ctx context.Context, cid *signalpb.ConversationIdentifier) (networkid.PortalKey, bool) { - log := zerolog.Ctx(ctx) - switch ident := cid.GetIdentifier().(type) { - case *signalpb.ConversationIdentifier_ThreadServiceId: - serviceID, err := libsignalgo.ServiceIDFromString(ident.ThreadServiceId) - if err != nil { - log.Err(err).Str("chat_id", ident.ThreadServiceId).Msg("Failed to parse delete for me conversation ID") - return networkid.PortalKey{}, false - } - return s.makeDMPortalKey(serviceID), true - case *signalpb.ConversationIdentifier_ThreadServiceIdBinary: - serviceID, err := libsignalgo.ServiceIDFromBytes(ident.ThreadServiceIdBinary) - if err != nil { - log.Err(err).Hex("chat_id", ident.ThreadServiceIdBinary).Msg("Failed to parse delete for me conversation ID") - return networkid.PortalKey{}, false - } - return s.makeDMPortalKey(serviceID), true - case *signalpb.ConversationIdentifier_ThreadGroupId: - if len(ident.ThreadGroupId) != libsignalgo.GroupIdentifierLength { - log.Error(). - Str("chat_id", base64.StdEncoding.EncodeToString(ident.ThreadGroupId)). - Msg("Invalid group ID length in delete for me conversation") - return networkid.PortalKey{}, false - } - return s.makePortalKey((*libsignalgo.GroupIdentifier)(ident.ThreadGroupId).String()), true - case *signalpb.ConversationIdentifier_ThreadE164: - log.Warn().Str("chat_id", ident.ThreadE164).Msg("Unsupported E164 conversation ID in delete for me") - return networkid.PortalKey{}, false - default: - log.Warn(). - Type("chat_id_type", ident). - Msg("Unsupported conversation ID protobuf type in delete for me") - return networkid.PortalKey{}, false - } -} - -func (s *SignalClient) addressableMessageToID(ctx context.Context, portalKey networkid.PortalKey, am *signalpb.AddressableMessage) networkid.MessageID { - log := zerolog.Ctx(ctx) - switch typedAuthor := am.GetAuthor().(type) { - case *signalpb.AddressableMessage_AuthorServiceId: - serviceID, err := libsignalgo.ServiceIDFromString(typedAuthor.AuthorServiceId) - if err != nil { - log.Err(err). - Object("portal_key", portalKey). - Str("author_service_id", typedAuthor.AuthorServiceId). - Msg("Failed to parse delete for me message author service ID") - return "" - } else if serviceID.Type != libsignalgo.ServiceIDTypeACI { - log.Warn(). - Object("portal_key", portalKey). - Str("author_service_id", typedAuthor.AuthorServiceId). - Msg("Dropping delete for me message with unsupported service ID type") - return "" - } - return signalid.MakeMessageID(serviceID.UUID, am.GetSentTimestamp()) - case *signalpb.AddressableMessage_AuthorServiceIdBinary: - serviceID, err := libsignalgo.ServiceIDFromBytes(typedAuthor.AuthorServiceIdBinary) - if err != nil { - log.Err(err). - Object("portal_key", portalKey). - Hex("author_service_id_binary", typedAuthor.AuthorServiceIdBinary). - Msg("Failed to parse delete for me message author service ID") - return "" - } else if serviceID.Type != libsignalgo.ServiceIDTypeACI { - log.Warn(). - Object("portal_key", portalKey). - Hex("author_service_id_binary", typedAuthor.AuthorServiceIdBinary). - Msg("Dropping delete for me message with unsupported service ID type") - return "" - } - return signalid.MakeMessageID(serviceID.UUID, am.GetSentTimestamp()) - case *signalpb.AddressableMessage_AuthorE164: - log.Warn(). - Object("portal_key", portalKey). - Str("author_e164", typedAuthor.AuthorE164). - Msg("Dropping delete for me message with unsupported E164 author") - return "" - default: - log.Warn(). - Object("portal_key", portalKey). - Type("author_type", typedAuthor). - Msg("Dropping delete for me message with unrecognized author protobuf type") - return "" - } -} - -func (s *SignalClient) handleSignalDeleteForMe(evt *events.DeleteForMe) bool { - log := s.UserLogin.Log.With(). - Str("action", "handle signal delete for me"). - Logger() - ctx := log.WithContext(s.Main.Bridge.BackgroundCtx) - for _, conv := range evt.GetConversationDeletes() { - if !conv.GetIsFullDelete() { - // Non-full deletes might mean clearing chats? - continue - } - portalKey, ok := s.conversationIDToPortalKey(ctx, conv.GetConversation()) - if !ok { - continue - } - - res := s.UserLogin.QueueRemoteEvent(&simplevent.ChatDelete{ - EventMeta: simplevent.EventMeta{ - Type: bridgev2.RemoteEventChatDelete, - PortalKey: portalKey, - Timestamp: time.UnixMilli(int64(evt.Timestamp)), - StreamOrder: int64(evt.Timestamp), - }, - OnlyForMe: true, - }) - if !res.Success { - return false - } - } - for _, conv := range evt.GetLocalOnlyConversationDeletes() { - portalKey, ok := s.conversationIDToPortalKey(ctx, conv.GetConversation()) - if !ok { - continue - } - - res := s.UserLogin.QueueRemoteEvent(&simplevent.ChatDelete{ - EventMeta: simplevent.EventMeta{ - Type: bridgev2.RemoteEventChatDelete, - PortalKey: portalKey, - Timestamp: time.UnixMilli(int64(evt.Timestamp)), - StreamOrder: int64(evt.Timestamp), - }, - OnlyForMe: true, - }) - if !res.Success { - return false - } - } - for _, conv := range evt.GetMessageDeletes() { - portalKey, ok := s.conversationIDToPortalKey(ctx, conv.GetConversation()) - if !ok { - continue - } - for _, msg := range conv.GetMessages() { - msgID := s.addressableMessageToID(ctx, portalKey, msg) - if msgID == "" { - continue - } - res := s.UserLogin.QueueRemoteEvent(&simplevent.MessageRemove{ - EventMeta: simplevent.EventMeta{ - Type: bridgev2.RemoteEventMessageRemove, - PortalKey: portalKey, - Timestamp: time.UnixMilli(int64(evt.Timestamp)), - StreamOrder: int64(evt.Timestamp), - }, - OnlyForMe: true, - TargetMessage: msgID, - }) - if !res.Success { - return false - } - } - } - return true -} - -func (s *SignalClient) handleSignalMessageRequestResponse(evt *events.MessageRequestResponse) bool { - if evt.Type != signalpb.SyncMessage_MessageRequestResponse_ACCEPT { - // TODO do we need to do anything with blocks/deletes here or are they sent as normal delete events? - return true - } - var portalKey networkid.PortalKey - if evt.GroupID != nil { - portalKey = s.makePortalKey(evt.GroupID.String()) - } else if evt.ThreadACI != uuid.Nil { - portalKey = s.makeDMPortalKey(libsignalgo.NewACIServiceID(evt.ThreadACI)) - } else { - return true - } - res := s.UserLogin.QueueRemoteEvent(&simplevent.ChatInfoChange{ - EventMeta: simplevent.EventMeta{ - Type: bridgev2.RemoteEventChatInfoChange, - PortalKey: portalKey, - Timestamp: time.UnixMilli(int64(evt.Timestamp)), - StreamOrder: int64(evt.Timestamp), - LogContext: func(c zerolog.Context) zerolog.Context { - return c.Str("action", "unmark message request").Str("source", "sync message") - }, - }, - ChatInfoChange: &bridgev2.ChatInfoChange{ - ChatInfo: &bridgev2.ChatInfo{ - MessageRequest: ptr.Ptr(false), - }, - }, - }) - return res.Success -} - -func (s *SignalClient) handleSignalACIFound(evt *events.ACIFound) { - log := s.UserLogin.Log.With(). - Str("action", "handle aci found"). - Stringer("aci", evt.ACI). - Stringer("pni", evt.PNI). - Logger() - ctx := log.WithContext(s.Main.Bridge.BackgroundCtx) - pniPortalKey := s.makeDMPortalKey(evt.PNI) - aciPortalKey := s.makeDMPortalKey(evt.ACI) - result, portal, err := s.Main.Bridge.ReIDPortal(ctx, pniPortalKey, aciPortalKey) - if err != nil { - log.Err(err).Msg("Failed to re-ID portal") - } else if result == bridgev2.ReIDResultSourceReIDd || result == bridgev2.ReIDResultTargetDeletedAndSourceReIDd { - // If the source portal is re-ID'd, we need to sync metadata and participants. - // If the source is deleted, then it doesn't matter, any existing target will already be correct - info, err := s.GetChatInfo(ctx, portal) - if err != nil { - log.Err(err).Msg("Failed to get chat info to update portal after re-ID") - } else { - portal.UpdateInfo(ctx, info, s.UserLogin, nil, time.Time{}) - } - } -} - -func (s *SignalClient) handleSignalContactList(evt *events.ContactList) { - log := s.UserLogin.Log.With().Str("action", "handle contact list").Logger() - ctx := log.WithContext(s.Main.Bridge.BackgroundCtx) - for _, contact := range evt.Contacts { - if contact.ACI == uuid.Nil { - continue - } - if !evt.IsFromDB { - fullContact, err := s.Client.ContactByACI(ctx, contact.ACI) - if err != nil { - log.Err(err).Msg("Failed to get full contact info from store") - continue - } - fullContact.ContactAvatar = contact.ContactAvatar - contact = fullContact - } - ghost, err := s.Main.Bridge.GetGhostByID(ctx, signalid.MakeUserID(contact.ACI)) - if err != nil { - log.Err(err).Msg("Failed to get ghost to update contact info") - continue - } - userInfo, err := s.contactToUserInfo(ctx, contact) - if err != nil { - log.Err(err).Msg("Failed to convert contact info") - continue - } - ghost.UpdateInfo(ctx, userInfo) - if contact.ACI == s.Client.Store.ACI { - s.updateRemoteProfile(ctx, true) - } - if ptr.Val(contact.Whitelisted) { - portal, err := s.Main.Bridge.GetExistingPortalByKey(ctx, s.makeDMPortalKey(libsignalgo.NewACIServiceID(contact.ACI))) - if err != nil { - log.Err(err).Msg("Failed to get existing portal to update contact info") - continue - } else if portal != nil && portal.MessageRequest { - s.UserLogin.QueueRemoteEvent(&simplevent.ChatInfoChange{ - EventMeta: simplevent.EventMeta{ - Type: bridgev2.RemoteEventChatInfoChange, - LogContext: func(c zerolog.Context) zerolog.Context { - return c.Str("action", "unmark message request").Str("source", "contact list") - }, - PortalKey: portal.PortalKey, - }, - ChatInfoChange: &bridgev2.ChatInfoChange{ - ChatInfo: &bridgev2.ChatInfo{ - MessageRequest: ptr.Ptr(false), - }, - }, - }) - } - } - } - s.UserLogin.Metadata.(*signalid.UserLoginMetadata).LastContactSync = jsontime.UnixMilliNow() - err := s.UserLogin.Save(ctx) - if err != nil { - log.Err(err).Msg("Failed to update last contact sync time") - } -} - -func (s *SignalClient) updateRemoteProfile(ctx context.Context, resendState bool) { - var err error - if s.Ghost == nil { - s.Ghost, err = s.Main.Bridge.GetGhostByID(ctx, signalid.MakeUserID(s.Client.Store.ACI)) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to get ghost for remote profile update") - return - } - } - changed := false - if s.UserLogin.RemoteProfile.Name != s.Ghost.Name { - s.UserLogin.RemoteProfile.Name = s.Ghost.Name - changed = true - } - if s.UserLogin.RemoteProfile.Avatar != s.Ghost.AvatarMXC { - s.UserLogin.RemoteProfile.Avatar = s.Ghost.AvatarMXC - changed = true - } - if len(s.Ghost.Identifiers) > 0 && strings.HasPrefix(s.Ghost.Identifiers[0], "tel:") { - phone := strings.TrimPrefix(s.Ghost.Identifiers[0], "tel:") - if s.UserLogin.RemoteProfile.Phone != phone { - s.UserLogin.RemoteProfile.Phone = phone - changed = true - } - } - if changed { - err = s.UserLogin.Save(ctx) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to save updated remote profile") - } - if resendState { - // TODO this has potential race conditions - s.UserLogin.BridgeState.Send(s.UserLogin.BridgeState.GetPrevUnsent()) - } - } -} diff --git a/pkg/connector/id.go b/pkg/connector/id.go deleted file mode 100644 index 4c3f123..0000000 --- a/pkg/connector/id.go +++ /dev/null @@ -1,69 +0,0 @@ -// mautrix-signal - A Matrix-Signal puppeting bridge. -// Copyright (C) 2024 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package connector - -import ( - "fmt" - - "github.com/google/uuid" - "maunium.net/go/mautrix/bridgev2" - "maunium.net/go/mautrix/bridgev2/networkid" - - "go.mau.fi/mautrix-signal/pkg/libsignalgo" - "go.mau.fi/mautrix-signal/pkg/signalid" -) - -func (s *SignalClient) makePortalKey(chatID string) networkid.PortalKey { - key := networkid.PortalKey{ID: networkid.PortalID(chatID)} - // For non-group chats, add receiver - if s.Main.Bridge.Config.SplitPortals || len(chatID) != 44 { - key.Receiver = s.UserLogin.ID - } - return key -} - -func (s *SignalClient) makeDMPortalKey(serviceID libsignalgo.ServiceID) networkid.PortalKey { - return networkid.PortalKey{ - ID: signalid.MakeDMPortalID(serviceID), - Receiver: s.UserLogin.ID, - } -} - -func (s *SignalClient) makeEventSender(sender uuid.UUID) bridgev2.EventSender { - return bridgev2.EventSender{ - IsFromMe: sender == s.Client.Store.ACI, - SenderLogin: signalid.MakeUserLoginID(sender), - Sender: signalid.MakeUserID(sender), - } -} - -func (s *SignalClient) makePNIEventSender(sender uuid.UUID) bridgev2.EventSender { - return bridgev2.EventSender{ - Sender: signalid.MakeUserIDFromServiceID(libsignalgo.NewPNIServiceID(sender)), - } -} - -func (s *SignalClient) makeEventSenderFromServiceID(serviceID libsignalgo.ServiceID) bridgev2.EventSender { - switch serviceID.Type { - case libsignalgo.ServiceIDTypeACI: - return s.makeEventSender(serviceID.UUID) - case libsignalgo.ServiceIDTypePNI: - return s.makePNIEventSender(serviceID.UUID) - default: - panic(fmt.Errorf("invalid service ID type %d", serviceID.Type)) - } -} diff --git a/pkg/connector/login.go b/pkg/connector/login.go deleted file mode 100644 index 9116390..0000000 --- a/pkg/connector/login.go +++ /dev/null @@ -1,168 +0,0 @@ -// mautrix-signal - A Matrix-Signal puppeting bridge. -// Copyright (C) 2024 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package connector - -import ( - "context" - "fmt" - "time" - - "github.com/google/uuid" - "maunium.net/go/mautrix/bridgev2" - "maunium.net/go/mautrix/bridgev2/database" - "maunium.net/go/mautrix/bridgev2/status" - - "go.mau.fi/mautrix-signal/pkg/signalid" - "go.mau.fi/mautrix-signal/pkg/signalmeow" - "go.mau.fi/mautrix-signal/pkg/signalmeow/store" -) - -func (s *SignalConnector) GetLoginFlows() []bridgev2.LoginFlow { - return []bridgev2.LoginFlow{{ - Name: "QR", - Description: "Scan a QR code to pair the bridge to your Signal app", - ID: "qr", - }} -} - -func (s *SignalConnector) CreateLogin(ctx context.Context, user *bridgev2.User, flowID string) (bridgev2.LoginProcess, error) { - if flowID != "qr" { - return nil, fmt.Errorf("invalid login flow ID") - } - return &QRLogin{User: user, Main: s}, nil -} - -type QRLogin struct { - User *bridgev2.User - Main *SignalConnector - cancelChan context.CancelFunc - ProvChan chan signalmeow.ProvisioningResponse - newQRCount int -} - -var _ bridgev2.LoginProcessDisplayAndWait = (*QRLogin)(nil) - -func (qr *QRLogin) Cancel() { - qr.cancelChan() - go func() { - for range qr.ProvChan { - } - }() -} - -const ( - LoginStepQR = "fi.mau.signal.login.qr" - LoginStepProcess = "fi.mau.signal.login.processing" - LoginStepComplete = "fi.mau.signal.login.complete" -) - -func (qr *QRLogin) Start(ctx context.Context) (*bridgev2.LoginStep, error) { - log := qr.Main.Bridge.Log.With(). - Str("action", "login"). - Stringer("user_id", qr.User.MXID). - Logger() - provCtx, cancel := context.WithCancel(log.WithContext(qr.Main.Bridge.BackgroundCtx)) - qr.cancelChan = cancel - // Don't use the start context here: the channel will outlive the start request. - qr.ProvChan = signalmeow.PerformProvisioning( - provCtx, qr.Main.Store, qr.Main.Config.DeviceName, qr.Main.Bridge.Config.Backfill.Enabled, - ) - var resp signalmeow.ProvisioningResponse - select { - case resp = <-qr.ProvChan: - if resp.Err != nil { - return nil, resp.Err - } else if resp.State != signalmeow.StateProvisioningURLReceived { - return nil, fmt.Errorf("unexpected state %v", resp.State) - } - case <-ctx.Done(): - cancel() - return nil, ctx.Err() - // TODO separate timeout here? - } - return &bridgev2.LoginStep{ - Type: bridgev2.LoginStepTypeDisplayAndWait, - StepID: LoginStepQR, - Instructions: "Scan the QR code on your Signal app to log in", - DisplayAndWaitParams: &bridgev2.LoginDisplayAndWaitParams{ - Type: bridgev2.LoginDisplayTypeQR, - Data: resp.ProvisioningURL, - }, - }, nil -} - -func (qr *QRLogin) Wait(ctx context.Context) (*bridgev2.LoginStep, error) { - if qr.ProvChan == nil { - return nil, fmt.Errorf("login not started") - } - - select { - case resp := <-qr.ProvChan: - if resp.Err != nil { - qr.cancelChan() - return nil, resp.Err - } else if resp.State != signalmeow.StateProvisioningDataReceived { - qr.cancelChan() - return nil, fmt.Errorf("unexpected state %v", resp.State) - } else if resp.ProvisioningData.ACI == uuid.Nil { - qr.cancelChan() - return nil, fmt.Errorf("no signal account ID received") - } - return qr.loginComplete(ctx, resp.ProvisioningData) - - // Server will timeout the request after 60 seconds, but Signal Desktop opens - // a new socket and gets a new QR code after 45 seconds. We should do the same. - case <-time.After(45 * time.Second): - qr.cancelChan() - qr.newQRCount++ - if qr.newQRCount >= 6 { - return nil, fmt.Errorf("too many QR code refreshes") - } - return qr.Start(ctx) - - case <-ctx.Done(): - qr.cancelChan() - return nil, ctx.Err() - } -} - -func (qr *QRLogin) loginComplete(ctx context.Context, provData *store.DeviceData) (*bridgev2.LoginStep, error) { - defer qr.cancelChan() - ul, err := qr.User.NewLogin(ctx, &database.UserLogin{ - ID: signalid.MakeUserLoginID(provData.ACI), - RemoteName: provData.Number, - RemoteProfile: status.RemoteProfile{ - Phone: provData.Number, - }, - Metadata: &signalid.UserLoginMetadata{}, - }, &bridgev2.NewLoginParams{ - DeleteOnConflict: true, - }) - if err != nil { - return nil, fmt.Errorf("failed to create user login: %w", err) - } - ul.Client.(*SignalClient).postLoginConnect() - return &bridgev2.LoginStep{ - Type: bridgev2.LoginStepTypeComplete, - StepID: LoginStepComplete, - Instructions: fmt.Sprintf("Successfully logged in as %s / %s", provData.Number, provData.ACI), - CompleteParams: &bridgev2.LoginCompleteParams{ - UserLoginID: ul.ID, - UserLogin: ul, - }, - }, nil -} diff --git a/pkg/libsignalgo/address.go b/pkg/libsignalgo/address.go index cfc6e58..3866ca3 100644 --- a/pkg/libsignalgo/address.go +++ b/pkg/libsignalgo/address.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Sumner Evans -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,11 +17,14 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" import ( "runtime" + + "github.com/google/uuid" ) type Address struct { @@ -36,44 +38,27 @@ func wrapAddress(ptr *C.SignalProtocolAddress) *Address { return address } -func NewUUIDAddressFromString(uuidStr string, deviceID uint) (*Address, error) { - serviceID, err := ServiceIDFromString(uuidStr) - if err != nil { - return nil, err - } - return serviceID.Address(deviceID) -} - -func newAddress(name string, deviceID uint) (*Address, error) { - var pa C.SignalMutPointerProtocolAddress +func NewAddress(name string, deviceID uint) (*Address, error) { + var pa *C.SignalProtocolAddress signalFfiError := C.signal_address_new(&pa, C.CString(name), C.uint(deviceID)) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapAddress(pa.raw), nil -} - -func (pa *Address) mutPtr() C.SignalMutPointerProtocolAddress { - return C.SignalMutPointerProtocolAddress{pa.ptr} -} - -func (pa *Address) constPtr() C.SignalConstPointerProtocolAddress { - return C.SignalConstPointerProtocolAddress{pa.ptr} + return wrapAddress(pa), nil } func (pa *Address) Clone() (*Address, error) { - var cloned C.SignalMutPointerProtocolAddress - signalFfiError := C.signal_address_clone(&cloned, pa.constPtr()) - runtime.KeepAlive(pa) + var cloned *C.SignalProtocolAddress + signalFfiError := C.signal_address_clone(&cloned, pa.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapAddress(cloned.raw), nil + return wrapAddress(cloned), nil } func (pa *Address) Destroy() error { pa.CancelFinalizer() - return wrapError(C.signal_address_destroy(pa.mutPtr())) + return wrapError(C.signal_address_destroy(pa.ptr)) } func (pa *Address) CancelFinalizer() { @@ -82,26 +67,24 @@ func (pa *Address) CancelFinalizer() { func (pa *Address) Name() (string, error) { var name *C.char - signalFfiError := C.signal_address_get_name(&name, pa.constPtr()) - runtime.KeepAlive(pa) + signalFfiError := C.signal_address_get_name(&name, pa.ptr) if signalFfiError != nil { return "", wrapError(signalFfiError) } return CopyCStringToString(name), nil } -func (pa *Address) NameServiceID() (ServiceID, error) { +func (pa *Address) NameUUID() (uuid.UUID, error) { name, err := pa.Name() if err != nil { - return ServiceID{}, err + return uuid.Nil, err } - return ServiceIDFromString(name) + return uuid.Parse(name) } func (pa *Address) DeviceID() (uint, error) { var deviceID C.uint - signalFfiError := C.signal_address_get_device_id(&deviceID, pa.constPtr()) - runtime.KeepAlive(pa) + signalFfiError := C.signal_address_get_device_id(&deviceID, pa.ptr) if signalFfiError != nil { return 0, wrapError(signalFfiError) } diff --git a/pkg/libsignalgo/address_test.go b/pkg/libsignalgo/address_test.go index b72eb2f..ce7fa8c 100644 --- a/pkg/libsignalgo/address_test.go +++ b/pkg/libsignalgo/address_test.go @@ -19,7 +19,6 @@ package libsignalgo_test import ( "testing" - "github.com/google/uuid" "github.com/stretchr/testify/assert" "go.mau.fi/mautrix-signal/pkg/libsignalgo" @@ -29,14 +28,12 @@ import ( func TestAddress(t *testing.T) { setupLogging() - testUUID := uuid.New() - - addr, err := libsignalgo.NewPNIServiceID(testUUID).Address(5) + addr, err := libsignalgo.NewAddress("addr1", 5) assert.NoError(t, err) name, err := addr.Name() assert.NoError(t, err) - assert.Equal(t, "PNI:"+testUUID.String(), name) + assert.Equal(t, "addr1", name) deviceID, err := addr.DeviceID() assert.NoError(t, err) diff --git a/pkg/libsignalgo/aes256gcmsiv.go b/pkg/libsignalgo/aes256gcmsiv.go index 0fddea2..41aa3e6 100644 --- a/pkg/libsignalgo/aes256gcmsiv.go +++ b/pkg/libsignalgo/aes256gcmsiv.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Sumner Evans -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,6 +17,7 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" @@ -35,38 +35,23 @@ func wrapAES256_GCM_SIV(ptr *C.SignalAes256GcmSiv) *AES256_GCM_SIV { } func NewAES256_GCM_SIV(key []byte) (*AES256_GCM_SIV, error) { - var aes C.SignalMutPointerAes256GcmSiv + var aes *C.SignalAes256GcmSiv signalFfiError := C.signal_aes256_gcm_siv_new(&aes, BytesToBuffer(key)) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapAES256_GCM_SIV(aes.raw), nil -} - -func (aes *AES256_GCM_SIV) mutPtr() C.SignalMutPointerAes256GcmSiv { - return C.SignalMutPointerAes256GcmSiv{aes.ptr} -} - -func (aes *AES256_GCM_SIV) constPtr() C.SignalConstPointerAes256GcmSiv { - return C.SignalConstPointerAes256GcmSiv{aes.ptr} + return wrapAES256_GCM_SIV(aes), nil } func (aes *AES256_GCM_SIV) Destroy() error { runtime.SetFinalizer(aes, nil) - return wrapError(C.signal_aes256_gcm_siv_destroy(C.SignalMutPointerAes256GcmSiv{raw: aes.ptr})) + return wrapError(C.signal_aes256_gcm_siv_destroy(aes.ptr)) } func (aes *AES256_GCM_SIV) Encrypt(plaintext, nonce, associatedData []byte) ([]byte, error) { var encrypted C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_aes256_gcm_siv_encrypt( - &encrypted, - C.SignalConstPointerAes256GcmSiv{raw: aes.ptr}, - BytesToBuffer(plaintext), - BytesToBuffer(nonce), - BytesToBuffer(associatedData), - ) - runtime.KeepAlive(aes) + signalFfiError := C.signal_aes256_gcm_siv_encrypt(&encrypted, aes.ptr, BytesToBuffer(plaintext), BytesToBuffer(nonce), BytesToBuffer(associatedData)) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -75,13 +60,7 @@ func (aes *AES256_GCM_SIV) Encrypt(plaintext, nonce, associatedData []byte) ([]b func (aes *AES256_GCM_SIV) Decrypt(ciphertext, nonce, associatedData []byte) ([]byte, error) { var decrypted C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_aes256_gcm_siv_decrypt( - &decrypted, - C.SignalConstPointerAes256GcmSiv{raw: aes.ptr}, - BytesToBuffer(ciphertext), - BytesToBuffer(nonce), - BytesToBuffer(associatedData), - ) + signalFfiError := C.signal_aes256_gcm_siv_decrypt(&decrypted, aes.ptr, BytesToBuffer(ciphertext), BytesToBuffer(nonce), BytesToBuffer(associatedData)) if signalFfiError != nil { return nil, wrapError(signalFfiError) } diff --git a/pkg/libsignalgo/authcredential.go b/pkg/libsignalgo/authcredential.go index ab759b2..a0a0bc9 100644 --- a/pkg/libsignalgo/authcredential.go +++ b/pkg/libsignalgo/authcredential.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Scott Weber -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,12 +17,12 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" #include */ import "C" import ( - "fmt" "unsafe" "github.com/google/uuid" @@ -40,30 +39,37 @@ func (ac *AuthCredentialWithPni) Slice() []byte { } func ReceiveAuthCredentialWithPni( - serverPublicParams *ServerPublicParams, + serverPublicParams ServerPublicParams, aci uuid.UUID, pni uuid.UUID, redemptionTime uint64, authCredResponse AuthCredentialWithPniResponse, ) (*AuthCredentialWithPni, error) { - var c_result C.SignalOwnedBuffer = C.SignalOwnedBuffer{} + c_result := [C.SignalAUTH_CREDENTIAL_WITH_PNI_LEN]C.uchar{} + c_serverPublicParams := (*[C.SignalSERVER_PUBLIC_PARAMS_LEN]C.uchar)(unsafe.Pointer(&serverPublicParams[0])) + c_aci, err := SignalServiceIDFromUUID(aci) + if err != nil { + return nil, err + } + c_pni, err := SignalPNIServiceIDFromUUID(pni) + if err != nil { + return nil, err + } + c_authCredResponse := (*[C.SignalAUTH_CREDENTIAL_WITH_PNI_RESPONSE_LEN]C.uchar)(unsafe.Pointer(&authCredResponse[0])) - signalFfiError := C.signal_server_public_params_receive_auth_credential_with_pni_as_service_id( + signalFfiError := C.signal_server_public_params_receive_auth_credential_with_pni_as_aci( &c_result, - C.SignalConstPointerServerPublicParams{serverPublicParams}, - NewACIServiceID(aci).CFixedBytes(), - NewPNIServiceID(pni).CFixedBytes(), + c_serverPublicParams, + c_aci, + c_pni, C.uint64_t(redemptionTime), - BytesToBuffer(authCredResponse[:]), + c_authCredResponse, ) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - resultBytes := CopySignalOwnedBufferToBytes(c_result) - if len(resultBytes) != C.SignalAUTH_CREDENTIAL_WITH_PNI_LEN { - return nil, fmt.Errorf("invalid response length %d (expected %d)", len(resultBytes), C.SignalAUTH_CREDENTIAL_WITH_PNI_LEN) - } - return (*AuthCredentialWithPni)(resultBytes), nil + result := AuthCredentialWithPni(C.GoBytes(unsafe.Pointer(&c_result), C.int(C.SignalAUTH_CREDENTIAL_WITH_PNI_LEN))) + return &result, nil } func NewAuthCredentialWithPniResponse(b []byte) (*AuthCredentialWithPniResponse, error) { @@ -77,21 +83,23 @@ func NewAuthCredentialWithPniResponse(b []byte) (*AuthCredentialWithPniResponse, } func CreateAuthCredentialWithPniPresentation( - serverPublicParams *ServerPublicParams, + serverPublicParams ServerPublicParams, randomness Randomness, groupSecretParams GroupSecretParams, authCredWithPni AuthCredentialWithPni, ) (*AuthCredentialPresentation, error) { var c_result C.SignalOwnedBuffer = C.SignalOwnedBuffer{} + c_serverPublicParams := (*[C.SignalSERVER_PUBLIC_PARAMS_LEN]C.uchar)(unsafe.Pointer(&serverPublicParams[0])) c_randomness := (*[C.SignalRANDOMNESS_LEN]C.uchar)(unsafe.Pointer(&randomness[0])) c_groupSecretParams := (*[C.SignalGROUP_SECRET_PARAMS_LEN]C.uchar)(unsafe.Pointer(&groupSecretParams[0])) + c_authCredWithPni := (*[C.SignalAUTH_CREDENTIAL_WITH_PNI_LEN]C.uchar)(unsafe.Pointer(&authCredWithPni[0])) signalFfiError := C.signal_server_public_params_create_auth_credential_with_pni_presentation_deterministic( &c_result, - C.SignalConstPointerServerPublicParams{serverPublicParams}, + c_serverPublicParams, c_randomness, c_groupSecretParams, - BytesToBuffer(authCredWithPni[:]), + c_authCredWithPni, ) if signalFfiError != nil { return nil, wrapError(signalFfiError) diff --git a/pkg/libsignalgo/backupkey.go b/pkg/libsignalgo/backupkey.go deleted file mode 100644 index fd8a800..0000000 --- a/pkg/libsignalgo/backupkey.go +++ /dev/null @@ -1,140 +0,0 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2025 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package libsignalgo - -/* -#include "./libsignal-ffi.h" -*/ -import "C" -import ( - "runtime" - "unsafe" - - "go.mau.fi/util/random" -) - -type BackupKey [C.SignalBACKUP_KEY_LEN]byte - -func (bk *BackupKey) Slice() []byte { - if bk == nil { - return nil - } - return bk[:] -} - -const BackupIDLength = 16 - -type BackupID [BackupIDLength]byte -type BackupMetadataKey [C.SignalLOCAL_BACKUP_METADATA_KEY_LEN]byte -type BackupMediaID [C.SignalMEDIA_ID_LEN]byte -type BackupMediaKey [C.SignalMEDIA_ENCRYPTION_KEY_LEN]byte - -func GenerateRandomBackupKey() *BackupKey { - return (*BackupKey)(random.Bytes(C.SignalBACKUP_KEY_LEN)) -} - -func BytesToBackupKey(bytes []byte) *BackupKey { - if len(bytes) != C.SignalBACKUP_KEY_LEN { - return nil - } - return (*BackupKey)(bytes) -} - -func (bk *BackupKey) DeriveBackupID(aci ServiceID) (*BackupID, error) { - var out BackupID - signalFfiError := C.signal_backup_key_derive_backup_id( - (*[BackupIDLength]C.uint8_t)(unsafe.Pointer(&out)), - (*[C.SignalBACKUP_KEY_LEN]C.uint8_t)(unsafe.Pointer(bk)), - aci.CFixedBytes(), - ) - runtime.KeepAlive(bk) - if signalFfiError != nil { - return nil, wrapError(signalFfiError) - } - return &out, nil -} - -func (bk *BackupKey) DeriveECKey(aci ServiceID) (*PrivateKey, error) { - var out C.SignalMutPointerPrivateKey - signalFfiError := C.signal_backup_key_derive_ec_key( - &out, - (*[C.SignalBACKUP_KEY_LEN]C.uint8_t)(unsafe.Pointer(&bk)), - aci.CFixedBytes(), - ) - runtime.KeepAlive(bk) - if signalFfiError != nil { - return nil, wrapError(signalFfiError) - } - return wrapPrivateKey(out.raw), nil -} - -func (bk *BackupKey) DeriveLocalBackupMetadataKey() (*BackupMetadataKey, error) { - var out BackupMetadataKey - signalFfiError := C.signal_backup_key_derive_local_backup_metadata_key( - (*[C.SignalLOCAL_BACKUP_METADATA_KEY_LEN]C.uint8_t)(unsafe.Pointer(&out)), - (*[C.SignalBACKUP_KEY_LEN]C.uint8_t)(unsafe.Pointer(bk)), - ) - runtime.KeepAlive(bk) - if signalFfiError != nil { - return nil, wrapError(signalFfiError) - } - return &out, nil -} - -func (bk *BackupKey) DeriveMediaID(mediaName string) (*BackupMediaID, error) { - var out BackupMediaID - signalFfiError := C.signal_backup_key_derive_media_id( - (*[C.SignalMEDIA_ID_LEN]C.uint8_t)(unsafe.Pointer(&out)), - (*[C.SignalBACKUP_KEY_LEN]C.uint8_t)(unsafe.Pointer(bk)), - C.CString(mediaName), - ) - runtime.KeepAlive(bk) - if signalFfiError != nil { - return nil, wrapError(signalFfiError) - } - return &out, nil -} - -func (bk *BackupKey) DeriveMediaEncryptionKey(mediaID *BackupMediaID) (*BackupMediaKey, error) { - var out BackupMediaKey - signalFfiError := C.signal_backup_key_derive_media_encryption_key( - (*[C.SignalMEDIA_ENCRYPTION_KEY_LEN]C.uint8_t)(unsafe.Pointer(&out)), - (*[C.SignalBACKUP_KEY_LEN]C.uint8_t)(unsafe.Pointer(bk)), - (*[C.SignalMEDIA_ID_LEN]C.uint8_t)(unsafe.Pointer(mediaID)), - ) - runtime.KeepAlive(bk) - runtime.KeepAlive(mediaID) - if signalFfiError != nil { - return nil, wrapError(signalFfiError) - } - return &out, nil -} - -func (bk *BackupKey) DeriveThumbnailTransitEncryptionKey(mediaID *BackupMediaID) (*BackupMediaKey, error) { - var out BackupMediaKey - signalFfiError := C.signal_backup_key_derive_thumbnail_transit_encryption_key( - (*[C.SignalMEDIA_ENCRYPTION_KEY_LEN]C.uint8_t)(unsafe.Pointer(&out)), - (*[C.SignalBACKUP_KEY_LEN]C.uint8_t)(unsafe.Pointer(bk)), - (*[C.SignalMEDIA_ID_LEN]C.uint8_t)(unsafe.Pointer(mediaID)), - ) - runtime.KeepAlive(bk) - runtime.KeepAlive(mediaID) - if signalFfiError != nil { - return nil, wrapError(signalFfiError) - } - return &out, nil -} diff --git a/pkg/libsignalgo/buffer.go b/pkg/libsignalgo/buffer.go index 5518656..f6e0ef9 100644 --- a/pkg/libsignalgo/buffer.go +++ b/pkg/libsignalgo/buffer.go @@ -17,12 +17,11 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" import ( - "fmt" - "runtime" "unsafe" ) @@ -30,13 +29,13 @@ func BorrowedMutableBuffer(length int) C.SignalBorrowedMutableBuffer { data := make([]byte, length) return C.SignalBorrowedMutableBuffer{ base: (*C.uchar)(unsafe.Pointer(&data[0])), - length: C.size_t(len(data)), + length: C.uintptr_t(len(data)), } } func BytesToBuffer(data []byte) C.SignalBorrowedBuffer { buf := C.SignalBorrowedBuffer{ - length: C.size_t(len(data)), + length: C.uintptr_t(len(data)), } if len(data) > 0 { buf.base = (*C.uchar)(unsafe.Pointer(&data[0])) @@ -44,22 +43,6 @@ func BytesToBuffer(data []byte) C.SignalBorrowedBuffer { return buf } -func ManyBytesToBuffer[T ~[]byte](datas []T) (C.SignalBorrowedSliceOfBuffers, func()) { - buffers := make([]C.SignalBorrowedBuffer, len(datas)) - var pinner runtime.Pinner - for i, data := range datas { - if len(data) == 0 { - panic(fmt.Errorf("empty slice passed to ManyBytesToBuffer at index %d", i)) - } - pinner.Pin(&data[0]) - buffers[i] = BytesToBuffer(data) - } - return C.SignalBorrowedSliceOfBuffers{ - base: unsafe.SliceData(buffers), - length: C.size_t(len(buffers)), - }, pinner.Unpin -} - func EmptyBorrowedBuffer() C.SignalBorrowedBuffer { return C.SignalBorrowedBuffer{} } diff --git a/pkg/libsignalgo/cflags.go b/pkg/libsignalgo/cflags.go deleted file mode 100644 index e1bb7d5..0000000 --- a/pkg/libsignalgo/cflags.go +++ /dev/null @@ -1,6 +0,0 @@ -package libsignalgo - -/* -#cgo LDFLAGS: -lsignal_ffi -ldl -lm -lz -lstdc++ -*/ -import "C" diff --git a/pkg/libsignalgo/ciphertextmessage.go b/pkg/libsignalgo/ciphertextmessage.go index f74fcd5..d7368fe 100644 --- a/pkg/libsignalgo/ciphertextmessage.go +++ b/pkg/libsignalgo/ciphertextmessage.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Sumner Evans -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,6 +17,7 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" @@ -44,28 +44,17 @@ func wrapCiphertextMessage(ptr *C.SignalCiphertextMessage) *CiphertextMessage { } func NewCiphertextMessage(plaintext *PlaintextContent) (*CiphertextMessage, error) { - var ciphertextMessage C.SignalMutPointerCiphertextMessage - signalFfiError := C.signal_ciphertext_message_from_plaintext_content( - &ciphertextMessage, - plaintext.constPtr(), - ) + var ciphertextMessage *C.SignalCiphertextMessage + signalFfiError := C.signal_ciphertext_message_from_plaintext_content(&ciphertextMessage, plaintext.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapCiphertextMessage(ciphertextMessage.raw), nil -} - -func (c *CiphertextMessage) mutPtr() C.SignalMutPointerCiphertextMessage { - return C.SignalMutPointerCiphertextMessage{c.ptr} -} - -func (c *CiphertextMessage) constPtr() C.SignalConstPointerCiphertextMessage { - return C.SignalConstPointerCiphertextMessage{c.ptr} + return wrapCiphertextMessage(ciphertextMessage), nil } func (c *CiphertextMessage) Destroy() error { c.CancelFinalizer() - return wrapError(C.signal_ciphertext_message_destroy(c.mutPtr())) + return wrapError(C.signal_ciphertext_message_destroy(c.ptr)) } func (c *CiphertextMessage) CancelFinalizer() { @@ -74,8 +63,7 @@ func (c *CiphertextMessage) CancelFinalizer() { func (c *CiphertextMessage) Serialize() ([]byte, error) { var serialized C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_ciphertext_message_serialize(&serialized, c.constPtr()) - runtime.KeepAlive(c) + signalFfiError := C.signal_ciphertext_message_serialize(&serialized, c.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -84,8 +72,7 @@ func (c *CiphertextMessage) Serialize() ([]byte, error) { func (c *CiphertextMessage) MessageType() (CiphertextMessageType, error) { var messageType C.uint8_t - signalFfiError := C.signal_ciphertext_message_type(&messageType, c.constPtr()) - runtime.KeepAlive(c) + signalFfiError := C.signal_ciphertext_message_type(&messageType, c.ptr) if signalFfiError != nil { return 0, wrapError(signalFfiError) } diff --git a/pkg/libsignalgo/conversions.go b/pkg/libsignalgo/conversions.go index 1963687..a2da098 100644 --- a/pkg/libsignalgo/conversions.go +++ b/pkg/libsignalgo/conversions.go @@ -17,6 +17,7 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" @@ -39,17 +40,3 @@ func CopySignalOwnedBufferToBytes(buffer C.SignalOwnedBuffer) (b []byte) { C.signal_free_buffer(buffer.base, buffer.length) return } - -func CopySignalBytestringArray[T ~[]byte](buffer C.SignalBytestringArray) (b []T) { - concatted := C.GoBytes(unsafe.Pointer(buffer.bytes.base), C.int(buffer.bytes.length)) - b = make([]T, int(buffer.lengths.length)) - sizeTSize := unsafe.Sizeof(C.size_t(0)) - offset := 0 - for i := 0; i < int(buffer.lengths.length); i++ { - length := int(*(*C.size_t)(unsafe.Add(unsafe.Pointer(buffer.lengths.base), uintptr(i)*sizeTSize))) - b[i] = concatted[offset : offset+length] - offset += length - } - C.signal_free_bytestring_array(buffer) - return -} diff --git a/pkg/libsignalgo/decryptionerrormessage.go b/pkg/libsignalgo/decryptionerrormessage.go index 434d40f..4eaf2c9 100644 --- a/pkg/libsignalgo/decryptionerrormessage.go +++ b/pkg/libsignalgo/decryptionerrormessage.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Sumner Evans -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,11 +17,13 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" import ( "runtime" + "time" ) type DecryptionErrorMessage struct { @@ -37,64 +38,44 @@ func wrapDecryptionErrorMessage(ptr *C.SignalDecryptionErrorMessage) *Decryption } func DeserializeDecryptionErrorMessage(messageBytes []byte) (*DecryptionErrorMessage, error) { - var dem C.SignalMutPointerDecryptionErrorMessage - signalFfiError := C.signal_decryption_error_message_deserialize( - &dem, - BytesToBuffer(messageBytes), - ) + var dem *C.SignalDecryptionErrorMessage + signalFfiError := C.signal_decryption_error_message_deserialize(&dem, BytesToBuffer(messageBytes)) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapDecryptionErrorMessage(dem.raw), nil + return wrapDecryptionErrorMessage(dem), nil } -func DecryptionErrorMessageForOriginalMessage(originalBytes []byte, originalType CiphertextMessageType, originalTs uint64, originalSenderDeviceID uint) (*DecryptionErrorMessage, error) { - var dem C.SignalMutPointerDecryptionErrorMessage - signalFfiError := C.signal_decryption_error_message_for_original_message( - &dem, - BytesToBuffer(originalBytes), - C.uint8_t(originalType), - C.uint64_t(originalTs), - C.uint32_t(originalSenderDeviceID), - ) - runtime.KeepAlive(originalBytes) +func DecryptionErrorMessageForOriginalMessage(originalBytes []byte, originalType uint8, originalTs uint64, originalSenderDeviceID uint) (*DecryptionErrorMessage, error) { + var dem *C.SignalDecryptionErrorMessage + signalFfiError := C.signal_decryption_error_message_for_original_message(&dem, BytesToBuffer(originalBytes), C.uint8_t(originalType), C.uint64_t(originalTs), C.uint32_t(originalSenderDeviceID)) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapDecryptionErrorMessage(dem.raw), nil + return wrapDecryptionErrorMessage(dem), nil } func DecryptionErrorMessageFromSerializedContent(serialized []byte) (*DecryptionErrorMessage, error) { - var dem C.SignalMutPointerDecryptionErrorMessage + var dem *C.SignalDecryptionErrorMessage signalFfiError := C.signal_decryption_error_message_extract_from_serialized_content(&dem, BytesToBuffer(serialized)) - runtime.KeepAlive(serialized) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapDecryptionErrorMessage(dem.raw), nil -} - -func (dem *DecryptionErrorMessage) mutPtr() C.SignalMutPointerDecryptionErrorMessage { - return C.SignalMutPointerDecryptionErrorMessage{dem.ptr} -} - -func (dem *DecryptionErrorMessage) constPtr() C.SignalConstPointerDecryptionErrorMessage { - return C.SignalConstPointerDecryptionErrorMessage{dem.ptr} + return wrapDecryptionErrorMessage(dem), nil } func (dem *DecryptionErrorMessage) Clone() (*DecryptionErrorMessage, error) { - var cloned C.SignalMutPointerDecryptionErrorMessage - signalFfiError := C.signal_decryption_error_message_clone(&cloned, dem.constPtr()) - runtime.KeepAlive(dem) + var cloned *C.SignalDecryptionErrorMessage + signalFfiError := C.signal_decryption_error_message_clone(&cloned, dem.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapDecryptionErrorMessage(cloned.raw), nil + return wrapDecryptionErrorMessage(cloned), nil } func (dem *DecryptionErrorMessage) Destroy() error { dem.CancelFinalizer() - return wrapError(C.signal_decryption_error_message_destroy(dem.mutPtr())) + return wrapError(C.signal_decryption_error_message_destroy(dem.ptr)) } func (dem *DecryptionErrorMessage) CancelFinalizer() { @@ -103,28 +84,25 @@ func (dem *DecryptionErrorMessage) CancelFinalizer() { func (dem *DecryptionErrorMessage) Serialize() ([]byte, error) { var serialized C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_decryption_error_message_serialize(&serialized, dem.constPtr()) - runtime.KeepAlive(dem) + signalFfiError := C.signal_decryption_error_message_serialize(&serialized, dem.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } return CopySignalOwnedBufferToBytes(serialized), nil } -func (dem *DecryptionErrorMessage) GetTimestamp() (uint64, error) { +func (dem *DecryptionErrorMessage) GetTimestamp() (time.Time, error) { var ts C.uint64_t - signalFfiError := C.signal_decryption_error_message_get_timestamp(&ts, dem.constPtr()) - runtime.KeepAlive(dem) + signalFfiError := C.signal_decryption_error_message_get_timestamp(&ts, dem.ptr) if signalFfiError != nil { - return 0, wrapError(signalFfiError) + return time.Time{}, wrapError(signalFfiError) } - return uint64(ts), nil + return time.UnixMilli(int64(ts)), nil } func (dem *DecryptionErrorMessage) GetDeviceID() (uint32, error) { var deviceID C.uint32_t - signalFfiError := C.signal_decryption_error_message_get_device_id(&deviceID, dem.constPtr()) - runtime.KeepAlive(dem) + signalFfiError := C.signal_decryption_error_message_get_device_id(&deviceID, dem.ptr) if signalFfiError != nil { return 0, wrapError(signalFfiError) } @@ -132,11 +110,10 @@ func (dem *DecryptionErrorMessage) GetDeviceID() (uint32, error) { } func (dem *DecryptionErrorMessage) GetRatchetKey() (*PublicKey, error) { - var pk C.SignalMutPointerPublicKey - signalFfiError := C.signal_decryption_error_message_get_ratchet_key(&pk, dem.constPtr()) - runtime.KeepAlive(dem) + var pk *C.SignalPublicKey + signalFfiError := C.signal_decryption_error_message_get_ratchet_key(&pk, dem.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapPublicKey(pk.raw), nil + return wrapPublicKey(pk), nil } diff --git a/pkg/libsignalgo/devicetransfer.go b/pkg/libsignalgo/devicetransfer.go index f994e51..6d7e063 100644 --- a/pkg/libsignalgo/devicetransfer.go +++ b/pkg/libsignalgo/devicetransfer.go @@ -17,12 +17,10 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" -import ( - "runtime" -) type DeviceTransferKey struct { privateKey []byte @@ -44,7 +42,6 @@ func (dtk *DeviceTransferKey) PrivateKeyMaterial() []byte { func (dtk *DeviceTransferKey) GenerateCertificate(name string, days int) ([]byte, error) { var resp C.SignalOwnedBuffer = C.SignalOwnedBuffer{} signalFfiError := C.signal_device_transfer_generate_certificate(&resp, BytesToBuffer(dtk.privateKey), C.CString(name), C.uint32_t(days)) - runtime.KeepAlive(dtk) if signalFfiError != nil { return nil, wrapError(signalFfiError) } diff --git a/pkg/libsignalgo/error.go b/pkg/libsignalgo/error.go index 888f8ea..25d0387 100644 --- a/pkg/libsignalgo/error.go +++ b/pkg/libsignalgo/error.go @@ -17,6 +17,7 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" @@ -26,91 +27,34 @@ import ( type ErrorCode int -func (e ErrorCode) Error() string { - return fmt.Sprintf("libsignalgo.ErrorCode(%d)", int(e)) -} - const ( - ErrorCodeUnknownError ErrorCode = 1 - ErrorCodeInvalidState ErrorCode = 2 - ErrorCodeInternalError ErrorCode = 3 - ErrorCodeNullParameter ErrorCode = 4 - ErrorCodeInvalidArgument ErrorCode = 5 - ErrorCodeInvalidType ErrorCode = 6 - ErrorCodeInvalidUtf8String ErrorCode = 7 - ErrorCodeCancelled ErrorCode = 8 - ErrorCodeProtobufError ErrorCode = 10 - ErrorCodeLegacyCiphertextVersion ErrorCode = 21 - ErrorCodeUnknownCiphertextVersion ErrorCode = 22 - ErrorCodeUnrecognizedMessageVersion ErrorCode = 23 - ErrorCodeInvalidMessage ErrorCode = 30 - ErrorCodeSealedSenderSelfSend ErrorCode = 31 - ErrorCodeInvalidKey ErrorCode = 40 - ErrorCodeInvalidSignature ErrorCode = 41 - ErrorCodeInvalidAttestationData ErrorCode = 42 - ErrorCodeFingerprintVersionMismatch ErrorCode = 51 - ErrorCodeFingerprintParsingError ErrorCode = 52 - ErrorCodeUntrustedIdentity ErrorCode = 60 - ErrorCodeInvalidKeyIdentifier ErrorCode = 70 - ErrorCodeSessionNotFound ErrorCode = 80 - ErrorCodeInvalidRegistrationId ErrorCode = 81 - ErrorCodeInvalidSession ErrorCode = 82 - ErrorCodeInvalidSenderKeySession ErrorCode = 83 - ErrorCodeInvalidProtocolAddress ErrorCode = 84 - ErrorCodeDuplicatedMessage ErrorCode = 90 - ErrorCodeCallbackError ErrorCode = 100 - ErrorCodeVerificationFailure ErrorCode = 110 - ErrorCodeUsernameCannotBeEmpty ErrorCode = 120 - ErrorCodeUsernameCannotStartWithDigit ErrorCode = 121 - ErrorCodeUsernameMissingSeparator ErrorCode = 122 - ErrorCodeUsernameBadDiscriminatorCharacter ErrorCode = 123 - ErrorCodeUsernameBadNicknameCharacter ErrorCode = 124 - ErrorCodeUsernameTooShort ErrorCode = 125 - ErrorCodeUsernameTooLong ErrorCode = 126 - ErrorCodeUsernameLinkInvalidEntropyDataLength ErrorCode = 127 - ErrorCodeUsernameLinkInvalid ErrorCode = 128 - ErrorCodeUsernameDiscriminatorCannotBeEmpty ErrorCode = 130 - ErrorCodeUsernameDiscriminatorCannotBeZero ErrorCode = 131 - ErrorCodeUsernameDiscriminatorCannotBeSingleDigit ErrorCode = 132 - ErrorCodeUsernameDiscriminatorCannotHaveLeadingZeros ErrorCode = 133 - ErrorCodeUsernameDiscriminatorTooLarge ErrorCode = 134 - ErrorCodeIoError ErrorCode = 140 - ErrorCodeInvalidMediaInput ErrorCode = 141 - ErrorCodeUnsupportedMediaInput ErrorCode = 142 - ErrorCodeConnectionTimedOut ErrorCode = 143 - ErrorCodeNetworkProtocol ErrorCode = 144 - ErrorCodeRateLimited ErrorCode = 145 - ErrorCodeWebSocket ErrorCode = 146 - ErrorCodeCdsiInvalidToken ErrorCode = 147 - ErrorCodeConnectionFailed ErrorCode = 148 - ErrorCodeChatServiceInactive ErrorCode = 149 - ErrorCodeRequestTimedOut ErrorCode = 150 - ErrorCodeRateLimitChallenge ErrorCode = 151 - ErrorCodePossibleCaptiveNetwork ErrorCode = 152 - ErrorCodeSvrDataMissing ErrorCode = 160 - ErrorCodeSvrRestoreFailed ErrorCode = 161 - ErrorCodeSvrRotationMachineTooManySteps ErrorCode = 162 - ErrorCodeSvrRequestFailed ErrorCode = 163 - ErrorCodeAppExpired ErrorCode = 170 - ErrorCodeDeviceDeregistered ErrorCode = 171 - ErrorCodeConnectionInvalidated ErrorCode = 172 - ErrorCodeConnectedElsewhere ErrorCode = 173 - ErrorCodeBackupValidation ErrorCode = 180 - ErrorCodeRegistrationInvalidSessionId ErrorCode = 190 - ErrorCodeRegistrationUnknown ErrorCode = 192 - ErrorCodeRegistrationSessionNotFound ErrorCode = 193 - ErrorCodeRegistrationNotReadyForVerification ErrorCode = 194 - ErrorCodeRegistrationSendVerificationCodeFailed ErrorCode = 195 - ErrorCodeRegistrationCodeNotDeliverable ErrorCode = 196 - ErrorCodeRegistrationSessionUpdateRejected ErrorCode = 197 - ErrorCodeRegistrationCredentialsCouldNotBeParsed ErrorCode = 198 - ErrorCodeRegistrationDeviceTransferPossible ErrorCode = 199 - ErrorCodeRegistrationRecoveryVerificationFailed ErrorCode = 200 - ErrorCodeRegistrationLock ErrorCode = 201 - ErrorCodeKeyTransparencyError ErrorCode = 210 - ErrorCodeKeyTransparencyVerificationFailed ErrorCode = 211 - ErrorCodeRequestUnauthorized ErrorCode = 220 - ErrorCodeMismatchedDevices ErrorCode = 221 + ErrorCodeUnknownError ErrorCode = 1 + ErrorCodeInvalidState ErrorCode = 2 + ErrorCodeInternalError ErrorCode = 3 + ErrorCodeNullParameter ErrorCode = 4 + ErrorCodeInvalidArgument ErrorCode = 5 + ErrorCodeInvalidType ErrorCode = 6 + ErrorCodeInvalidUtf8String ErrorCode = 7 + ErrorCodeProtobufError ErrorCode = 10 + ErrorCodeLegacyCiphertextVersion ErrorCode = 21 + ErrorCodeUnknownCiphertextVersion ErrorCode = 22 + ErrorCodeUnrecognizedMessageVersion ErrorCode = 23 + ErrorCodeInvalidMessage ErrorCode = 30 + ErrorCodeSealedSenderSelfSend ErrorCode = 31 + ErrorCodeInvalidKey ErrorCode = 40 + ErrorCodeInvalidSignature ErrorCode = 41 + ErrorCodeInvalidAttestationData ErrorCode = 42 + ErrorCodeFingerprintVersionMismatch ErrorCode = 51 + ErrorCodeFingerprintParsingError ErrorCode = 52 + ErrorCodeUntrustedIdentity ErrorCode = 60 + ErrorCodeInvalidKeyIdentifier ErrorCode = 70 + ErrorCodeSessionNotFound ErrorCode = 80 + ErrorCodeInvalidRegistrationId ErrorCode = 81 + ErrorCodeInvalidSession ErrorCode = 82 + ErrorCodeInvalidSenderKeySession ErrorCode = 83 + ErrorCodeDuplicatedMessage ErrorCode = 90 + ErrorCodeCallbackError ErrorCode = 100 + ErrorCodeVerificationFailure ErrorCode = 110 ) type SignalError struct { @@ -122,11 +66,7 @@ func (e *SignalError) Error() string { return fmt.Sprintf("%d: %s", e.Code, e.Message) } -func (e *SignalError) Unwrap() error { - return e.Code -} - -func (ctx *CallbackContext) wrapError(signalError *C.SignalFfiError) error { +func wrapCallbackError(signalError *C.SignalFfiError, ctx *CallbackContext) error { if signalError == nil { return nil } @@ -153,9 +93,10 @@ func wrapError(signalError *C.SignalFfiError) error { func wrapSignalError(signalError *C.SignalFfiError, errorType C.uint32_t) error { var messageBytes *C.char - getMessageError := C.signal_error_get_message(&messageBytes, signalError) + getMessageError := C.signal_error_get_message(signalError, &messageBytes) if getMessageError != nil { - // Ignore any errors from this, it will just end up being an empty string. + // Ignore any errors from this, it will just end up being an empty + // string. C.signal_error_free(getMessageError) } return &SignalError{Code: ErrorCode(errorType), Message: CopyCStringToString(messageBytes)} diff --git a/pkg/libsignalgo/fingerprint.go b/pkg/libsignalgo/fingerprint.go index b2ef8ce..24fb82f 100644 --- a/pkg/libsignalgo/fingerprint.go +++ b/pkg/libsignalgo/fingerprint.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Sumner Evans -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,6 +17,7 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" @@ -42,49 +42,31 @@ func wrapFingerprint(ptr *C.SignalFingerprint) *Fingerprint { } func NewFingerprint(iterations, version FingerprintVersion, localIdentifier []byte, localKey *PublicKey, remoteIdentifier []byte, remoteKey *PublicKey) (*Fingerprint, error) { - var pa C.SignalMutPointerFingerprint - signalFfiError := C.signal_fingerprint_new( - &pa, - C.uint32_t(iterations), - C.uint32_t(version), - BytesToBuffer(localIdentifier), - localKey.constPtr(), - BytesToBuffer(remoteIdentifier), - remoteKey.constPtr(), - ) + var pa *C.SignalFingerprint + signalFfiError := C.signal_fingerprint_new(&pa, C.uint32_t(iterations), C.uint32_t(version), BytesToBuffer(localIdentifier), localKey.ptr, BytesToBuffer(remoteIdentifier), remoteKey.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapFingerprint(pa.raw), nil -} - -func (f *Fingerprint) mutPtr() C.SignalMutPointerFingerprint { - return C.SignalMutPointerFingerprint{f.ptr} -} - -func (f *Fingerprint) constPtr() C.SignalConstPointerFingerprint { - return C.SignalConstPointerFingerprint{f.ptr} + return wrapFingerprint(pa), nil } func (f *Fingerprint) Clone() (*Fingerprint, error) { - var cloned C.SignalMutPointerFingerprint - signalFfiError := C.signal_fingerprint_clone(&cloned, f.constPtr()) - runtime.KeepAlive(f) + var cloned *C.SignalFingerprint + signalFfiError := C.signal_fingerprint_clone(&cloned, f.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapFingerprint(cloned.raw), nil + return wrapFingerprint(cloned), nil } func (f *Fingerprint) Destroy() error { runtime.SetFinalizer(f, nil) - return wrapError(C.signal_fingerprint_destroy(f.mutPtr())) + return wrapError(C.signal_fingerprint_destroy(f.ptr)) } func (f *Fingerprint) ScannableEncoding() ([]byte, error) { var scannableEncoding C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_fingerprint_scannable_encoding(&scannableEncoding, f.constPtr()) - runtime.KeepAlive(f) + signalFfiError := C.signal_fingerprint_scannable_encoding(&scannableEncoding, f.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -93,8 +75,7 @@ func (f *Fingerprint) ScannableEncoding() ([]byte, error) { func (f *Fingerprint) DisplayString() (string, error) { var displayString *C.char - signalFfiError := C.signal_fingerprint_display_string(&displayString, f.constPtr()) - runtime.KeepAlive(f) + signalFfiError := C.signal_fingerprint_display_string(&displayString, f.ptr) if signalFfiError != nil { return "", wrapError(signalFfiError) } @@ -104,9 +85,6 @@ func (f *Fingerprint) DisplayString() (string, error) { func (f *Fingerprint) Compare(fingerprint1, fingerprint2 []byte) (bool, error) { var compare C.bool signalFfiError := C.signal_fingerprint_compare(&compare, BytesToBuffer(fingerprint1), BytesToBuffer(fingerprint2)) - runtime.KeepAlive(f) - runtime.KeepAlive(fingerprint1) - runtime.KeepAlive(fingerprint2) if signalFfiError != nil { return false, wrapError(signalFfiError) } diff --git a/pkg/libsignalgo/groupcipher.go b/pkg/libsignalgo/groupcipher.go index 9ec5997..50d8755 100644 --- a/pkg/libsignalgo/groupcipher.go +++ b/pkg/libsignalgo/groupcipher.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Sumner Evans -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,48 +17,46 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" import ( - "context" - "runtime" "unsafe" "github.com/google/uuid" + gopointer "github.com/mattn/go-pointer" ) -func GroupEncrypt(ctx context.Context, ptext []byte, sender *Address, distributionID uuid.UUID, store SenderKeyStore) (*CiphertextMessage, error) { - callbackCtx := NewCallbackContext(ctx) - defer callbackCtx.Unref() - var ciphertextMessage C.SignalMutPointerCiphertextMessage +func GroupEncrypt(ptext []byte, sender *Address, distributionID uuid.UUID, store SenderKeyStore, ctx *CallbackContext) (*CiphertextMessage, error) { + contextPointer := gopointer.Save(ctx) + defer gopointer.Unref(contextPointer) + + var ciphertextMessage *C.SignalCiphertextMessage signalFfiError := C.signal_group_encrypt_message( &ciphertextMessage, - sender.constPtr(), - *(*C.SignalUuid)(unsafe.Pointer(&distributionID)), + sender.ptr, + (*[C.SignalUUID_LEN]C.uchar)(unsafe.Pointer(&distributionID)), BytesToBuffer(ptext), - callbackCtx.wrapSenderKeyStore(store)) - runtime.KeepAlive(ptext) - runtime.KeepAlive(sender) + wrapSenderKeyStore(store)) if signalFfiError != nil { - return nil, callbackCtx.wrapError(signalFfiError) + return nil, wrapCallbackError(signalFfiError, ctx) } - return wrapCiphertextMessage(ciphertextMessage.raw), nil + return wrapCiphertextMessage(ciphertextMessage), nil } -func GroupDecrypt(ctx context.Context, ctext []byte, sender *Address, store SenderKeyStore) ([]byte, error) { - callbackCtx := NewCallbackContext(ctx) - defer callbackCtx.Unref() +func GroupDecrypt(ctext []byte, sender *Address, store SenderKeyStore, ctx *CallbackContext) ([]byte, error) { + contextPointer := gopointer.Save(ctx) + defer gopointer.Unref(contextPointer) + var resp C.SignalOwnedBuffer = C.SignalOwnedBuffer{} signalFfiError := C.signal_group_decrypt_message( &resp, - sender.constPtr(), + sender.ptr, BytesToBuffer(ctext), - callbackCtx.wrapSenderKeyStore(store)) - runtime.KeepAlive(ctext) - runtime.KeepAlive(sender) + wrapSenderKeyStore(store)) if signalFfiError != nil { - return nil, callbackCtx.wrapError(signalFfiError) + return nil, wrapCallbackError(signalFfiError, ctx) } return CopySignalOwnedBufferToBytes(resp), nil } diff --git a/pkg/libsignalgo/groupcipher_test.go b/pkg/libsignalgo/groupcipher_test.go index eda4fdf..e624385 100644 --- a/pkg/libsignalgo/groupcipher_test.go +++ b/pkg/libsignalgo/groupcipher_test.go @@ -17,7 +17,6 @@ package libsignalgo_test import ( - "context" "testing" "github.com/google/uuid" @@ -28,9 +27,8 @@ import ( // From PublicAPITests.swift:testGroupCipher func TestGroupCipher(t *testing.T) { - ctx := context.TODO() - - sender, err := libsignalgo.NewACIServiceID(uuid.New()).Address(4) + ctx := libsignalgo.NewEmptyCallbackContext() + sender, err := libsignalgo.NewAddress("+14159999111", 4) assert.NoError(t, err) distributionID, err := uuid.Parse("d1d1d1d1-7000-11eb-b32a-33b8a8a487a6") @@ -38,7 +36,7 @@ func TestGroupCipher(t *testing.T) { aliceStore := NewInMemorySignalProtocolStore() - skdm, err := libsignalgo.NewSenderKeyDistributionMessage(ctx, sender, distributionID, aliceStore) + skdm, err := libsignalgo.NewSenderKeyDistributionMessage(sender, distributionID, aliceStore, ctx) assert.NoError(t, err) serialized, err := skdm.Serialize() @@ -47,17 +45,17 @@ func TestGroupCipher(t *testing.T) { skdmReloaded, err := libsignalgo.DeserializeSenderKeyDistributionMessage(serialized) assert.NoError(t, err) - aliceCiphertextMessage, err := libsignalgo.GroupEncrypt(ctx, []byte{1, 2, 3}, sender, distributionID, aliceStore) + aliceCiphertextMessage, err := libsignalgo.GroupEncrypt([]byte{1, 2, 3}, sender, distributionID, aliceStore, ctx) assert.NoError(t, err) aliceCiphertext, err := aliceCiphertextMessage.Serialize() assert.NoError(t, err) bobStore := NewInMemorySignalProtocolStore() - err = skdmReloaded.Process(ctx, sender, bobStore) + err = skdmReloaded.Process(sender, bobStore, ctx) assert.NoError(t, err) - bobPtext, err := libsignalgo.GroupDecrypt(ctx, aliceCiphertext, sender, bobStore) + bobPtext, err := libsignalgo.GroupDecrypt(aliceCiphertext, sender, bobStore, ctx) assert.NoError(t, err) assert.Equal(t, []byte{1, 2, 3}, bobPtext) } diff --git a/pkg/libsignalgo/groupsecretparams.go b/pkg/libsignalgo/groupsecretparams.go index a6b370c..74ea615 100644 --- a/pkg/libsignalgo/groupsecretparams.go +++ b/pkg/libsignalgo/groupsecretparams.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Sumner Evans -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,14 +17,12 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" import ( "crypto/rand" - "encoding/base64" - "fmt" - "runtime" "unsafe" "github.com/google/uuid" @@ -33,57 +30,31 @@ import ( type Randomness [C.SignalRANDOMNESS_LEN]byte -func GenerateRandomness() Randomness { +func GenerateRandomness() (Randomness, error) { var randomness Randomness _, err := rand.Read(randomness[:]) - if err != nil { - panic(err) - } - return randomness + return randomness, err } -const GroupMasterKeyLength = C.SignalGROUP_MASTER_KEY_LEN -const GroupIdentifierLength = C.SignalGROUP_IDENTIFIER_LEN - -type GroupMasterKey [GroupMasterKeyLength]byte +type GroupMasterKey [C.SignalGROUP_MASTER_KEY_LEN]byte type GroupSecretParams [C.SignalGROUP_SECRET_PARAMS_LEN]byte type GroupPublicParams [C.SignalGROUP_PUBLIC_PARAMS_LEN]byte -type GroupIdentifier [GroupIdentifierLength]byte - -func (gid *GroupIdentifier) String() string { - if gid == nil { - return "" - } - return base64.StdEncoding.EncodeToString(gid[:]) -} +type GroupIdentifier [C.SignalGROUP_IDENTIFIER_LEN]byte type UUIDCiphertext [C.SignalUUID_CIPHERTEXT_LEN]byte type ProfileKeyCiphertext [C.SignalPROFILE_KEY_CIPHERTEXT_LEN]byte func GenerateGroupSecretParams() (GroupSecretParams, error) { - return GenerateGroupSecretParamsWithRandomness(GenerateRandomness()) -} - -func (gmk GroupMasterKey) GroupIdentifier() (*GroupIdentifier, error) { - if groupSecretParams, err := DeriveGroupSecretParamsFromMasterKey(gmk); err != nil { - return nil, fmt.Errorf("DeriveGroupSecretParamsFromMasterKey error: %w", err) - } else if groupPublicParams, err := groupSecretParams.GetPublicParams(); err != nil { - return nil, fmt.Errorf("GetPublicParams error: %w", err) - } else if groupIdentifier, err := GetGroupIdentifier(*groupPublicParams); err != nil { - return nil, fmt.Errorf("GetGroupIdentifier error: %w", err) - } else { - return groupIdentifier, nil + randomness, err := GenerateRandomness() + if err != nil { + return GroupSecretParams{}, err } -} - -func (gmk GroupMasterKey) SecretParams() (GroupSecretParams, error) { - return DeriveGroupSecretParamsFromMasterKey(gmk) + return GenerateGroupSecretParamsWithRandomness(randomness) } func GenerateGroupSecretParamsWithRandomness(randomness Randomness) (GroupSecretParams, error) { var params [C.SignalGROUP_SECRET_PARAMS_LEN]C.uchar signalFfiError := C.signal_group_secret_params_generate_deterministic(¶ms, (*[C.SignalRANDOMNESS_LEN]C.uint8_t)(unsafe.Pointer(&randomness))) - runtime.KeepAlive(randomness) if signalFfiError != nil { return GroupSecretParams{}, wrapError(signalFfiError) } @@ -95,7 +66,6 @@ func GenerateGroupSecretParamsWithRandomness(randomness Randomness) (GroupSecret func DeriveGroupSecretParamsFromMasterKey(groupMasterKey GroupMasterKey) (GroupSecretParams, error) { var params [C.SignalGROUP_SECRET_PARAMS_LEN]C.uchar signalFfiError := C.signal_group_secret_params_derive_from_master_key(¶ms, (*[C.SignalGROUP_MASTER_KEY_LEN]C.uint8_t)(unsafe.Pointer(&groupMasterKey))) - runtime.KeepAlive(groupMasterKey) if signalFfiError != nil { return GroupSecretParams{}, wrapError(signalFfiError) } @@ -107,7 +77,6 @@ func DeriveGroupSecretParamsFromMasterKey(groupMasterKey GroupMasterKey) (GroupS func (gsp *GroupSecretParams) GetPublicParams() (*GroupPublicParams, error) { var publicParams [C.SignalGROUP_PUBLIC_PARAMS_LEN]C.uchar signalFfiError := C.signal_group_secret_params_get_public_params(&publicParams, (*[C.SignalGROUP_SECRET_PARAMS_LEN]C.uint8_t)(unsafe.Pointer(gsp))) - runtime.KeepAlive(gsp) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -119,7 +88,6 @@ func (gsp *GroupSecretParams) GetPublicParams() (*GroupPublicParams, error) { func GetGroupIdentifier(groupPublicParams GroupPublicParams) (*GroupIdentifier, error) { var groupIdentifier [C.SignalGROUP_IDENTIFIER_LEN]C.uchar signalFfiError := C.signal_group_public_params_get_group_identifier(&groupIdentifier, (*[C.SignalGROUP_PUBLIC_PARAMS_LEN]C.uint8_t)(unsafe.Pointer(&groupPublicParams))) - runtime.KeepAlive(groupPublicParams) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -136,78 +104,42 @@ func (gsp *GroupSecretParams) DecryptBlobWithPadding(blob []byte) ([]byte, error (*[C.SignalGROUP_SECRET_PARAMS_LEN]C.uint8_t)(unsafe.Pointer(gsp)), borrowedBlob, ) - runtime.KeepAlive(gsp) - runtime.KeepAlive(blob) if signalFfiError != nil { return nil, wrapError(signalFfiError) } return CopySignalOwnedBufferToBytes(plaintext), nil } -func (gsp *GroupSecretParams) EncryptBlobWithPaddingDeterministic(randomness Randomness, plaintext []byte, padding_len uint32) ([]byte, error) { - var ciphertext C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - borrowedPlaintext := BytesToBuffer(plaintext) - signalFfiError := C.signal_group_secret_params_encrypt_blob_with_padding_deterministic( - &ciphertext, - (*[C.SignalGROUP_SECRET_PARAMS_LEN]C.uint8_t)(unsafe.Pointer(gsp)), - (*[C.SignalRANDOMNESS_LEN]C.uint8_t)(unsafe.Pointer(&randomness)), - borrowedPlaintext, - (C.uint32_t)(padding_len), - ) - runtime.KeepAlive(randomness) - runtime.KeepAlive(gsp) - runtime.KeepAlive(plaintext) - runtime.KeepAlive(padding_len) - if signalFfiError != nil { - return nil, wrapError(signalFfiError) - } - return CopySignalOwnedBufferToBytes(ciphertext), nil -} - -func (gsp *GroupSecretParams) DecryptServiceID(ciphertextServiceID UUIDCiphertext) (ServiceID, error) { +func (gsp *GroupSecretParams) DecryptUUID(ciphertextUUID UUIDCiphertext) (*uuid.UUID, error) { u := C.SignalServiceIdFixedWidthBinaryBytes{} signalFfiError := C.signal_group_secret_params_decrypt_service_id( &u, (*[C.SignalGROUP_SECRET_PARAMS_LEN]C.uint8_t)(unsafe.Pointer(gsp)), - (*[C.SignalUUID_CIPHERTEXT_LEN]C.uint8_t)(unsafe.Pointer(&ciphertextServiceID)), + (*[C.SignalUUID_CIPHERTEXT_LEN]C.uint8_t)(unsafe.Pointer(&ciphertextUUID)), ) - runtime.KeepAlive(gsp) - runtime.KeepAlive(ciphertextServiceID) - if signalFfiError != nil { - return EmptyServiceID, wrapError(signalFfiError) - } - - serviceID := ServiceIDFromCFixedBytes(&u) - return serviceID, nil -} - -func (gsp *GroupSecretParams) EncryptServiceID(serviceID ServiceID) (*UUIDCiphertext, error) { - var cipherTextServiceID [C.SignalUUID_CIPHERTEXT_LEN]C.uchar - signalFfiError := C.signal_group_secret_params_encrypt_service_id( - &cipherTextServiceID, - (*[C.SignalGROUP_SECRET_PARAMS_LEN]C.uint8_t)(unsafe.Pointer(gsp)), - serviceID.CFixedBytes(), - ) - runtime.KeepAlive(gsp) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - var result UUIDCiphertext - copy(result[:], C.GoBytes(unsafe.Pointer(&cipherTextServiceID), C.int(C.SignalUUID_CIPHERTEXT_LEN))) + + result, err := SignalServiceIDToUUID(&u) + if err != nil { + return nil, err + } return &result, nil } func (gsp *GroupSecretParams) DecryptProfileKey(ciphertextProfileKey ProfileKeyCiphertext, u uuid.UUID) (*ProfileKey, error) { profileKey := [C.SignalPROFILE_KEY_LEN]C.uchar{} + serviceId, err := SignalServiceIDFromUUID(u) + if err != nil { + return nil, err + } signalFfiError := C.signal_group_secret_params_decrypt_profile_key( &profileKey, (*[C.SignalGROUP_SECRET_PARAMS_LEN]C.uint8_t)(unsafe.Pointer(gsp)), (*[C.SignalPROFILE_KEY_CIPHERTEXT_LEN]C.uint8_t)(unsafe.Pointer(&ciphertextProfileKey)), - NewACIServiceID(u).CFixedBytes(), + serviceId, ) - runtime.KeepAlive(gsp) - runtime.KeepAlive(ciphertextProfileKey) - runtime.KeepAlive(u) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -215,57 +147,3 @@ func (gsp *GroupSecretParams) DecryptProfileKey(ciphertextProfileKey ProfileKeyC copy(result[:], C.GoBytes(unsafe.Pointer(&profileKey), C.int(C.SignalPROFILE_KEY_LEN))) return &result, nil } - -func (gsp *GroupSecretParams) EncryptProfileKey(profileKey ProfileKey, u uuid.UUID) (*ProfileKeyCiphertext, error) { - ciphertextProfileKey := [C.SignalPROFILE_KEY_CIPHERTEXT_LEN]C.uchar{} - signalFfiError := C.signal_group_secret_params_encrypt_profile_key( - &ciphertextProfileKey, - (*[C.SignalGROUP_SECRET_PARAMS_LEN]C.uint8_t)(unsafe.Pointer(gsp)), - (*[C.SignalPROFILE_KEY_LEN]C.uint8_t)(unsafe.Pointer(&profileKey)), - NewACIServiceID(u).CFixedBytes(), - ) - runtime.KeepAlive(gsp) - runtime.KeepAlive(profileKey) - if signalFfiError != nil { - return nil, wrapError(signalFfiError) - } - var result ProfileKeyCiphertext - copy(result[:], C.GoBytes(unsafe.Pointer(&ciphertextProfileKey), C.int(C.SignalPROFILE_KEY_CIPHERTEXT_LEN))) - return &result, nil -} - -func (gsp *GroupSecretParams) CreateExpiringProfileKeyCredentialPresentation(spp *ServerPublicParams, credential ExpiringProfileKeyCredential) (*ProfileKeyCredentialPresentation, error) { - var out C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - randomness := GenerateRandomness() - signalFfiError := C.signal_server_public_params_create_expiring_profile_key_credential_presentation_deterministic( - &out, - C.SignalConstPointerServerPublicParams{spp}, - (*[C.SignalRANDOMNESS_LEN]C.uint8_t)(unsafe.Pointer(&randomness)), - (*[C.SignalGROUP_SECRET_PARAMS_LEN]C.uchar)(unsafe.Pointer(gsp)), - (*[C.SignalEXPIRING_PROFILE_KEY_CREDENTIAL_LEN]C.uchar)(unsafe.Pointer(&credential)), - ) - runtime.KeepAlive(gsp) - runtime.KeepAlive(credential) - runtime.KeepAlive(randomness) - if signalFfiError != nil { - return nil, wrapError(signalFfiError) - } - presentationBytes := CopySignalOwnedBufferToBytes(out) - presentation := ProfileKeyCredentialPresentation(presentationBytes) - return &presentation, nil -} - -func (gsp *GroupSecretParams) GetMasterKey() (*GroupMasterKey, error) { - masterKeyBytes := [C.SignalGROUP_MASTER_KEY_LEN]C.uchar{} - signalFfiError := C.signal_group_secret_params_get_master_key( - &masterKeyBytes, - (*[C.SignalGROUP_SECRET_PARAMS_LEN]C.uchar)(unsafe.Pointer(gsp)), - ) - runtime.KeepAlive(gsp) - if signalFfiError != nil { - return nil, wrapError(signalFfiError) - } - var groupMasterKey GroupMasterKey - copy(groupMasterKey[:], C.GoBytes(unsafe.Pointer(&masterKeyBytes), C.int(C.SignalGROUP_MASTER_KEY_LEN))) - return &groupMasterKey, nil -} diff --git a/pkg/libsignalgo/groupsendendorsement.go b/pkg/libsignalgo/groupsendendorsement.go deleted file mode 100644 index 73f175e..0000000 --- a/pkg/libsignalgo/groupsendendorsement.go +++ /dev/null @@ -1,215 +0,0 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2025 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package libsignalgo - -/* -#include "./libsignal-ffi.h" -*/ -import "C" -import ( - "encoding/base64" - "runtime" - "time" - "unsafe" -) - -type GroupSendFullToken []byte - -func (gsft GroupSendFullToken) String() string { - return base64.StdEncoding.EncodeToString(gsft) -} - -func (gsft GroupSendFullToken) CheckValidContents() error { - signalFfiError := C.signal_group_send_full_token_check_valid_contents( - BytesToBuffer(gsft), - ) - runtime.KeepAlive(gsft) - if signalFfiError != nil { - return wrapError(signalFfiError) - } - return nil -} - -func (gsft GroupSendFullToken) GetExpiration() (time.Time, error) { - var expiration C.uint64_t - signalFfiError := C.signal_group_send_full_token_get_expiration( - &expiration, - BytesToBuffer(gsft), - ) - runtime.KeepAlive(gsft) - if signalFfiError != nil { - return time.Time{}, wrapError(signalFfiError) - } - return time.Unix(int64(expiration), 0), nil -} - -type GroupSendToken []byte - -func (gst GroupSendToken) CheckValidContents() error { - signalFfiError := C.signal_group_send_token_check_valid_contents( - BytesToBuffer(gst), - ) - runtime.KeepAlive(gst) - if signalFfiError != nil { - return wrapError(signalFfiError) - } - return nil -} - -func (gst GroupSendToken) ToFullToken(expiration time.Time) (GroupSendFullToken, error) { - var fullToken C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_group_send_token_to_full_token( - &fullToken, - BytesToBuffer(gst), - C.uint64_t(expiration.Unix()), - ) - runtime.KeepAlive(gst) - if signalFfiError != nil { - return nil, wrapError(signalFfiError) - } - return CopySignalOwnedBufferToBytes(fullToken), nil -} - -type GroupSendEndorsement []byte - -func (gse GroupSendEndorsement) ToToken(groupSecretParams *GroupSecretParams) (GroupSendToken, error) { - var token C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_group_send_endorsement_to_token( - &token, - BytesToBuffer(gse), - (*[C.SignalGROUP_SECRET_PARAMS_LEN]C.uint8_t)(unsafe.Pointer(groupSecretParams)), - ) - runtime.KeepAlive(gse) - runtime.KeepAlive(groupSecretParams) - if signalFfiError != nil { - return nil, wrapError(signalFfiError) - } - return CopySignalOwnedBufferToBytes(token), nil -} - -func (gse GroupSendEndorsement) ToFullToken(params *GroupSecretParams, expiration time.Time) (GroupSendFullToken, error) { - token, err := gse.ToToken(params) - if err != nil { - return nil, err - } - return token.ToFullToken(expiration) -} - -func (gse GroupSendEndorsement) CheckValidContents() error { - signalFfiError := C.signal_group_send_endorsement_check_valid_contents( - BytesToBuffer(gse), - ) - runtime.KeepAlive(gse) - if signalFfiError != nil { - return wrapError(signalFfiError) - } - return nil -} - -func (gse GroupSendEndorsement) Remove(other GroupSendEndorsement) (GroupSendEndorsement, error) { - var result C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_group_send_endorsement_remove( - &result, - BytesToBuffer(gse), - BytesToBuffer(other), - ) - runtime.KeepAlive(gse) - runtime.KeepAlive(other) - if signalFfiError != nil { - return nil, wrapError(signalFfiError) - } - return CopySignalOwnedBufferToBytes(result), nil -} - -func GroupSendEndorsementCombine(endorsements ...GroupSendEndorsement) (GroupSendEndorsement, error) { - var result C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - cEndorsements, unpin := ManyBytesToBuffer(endorsements) - defer unpin() - signalFfiError := C.signal_group_send_endorsement_combine( - &result, - cEndorsements, - ) - runtime.KeepAlive(endorsements) - if signalFfiError != nil { - return nil, wrapError(signalFfiError) - } - return CopySignalOwnedBufferToBytes(result), nil -} - -type GroupSendEndorsementsResponse []byte - -func (gser GroupSendEndorsementsResponse) GetExpiration() (time.Time, error) { - var expiration C.uint64_t - signalFfiError := C.signal_group_send_endorsements_response_get_expiration( - &expiration, - BytesToBuffer(gser), - ) - runtime.KeepAlive(gser) - if signalFfiError != nil { - return time.Time{}, wrapError(signalFfiError) - } - return time.Unix(int64(expiration), 0), nil -} - -func (gser GroupSendEndorsementsResponse) CheckValidContents() error { - signalFfiError := C.signal_group_send_endorsements_response_check_valid_contents( - BytesToBuffer(gser), - ) - runtime.KeepAlive(gser) - if signalFfiError != nil { - return wrapError(signalFfiError) - } - return nil -} - -func (gser GroupSendEndorsementsResponse) ReceiveWithServiceIDs( - groupMembers []ServiceID, localUser ServiceID, params *GroupSecretParams, spp *ServerPublicParams, -) (GroupSendEndorsement, map[ServiceID]GroupSendEndorsement, error) { - var out C.SignalBytestringArray = C.SignalBytestringArray{} - concatenatedMembers := make([]byte, len(groupMembers)*17) - for i, member := range groupMembers { - copy(concatenatedMembers[i*17:(i+1)*17], member.FixedBytes()[:]) - } - signalFfiError := C.signal_group_send_endorsements_response_receive_and_combine_with_service_ids( - &out, - BytesToBuffer(gser), - BytesToBuffer(concatenatedMembers), - localUser.CFixedBytes(), - C.uint64_t(time.Now().Unix()), - (*[C.SignalGROUP_SECRET_PARAMS_LEN]C.uint8_t)(unsafe.Pointer(params)), - C.SignalConstPointerServerPublicParams{spp}, - ) - runtime.KeepAlive(gser) - runtime.KeepAlive(concatenatedMembers) - runtime.KeepAlive(params) - runtime.KeepAlive(spp) - if signalFfiError != nil { - return nil, nil, wrapError(signalFfiError) - } - endorsements := CopySignalBytestringArray[GroupSendEndorsement](out) - memberEndorsements := make(map[ServiceID]GroupSendEndorsement, len(groupMembers)) - for i, member := range groupMembers { - if len(endorsements) > i && len(endorsements[i]) > 0 { - memberEndorsements[member] = endorsements[i] - } - } - combined, err := GroupSendEndorsementCombine(endorsements...) - if err != nil { - return nil, memberEndorsements, err - } - return combined, memberEndorsements, nil -} diff --git a/pkg/libsignalgo/hsmenclave.go b/pkg/libsignalgo/hsmenclave.go index 2eb61cd..819be0a 100644 --- a/pkg/libsignalgo/hsmenclave.go +++ b/pkg/libsignalgo/hsmenclave.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Sumner Evans -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,6 +17,7 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" @@ -35,35 +35,22 @@ func wrapHSMEnclaveClient(ptr *C.SignalHsmEnclaveClient) *HSMEnclaveClient { } func NewHSMEnclaveClient(trustedPublicKey, trustedCodeHashes []byte) (*HSMEnclaveClient, error) { - var cds C.SignalMutPointerHsmEnclaveClient - signalFfiError := C.signal_hsm_enclave_client_new( - &cds, - BytesToBuffer(trustedPublicKey), - BytesToBuffer(trustedCodeHashes), - ) + var cds *C.SignalHsmEnclaveClient + signalFfiError := C.signal_hsm_enclave_client_new(&cds, BytesToBuffer(trustedPublicKey), BytesToBuffer(trustedCodeHashes)) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapHSMEnclaveClient(cds.raw), nil -} - -func (hsm *HSMEnclaveClient) mutPtr() C.SignalMutPointerHsmEnclaveClient { - return C.SignalMutPointerHsmEnclaveClient{hsm.ptr} -} - -func (hsm *HSMEnclaveClient) constPtr() C.SignalConstPointerHsmEnclaveClient { - return C.SignalConstPointerHsmEnclaveClient{hsm.ptr} + return wrapHSMEnclaveClient(cds), nil } func (hsm *HSMEnclaveClient) Destroy() error { runtime.SetFinalizer(hsm, nil) - return wrapError(C.signal_hsm_enclave_client_destroy(hsm.mutPtr())) + return wrapError(C.signal_hsm_enclave_client_destroy(hsm.ptr)) } func (hsm *HSMEnclaveClient) InitialRequest() ([]byte, error) { var resp C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_hsm_enclave_client_initial_request(&resp, hsm.constPtr()) - runtime.KeepAlive(hsm) + signalFfiError := C.signal_hsm_enclave_client_initial_request(&resp, hsm.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -71,17 +58,13 @@ func (hsm *HSMEnclaveClient) InitialRequest() ([]byte, error) { } func (hsm *HSMEnclaveClient) CompleteHandshake(handshakeReceived []byte) error { - signalFfiError := C.signal_hsm_enclave_client_complete_handshake(hsm.mutPtr(), BytesToBuffer(handshakeReceived)) - runtime.KeepAlive(hsm) - runtime.KeepAlive(handshakeReceived) + signalFfiError := C.signal_hsm_enclave_client_complete_handshake(hsm.ptr, BytesToBuffer(handshakeReceived)) return wrapError(signalFfiError) } func (hsm *HSMEnclaveClient) EstablishedSend(plaintext []byte) ([]byte, error) { var resp C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_hsm_enclave_client_established_send(&resp, hsm.mutPtr(), BytesToBuffer(plaintext)) - runtime.KeepAlive(hsm) - runtime.KeepAlive(plaintext) + signalFfiError := C.signal_hsm_enclave_client_established_send(&resp, hsm.ptr, BytesToBuffer(plaintext)) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -90,9 +73,7 @@ func (hsm *HSMEnclaveClient) EstablishedSend(plaintext []byte) ([]byte, error) { func (hsm *HSMEnclaveClient) EstablishedReceive(ciphertext []byte) ([]byte, error) { var resp C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_hsm_enclave_client_established_recv(&resp, hsm.mutPtr(), BytesToBuffer(ciphertext)) - runtime.KeepAlive(hsm) - runtime.KeepAlive(ciphertext) + signalFfiError := C.signal_hsm_enclave_client_established_recv(&resp, hsm.ptr, BytesToBuffer(ciphertext)) if signalFfiError != nil { return nil, wrapError(signalFfiError) } diff --git a/pkg/libsignalgo/identitykey.go b/pkg/libsignalgo/identitykey.go index 0226e11..b373860 100644 --- a/pkg/libsignalgo/identitykey.go +++ b/pkg/libsignalgo/identitykey.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Sumner Evans -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,12 +17,10 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" -import ( - "runtime" -) type IdentityKey struct { publicKey *PublicKey @@ -41,42 +38,22 @@ func NewIdentityKeyFromBytes(bytes []byte) (*IdentityKey, error) { return &IdentityKey{publicKey: publicKey}, nil } -func (i *IdentityKey) TrySerialize() []byte { - if i == nil { - return nil - } - serialized, err := i.Serialize() - if err != nil { - return nil - } - return serialized -} - func (i *IdentityKey) Serialize() ([]byte, error) { return i.publicKey.Serialize() } func DeserializeIdentityKey(bytes []byte) (*IdentityKey, error) { - var publicKey C.SignalMutPointerPublicKey + var publicKey *C.SignalPublicKey signalFfiError := C.signal_publickey_deserialize(&publicKey, BytesToBuffer(bytes)) - runtime.KeepAlive(bytes) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return &IdentityKey{publicKey: wrapPublicKey(publicKey.raw)}, nil + return &IdentityKey{publicKey: wrapPublicKey(publicKey)}, nil } func (i *IdentityKey) VerifyAlternateIdentity(other *IdentityKey, signature []byte) (bool, error) { var verify C.bool - signalFfiError := C.signal_identitykey_verify_alternate_identity( - &verify, - i.publicKey.constPtr(), - other.publicKey.constPtr(), - BytesToBuffer(signature), - ) - runtime.KeepAlive(i) - runtime.KeepAlive(other) - runtime.KeepAlive(signature) + signalFfiError := C.signal_identitykey_verify_alternate_identity(&verify, i.publicKey.ptr, other.publicKey.ptr, BytesToBuffer(signature)) if signalFfiError != nil { return false, wrapError(signalFfiError) } @@ -84,7 +61,8 @@ func (i *IdentityKey) VerifyAlternateIdentity(other *IdentityKey, signature []by } func (i *IdentityKey) Equal(other *IdentityKey) (bool, error) { - return i.publicKey.Equal(other.publicKey) + result, err := i.publicKey.Compare(other.publicKey) + return result == 0, err } type IdentityKeyPair struct { @@ -113,13 +91,13 @@ func GenerateIdentityKeyPair() (*IdentityKeyPair, error) { } func DeserializeIdentityKeyPair(bytes []byte) (*IdentityKeyPair, error) { - var keys C.SignalPairOfMutPointerPublicKeyMutPointerPrivateKey - signalFfiError := C.signal_identitykeypair_deserialize(&keys, BytesToBuffer(bytes)) - runtime.KeepAlive(bytes) + var privateKey *C.SignalPrivateKey + var publicKey *C.SignalPublicKey + signalFfiError := C.signal_identitykeypair_deserialize(&privateKey, &publicKey, BytesToBuffer(bytes)) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return &IdentityKeyPair{publicKey: wrapPublicKey(keys.first.raw), privateKey: wrapPrivateKey(keys.second.raw)}, nil + return &IdentityKeyPair{publicKey: wrapPublicKey(publicKey), privateKey: wrapPrivateKey(privateKey)}, nil } func NewIdentityKeyPair(publicKey *PublicKey, privateKey *PrivateKey) (*IdentityKeyPair, error) { @@ -128,12 +106,7 @@ func NewIdentityKeyPair(publicKey *PublicKey, privateKey *PrivateKey) (*Identity func (i *IdentityKeyPair) Serialize() ([]byte, error) { var serialized C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_identitykeypair_serialize( - &serialized, - i.publicKey.constPtr(), - i.privateKey.constPtr(), - ) - runtime.KeepAlive(i) + signalFfiError := C.signal_identitykeypair_serialize(&serialized, i.publicKey.ptr, i.privateKey.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -146,14 +119,7 @@ func (i *IdentityKeyPair) GetIdentityKey() *IdentityKey { func (i *IdentityKeyPair) SignAlternateIdentity(other *IdentityKey) ([]byte, error) { var signature C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_identitykeypair_sign_alternate_identity( - &signature, - i.publicKey.constPtr(), - i.privateKey.constPtr(), - other.publicKey.constPtr(), - ) - runtime.KeepAlive(i) - runtime.KeepAlive(other) + signalFfiError := C.signal_identitykeypair_sign_alternate_identity(&signature, i.publicKey.ptr, i.privateKey.ptr, other.publicKey.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } diff --git a/pkg/libsignalgo/identitykeystore.go b/pkg/libsignalgo/identitykeystore.go index ba26f06..bd81e48 100644 --- a/pkg/libsignalgo/identitykeystore.go +++ b/pkg/libsignalgo/identitykeystore.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Sumner Evans -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,19 +17,24 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" -extern int signal_get_identity_key_pair_callback(void *store_ctx, SignalPairOfMutPointerPrivateKeyMutPointerPublicKey *keyp); -extern int signal_get_local_registration_id_callback(void *store_ctx, uint32_t *idp); -extern int signal_save_identity_key_callback(void *store_ctx, uint8_t *out, SignalMutPointerProtocolAddress address, SignalMutPointerPublicKey public_key); -extern int signal_get_identity_key_callback(void *store_ctx, SignalMutPointerPublicKey *public_keyp, SignalMutPointerProtocolAddress address); -extern int signal_is_trusted_identity_callback(void *store_ctx, bool *out, SignalMutPointerProtocolAddress address, SignalMutPointerPublicKey public_key, uint32_t direction); -extern void signal_destroy_identity_key_store_callback(void *store_ctx); +typedef const SignalProtocolAddress const_address; +typedef const SignalPublicKey const_public_key; + +extern int signal_get_identity_key_pair_callback(void *store_ctx, SignalPrivateKey **keyp, void *ctx); +extern int signal_get_local_registration_id_callback(void *store_ctx, uint32_t *idp, void *ctx); +extern int signal_save_identity_key_callback(void *store_ctx, const_address *address, const_public_key *public_key, void *ctx); +extern int signal_get_identity_key_callback(void *store_ctx, SignalPublicKey **public_keyp, const_address *address, void *ctx); +extern int signal_is_trusted_identity_callback(void *store_ctx, const_address *address, const_public_key *public_key, unsigned int direction, void *ctx); */ import "C" import ( "context" "unsafe" + + gopointer "github.com/mattn/go-pointer" ) type SignalDirection uint @@ -43,42 +47,35 @@ const ( type IdentityKeyStore interface { GetIdentityKeyPair(ctx context.Context) (*IdentityKeyPair, error) GetLocalRegistrationID(ctx context.Context) (uint32, error) - SaveIdentityKey(ctx context.Context, theirServiceID ServiceID, identityKey *IdentityKey) (bool, error) - GetIdentityKey(ctx context.Context, theirServiceID ServiceID) (*IdentityKey, error) - IsTrustedIdentity(ctx context.Context, theirServiceID ServiceID, identityKey *IdentityKey, direction SignalDirection) (bool, error) + SaveIdentityKey(address *Address, identityKey *IdentityKey, ctx context.Context) (bool, error) + GetIdentityKey(address *Address, ctx context.Context) (*IdentityKey, error) + IsTrustedIdentity(address *Address, identityKey *IdentityKey, direction SignalDirection, ctx context.Context) (bool, error) } //export signal_get_identity_key_pair_callback -func signal_get_identity_key_pair_callback(storeCtx unsafe.Pointer, keyp *C.SignalPairOfMutPointerPrivateKeyMutPointerPublicKey) C.int { - return wrapStoreCallback(storeCtx, func(store IdentityKeyStore, ctx context.Context) error { +func signal_get_identity_key_pair_callback(storeCtx unsafe.Pointer, keyp **C.SignalPrivateKey, ctxPtr unsafe.Pointer) C.int { + return wrapStoreCallback(storeCtx, ctxPtr, func(store IdentityKeyStore, ctx context.Context) error { key, err := store.GetIdentityKeyPair(ctx) if err != nil { return err } if key == nil { - keyp.first.raw = nil - keyp.second.raw = nil - return nil + *keyp = nil + } else { + clone, err := key.privateKey.Clone() + if err != nil { + return err + } + clone.CancelFinalizer() + *keyp = clone.ptr } - privClone, err := key.privateKey.Clone() - if err != nil { - return err - } - pubClone, err := key.publicKey.Clone() - if err != nil { - return err - } - privClone.CancelFinalizer() - pubClone.CancelFinalizer() - keyp.first.raw = privClone.ptr - keyp.second.raw = pubClone.ptr return err }) } //export signal_get_local_registration_id_callback -func signal_get_local_registration_id_callback(storeCtx unsafe.Pointer, idp *C.uint32_t) C.int { - return wrapStoreCallback(storeCtx, func(store IdentityKeyStore, ctx context.Context) error { +func signal_get_local_registration_id_callback(storeCtx unsafe.Pointer, idp *C.uint32_t, ctxPtr unsafe.Pointer) C.int { + return wrapStoreCallback(storeCtx, ctxPtr, func(store IdentityKeyStore, ctx context.Context) error { registrationID, err := store.GetLocalRegistrationID(ctx) if err == nil { *idp = C.uint32_t(registrationID) @@ -88,82 +85,88 @@ func signal_get_local_registration_id_callback(storeCtx unsafe.Pointer, idp *C.u } //export signal_save_identity_key_callback -func signal_save_identity_key_callback(storeCtx unsafe.Pointer, out *C.uint8_t, address C.SignalMutPointerProtocolAddress, publicKey C.SignalMutPointerPublicKey) C.int { - return wrapStoreCallback(storeCtx, func(store IdentityKeyStore, ctx context.Context) error { - publicKeyStruct := PublicKey{ptr: publicKey.raw} - cloned, err := publicKeyStruct.Clone() - if err != nil { - return err +func signal_save_identity_key_callback(storeCtx unsafe.Pointer, address *C.const_address, publicKey *C.const_public_key, ctxPtr unsafe.Pointer) C.int { + // Can't use wrapStoreCallback, because we don't just return an error value in the int + store := gopointer.Restore(storeCtx).(IdentityKeyStore) + ctx := NewEmptyCallbackContext() + if ctxPtr != nil { + if restored := gopointer.Restore(ctxPtr); restored != nil { + ctx = restored.(*CallbackContext) } - addr := &Address{ptr: address.raw} - theirServiceID, err := addr.NameServiceID() - if err != nil { - return err - } - replaced, err := store.SaveIdentityKey( - ctx, - theirServiceID, - &IdentityKey{cloned}, - ) - if err != nil { - return err - } - if replaced { - *out = 1 - } else { - *out = 0 - } - return nil - }) + } + + publicKeyStruct := PublicKey{ptr: (*C.SignalPublicKey)(unsafe.Pointer(publicKey))} + cloned, err := publicKeyStruct.Clone() + if err != nil { + ctx.Error = err + return -1 + } + replaced, err := store.SaveIdentityKey( + &Address{ptr: (*C.SignalProtocolAddress)(unsafe.Pointer(address))}, + &IdentityKey{cloned}, + ctx.Ctx, + ) + if err != nil { + ctx.Error = err + return -1 + } + if replaced { + return 1 + } else { + return 0 + } } //export signal_get_identity_key_callback -func signal_get_identity_key_callback(storeCtx unsafe.Pointer, public_keyp *C.SignalMutPointerPublicKey, address C.SignalMutPointerProtocolAddress) C.int { - return wrapStoreCallback(storeCtx, func(store IdentityKeyStore, ctx context.Context) error { - addr := &Address{ptr: address.raw} - theirServiceID, err := addr.NameServiceID() - if err != nil { - return err - } - key, err := store.GetIdentityKey(ctx, theirServiceID) +func signal_get_identity_key_callback(storeCtx unsafe.Pointer, public_keyp **C.SignalPublicKey, address *C.const_address, ctxPtr unsafe.Pointer) C.int { + return wrapStoreCallback(storeCtx, ctxPtr, func(store IdentityKeyStore, ctx context.Context) error { + key, err := store.GetIdentityKey( + &Address{ptr: (*C.SignalProtocolAddress)(unsafe.Pointer(address))}, + ctx, + ) if err == nil && key != nil { key.publicKey.CancelFinalizer() - public_keyp.raw = key.publicKey.ptr + *public_keyp = key.publicKey.ptr } return err }) } //export signal_is_trusted_identity_callback -func signal_is_trusted_identity_callback(storeCtx unsafe.Pointer, out *C.bool, address C.SignalMutPointerProtocolAddress, public_key C.SignalMutPointerPublicKey, direction C.uint32_t) C.int { - return wrapStoreCallback(storeCtx, func(store IdentityKeyStore, ctx context.Context) error { - addr := &Address{ptr: address.raw} - theirServiceID, err := addr.NameServiceID() - if err != nil { - return err +func signal_is_trusted_identity_callback(storeCtx unsafe.Pointer, address *C.const_address, public_key *C.const_public_key, direction C.uint, ctxPtr unsafe.Pointer) C.int { + // Can't use wrapStoreCallback, because we don't just return an error value in the int + store := gopointer.Restore(storeCtx).(IdentityKeyStore) + ctx := NewEmptyCallbackContext() + if ctxPtr != nil { + if restored := gopointer.Restore(ctxPtr); restored != nil { + ctx = restored.(*CallbackContext) } - trusted, err := store.IsTrustedIdentity(ctx, theirServiceID, &IdentityKey{&PublicKey{ptr: public_key.raw}}, SignalDirection(direction)) - if err != nil { - return err - } - *out = C.bool(trusted) - return nil - }) + } + trusted, err := store.IsTrustedIdentity( + &Address{ptr: (*C.SignalProtocolAddress)(unsafe.Pointer(address))}, + &IdentityKey{&PublicKey{ptr: (*C.SignalPublicKey)(unsafe.Pointer(public_key))}}, + SignalDirection(direction), + ctx.Ctx, + ) + if err != nil { + ctx.Error = err + return -1 + } + if trusted { + return 1 + } else { + return 0 + } } -//export signal_destroy_identity_key_store_callback -func signal_destroy_identity_key_store_callback(storeCtx unsafe.Pointer) { - // No-op: Go's garbage collector handles cleanup -} - -func (ctx *CallbackContext) wrapIdentityKeyStore(store IdentityKeyStore) C.SignalConstPointerFfiIdentityKeyStoreStruct { - return C.SignalConstPointerFfiIdentityKeyStoreStruct{&C.SignalIdentityKeyStore{ - ctx: wrapStore(ctx, store), - get_local_identity_key_pair: C.SignalFfiIdentityKeyStoreGetLocalIdentityKeyPair(C.signal_get_identity_key_pair_callback), - get_local_registration_id: C.SignalFfiIdentityKeyStoreGetLocalRegistrationId(C.signal_get_local_registration_id_callback), - get_identity_key: C.SignalFfiIdentityKeyStoreGetIdentityKey(C.signal_get_identity_key_callback), - save_identity_key: C.SignalFfiIdentityKeyStoreSaveIdentityKey(C.signal_save_identity_key_callback), - is_trusted_identity: C.SignalFfiIdentityKeyStoreIsTrustedIdentity(C.signal_is_trusted_identity_callback), - destroy: C.SignalFfiIdentityKeyStoreDestroy(C.signal_destroy_identity_key_store_callback), - }} +func wrapIdentityKeyStore(store IdentityKeyStore) *C.SignalIdentityKeyStore { + // TODO: This is probably a memory leak + return &C.SignalIdentityKeyStore{ + ctx: gopointer.Save(store), + get_identity_key_pair: C.SignalGetIdentityKeyPair(C.signal_get_identity_key_pair_callback), + get_local_registration_id: C.SignalGetLocalRegistrationId(C.signal_get_local_registration_id_callback), + save_identity: C.SignalSaveIdentityKey(C.signal_save_identity_key_callback), + get_identity: C.SignalGetIdentityKey(C.signal_get_identity_key_callback), + is_trusted_identity: C.SignalIsTrustedIdentity(C.signal_is_trusted_identity_callback), + } } diff --git a/pkg/libsignalgo/inmemorystore_test.go b/pkg/libsignalgo/inmemorystore_test.go index 1c95ae9..6c6340e 100644 --- a/pkg/libsignalgo/inmemorystore_test.go +++ b/pkg/libsignalgo/inmemorystore_test.go @@ -44,7 +44,7 @@ type InMemorySignalProtocolStore struct { identityKeyPair *libsignalgo.IdentityKeyPair registrationID uint32 - identityKeyMap map[libsignalgo.ServiceID][]byte + identityKeyMap map[AddressKey][]byte preKeyMap map[uint32]*libsignalgo.PreKeyRecord senderKeyMap map[SenderKeyName]*libsignalgo.SenderKeyRecord sessionMap map[AddressKey]*libsignalgo.SessionRecord @@ -67,7 +67,7 @@ func NewInMemorySignalProtocolStore() *InMemorySignalProtocolStore { identityKeyPair: identityKeyPair, registrationID: uint32(registrationID.Uint64()), - identityKeyMap: make(map[libsignalgo.ServiceID][]byte), + identityKeyMap: make(map[AddressKey][]byte), preKeyMap: make(map[uint32]*libsignalgo.PreKeyRecord), senderKeyMap: make(map[SenderKeyName]*libsignalgo.SenderKeyRecord), sessionMap: make(map[AddressKey]*libsignalgo.SessionRecord), @@ -78,7 +78,7 @@ func NewInMemorySignalProtocolStore() *InMemorySignalProtocolStore { // Implementation of the SessionStore interface -func (ps *InMemorySignalProtocolStore) LoadSession(ctx context.Context, address *libsignalgo.Address) (*libsignalgo.SessionRecord, error) { +func (ps *InMemorySignalProtocolStore) LoadSession(address *libsignalgo.Address, ctx context.Context) (*libsignalgo.SessionRecord, error) { log.Debug().Msg("LoadSession called") name, err := address.Name() if err != nil { @@ -92,7 +92,7 @@ func (ps *InMemorySignalProtocolStore) LoadSession(ctx context.Context, address return ps.sessionMap[AddressKey{name, deviceID}], nil } -func (ps *InMemorySignalProtocolStore) StoreSession(ctx context.Context, address *libsignalgo.Address, record *libsignalgo.SessionRecord) error { +func (ps *InMemorySignalProtocolStore) StoreSession(address *libsignalgo.Address, record *libsignalgo.SessionRecord, ctx context.Context) error { log.Debug().Msg("StoreSession called") name, err := address.Name() if err != nil { @@ -108,7 +108,7 @@ func (ps *InMemorySignalProtocolStore) StoreSession(ctx context.Context, address // Implementation of the SenderKeyStore interface -func (ps *InMemorySignalProtocolStore) LoadSenderKey(ctx context.Context, sender *libsignalgo.Address, distributionID uuid.UUID) (*libsignalgo.SenderKeyRecord, error) { +func (ps *InMemorySignalProtocolStore) LoadSenderKey(sender *libsignalgo.Address, distributionID uuid.UUID, ctx context.Context) (*libsignalgo.SenderKeyRecord, error) { log.Debug().Msg("LoadSenderKey called") name, err := sender.Name() if err != nil { @@ -121,7 +121,7 @@ func (ps *InMemorySignalProtocolStore) LoadSenderKey(ctx context.Context, sender return ps.senderKeyMap[SenderKeyName{name, deviceID, distributionID}], nil } -func (ps *InMemorySignalProtocolStore) StoreSenderKey(ctx context.Context, sender *libsignalgo.Address, distributionID uuid.UUID, record *libsignalgo.SenderKeyRecord) error { +func (ps *InMemorySignalProtocolStore) StoreSenderKey(sender *libsignalgo.Address, distributionID uuid.UUID, record *libsignalgo.SenderKeyRecord, ctx context.Context) error { log.Debug().Msg("StoreSenderKey called") name, err := sender.Name() if err != nil { @@ -147,10 +147,18 @@ func (ps *InMemorySignalProtocolStore) GetLocalRegistrationID(ctx context.Contex return ps.registrationID, nil } -func (ps *InMemorySignalProtocolStore) SaveIdentityKey(ctx context.Context, theirServiceID libsignalgo.ServiceID, identityKey *libsignalgo.IdentityKey) (bool, error) { +func (ps *InMemorySignalProtocolStore) SaveIdentityKey(address *libsignalgo.Address, identityKey *libsignalgo.IdentityKey, ctx context.Context) (bool, error) { log.Debug().Msg("SaveIdentityKey called") + name, err := address.Name() + if err != nil { + return false, err + } + deviceID, err := address.DeviceID() + if err != nil { + return false, err + } replacing := false - oldKeySerialized, ok := ps.identityKeyMap[theirServiceID] + oldKeySerialized, ok := ps.identityKeyMap[AddressKey{name, deviceID}] if ok { oldKey, err := libsignalgo.DeserializeIdentityKey(oldKeySerialized) if err != nil { @@ -172,22 +180,40 @@ func (ps *InMemorySignalProtocolStore) SaveIdentityKey(ctx context.Context, thei hexIdentityKey := hex.EncodeToString(serializedIdentityKey) log.Debug().Str("hexIdentityKey", hexIdentityKey).Msg("SaveIdentityKey") - ps.identityKeyMap[theirServiceID] = serializedIdentityKey + ps.identityKeyMap[AddressKey{name, deviceID}] = serializedIdentityKey return replacing, nil } -func (ps *InMemorySignalProtocolStore) GetIdentityKey(ctx context.Context, theirServiceID libsignalgo.ServiceID) (*libsignalgo.IdentityKey, error) { +func (ps *InMemorySignalProtocolStore) GetIdentityKey(address *libsignalgo.Address, ctx context.Context) (*libsignalgo.IdentityKey, error) { log.Debug().Msg("GetIdentityKey called") - serializedIdentityKey, ok := ps.identityKeyMap[theirServiceID] + name, err := address.Name() + if err != nil { + return nil, err + } + deviceID, err := address.DeviceID() + if err != nil { + return nil, err + } + serializedIdentityKey, ok := ps.identityKeyMap[AddressKey{name, deviceID}] if !ok { return nil, nil } return libsignalgo.DeserializeIdentityKey(serializedIdentityKey) } -func (ps *InMemorySignalProtocolStore) IsTrustedIdentity(ctx context.Context, theirServiceID libsignalgo.ServiceID, identityKey *libsignalgo.IdentityKey, direction libsignalgo.SignalDirection) (bool, error) { +func (ps *InMemorySignalProtocolStore) IsTrustedIdentity(address *libsignalgo.Address, identityKey *libsignalgo.IdentityKey, direction libsignalgo.SignalDirection, ctx context.Context) (bool, error) { log.Debug().Msg("IsTrustedIdentity called") - if existingSerialized, ok := ps.identityKeyMap[theirServiceID]; ok { + name, err := address.Name() + if err != nil { + log.Error().Err(err).Msg("Error getting name") + return false, err + } + deviceID, err := address.DeviceID() + if err != nil { + log.Error().Err(err).Msg("Error getting deviceID") + return false, err + } + if existingSerialized, ok := ps.identityKeyMap[AddressKey{name, deviceID}]; ok { existingKey, err := libsignalgo.DeserializeIdentityKey(existingSerialized) if err != nil { log.Error().Err(err).Interface("existingKey", existingKey).Msg("Error deserializing existing identity key") @@ -201,27 +227,27 @@ func (ps *InMemorySignalProtocolStore) IsTrustedIdentity(ctx context.Context, th // Implementation of the PreKeyStore interface -func (ps *InMemorySignalProtocolStore) LoadPreKey(ctx context.Context, id uint32) (*libsignalgo.PreKeyRecord, error) { +func (ps *InMemorySignalProtocolStore) LoadPreKey(id uint32, ctx context.Context) (*libsignalgo.PreKeyRecord, error) { return ps.preKeyMap[id], nil } -func (ps *InMemorySignalProtocolStore) StorePreKey(ctx context.Context, id uint32, preKeyRecord *libsignalgo.PreKeyRecord) error { +func (ps *InMemorySignalProtocolStore) StorePreKey(id uint32, preKeyRecord *libsignalgo.PreKeyRecord, ctx context.Context) error { ps.preKeyMap[id] = preKeyRecord return nil } -func (ps *InMemorySignalProtocolStore) RemovePreKey(ctx context.Context, id uint32) error { +func (ps *InMemorySignalProtocolStore) RemovePreKey(id uint32, ctx context.Context) error { delete(ps.preKeyMap, id) return nil } // Implementation of the SignedPreKeyStore interface -func (ps *InMemorySignalProtocolStore) LoadSignedPreKey(context context.Context, id uint32) (*libsignalgo.SignedPreKeyRecord, error) { +func (ps *InMemorySignalProtocolStore) LoadSignedPreKey(id uint32, ctx context.Context) (*libsignalgo.SignedPreKeyRecord, error) { return ps.signedPreKeyMap[id], nil } -func (ps *InMemorySignalProtocolStore) StoreSignedPreKey(context context.Context, id uint32, signedPreKeyRecord *libsignalgo.SignedPreKeyRecord) error { +func (ps *InMemorySignalProtocolStore) StoreSignedPreKey(id uint32, signedPreKeyRecord *libsignalgo.SignedPreKeyRecord, ctx context.Context) error { ps.signedPreKeyMap[id] = signedPreKeyRecord return nil } @@ -230,27 +256,27 @@ type BadInMemorySignalProtocolStore struct { *InMemorySignalProtocolStore } -func (ps *BadInMemorySignalProtocolStore) LoadPreKey(ctx context.Context, id uint32) (*libsignalgo.PreKeyRecord, error) { +func (ps *BadInMemorySignalProtocolStore) LoadPreKey(id uint32, ctx context.Context) (*libsignalgo.PreKeyRecord, error) { return nil, errors.New("Test error") } -func (ps *BadInMemorySignalProtocolStore) LoadKyberPreKey(ctx context.Context, id uint32) (*libsignalgo.KyberPreKeyRecord, error) { +func (ps *BadInMemorySignalProtocolStore) LoadKyberPreKey(id uint32, ctx context.Context) (*libsignalgo.KyberPreKeyRecord, error) { return nil, errors.New("Test error") } // Implementation of the KyberPreKeyStore interface // TODO: this is just stubs, not implemented yet -func (ps *InMemorySignalProtocolStore) LoadKyberPreKey(ctx context.Context, id uint32) (*libsignalgo.KyberPreKeyRecord, error) { +func (ps *InMemorySignalProtocolStore) LoadKyberPreKey(id uint32, ctx context.Context) (*libsignalgo.KyberPreKeyRecord, error) { return ps.kyberPreKeyMap[id], nil } -func (ps *InMemorySignalProtocolStore) StoreKyberPreKey(ctx context.Context, id uint32, kyberPreKeyRecord *libsignalgo.KyberPreKeyRecord) error { +func (ps *InMemorySignalProtocolStore) StoreKyberPreKey(id uint32, kyberPreKeyRecord *libsignalgo.KyberPreKeyRecord, ctx context.Context) error { ps.kyberPreKeyMap[id] = kyberPreKeyRecord return nil } -func (ps *InMemorySignalProtocolStore) MarkKyberPreKeyUsed(ctx context.Context, id uint32) error { +func (ps *InMemorySignalProtocolStore) MarkKyberPreKeyUsed(id uint32, ctx context.Context) error { //delete(ps.kyberPreKeyMap, id) return nil } diff --git a/pkg/libsignalgo/kdf.go b/pkg/libsignalgo/kdf.go index 2f6a497..e4b7813 100644 --- a/pkg/libsignalgo/kdf.go +++ b/pkg/libsignalgo/kdf.go @@ -17,20 +17,15 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" -import ( - "runtime" - "unsafe" -) +import "unsafe" func HKDFDerive(outputLength int, inputKeyMaterial, salt, info []byte) ([]byte, error) { output := BorrowedMutableBuffer(outputLength) signalFfiError := C.signal_hkdf_derive(output, BytesToBuffer(inputKeyMaterial), BytesToBuffer(info), BytesToBuffer(salt)) - runtime.KeepAlive(inputKeyMaterial) - runtime.KeepAlive(salt) - runtime.KeepAlive(info) if signalFfiError != nil { return nil, wrapError(signalFfiError) } diff --git a/pkg/libsignalgo/kyberprekey.go b/pkg/libsignalgo/kyberprekey.go index 707db76..c97adfd 100644 --- a/pkg/libsignalgo/kyberprekey.go +++ b/pkg/libsignalgo/kyberprekey.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Scott Weber -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,6 +17,7 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" @@ -52,17 +52,9 @@ func wrapKyberKeyPair(ptr *C.SignalKyberKeyPair) *KyberKeyPair { return kp } -func (kp *KyberKeyPair) mutPtr() C.SignalMutPointerKyberKeyPair { - return C.SignalMutPointerKyberKeyPair{kp.ptr} -} - -func (kp *KyberKeyPair) constPtr() C.SignalConstPointerKyberKeyPair { - return C.SignalConstPointerKyberKeyPair{kp.ptr} -} - func (kp *KyberKeyPair) Destroy() error { kp.CancelFinalizer() - return wrapError(C.signal_kyber_key_pair_destroy(kp.mutPtr())) + return wrapError(C.signal_kyber_key_pair_destroy(kp.ptr)) } func (kp *KyberKeyPair) CancelFinalizer() { @@ -75,17 +67,9 @@ func wrapKyberPublicKey(ptr *C.SignalKyberPublicKey) *KyberPublicKey { return publicKey } -func (k *KyberPublicKey) mutPtr() C.SignalMutPointerKyberPublicKey { - return C.SignalMutPointerKyberPublicKey{k.ptr} -} - -func (k *KyberPublicKey) constPtr() C.SignalConstPointerKyberPublicKey { - return C.SignalConstPointerKyberPublicKey{k.ptr} -} - func (k *KyberPublicKey) Destroy() error { k.CancelFinalizer() - return wrapError(C.signal_kyber_public_key_destroy(k.mutPtr())) + return wrapError(C.signal_publickey_destroy(k.ptr)) } func (k *KyberPublicKey) CancelFinalizer() { @@ -98,17 +82,9 @@ func wrapKyberSecretKey(ptr *C.SignalKyberSecretKey) *KyberSecretKey { return secretKey } -func (k *KyberSecretKey) mutPtr() C.SignalMutPointerKyberSecretKey { - return C.SignalMutPointerKyberSecretKey{k.ptr} -} - -func (k *KyberSecretKey) constPtr() C.SignalConstPointerKyberSecretKey { - return C.SignalConstPointerKyberSecretKey{k.ptr} -} - func (k *KyberSecretKey) Destroy() error { k.CancelFinalizer() - return wrapError(C.signal_kyber_secret_key_destroy(k.mutPtr())) + return wrapError(C.signal_kyber_secret_key_destroy(k.ptr)) } func (k *KyberSecretKey) CancelFinalizer() { @@ -122,19 +98,17 @@ func wrapKyberPreKeyRecord(ptr *C.SignalKyberPreKeyRecord) *KyberPreKeyRecord { } func (kp *KyberKeyPair) GetPublicKey() (*KyberPublicKey, error) { - var pub C.SignalMutPointerKyberPublicKey - signalFfiError := C.signal_kyber_key_pair_get_public_key(&pub, kp.constPtr()) - runtime.KeepAlive(kp) + var pub *C.SignalKyberPublicKey + signalFfiError := C.signal_kyber_key_pair_get_public_key(&pub, kp.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapKyberPublicKey(pub.raw), nil + return wrapKyberPublicKey(pub), nil } -func (kp *KyberPublicKey) Serialize() ([]byte, error) { +func (kyberPublicKey *KyberPublicKey) Serialize() ([]byte, error) { var serialized C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_kyber_public_key_serialize(&serialized, kp.constPtr()) - runtime.KeepAlive(kp) + signalFfiError := C.signal_kyber_public_key_serialize(&serialized, kyberPublicKey.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -142,63 +116,44 @@ func (kp *KyberPublicKey) Serialize() ([]byte, error) { } func DeserializeKyberPublicKey(serialized []byte) (*KyberPublicKey, error) { - var kyberPublicKey C.SignalMutPointerKyberPublicKey + var kyberPublicKey *C.SignalKyberPublicKey signalFfiError := C.signal_kyber_public_key_deserialize(&kyberPublicKey, BytesToBuffer(serialized)) - runtime.KeepAlive(serialized) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapKyberPublicKey(kyberPublicKey.raw), nil + return wrapKyberPublicKey(kyberPublicKey), nil } func NewKyberPreKeyRecord(id uint32, timestamp time.Time, keyPair *KyberKeyPair, signature []byte) (*KyberPreKeyRecord, error) { - var kpkr C.SignalMutPointerKyberPreKeyRecord - signalFfiError := C.signal_kyber_pre_key_record_new( - &kpkr, - C.uint32_t(id), - C.uint64_t(timestamp.UnixMilli()), - keyPair.constPtr(), - BytesToBuffer(signature), - ) - runtime.KeepAlive(keyPair) - runtime.KeepAlive(signature) + var kpkr *C.SignalKyberPreKeyRecord + signalFfiError := C.signal_kyber_pre_key_record_new(&kpkr, C.uint32_t(id), C.uint64_t(timestamp.UnixMilli()), keyPair.ptr, BytesToBuffer(signature)) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapKyberPreKeyRecord(kpkr.raw), nil + return wrapKyberPreKeyRecord(kpkr), nil } func DeserializeKyberPreKeyRecord(serialized []byte) (*KyberPreKeyRecord, error) { - var kpkr C.SignalMutPointerKyberPreKeyRecord + var kpkr *C.SignalKyberPreKeyRecord signalFfiError := C.signal_kyber_pre_key_record_deserialize(&kpkr, BytesToBuffer(serialized)) - runtime.KeepAlive(serialized) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapKyberPreKeyRecord(kpkr.raw), nil -} - -func (kpkr *KyberPreKeyRecord) mutPtr() C.SignalMutPointerKyberPreKeyRecord { - return C.SignalMutPointerKyberPreKeyRecord{kpkr.ptr} -} - -func (kpkr *KyberPreKeyRecord) constPtr() C.SignalConstPointerKyberPreKeyRecord { - return C.SignalConstPointerKyberPreKeyRecord{kpkr.ptr} + return wrapKyberPreKeyRecord(kpkr), nil } func (kpkr *KyberPreKeyRecord) Clone() (*KyberPreKeyRecord, error) { - var cloned C.SignalMutPointerKyberPreKeyRecord - signalFfiError := C.signal_kyber_pre_key_record_clone(&cloned, kpkr.constPtr()) - runtime.KeepAlive(kpkr) + var cloned *C.SignalKyberPreKeyRecord + signalFfiError := C.signal_kyber_pre_key_record_clone(&cloned, kpkr.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapKyberPreKeyRecord(cloned.raw), nil + return wrapKyberPreKeyRecord(cloned), nil } func (kpkr *KyberPreKeyRecord) Destroy() error { kpkr.CancelFinalizer() - return wrapError(C.signal_kyber_pre_key_record_destroy(kpkr.mutPtr())) + return wrapError(C.signal_kyber_pre_key_record_destroy(kpkr.ptr)) } func (kpkr *KyberPreKeyRecord) CancelFinalizer() { @@ -207,8 +162,7 @@ func (kpkr *KyberPreKeyRecord) CancelFinalizer() { func (kpkr *KyberPreKeyRecord) Serialize() ([]byte, error) { var serialized C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_kyber_pre_key_record_serialize(&serialized, kpkr.constPtr()) - runtime.KeepAlive(kpkr) + signalFfiError := C.signal_kyber_pre_key_record_serialize(&serialized, kpkr.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -217,28 +171,25 @@ func (kpkr *KyberPreKeyRecord) Serialize() ([]byte, error) { func (kpkr *KyberPreKeyRecord) GetSignature() ([]byte, error) { var signature C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_kyber_pre_key_record_get_signature(&signature, kpkr.constPtr()) - runtime.KeepAlive(kpkr) + signalFfiError := C.signal_kyber_pre_key_record_get_signature(&signature, kpkr.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } return CopySignalOwnedBufferToBytes(signature), nil } -func (kpkr *KyberPreKeyRecord) GetID() (uint32, error) { +func (kpkr *KyberPreKeyRecord) GetID() (uint, error) { var id C.uint32_t - signalFfiError := C.signal_kyber_pre_key_record_get_id(&id, kpkr.constPtr()) - runtime.KeepAlive(kpkr) + signalFfiError := C.signal_kyber_pre_key_record_get_id(&id, kpkr.ptr) if signalFfiError != nil { return 0, wrapError(signalFfiError) } - return uint32(id), nil + return uint(id), nil } func (kpkr *KyberPreKeyRecord) GetTimestamp() (time.Time, error) { var ts C.uint64_t - signalFfiError := C.signal_kyber_pre_key_record_get_timestamp(&ts, kpkr.constPtr()) - runtime.KeepAlive(kpkr) + signalFfiError := C.signal_kyber_pre_key_record_get_timestamp(&ts, kpkr.ptr) if signalFfiError != nil { return time.Time{}, wrapError(signalFfiError) } @@ -246,30 +197,28 @@ func (kpkr *KyberPreKeyRecord) GetTimestamp() (time.Time, error) { } func (kpkr *KyberPreKeyRecord) GetPublicKey() (*KyberPublicKey, error) { - var pub C.SignalMutPointerKyberPublicKey - signalFfiError := C.signal_kyber_pre_key_record_get_public_key(&pub, kpkr.constPtr()) - runtime.KeepAlive(kpkr) + var pub *C.SignalKyberPublicKey + signalFfiError := C.signal_kyber_pre_key_record_get_public_key(&pub, kpkr.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapKyberPublicKey(pub.raw), nil + return wrapKyberPublicKey(pub), nil } func (kpkr *KyberPreKeyRecord) GetSecretKey() (*KyberSecretKey, error) { - var sec C.SignalMutPointerKyberSecretKey - signalFfiError := C.signal_kyber_pre_key_record_get_secret_key(&sec, kpkr.constPtr()) - runtime.KeepAlive(kpkr) + var sec *C.SignalKyberSecretKey + signalFfiError := C.signal_kyber_pre_key_record_get_secret_key(&sec, kpkr.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapKyberSecretKey(sec.raw), nil + return wrapKyberSecretKey(sec), nil } func KyberKeyPairGenerate() (*KyberKeyPair, error) { - var kp C.SignalMutPointerKyberKeyPair + var kp *C.SignalKyberKeyPair signalFfiError := C.signal_kyber_key_pair_generate(&kp) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapKyberKeyPair(kp.raw), nil + return wrapKyberKeyPair(kp), nil } diff --git a/pkg/libsignalgo/kyberprekeystore.go b/pkg/libsignalgo/kyberprekeystore.go index 9deea17..324aeef 100644 --- a/pkg/libsignalgo/kyberprekeystore.go +++ b/pkg/libsignalgo/kyberprekeystore.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Scott Weber -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,68 +17,67 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" -extern int signal_load_kyber_pre_key_callback(void *store_ctx, SignalMutPointerKyberPreKeyRecord *recordp, uint32_t id); -extern int signal_store_kyber_pre_key_callback(void *store_ctx, uint32_t id, SignalMutPointerKyberPreKeyRecord record); -extern int signal_mark_kyber_pre_key_used_callback(void *store_ctx, uint32_t id, uint32_t ec_prekey_id, SignalMutPointerPublicKey base_key); -extern void signal_destroy_kyber_pre_key_store_callback(void *store_ctx); +typedef const SignalKyberPreKeyRecord const_kyber_pre_key_record; + +extern int signal_load_kyber_pre_key_callback(void *store_ctx, SignalKyberPreKeyRecord **recordp, uint32_t id, void *ctx); +extern int signal_store_kyber_pre_key_callback(void *store_ctx, uint32_t id, const_kyber_pre_key_record *record, void *ctx); +extern int signal_mark_kyber_pre_key_used_callback(void *store_ctx, uint32_t id, void *ctx); */ import "C" import ( "context" "unsafe" + + gopointer "github.com/mattn/go-pointer" ) type KyberPreKeyStore interface { - LoadKyberPreKey(ctx context.Context, id uint32) (*KyberPreKeyRecord, error) - StoreKyberPreKey(ctx context.Context, id uint32, kyberPreKeyRecord *KyberPreKeyRecord) error - MarkKyberPreKeyUsed(ctx context.Context, id uint32) error + LoadKyberPreKey(id uint32, context context.Context) (*KyberPreKeyRecord, error) + StoreKyberPreKey(id uint32, kyberPreKeyRecord *KyberPreKeyRecord, context context.Context) error + MarkKyberPreKeyUsed(id uint32, context context.Context) error } //export signal_load_kyber_pre_key_callback -func signal_load_kyber_pre_key_callback(storeCtx unsafe.Pointer, keyp *C.SignalMutPointerKyberPreKeyRecord, id C.uint32_t) C.int { - return wrapStoreCallback(storeCtx, func(store KyberPreKeyStore, ctx context.Context) error { - key, err := store.LoadKyberPreKey(ctx, uint32(id)) +func signal_load_kyber_pre_key_callback(storeCtx unsafe.Pointer, keyp **C.SignalKyberPreKeyRecord, id C.uint32_t, ctxPtr unsafe.Pointer) C.int { + return wrapStoreCallback(storeCtx, ctxPtr, func(store KyberPreKeyStore, ctx context.Context) error { + key, err := store.LoadKyberPreKey(uint32(id), ctx) if err == nil && key != nil { key.CancelFinalizer() - keyp.raw = key.ptr + *keyp = key.ptr } return err }) } //export signal_store_kyber_pre_key_callback -func signal_store_kyber_pre_key_callback(storeCtx unsafe.Pointer, id C.uint32_t, preKeyRecord C.SignalMutPointerKyberPreKeyRecord) C.int { - return wrapStoreCallback(storeCtx, func(store KyberPreKeyStore, ctx context.Context) error { - record := KyberPreKeyRecord{ptr: preKeyRecord.raw} +func signal_store_kyber_pre_key_callback(storeCtx unsafe.Pointer, id C.uint32_t, preKeyRecord *C.const_kyber_pre_key_record, ctxPtr unsafe.Pointer) C.int { + return wrapStoreCallback(storeCtx, ctxPtr, func(store KyberPreKeyStore, ctx context.Context) error { + record := KyberPreKeyRecord{ptr: (*C.SignalKyberPreKeyRecord)(unsafe.Pointer(preKeyRecord))} cloned, err := record.Clone() if err != nil { return err } - return store.StoreKyberPreKey(ctx, uint32(id), cloned) + return store.StoreKyberPreKey(uint32(id), cloned, ctx) }) } //export signal_mark_kyber_pre_key_used_callback -func signal_mark_kyber_pre_key_used_callback(storeCtx unsafe.Pointer, id C.uint32_t, ecPrekeyID C.uint32_t, baseKey C.SignalMutPointerPublicKey) C.int { - return wrapStoreCallback(storeCtx, func(store KyberPreKeyStore, ctx context.Context) error { - // TODO use ecPrekeyID and baseKey? - return store.MarkKyberPreKeyUsed(ctx, uint32(id)) +func signal_mark_kyber_pre_key_used_callback(storeCtx unsafe.Pointer, id C.uint32_t, ctxPtr unsafe.Pointer) C.int { + return wrapStoreCallback(storeCtx, ctxPtr, func(store KyberPreKeyStore, ctx context.Context) error { + err := store.MarkKyberPreKeyUsed(uint32(id), ctx) + return err }) } -//export signal_destroy_kyber_pre_key_store_callback -func signal_destroy_kyber_pre_key_store_callback(storeCtx unsafe.Pointer) { - // No-op: Go's garbage collector handles cleanup -} - -func (ctx *CallbackContext) wrapKyberPreKeyStore(store KyberPreKeyStore) C.SignalConstPointerFfiKyberPreKeyStoreStruct { - return C.SignalConstPointerFfiKyberPreKeyStoreStruct{&C.SignalKyberPreKeyStore{ - ctx: wrapStore(ctx, store), - load_kyber_pre_key: C.SignalFfiKyberPreKeyStoreLoadKyberPreKey(C.signal_load_kyber_pre_key_callback), - store_kyber_pre_key: C.SignalFfiKyberPreKeyStoreStoreKyberPreKey(C.signal_store_kyber_pre_key_callback), - mark_kyber_pre_key_used: C.SignalFfiKyberPreKeyStoreMarkKyberPreKeyUsed(C.signal_mark_kyber_pre_key_used_callback), - destroy: C.SignalFfiKyberPreKeyStoreDestroy(C.signal_destroy_kyber_pre_key_store_callback), - }} +func wrapKyberPreKeyStore(store KyberPreKeyStore) *C.SignalKyberPreKeyStore { + // TODO: This is probably a memory leak + return &C.SignalKyberPreKeyStore{ + ctx: gopointer.Save(store), + load_kyber_pre_key: C.SignalLoadKyberPreKey(C.signal_load_kyber_pre_key_callback), + store_kyber_pre_key: C.SignalStoreKyberPreKey(C.signal_store_kyber_pre_key_callback), + mark_kyber_pre_key_used: C.SignalMarkKyberPreKeyUsed(C.signal_mark_kyber_pre_key_used_callback), + } } diff --git a/pkg/libsignalgo/libsignal b/pkg/libsignalgo/libsignal index bbc1688..126f87b 160000 --- a/pkg/libsignalgo/libsignal +++ b/pkg/libsignalgo/libsignal @@ -1 +1 @@ -Subproject commit bbc16886cae2feab1cd1fe271ccc651e8860ce96 +Subproject commit 126f87b73c3c3c75e3cc25ff41210f059dd654f2 diff --git a/pkg/libsignalgo/libsignal-ffi.h b/pkg/libsignalgo/libsignal-ffi.h index b75462a..6f2bf57 100644 --- a/pkg/libsignalgo/libsignal-ffi.h +++ b/pkg/libsignalgo/libsignal-ffi.h @@ -11,25 +11,15 @@ SPDX-License-Identifier: AGPL-3.0-only #include #include -#include #include #include -#define SignalSVR_KEY_LEN 32 +/** + * The encoded length of a [`FourCC`], in bytes. + */ +#define SignalFourCC_ENCODED_LEN 4 -#define SignalBACKUP_KEY_LEN 32 - -#define SignalLOCAL_BACKUP_METADATA_KEY_LEN 32 - -#define SignalMEDIA_ID_LEN 15 - -#define SignalBACKUP_FORWARD_SECRECY_TOKEN_LEN 32 - -#define SignalMEDIA_ENCRYPTION_KEY_LEN (32 + 32) - -#define SignalBackupId_LEN 16 - -#define SignalCallLinkSecretParams_ROOT_KEY_MAX_BYTES_FOR_SHO 16 +#define SignalBoxHeader_MAX_SIZE 32 #define SignalNUM_AUTH_CRED_ATTRIBUTES 3 @@ -43,8 +33,6 @@ SPDX-License-Identifier: AGPL-3.0-only #define SignalPRESENTATION_VERSION_3 2 -#define SignalPRESENTATION_VERSION_4 3 - #define SignalAES_KEY_LEN 32 #define SignalAESGCM_NONCE_LEN 12 @@ -103,9 +91,9 @@ SPDX-License-Identifier: AGPL-3.0-only #define SignalRESERVED_LEN 1 -#define SignalSERVER_SECRET_PARAMS_LEN 2721 +#define SignalSERVER_SECRET_PARAMS_LEN 2305 -#define SignalSERVER_PUBLIC_PARAMS_LEN 673 +#define SignalSERVER_PUBLIC_PARAMS_LEN 417 #define SignalUUID_CIPHERTEXT_LEN 65 @@ -122,17 +110,6 @@ SPDX-License-Identifier: AGPL-3.0-only */ #define SignalSECONDS_PER_DAY 86400 -/** - * The encoded length of a [`FourCC`], in bytes. - */ -#define SignalFourCC_ENCODED_LEN 4 - -enum SignalChallengeOption { - SignalChallengeOptionPushChallenge, - SignalChallengeOptionCaptcha, -}; -typedef uint8_t SignalChallengeOption; - typedef enum { SignalCiphertextMessageTypeWhisper = 2, SignalCiphertextMessageTypePreKey = 3, @@ -151,26 +128,6 @@ typedef enum { SignalDirectionReceiving = 1, } SignalDirection; -enum SignalFfiPublicKeyType { - SignalFfiPublicKeyTypeECC, - SignalFfiPublicKeyTypeKyber, -}; -typedef uint8_t SignalFfiPublicKeyType; - -/** - * The result of saving a new identity key for a protocol address. - */ -typedef enum { - /** - * The protocol address didn't have an identity key or had the same key. - */ - SignalIdentityChangeNewOrUnchanged, - /** - * The new identity key replaced a different key for the protocol address. - */ - SignalIdentityChangeReplacedExisting, -} SignalIdentityChange; - typedef enum { SignalLogLevelError = 1, SignalLogLevelWarn, @@ -187,7 +144,6 @@ typedef enum { SignalErrorCodeInvalidArgument = 5, SignalErrorCodeInvalidType = 6, SignalErrorCodeInvalidUtf8String = 7, - SignalErrorCodeCancelled = 8, SignalErrorCodeProtobufError = 10, SignalErrorCodeLegacyCiphertextVersion = 21, SignalErrorCodeUnknownCiphertextVersion = 22, @@ -205,74 +161,23 @@ typedef enum { SignalErrorCodeInvalidRegistrationId = 81, SignalErrorCodeInvalidSession = 82, SignalErrorCodeInvalidSenderKeySession = 83, - SignalErrorCodeInvalidProtocolAddress = 84, SignalErrorCodeDuplicatedMessage = 90, SignalErrorCodeCallbackError = 100, SignalErrorCodeVerificationFailure = 110, SignalErrorCodeUsernameCannotBeEmpty = 120, SignalErrorCodeUsernameCannotStartWithDigit = 121, SignalErrorCodeUsernameMissingSeparator = 122, - SignalErrorCodeUsernameBadDiscriminatorCharacter = 123, - SignalErrorCodeUsernameBadNicknameCharacter = 124, + SignalErrorCodeUsernameBadDiscriminator = 123, + SignalErrorCodeUsernameBadCharacter = 124, SignalErrorCodeUsernameTooShort = 125, SignalErrorCodeUsernameTooLong = 126, SignalErrorCodeUsernameLinkInvalidEntropyDataLength = 127, SignalErrorCodeUsernameLinkInvalid = 128, - SignalErrorCodeUsernameDiscriminatorCannotBeEmpty = 130, - SignalErrorCodeUsernameDiscriminatorCannotBeZero = 131, - SignalErrorCodeUsernameDiscriminatorCannotBeSingleDigit = 132, - SignalErrorCodeUsernameDiscriminatorCannotHaveLeadingZeros = 133, - SignalErrorCodeUsernameDiscriminatorTooLarge = 134, - SignalErrorCodeIoError = 140, - SignalErrorCodeInvalidMediaInput = 141, - SignalErrorCodeUnsupportedMediaInput = 142, - SignalErrorCodeConnectionTimedOut = 143, - SignalErrorCodeNetworkProtocol = 144, - SignalErrorCodeRateLimited = 145, - SignalErrorCodeWebSocket = 146, - SignalErrorCodeCdsiInvalidToken = 147, - SignalErrorCodeConnectionFailed = 148, - SignalErrorCodeChatServiceInactive = 149, - SignalErrorCodeRequestTimedOut = 150, - SignalErrorCodeRateLimitChallenge = 151, - SignalErrorCodePossibleCaptiveNetwork = 152, - SignalErrorCodeSvrDataMissing = 160, - SignalErrorCodeSvrRestoreFailed = 161, - SignalErrorCodeSvrRotationMachineTooManySteps = 162, - SignalErrorCodeSvrRequestFailed = 163, - SignalErrorCodeAppExpired = 170, - SignalErrorCodeDeviceDeregistered = 171, - SignalErrorCodeConnectionInvalidated = 172, - SignalErrorCodeConnectedElsewhere = 173, - SignalErrorCodeBackupValidation = 180, - SignalErrorCodeRegistrationInvalidSessionId = 190, - SignalErrorCodeRegistrationUnknown = 192, - SignalErrorCodeRegistrationSessionNotFound = 193, - SignalErrorCodeRegistrationNotReadyForVerification = 194, - SignalErrorCodeRegistrationSendVerificationCodeFailed = 195, - SignalErrorCodeRegistrationCodeNotDeliverable = 196, - SignalErrorCodeRegistrationSessionUpdateRejected = 197, - SignalErrorCodeRegistrationCredentialsCouldNotBeParsed = 198, - SignalErrorCodeRegistrationDeviceTransferPossible = 199, - SignalErrorCodeRegistrationRecoveryVerificationFailed = 200, - SignalErrorCodeRegistrationLock = 201, - SignalErrorCodeKeyTransparencyError = 210, - SignalErrorCodeKeyTransparencyVerificationFailed = 211, - SignalErrorCodeRequestUnauthorized = 220, - SignalErrorCodeMismatchedDevices = 221, - SignalErrorCodeServiceIdNotFound = 222, - SignalErrorCodeUploadTooLarge = 223, + SignalErrorCodeIoError = 130, + SignalErrorCodeInvalidMediaInput = 131, + SignalErrorCodeUnsupportedMediaInput = 132, } SignalErrorCode; -enum SignalSvr2CredentialsResult { - SignalSvr2CredentialsResultMatch, - SignalSvr2CredentialsResultNoMatch, - SignalSvr2CredentialsResultInvalid, -}; -typedef uint8_t SignalSvr2CredentialsResult; - -typedef struct SignalAccountAttributes SignalAccountAttributes; - /** * A wrapper around [`ctr::Ctr32BE`] that uses a smaller nonce and supports an initial counter. */ @@ -284,35 +189,14 @@ typedef struct SignalAes256GcmEncryption SignalAes256GcmEncryption; typedef struct SignalAes256GcmSiv SignalAes256GcmSiv; -typedef struct SignalAuthenticatedChatConnection SignalAuthenticatedChatConnection; - -typedef struct SignalBackupRestoreResponse SignalBackupRestoreResponse; - -typedef struct SignalBackupStoreResponse SignalBackupStoreResponse; - -typedef struct SignalBridgedStringMap SignalBridgedStringMap; - -typedef struct SignalCdsiLookup SignalCdsiLookup; - typedef struct SignalCiphertextMessage SignalCiphertextMessage; -/** - * Information about an established connection. - */ -typedef struct SignalConnectionInfo SignalConnectionInfo; - -typedef struct SignalConnectionManager SignalConnectionManager; - -typedef struct SignalConnectionProxyConfig SignalConnectionProxyConfig; - typedef struct SignalDecryptionErrorMessage SignalDecryptionErrorMessage; typedef struct SignalFingerprint SignalFingerprint; typedef struct SignalHsmEnclaveClient SignalHsmEnclaveClient; -typedef struct SignalHttpRequest SignalHttpRequest; - typedef struct SignalIncrementalMac SignalIncrementalMac; typedef struct SignalKeyPair SignalKeyPair; @@ -321,13 +205,9 @@ typedef struct SignalKeySecret SignalKeySecret; typedef struct SignalKyberPreKeyRecord SignalKyberPreKeyRecord; -typedef struct SignalLookupRequest SignalLookupRequest; +typedef struct SignalNonSuspendingBackgroundThreadRuntime SignalNonSuspendingBackgroundThreadRuntime; -typedef struct SignalMessageBackupKey SignalMessageBackupKey; - -typedef struct SignalMessageBackupValidationOutcome SignalMessageBackupValidationOutcome; - -typedef struct SignalOnlineBackupValidator SignalOnlineBackupValidator; +typedef struct SignalOtherTestingHandleType SignalOtherTestingHandleType; typedef struct SignalPinHash SignalPinHash; @@ -346,18 +226,11 @@ typedef struct SignalPrivateKey SignalPrivateKey; */ typedef struct SignalProtocolAddress SignalProtocolAddress; -typedef struct SignalProvisioningChatConnection SignalProvisioningChatConnection; - typedef struct SignalPublicKey SignalPublicKey; -typedef struct SignalRegisterAccountRequest SignalRegisterAccountRequest; - -typedef struct SignalRegisterAccountResponse SignalRegisterAccountResponse; - -typedef struct SignalRegistrationService SignalRegistrationService; - -typedef struct SignalRegistrationSession SignalRegistrationSession; - +/** + * Sanitized metadata returned by the sanitizer. + */ typedef struct SignalSanitizedMetadata SignalSanitizedMetadata; typedef struct SignalSenderCertificate SignalSenderCertificate; @@ -370,26 +243,12 @@ typedef struct SignalSenderKeyRecord SignalSenderKeyRecord; typedef struct SignalServerCertificate SignalServerCertificate; -/** - * Wraps a named type and a single-use guard around [`chat::server_requests::ResponseEnvelopeSender`]. - */ -typedef struct SignalServerMessageAck SignalServerMessageAck; - -typedef struct SignalServerPublicParams SignalServerPublicParams; - -typedef struct SignalServerSecretParams SignalServerSecretParams; - typedef struct SignalSessionRecord SignalSessionRecord; typedef struct SignalSgxClientState SignalSgxClientState; /** * The top-level error type (opaquely) returned to C clients when something goes wrong. - * - * Ideally this would use [ThinBox][], and then we wouldn't need an extra level of indirection when - * returning it to C, but unfortunately that isn't stable yet. - * - * [ThinBox]: https://doc.rust-lang.org/std/boxed/struct.ThinBox.html */ typedef struct SignalFfiError SignalFfiError; @@ -397,769 +256,95 @@ typedef struct SignalMessage SignalMessage; typedef struct SignalSignedPreKeyRecord SignalSignedPreKeyRecord; -typedef struct SignalTokioAsyncContext SignalTokioAsyncContext; - -typedef struct SignalUnauthenticatedChatConnection SignalUnauthenticatedChatConnection; +typedef struct SignalTestingHandleType SignalTestingHandleType; typedef struct SignalUnidentifiedSenderMessageContent SignalUnidentifiedSenderMessageContent; typedef struct SignalValidatingMac SignalValidatingMac; -typedef struct { - SignalProtocolAddress *raw; -} SignalMutPointerProtocolAddress; - -typedef struct { - const SignalProtocolAddress *raw; -} SignalConstPointerProtocolAddress; - -typedef struct { - SignalAes256Ctr32 *raw; -} SignalMutPointerAes256Ctr32; - typedef struct { const unsigned char *base; - size_t length; + uintptr_t length; } SignalBorrowedBuffer; typedef struct { unsigned char *base; - size_t length; -} SignalBorrowedMutableBuffer; - -typedef struct { - SignalAes256GcmDecryption *raw; -} SignalMutPointerAes256GcmDecryption; - -/** - * A representation of a array allocated on the Rust heap for use in C code. - */ -typedef struct { - unsigned char *base; - /** - * The number of elements in the buffer (not necessarily the number of bytes). - */ - size_t length; + uintptr_t length; } SignalOwnedBuffer; -typedef struct { - SignalAes256GcmEncryption *raw; -} SignalMutPointerAes256GcmEncryption; +typedef int (*SignalLoadSession)(void *store_ctx, SignalSessionRecord **recordp, const SignalProtocolAddress *address); -typedef struct { - const SignalAes256GcmSiv *raw; -} SignalConstPointerAes256GcmSiv; - -typedef struct { - SignalAes256GcmSiv *raw; -} SignalMutPointerAes256GcmSiv; - -typedef struct { - SignalAuthenticatedChatConnection *raw; -} SignalMutPointerAuthenticatedChatConnection; - -typedef uint64_t SignalCancellationId; - -/** - * A C callback used to report the results of Rust futures. - * - * cbindgen will produce independent C types like `SignalCPromisei32` and - * `SignalCPromiseProtocolAddress`. - * - * This derives Copy because it behaves like a C type; nevertheless, a promise should still only be - * completed once. - */ -typedef struct { - void (*complete)(SignalFfiError *error, const SignalMutPointerAuthenticatedChatConnection *result, const void *context); - const void *context; - SignalCancellationId cancellation_id; -} SignalCPromiseMutPointerAuthenticatedChatConnection; - -typedef struct { - const SignalTokioAsyncContext *raw; -} SignalConstPointerTokioAsyncContext; - -typedef struct { - const SignalConnectionManager *raw; -} SignalConstPointerConnectionManager; - -typedef struct { - const size_t *base; - size_t length; -} SignalBorrowedSliceOfusize; - -typedef struct { - SignalBorrowedBuffer bytes; - SignalBorrowedSliceOfusize lengths; -} SignalBorrowedBytestringArray; - -/** - * A C callback used to report the results of Rust futures. - * - * cbindgen will produce independent C types like `SignalCPromisei32` and - * `SignalCPromiseProtocolAddress`. - * - * This derives Copy because it behaves like a C type; nevertheless, a promise should still only be - * completed once. - */ -typedef struct { - void (*complete)(SignalFfiError *error, const bool *result, const void *context); - const void *context; - SignalCancellationId cancellation_id; -} SignalCPromisebool; - -typedef struct { - const SignalAuthenticatedChatConnection *raw; -} SignalConstPointerAuthenticatedChatConnection; - -/** - * A type alias to be used with [`OwnedBufferOf`], so that `OwnedBufferOf` and - * `OwnedBufferOf<*const c_char>` get distinct names. - */ -typedef const char *SignalCStringPtr; - -/** - * A representation of a array allocated on the Rust heap for use in C code. - */ -typedef struct { - SignalCStringPtr *base; - /** - * The number of elements in the buffer (not necessarily the number of bytes). - */ - size_t length; -} SignalOwnedBufferOfCStringPtr; - -typedef struct { - uint32_t cdn; - SignalCStringPtr key; - SignalOwnedBufferOfCStringPtr header_keys; - SignalOwnedBufferOfCStringPtr header_values; - SignalCStringPtr signed_upload_url; -} SignalFfiUploadForm; - -/** - * A C callback used to report the results of Rust futures. - * - * cbindgen will produce independent C types like `SignalCPromisei32` and - * `SignalCPromiseProtocolAddress`. - * - * This derives Copy because it behaves like a C type; nevertheless, a promise should still only be - * completed once. - */ -typedef struct { - void (*complete)(SignalFfiError *error, const SignalFfiUploadForm *result, const void *context); - const void *context; - SignalCancellationId cancellation_id; -} SignalCPromiseFfiUploadForm; - -typedef SignalConnectionInfo SignalChatConnectionInfo; - -typedef struct { - SignalChatConnectionInfo *raw; -} SignalMutPointerChatConnectionInfo; - -typedef struct { - SignalServerMessageAck *raw; -} SignalMutPointerServerMessageAck; - -typedef int (*SignalFfiChatListenerReceivedIncomingMessage)(void *ctx, SignalOwnedBuffer envelope, uint64_t timestamp, SignalMutPointerServerMessageAck ack); - -typedef int (*SignalFfiChatListenerReceivedQueueEmpty)(void *ctx); - -/** - * A representation of a array allocated on the Rust heap for use in C code. - */ -typedef struct { - size_t *base; - /** - * The number of elements in the buffer (not necessarily the number of bytes). - */ - size_t length; -} SignalOwnedBufferOfusize; - -typedef struct { - SignalOwnedBuffer bytes; - SignalOwnedBufferOfusize lengths; -} SignalBytestringArray; - -typedef SignalBytestringArray SignalStringArray; - -typedef int (*SignalFfiChatListenerReceivedAlerts)(void *ctx, SignalStringArray alerts); - -typedef int (*SignalFfiChatListenerConnectionInterrupted)(void *ctx, SignalFfiError *disconnect_cause); - -typedef void (*SignalFfiChatListenerDestroy)(void *ctx); +typedef int (*SignalStoreSession)(void *store_ctx, const SignalProtocolAddress *address, const SignalSessionRecord *record); typedef struct { void *ctx; - SignalFfiChatListenerReceivedIncomingMessage received_incoming_message; - SignalFfiChatListenerReceivedQueueEmpty received_queue_empty; - SignalFfiChatListenerReceivedAlerts received_alerts; - SignalFfiChatListenerConnectionInterrupted connection_interrupted; - SignalFfiChatListenerDestroy destroy; -} SignalFfiChatListenerStruct; - -typedef struct { - const SignalFfiChatListenerStruct *raw; -} SignalConstPointerFfiChatListenerStruct; - -typedef struct { - uint16_t status; - const char *message; - SignalOwnedBufferOfCStringPtr headers; - SignalOwnedBuffer body; -} SignalFfiChatResponse; - -/** - * A C callback used to report the results of Rust futures. - * - * cbindgen will produce independent C types like `SignalCPromisei32` and - * `SignalCPromiseProtocolAddress`. - * - * This derives Copy because it behaves like a C type; nevertheless, a promise should still only be - * completed once. - */ -typedef struct { - void (*complete)(SignalFfiError *error, const SignalFfiChatResponse *result, const void *context); - const void *context; - SignalCancellationId cancellation_id; -} SignalCPromiseFfiChatResponse; - -typedef struct { - const SignalHttpRequest *raw; -} SignalConstPointerHttpRequest; - -/** - * The fixed-width binary representation of a ServiceId. - * - * Rarely used. The variable-width format that privileges ACIs is preferred. - */ -typedef uint8_t SignalServiceIdFixedWidthBinaryBytes[17]; - -typedef struct { - const uint32_t *base; - size_t length; -} SignalBorrowedSliceOfu32; - -typedef struct { - const SignalCiphertextMessage *raw; -} SignalConstPointerCiphertextMessage; - -typedef struct { - const SignalConstPointerCiphertextMessage *base; - size_t length; -} SignalBorrowedSliceOfConstPointerCiphertextMessage; - -/** - * A wrapper type for raw UUIDs, because C treats arrays specially in argument position. - */ -typedef struct { - uint8_t bytes[16]; -} SignalUuid; - -typedef struct { - SignalPrivateKey *raw; -} SignalMutPointerPrivateKey; - -typedef struct { - SignalBackupRestoreResponse *raw; -} SignalMutPointerBackupRestoreResponse; - -typedef struct { - const SignalBackupRestoreResponse *raw; -} SignalConstPointerBackupRestoreResponse; - -typedef struct { - SignalBackupStoreResponse *raw; -} SignalMutPointerBackupStoreResponse; - -typedef struct { - const SignalBackupStoreResponse *raw; -} SignalConstPointerBackupStoreResponse; - -typedef struct { - SignalBridgedStringMap *raw; -} SignalMutPointerBridgedStringMap; - -typedef struct { - const SignalBridgedStringMap *raw; -} SignalConstPointerBridgedStringMap; - -typedef struct { - SignalSgxClientState *raw; -} SignalMutPointerSgxClientState; - -typedef struct { - /** - * Telephone number, as an unformatted e164. - */ - uint64_t e164; - uint8_t rawAciUuid[16]; - uint8_t rawPniUuid[16]; -} SignalFfiCdsiLookupResponseEntry; - -/** - * A representation of a array allocated on the Rust heap for use in C code. - */ -typedef struct { - SignalFfiCdsiLookupResponseEntry *base; - /** - * The number of elements in the buffer (not necessarily the number of bytes). - */ - size_t length; -} SignalOwnedBufferOfFfiCdsiLookupResponseEntry; - -typedef struct { - SignalOwnedBufferOfFfiCdsiLookupResponseEntry entries; - int32_t debug_permits_used; -} SignalFfiCdsiLookupResponse; - -/** - * A C callback used to report the results of Rust futures. - * - * cbindgen will produce independent C types like `SignalCPromisei32` and - * `SignalCPromiseProtocolAddress`. - * - * This derives Copy because it behaves like a C type; nevertheless, a promise should still only be - * completed once. - */ -typedef struct { - void (*complete)(SignalFfiError *error, const SignalFfiCdsiLookupResponse *result, const void *context); - const void *context; - SignalCancellationId cancellation_id; -} SignalCPromiseFfiCdsiLookupResponse; - -typedef struct { - const SignalCdsiLookup *raw; -} SignalConstPointerCdsiLookup; - -typedef struct { - SignalCdsiLookup *raw; -} SignalMutPointerCdsiLookup; - -/** - * A C callback used to report the results of Rust futures. - * - * cbindgen will produce independent C types like `SignalCPromisei32` and - * `SignalCPromiseProtocolAddress`. - * - * This derives Copy because it behaves like a C type; nevertheless, a promise should still only be - * completed once. - */ -typedef struct { - void (*complete)(SignalFfiError *error, const SignalMutPointerCdsiLookup *result, const void *context); - const void *context; - SignalCancellationId cancellation_id; -} SignalCPromiseMutPointerCdsiLookup; - -typedef struct { - const SignalLookupRequest *raw; -} SignalConstPointerLookupRequest; - -typedef struct { - const SignalChatConnectionInfo *raw; -} SignalConstPointerChatConnectionInfo; - -typedef struct { - SignalCiphertextMessage *raw; -} SignalMutPointerCiphertextMessage; - -typedef struct { - const SignalPlaintextContent *raw; -} SignalConstPointerPlaintextContent; - -typedef struct { - SignalConnectionInfo *raw; -} SignalMutPointerConnectionInfo; - -typedef struct { - SignalConnectionManager *raw; -} SignalMutPointerConnectionManager; - -typedef struct { - const SignalConnectionProxyConfig *raw; -} SignalConstPointerConnectionProxyConfig; - -typedef struct { - SignalConnectionProxyConfig *raw; -} SignalMutPointerConnectionProxyConfig; - -typedef struct { - const SignalMessage *raw; -} SignalConstPointerSignalMessage; - -typedef struct { - SignalSessionRecord *raw; -} SignalMutPointerSessionRecord; - -typedef int (*SignalFfiSessionStoreLoadSession)(void *ctx, SignalMutPointerSessionRecord *out, SignalMutPointerProtocolAddress address); - -typedef int (*SignalFfiSessionStoreStoreSession)(void *ctx, SignalMutPointerProtocolAddress address, SignalMutPointerSessionRecord record); - -typedef void (*SignalFfiSessionStoreDestroy)(void *ctx); - -typedef struct { - void *ctx; - SignalFfiSessionStoreLoadSession load_session; - SignalFfiSessionStoreStoreSession store_session; - SignalFfiSessionStoreDestroy destroy; + SignalLoadSession load_session; + SignalStoreSession store_session; } SignalSessionStore; -typedef struct { - const SignalSessionStore *raw; -} SignalConstPointerFfiSessionStoreStruct; +typedef int (*SignalGetIdentityKeyPair)(void *store_ctx, SignalPrivateKey **keyp); -typedef struct { - SignalPublicKey *raw; -} SignalMutPointerPublicKey; +typedef int (*SignalGetLocalRegistrationId)(void *store_ctx, uint32_t *idp); -typedef struct { - SignalMutPointerPrivateKey first; - SignalMutPointerPublicKey second; -} SignalPairOfMutPointerPrivateKeyMutPointerPublicKey; +typedef int (*SignalSaveIdentityKey)(void *store_ctx, const SignalProtocolAddress *address, const SignalPublicKey *public_key); -typedef int (*SignalFfiIdentityKeyStoreGetLocalIdentityKeyPair)(void *ctx, SignalPairOfMutPointerPrivateKeyMutPointerPublicKey *out); +typedef int (*SignalGetIdentityKey)(void *store_ctx, SignalPublicKey **public_keyp, const SignalProtocolAddress *address); -typedef int (*SignalFfiIdentityKeyStoreGetLocalRegistrationId)(void *ctx, uint32_t *out); - -typedef int (*SignalFfiIdentityKeyStoreGetIdentityKey)(void *ctx, SignalMutPointerPublicKey *out, SignalMutPointerProtocolAddress address); - -typedef int (*SignalFfiIdentityKeyStoreSaveIdentityKey)(void *ctx, uint8_t *out, SignalMutPointerProtocolAddress address, SignalMutPointerPublicKey public_key); - -typedef int (*SignalFfiIdentityKeyStoreIsTrustedIdentity)(void *ctx, bool *out, SignalMutPointerProtocolAddress address, SignalMutPointerPublicKey public_key, uint32_t direction); - -typedef void (*SignalFfiIdentityKeyStoreDestroy)(void *ctx); +typedef int (*SignalIsTrustedIdentity)(void *store_ctx, const SignalProtocolAddress *address, const SignalPublicKey *public_key, unsigned int direction); typedef struct { void *ctx; - SignalFfiIdentityKeyStoreGetLocalIdentityKeyPair get_local_identity_key_pair; - SignalFfiIdentityKeyStoreGetLocalRegistrationId get_local_registration_id; - SignalFfiIdentityKeyStoreGetIdentityKey get_identity_key; - SignalFfiIdentityKeyStoreSaveIdentityKey save_identity_key; - SignalFfiIdentityKeyStoreIsTrustedIdentity is_trusted_identity; - SignalFfiIdentityKeyStoreDestroy destroy; + SignalGetIdentityKeyPair get_identity_key_pair; + SignalGetLocalRegistrationId get_local_registration_id; + SignalSaveIdentityKey save_identity; + SignalGetIdentityKey get_identity; + SignalIsTrustedIdentity is_trusted_identity; } SignalIdentityKeyStore; -typedef struct { - const SignalIdentityKeyStore *raw; -} SignalConstPointerFfiIdentityKeyStoreStruct; +typedef int (*SignalLoadPreKey)(void *store_ctx, SignalPreKeyRecord **recordp, uint32_t id); -typedef struct { - const SignalPreKeySignalMessage *raw; -} SignalConstPointerPreKeySignalMessage; +typedef int (*SignalStorePreKey)(void *store_ctx, uint32_t id, const SignalPreKeyRecord *record); -typedef struct { - SignalPreKeyRecord *raw; -} SignalMutPointerPreKeyRecord; - -typedef int (*SignalFfiPreKeyStoreLoadPreKey)(void *ctx, SignalMutPointerPreKeyRecord *out, uint32_t id); - -typedef int (*SignalFfiPreKeyStoreStorePreKey)(void *ctx, uint32_t id, SignalMutPointerPreKeyRecord record); - -typedef int (*SignalFfiPreKeyStoreRemovePreKey)(void *ctx, uint32_t id); - -typedef void (*SignalFfiPreKeyStoreDestroy)(void *ctx); +typedef int (*SignalRemovePreKey)(void *store_ctx, uint32_t id); typedef struct { void *ctx; - SignalFfiPreKeyStoreLoadPreKey load_pre_key; - SignalFfiPreKeyStoreStorePreKey store_pre_key; - SignalFfiPreKeyStoreRemovePreKey remove_pre_key; - SignalFfiPreKeyStoreDestroy destroy; + SignalLoadPreKey load_pre_key; + SignalStorePreKey store_pre_key; + SignalRemovePreKey remove_pre_key; } SignalPreKeyStore; -typedef struct { - const SignalPreKeyStore *raw; -} SignalConstPointerFfiPreKeyStoreStruct; +typedef int (*SignalLoadSignedPreKey)(void *store_ctx, SignalSignedPreKeyRecord **recordp, uint32_t id); -typedef struct { - SignalSignedPreKeyRecord *raw; -} SignalMutPointerSignedPreKeyRecord; - -typedef int (*SignalFfiSignedPreKeyStoreLoadSignedPreKey)(void *ctx, SignalMutPointerSignedPreKeyRecord *out, uint32_t id); - -typedef int (*SignalFfiSignedPreKeyStoreStoreSignedPreKey)(void *ctx, uint32_t id, SignalMutPointerSignedPreKeyRecord record); - -typedef void (*SignalFfiSignedPreKeyStoreDestroy)(void *ctx); +typedef int (*SignalStoreSignedPreKey)(void *store_ctx, uint32_t id, const SignalSignedPreKeyRecord *record); typedef struct { void *ctx; - SignalFfiSignedPreKeyStoreLoadSignedPreKey load_signed_pre_key; - SignalFfiSignedPreKeyStoreStoreSignedPreKey store_signed_pre_key; - SignalFfiSignedPreKeyStoreDestroy destroy; + SignalLoadSignedPreKey load_signed_pre_key; + SignalStoreSignedPreKey store_signed_pre_key; } SignalSignedPreKeyStore; -typedef struct { - const SignalSignedPreKeyStore *raw; -} SignalConstPointerFfiSignedPreKeyStoreStruct; +typedef bool (*SignalLogEnabledCallback)(const char *target, SignalLogLevel level); + +typedef void (*SignalLogCallback)(const char *target, SignalLogLevel level, const char *file, uint32_t line, const char *message); + +typedef void (*SignalLogFlushCallback)(void); typedef struct { - SignalKyberPreKeyRecord *raw; -} SignalMutPointerKyberPreKeyRecord; - -typedef int (*SignalFfiKyberPreKeyStoreLoadKyberPreKey)(void *ctx, SignalMutPointerKyberPreKeyRecord *out, uint32_t id); - -typedef int (*SignalFfiKyberPreKeyStoreStoreKyberPreKey)(void *ctx, uint32_t id, SignalMutPointerKyberPreKeyRecord record); - -typedef int (*SignalFfiKyberPreKeyStoreMarkKyberPreKeyUsed)(void *ctx, uint32_t id, uint32_t ec_prekey_id, SignalMutPointerPublicKey base_key); - -typedef void (*SignalFfiKyberPreKeyStoreDestroy)(void *ctx); + SignalLogEnabledCallback enabled; + SignalLogCallback log; + SignalLogFlushCallback flush; +} SignalFfiLogger; typedef struct { - void *ctx; - SignalFfiKyberPreKeyStoreLoadKyberPreKey load_kyber_pre_key; - SignalFfiKyberPreKeyStoreStoreKyberPreKey store_kyber_pre_key; - SignalFfiKyberPreKeyStoreMarkKyberPreKeyUsed mark_kyber_pre_key_used; - SignalFfiKyberPreKeyStoreDestroy destroy; -} SignalKyberPreKeyStore; - -typedef struct { - const SignalKyberPreKeyStore *raw; -} SignalConstPointerFfiKyberPreKeyStoreStruct; - -typedef struct { - SignalDecryptionErrorMessage *raw; -} SignalMutPointerDecryptionErrorMessage; - -typedef struct { - const SignalDecryptionErrorMessage *raw; -} SignalConstPointerDecryptionErrorMessage; - -/** - * Like [`std::panic::AssertUnwindSafe`], but FFI-compatible. - */ -typedef const SignalFfiError *SignalUnwindSafeArgSignalFfiError; - -typedef struct { - const char *first; - uint32_t second; -} SignalPairOfc_charu32; - -/** - * A representation of a array allocated on the Rust heap for use in C code. - */ -typedef struct { - uint32_t *base; - /** - * The number of elements in the buffer (not necessarily the number of bytes). - */ - size_t length; -} SignalOwnedBufferOfu32; - -typedef struct { - SignalServiceIdFixedWidthBinaryBytes account; - SignalOwnedBufferOfu32 missing_devices; - SignalOwnedBufferOfu32 extra_devices; - SignalOwnedBufferOfu32 stale_devices; -} SignalFfiMismatchedDevicesError; - -/** - * A representation of a array allocated on the Rust heap for use in C code. - */ -typedef struct { - SignalFfiMismatchedDevicesError *base; - /** - * The number of elements in the buffer (not necessarily the number of bytes). - */ - size_t length; -} SignalOwnedBufferOfFfiMismatchedDevicesError; - -typedef struct { - const char *first; - SignalOwnedBuffer second; -} SignalPairOfc_charOwnedBufferOfc_uchar; - -typedef struct { - SignalPairOfc_charOwnedBufferOfc_uchar first; - int64_t second; -} SignalPairOfPairOfc_charOwnedBufferOfc_uchari64; - -typedef struct { - const char *first; - bool second; -} SignalPairOfc_charbool; - -typedef struct { - SignalFingerprint *raw; -} SignalMutPointerFingerprint; - -typedef struct { - const SignalFingerprint *raw; -} SignalConstPointerFingerprint; - -typedef struct { - const SignalPublicKey *raw; -} SignalConstPointerPublicKey; - -typedef struct { - /** - * The badge ID. - */ - const char *id; - /** - * Whether the badge is currently configured to be visible. - */ - bool visible; - /** - * When the badge expires. - */ - double expiration_secs; -} SignalFfiRegisterResponseBadge; - -/** - * A representation of a array allocated on the Rust heap for use in C code. - */ -typedef struct { - SignalFfiRegisterResponseBadge *base; - /** - * The number of elements in the buffer (not necessarily the number of bytes). - */ - size_t length; -} SignalOwnedBufferOfFfiRegisterResponseBadge; - -/** - * A representation of a array allocated on the Rust heap for use in C code. - */ -typedef struct { - SignalServiceIdFixedWidthBinaryBytes *base; - /** - * The number of elements in the buffer (not necessarily the number of bytes). - */ - size_t length; -} SignalOwnedBufferOfServiceIdFixedWidthBinaryBytes; - -typedef struct { - SignalPreKeyBundle *raw; -} SignalMutPointerPreKeyBundle; - -/** - * A representation of a array allocated on the Rust heap for use in C code. - */ -typedef struct { - SignalMutPointerPreKeyBundle *base; - /** - * The number of elements in the buffer (not necessarily the number of bytes). - */ - size_t length; -} SignalOwnedBufferOfMutPointerPreKeyBundle; - -typedef struct { - SignalSenderKeyRecord *raw; -} SignalMutPointerSenderKeyRecord; - -typedef int (*SignalFfiSenderKeyStoreLoadSenderKey)(void *ctx, SignalMutPointerSenderKeyRecord *out, SignalMutPointerProtocolAddress sender, SignalUuid distribution_id); - -typedef int (*SignalFfiSenderKeyStoreStoreSenderKey)(void *ctx, SignalMutPointerProtocolAddress sender, SignalUuid distribution_id, SignalMutPointerSenderKeyRecord record); - -typedef void (*SignalFfiSenderKeyStoreDestroy)(void *ctx); - -typedef struct { - void *ctx; - SignalFfiSenderKeyStoreLoadSenderKey load_sender_key; - SignalFfiSenderKeyStoreStoreSenderKey store_sender_key; - SignalFfiSenderKeyStoreDestroy destroy; -} SignalSenderKeyStore; - -typedef struct { - const SignalSenderKeyStore *raw; -} SignalConstPointerFfiSenderKeyStoreStruct; - -typedef struct { - const SignalServerSecretParams *raw; -} SignalConstPointerServerSecretParams; - -typedef struct { - const SignalBorrowedBuffer *base; - size_t length; -} SignalBorrowedSliceOfBuffers; - -typedef struct { - const SignalServerPublicParams *raw; -} SignalConstPointerServerPublicParams; - -typedef struct { - SignalHsmEnclaveClient *raw; -} SignalMutPointerHsmEnclaveClient; - -typedef struct { - const SignalHsmEnclaveClient *raw; -} SignalConstPointerHsmEnclaveClient; - -typedef struct { - SignalHttpRequest *raw; -} SignalMutPointerHttpRequest; - -typedef struct { - SignalMutPointerPublicKey first; - SignalMutPointerPrivateKey second; -} SignalPairOfMutPointerPublicKeyMutPointerPrivateKey; - -typedef struct { - const SignalPrivateKey *raw; -} SignalConstPointerPrivateKey; - -typedef struct { - SignalIncrementalMac *raw; -} SignalMutPointerIncrementalMac; - -typedef int (*SignalFfiLoggerLog)(void *ctx, SignalLogLevel level, const char *file, uint32_t line, const char *message); - -typedef int (*SignalFfiLoggerFlush)(void *ctx); - -typedef void (*SignalFfiLoggerDestroy)(void *ctx); - -typedef struct { - void *ctx; - SignalFfiLoggerLog log; - SignalFfiLoggerFlush flush; - SignalFfiLoggerDestroy destroy; -} SignalFfiLoggerStruct; - -typedef struct { - SignalOwnedBuffer first; - SignalOwnedBuffer second; -} SignalPairOfOwnedBufferOfc_ucharOwnedBufferOfc_uchar; - -/** - * A C callback used to report the results of Rust futures. - * - * cbindgen will produce independent C types like `SignalCPromisei32` and - * `SignalCPromiseProtocolAddress`. - * - * This derives Copy because it behaves like a C type; nevertheless, a promise should still only be - * completed once. - */ -typedef struct { - void (*complete)(SignalFfiError *error, const SignalPairOfOwnedBufferOfc_ucharOwnedBufferOfc_uchar *result, const void *context); - const void *context; - SignalCancellationId cancellation_id; -} SignalCPromisePairOfOwnedBufferOfc_ucharOwnedBufferOfc_uchar; - -typedef struct { - const SignalUnauthenticatedChatConnection *raw; -} SignalConstPointerUnauthenticatedChatConnection; - -typedef struct { - bool present; - SignalBorrowedBuffer value; -} SignalOptionalBorrowedSliceOfc_uchar; + unsigned char *base; + uintptr_t length; +} SignalBorrowedMutableBuffer; typedef SignalKeyPair SignalKyberKeyPair; -typedef struct { - SignalKyberKeyPair *raw; -} SignalMutPointerKyberKeyPair; - -typedef struct { - const SignalKyberKeyPair *raw; -} SignalConstPointerKyberKeyPair; - typedef SignalPublicKey SignalKyberPublicKey; -typedef struct { - SignalKyberPublicKey *raw; -} SignalMutPointerKyberPublicKey; - /** * A KEM secret key with the ability to decapsulate a shared secret. */ @@ -1167,716 +352,781 @@ typedef SignalKeySecret SignalSecretKey; typedef SignalSecretKey SignalKyberSecretKey; -typedef struct { - SignalKyberSecretKey *raw; -} SignalMutPointerKyberSecretKey; +/** + * The fixed-width binary representation of a ServiceId. + * + * Rarely used. The variable-width format that privileges ACIs is preferred. + */ +typedef uint8_t SignalServiceIdFixedWidthBinaryBytes[17]; -typedef struct { - const SignalKyberPreKeyRecord *raw; -} SignalConstPointerKyberPreKeyRecord; +typedef int (*SignalLoadKyberPreKey)(void *store_ctx, SignalKyberPreKeyRecord **recordp, uint32_t id); -typedef struct { - const SignalKyberPublicKey *raw; -} SignalConstPointerKyberPublicKey; +typedef int (*SignalStoreKyberPreKey)(void *store_ctx, uint32_t id, const SignalKyberPreKeyRecord *record); -typedef struct { - const SignalKyberSecretKey *raw; -} SignalConstPointerKyberSecretKey; - -typedef struct { - SignalLookupRequest *raw; -} SignalMutPointerLookupRequest; - -typedef struct { - SignalMessageBackupKey *raw; -} SignalMutPointerMessageBackupKey; - -typedef struct { - const SignalMessageBackupKey *raw; -} SignalConstPointerMessageBackupKey; - -typedef struct { - SignalMessageBackupValidationOutcome *raw; -} SignalMutPointerMessageBackupValidationOutcome; - -typedef struct { - const SignalMessageBackupValidationOutcome *raw; -} SignalConstPointerMessageBackupValidationOutcome; - -typedef int (*SignalFfiInputStreamRead)(void *ctx, size_t *out, SignalBorrowedMutableBuffer buf); - -typedef int (*SignalFfiInputStreamSkip)(void *ctx, uint64_t amount); - -typedef void (*SignalFfiInputStreamDestroy)(void *ctx); +typedef int (*SignalMarkKyberPreKeyUsed)(void *store_ctx, uint32_t id); typedef struct { void *ctx; - SignalFfiInputStreamRead read; - SignalFfiInputStreamSkip skip; - SignalFfiInputStreamDestroy destroy; + SignalLoadKyberPreKey load_kyber_pre_key; + SignalStoreKyberPreKey store_kyber_pre_key; + SignalMarkKyberPreKeyUsed mark_kyber_pre_key_used; +} SignalKyberPreKeyStore; + +typedef struct { + const SignalProtocolAddress *const *base; + uintptr_t length; +} SignalBorrowedSliceOfProtocolAddress; + +typedef struct { + const SignalSessionRecord *const *base; + uintptr_t length; +} SignalBorrowedSliceOfSessionRecord; + +typedef int (*SignalLoadSenderKey)(void *store_ctx, SignalSenderKeyRecord**, const SignalProtocolAddress*, const uint8_t (*distribution_id)[16]); + +typedef int (*SignalStoreSenderKey)(void *store_ctx, const SignalProtocolAddress*, const uint8_t (*distribution_id)[16], const SignalSenderKeyRecord*); + +typedef struct { + void *ctx; + SignalLoadSenderKey load_sender_key; + SignalStoreSenderKey store_sender_key; +} SignalSenderKeyStore; + +typedef int (*SignalRead)(void *ctx, uint8_t *buf, uintptr_t buf_len, uintptr_t *amount_read); + +typedef int (*SignalSkip)(void *ctx, uint64_t amount); + +typedef struct { + void *ctx; + SignalRead read; + SignalSkip skip; } SignalInputStream; -typedef struct { - const SignalInputStream *raw; -} SignalConstPointerFfiInputStreamStruct; - -typedef struct { - SignalMessage *raw; -} SignalMutPointerSignalMessage; - -typedef struct { - SignalSanitizedMetadata *raw; -} SignalMutPointerSanitizedMetadata; - -typedef struct { - SignalOnlineBackupValidator *raw; -} SignalMutPointerOnlineBackupValidator; - -typedef struct { - const SignalPinHash *raw; -} SignalConstPointerPinHash; - -typedef struct { - SignalPinHash *raw; -} SignalMutPointerPinHash; - -typedef struct { - SignalPlaintextContent *raw; -} SignalMutPointerPlaintextContent; - -typedef struct { - const SignalPreKeyBundle *raw; -} SignalConstPointerPreKeyBundle; - -typedef struct { - const SignalPreKeyRecord *raw; -} SignalConstPointerPreKeyRecord; - -typedef struct { - SignalPreKeySignalMessage *raw; -} SignalMutPointerPreKeySignalMessage; - -typedef struct { - const SignalSenderKeyDistributionMessage *raw; -} SignalConstPointerSenderKeyDistributionMessage; - -typedef struct { - SignalProvisioningChatConnection *raw; -} SignalMutPointerProvisioningChatConnection; - -/** - * A C callback used to report the results of Rust futures. - * - * cbindgen will produce independent C types like `SignalCPromisei32` and - * `SignalCPromiseProtocolAddress`. - * - * This derives Copy because it behaves like a C type; nevertheless, a promise should still only be - * completed once. - */ -typedef struct { - void (*complete)(SignalFfiError *error, const SignalMutPointerProvisioningChatConnection *result, const void *context); - const void *context; - SignalCancellationId cancellation_id; -} SignalCPromiseMutPointerProvisioningChatConnection; - -typedef struct { - const SignalProvisioningChatConnection *raw; -} SignalConstPointerProvisioningChatConnection; - -typedef int (*SignalFfiProvisioningListenerReceivedAddress)(void *ctx, const char *address, SignalMutPointerServerMessageAck send_ack); - -typedef int (*SignalFfiProvisioningListenerReceivedEnvelope)(void *ctx, SignalOwnedBuffer envelope, SignalMutPointerServerMessageAck send_ack); - -typedef int (*SignalFfiProvisioningListenerConnectionInterrupted)(void *ctx, SignalFfiError *disconnect_cause); - -typedef void (*SignalFfiProvisioningListenerDestroy)(void *ctx); - -typedef struct { - void *ctx; - SignalFfiProvisioningListenerReceivedAddress received_address; - SignalFfiProvisioningListenerReceivedEnvelope received_envelope; - SignalFfiProvisioningListenerConnectionInterrupted connection_interrupted; - SignalFfiProvisioningListenerDestroy destroy; -} SignalFfiProvisioningListenerStruct; - -typedef struct { - const SignalFfiProvisioningListenerStruct *raw; -} SignalConstPointerFfiProvisioningListenerStruct; - -typedef struct { - SignalRegisterAccountRequest *raw; -} SignalMutPointerRegisterAccountRequest; - -typedef struct { - const SignalRegisterAccountRequest *raw; -} SignalConstPointerRegisterAccountRequest; - -typedef struct { - uint32_t key_id; - SignalFfiPublicKeyType public_key_type; - const void *public_key; - SignalBorrowedBuffer signature; -} SignalFfiSignedPublicPreKey; - -typedef struct { - SignalRegisterAccountResponse *raw; -} SignalMutPointerRegisterAccountResponse; - -typedef struct { - const SignalRegisterAccountResponse *raw; -} SignalConstPointerRegisterAccountResponse; - -typedef struct { - bool present; - uint8_t bytes[16]; -} SignalOptionalUuid; - -typedef SignalAccountAttributes SignalRegistrationAccountAttributes; - -typedef struct { - SignalRegistrationAccountAttributes *raw; -} SignalMutPointerRegistrationAccountAttributes; - -typedef struct { - /** - * Bridged as a string of bytes, but each entry is a UTF-8 `String` key - * concatenated with a byte for the value. - */ - SignalBytestringArray entries; -} SignalFfiCheckSvr2CredentialsResponse; - -/** - * A C callback used to report the results of Rust futures. - * - * cbindgen will produce independent C types like `SignalCPromisei32` and - * `SignalCPromiseProtocolAddress`. - * - * This derives Copy because it behaves like a C type; nevertheless, a promise should still only be - * completed once. - */ -typedef struct { - void (*complete)(SignalFfiError *error, const SignalFfiCheckSvr2CredentialsResponse *result, const void *context); - const void *context; - SignalCancellationId cancellation_id; -} SignalCPromiseFfiCheckSvr2CredentialsResponse; - -typedef struct { - const SignalRegistrationService *raw; -} SignalConstPointerRegistrationService; - -typedef struct { - SignalRegistrationService *raw; -} SignalMutPointerRegistrationService; - -/** - * A C callback used to report the results of Rust futures. - * - * cbindgen will produce independent C types like `SignalCPromisei32` and - * `SignalCPromiseProtocolAddress`. - * - * This derives Copy because it behaves like a C type; nevertheless, a promise should still only be - * completed once. - */ -typedef struct { - void (*complete)(SignalFfiError *error, const SignalMutPointerRegistrationService *result, const void *context); - const void *context; - SignalCancellationId cancellation_id; -} SignalCPromiseMutPointerRegistrationService; - -typedef struct { - const char *number; - const char *push_token; - const char *mcc; - const char *mnc; -} SignalFfiRegistrationCreateSessionRequest; - -typedef const SignalConnectionManager *(*SignalGetConnectChatConnectionManager)(void *ctx); - -typedef void (*SignalDestroyConnectChatBridge)(void *ctx); - -/** - * A ref-counting pointer to a [`ConnectionManager`] and a callback to - * decrement the count. - */ -typedef struct { - void *ctx; - SignalGetConnectChatConnectionManager get_connection_manager; - SignalDestroyConnectChatBridge destroy; -} SignalFfiConnectChatBridgeStruct; - -typedef struct { - const SignalFfiConnectChatBridgeStruct *raw; -} SignalConstPointerFfiConnectChatBridgeStruct; - -/** - * A C callback used to report the results of Rust futures. - * - * cbindgen will produce independent C types like `SignalCPromisei32` and - * `SignalCPromiseProtocolAddress`. - * - * This derives Copy because it behaves like a C type; nevertheless, a promise should still only be - * completed once. - */ -typedef struct { - void (*complete)(SignalFfiError *error, const SignalMutPointerRegisterAccountResponse *result, const void *context); - const void *context; - SignalCancellationId cancellation_id; -} SignalCPromiseMutPointerRegisterAccountResponse; - -typedef struct { - const SignalRegistrationAccountAttributes *raw; -} SignalConstPointerRegistrationAccountAttributes; - -typedef struct { - SignalRegistrationSession *raw; -} SignalMutPointerRegistrationSession; - -typedef struct { - const SignalRegistrationSession *raw; -} SignalConstPointerRegistrationSession; - -typedef struct { - const SignalSanitizedMetadata *raw; -} SignalConstPointerSanitizedMetadata; - -typedef struct { - const SignalConstPointerProtocolAddress *base; - size_t length; -} SignalBorrowedSliceOfConstPointerProtocolAddress; - -typedef struct { - const SignalSessionRecord *raw; -} SignalConstPointerSessionRecord; - -typedef struct { - const SignalConstPointerSessionRecord *base; - size_t length; -} SignalBorrowedSliceOfConstPointerSessionRecord; - -typedef struct { - const SignalUnidentifiedSenderMessageContent *raw; -} SignalConstPointerUnidentifiedSenderMessageContent; - -typedef struct { - SignalUnidentifiedSenderMessageContent *raw; -} SignalMutPointerUnidentifiedSenderMessageContent; - -typedef uint8_t SignalBackupKeyBytes[SignalBACKUP_KEY_LEN]; - -/** - * A C callback used to report the results of Rust futures. - * - * cbindgen will produce independent C types like `SignalCPromisei32` and - * `SignalCPromiseProtocolAddress`. - * - * This derives Copy because it behaves like a C type; nevertheless, a promise should still only be - * completed once. - */ -typedef struct { - void (*complete)(SignalFfiError *error, const SignalMutPointerBackupRestoreResponse *result, const void *context); - const void *context; - SignalCancellationId cancellation_id; -} SignalCPromiseMutPointerBackupRestoreResponse; - -/** - * A C callback used to report the results of Rust futures. - * - * cbindgen will produce independent C types like `SignalCPromisei32` and - * `SignalCPromiseProtocolAddress`. - * - * This derives Copy because it behaves like a C type; nevertheless, a promise should still only be - * completed once. - */ -typedef struct { - void (*complete)(SignalFfiError *error, const SignalMutPointerBackupStoreResponse *result, const void *context); - const void *context; - SignalCancellationId cancellation_id; -} SignalCPromiseMutPointerBackupStoreResponse; - -typedef struct { - SignalSenderCertificate *raw; -} SignalMutPointerSenderCertificate; - -typedef struct { - const SignalSenderCertificate *raw; -} SignalConstPointerSenderCertificate; - -typedef struct { - SignalServerCertificate *raw; -} SignalMutPointerServerCertificate; - -typedef struct { - const SignalServerCertificate *raw; -} SignalConstPointerServerCertificate; - -typedef struct { - const SignalConstPointerPublicKey *base; - size_t length; -} SignalBorrowedSliceOfConstPointerPublicKey; - -typedef struct { - SignalSenderKeyDistributionMessage *raw; -} SignalMutPointerSenderKeyDistributionMessage; - -typedef struct { - SignalSenderKeyMessage *raw; -} SignalMutPointerSenderKeyMessage; - -typedef struct { - const SignalSenderKeyMessage *raw; -} SignalConstPointerSenderKeyMessage; - -typedef struct { - const SignalSenderKeyRecord *raw; -} SignalConstPointerSenderKeyRecord; - -typedef struct { - const SignalServerMessageAck *raw; -} SignalConstPointerServerMessageAck; - -typedef struct { - SignalServerPublicParams *raw; -} SignalMutPointerServerPublicParams; - -typedef struct { - SignalServerSecretParams *raw; -} SignalMutPointerServerSecretParams; - -typedef struct { - const SignalSgxClientState *raw; -} SignalConstPointerSgxClientState; - -typedef struct { - const SignalSignedPreKeyRecord *raw; -} SignalConstPointerSignedPreKeyRecord; - -typedef struct { - SignalTokioAsyncContext *raw; -} SignalMutPointerTokioAsyncContext; - -typedef struct { - SignalUnauthenticatedChatConnection *raw; -} SignalMutPointerUnauthenticatedChatConnection; - -/** - * A C callback used to report the results of Rust futures. - * - * cbindgen will produce independent C types like `SignalCPromisei32` and - * `SignalCPromiseProtocolAddress`. - * - * This derives Copy because it behaves like a C type; nevertheless, a promise should still only be - * completed once. - */ -typedef struct { - void (*complete)(SignalFfiError *error, const SignalMutPointerUnauthenticatedChatConnection *result, const void *context); - const void *context; - SignalCancellationId cancellation_id; -} SignalCPromiseMutPointerUnauthenticatedChatConnection; - -typedef struct { - SignalMutPointerPublicKey identity_key; - SignalOwnedBufferOfMutPointerPreKeyBundle pre_key_bundles; -} SignalFfiPreKeysResponse; - -/** - * A C callback used to report the results of Rust futures. - * - * cbindgen will produce independent C types like `SignalCPromisei32` and - * `SignalCPromiseProtocolAddress`. - * - * This derives Copy because it behaves like a C type; nevertheless, a promise should still only be - * completed once. - */ -typedef struct { - void (*complete)(SignalFfiError *error, const SignalFfiPreKeysResponse *result, const void *context); - const void *context; - SignalCancellationId cancellation_id; -} SignalCPromiseFfiPreKeysResponse; - -/** - * A C callback used to report the results of Rust futures. - * - * cbindgen will produce independent C types like `SignalCPromisei32` and - * `SignalCPromiseProtocolAddress`. - * - * This derives Copy because it behaves like a C type; nevertheless, a promise should still only be - * completed once. - */ -typedef struct { - void (*complete)(SignalFfiError *error, const SignalOptionalUuid *result, const void *context); - const void *context; - SignalCancellationId cancellation_id; -} SignalCPromiseOptionalUuid; - -typedef struct { - bool present; - const char *first; - uint8_t second[32]; -} SignalOptionalPairOfc_charu832; - -/** - * A C callback used to report the results of Rust futures. - * - * cbindgen will produce independent C types like `SignalCPromisei32` and - * `SignalCPromiseProtocolAddress`. - * - * This derives Copy because it behaves like a C type; nevertheless, a promise should still only be - * completed once. - */ -typedef struct { - void (*complete)(SignalFfiError *error, const SignalOptionalPairOfc_charu832 *result, const void *context); - const void *context; - SignalCancellationId cancellation_id; -} SignalCPromiseOptionalPairOfc_charu832; - -/** - * A C callback used to report the results of Rust futures. - * - * cbindgen will produce independent C types like `SignalCPromisei32` and - * `SignalCPromiseProtocolAddress`. - * - * This derives Copy because it behaves like a C type; nevertheless, a promise should still only be - * completed once. - */ -typedef struct { - void (*complete)(SignalFfiError *error, const SignalOwnedBufferOfServiceIdFixedWidthBinaryBytes *result, const void *context); - const void *context; - SignalCancellationId cancellation_id; -} SignalCPromiseOwnedBufferOfServiceIdFixedWidthBinaryBytes; - -typedef struct { - SignalValidatingMac *raw; -} SignalMutPointerValidatingMac; - typedef SignalInputStream SignalSyncInputStream; -typedef struct { - const SignalSyncInputStream *raw; -} SignalConstPointerFfiSyncInputStreamStruct; +/** + * A C callback used to report the results of Rust futures. + * + * cbindgen will produce independent C types like `SignalCPromisei32` and + * `SignalCPromiseProtocolAddress`. + */ +typedef void (*SignalCPromisei32)(SignalFfiError *error, const int32_t *result, const void *context); + +/** + * A C callback used to report the results of Rust futures. + * + * cbindgen will produce independent C types like `SignalCPromisei32` and + * `SignalCPromiseProtocolAddress`. + */ +typedef void (*SignalCPromiseTestingHandleType)(SignalFfiError *error, SignalTestingHandleType *const *result, const void *context); + +/** + * A C callback used to report the results of Rust futures. + * + * cbindgen will produce independent C types like `SignalCPromisei32` and + * `SignalCPromiseProtocolAddress`. + */ +typedef void (*SignalCPromiseOtherTestingHandleType)(SignalFfiError *error, SignalOtherTestingHandleType *const *result, const void *context); + +/** + * A C callback used to report the results of Rust futures. + * + * cbindgen will produce independent C types like `SignalCPromisei32` and + * `SignalCPromiseProtocolAddress`. + */ +typedef void (*SignalCPromisebool)(SignalFfiError *error, const bool *result, const void *context); + +/** + * A C callback used to report the results of Rust futures. + * + * cbindgen will produce independent C types like `SignalCPromisei32` and + * `SignalCPromiseProtocolAddress`. + */ +typedef void (*SignalCPromiseRawPointer)(SignalFfiError *error, const void *const *result, const void *context); typedef uint8_t SignalRandomnessBytes[SignalRANDOMNESS_LEN]; -typedef uint8_t SignalUnidentifiedAccessKey[SignalACCESS_KEY_LEN]; +void signal_print_ptr(const void *p); +void signal_free_string(const char *buf); +void signal_free_buffer(const unsigned char *buf, size_t buf_len); -SignalFfiError *signal_account_entropy_pool_derive_backup_key(uint8_t (*out)[SignalBACKUP_KEY_LEN], const char *account_entropy); +SignalFfiError *signal_error_get_message(const SignalFfiError *err, const char **out); -SignalFfiError *signal_account_entropy_pool_derive_svr_key(uint8_t (*out)[SignalSVR_KEY_LEN], const char *account_entropy); +SignalFfiError *signal_error_get_address(const SignalFfiError *err, SignalProtocolAddress **out); -SignalFfiError *signal_account_entropy_pool_generate(const char **out); +SignalFfiError *signal_error_get_uuid(const SignalFfiError *err, uint8_t (*out)[16]); -SignalFfiError *signal_account_entropy_pool_is_valid(bool *out, const char *account_entropy); +uint32_t signal_error_get_type(const SignalFfiError *err); -SignalFfiError *signal_address_clone(SignalMutPointerProtocolAddress *new_obj, SignalConstPointerProtocolAddress obj); +void signal_error_free(SignalFfiError *err); -SignalFfiError *signal_address_destroy(SignalMutPointerProtocolAddress p); +SignalFfiError *signal_identitykeypair_deserialize(SignalPrivateKey **private_key, SignalPublicKey **public_key, SignalBorrowedBuffer input); -SignalFfiError *signal_address_get_device_id(uint32_t *out, SignalConstPointerProtocolAddress obj); +SignalFfiError *signal_sealed_session_cipher_decrypt(SignalOwnedBuffer *out, const char **sender_e164, const char **sender_uuid, uint32_t *sender_device_id, SignalBorrowedBuffer ctext, const SignalPublicKey *trust_root, uint64_t timestamp, const char *local_e164, const char *local_uuid, unsigned int local_device_id, const SignalSessionStore *session_store, const SignalIdentityKeyStore *identity_store, const SignalPreKeyStore *prekey_store, const SignalSignedPreKeyStore *signed_prekey_store); -SignalFfiError *signal_address_get_name(const char **out, SignalConstPointerProtocolAddress obj); +void signal_init_logger(SignalLogLevel max_level, SignalFfiLogger logger); -SignalFfiError *signal_address_new(SignalMutPointerProtocolAddress *out, const char *name, uint32_t device_id); +SignalFfiError *signal_aes256_gcm_siv_destroy(SignalAes256GcmSiv *p); -SignalFfiError *signal_aes256_ctr32_destroy(SignalMutPointerAes256Ctr32 p); +SignalFfiError *signal_aes256_ctr32_destroy(SignalAes256Ctr32 *p); -SignalFfiError *signal_aes256_ctr32_new(SignalMutPointerAes256Ctr32 *out, SignalBorrowedBuffer key, SignalBorrowedBuffer nonce, uint32_t initial_ctr); +SignalFfiError *signal_aes256_gcm_encryption_destroy(SignalAes256GcmEncryption *p); -SignalFfiError *signal_aes256_ctr32_process(SignalMutPointerAes256Ctr32 ctr, SignalBorrowedMutableBuffer data, uint32_t offset, uint32_t length); +SignalFfiError *signal_aes256_gcm_decryption_destroy(SignalAes256GcmDecryption *p); -SignalFfiError *signal_aes256_gcm_decryption_destroy(SignalMutPointerAes256GcmDecryption p); +SignalFfiError *signal_aes256_ctr32_new(SignalAes256Ctr32 **out, SignalBorrowedBuffer key, SignalBorrowedBuffer nonce, uint32_t initial_ctr); -SignalFfiError *signal_aes256_gcm_decryption_new(SignalMutPointerAes256GcmDecryption *out, SignalBorrowedBuffer key, SignalBorrowedBuffer nonce, SignalBorrowedBuffer associated_data); +SignalFfiError *signal_aes256_ctr32_process(SignalAes256Ctr32 *ctr, SignalBorrowedMutableBuffer data, uint32_t offset, uint32_t length); -SignalFfiError *signal_aes256_gcm_decryption_update(SignalMutPointerAes256GcmDecryption gcm, SignalBorrowedMutableBuffer data, uint32_t offset, uint32_t length); +SignalFfiError *signal_aes256_gcm_encryption_new(SignalAes256GcmEncryption **out, SignalBorrowedBuffer key, SignalBorrowedBuffer nonce, SignalBorrowedBuffer associated_data); -SignalFfiError *signal_aes256_gcm_decryption_verify_tag(bool *out, SignalMutPointerAes256GcmDecryption gcm, SignalBorrowedBuffer tag); +SignalFfiError *signal_aes256_gcm_encryption_update(SignalAes256GcmEncryption *gcm, SignalBorrowedMutableBuffer data, uint32_t offset, uint32_t length); -SignalFfiError *signal_aes256_gcm_encryption_compute_tag(SignalOwnedBuffer *out, SignalMutPointerAes256GcmEncryption gcm); +SignalFfiError *signal_aes256_gcm_encryption_compute_tag(SignalOwnedBuffer *out, SignalAes256GcmEncryption *gcm); -SignalFfiError *signal_aes256_gcm_encryption_destroy(SignalMutPointerAes256GcmEncryption p); +SignalFfiError *signal_aes256_gcm_decryption_new(SignalAes256GcmDecryption **out, SignalBorrowedBuffer key, SignalBorrowedBuffer nonce, SignalBorrowedBuffer associated_data); -SignalFfiError *signal_aes256_gcm_encryption_new(SignalMutPointerAes256GcmEncryption *out, SignalBorrowedBuffer key, SignalBorrowedBuffer nonce, SignalBorrowedBuffer associated_data); +SignalFfiError *signal_aes256_gcm_decryption_update(SignalAes256GcmDecryption *gcm, SignalBorrowedMutableBuffer data, uint32_t offset, uint32_t length); -SignalFfiError *signal_aes256_gcm_encryption_update(SignalMutPointerAes256GcmEncryption gcm, SignalBorrowedMutableBuffer data, uint32_t offset, uint32_t length); +SignalFfiError *signal_aes256_gcm_decryption_verify_tag(bool *out, SignalAes256GcmDecryption *gcm, SignalBorrowedBuffer tag); -SignalFfiError *signal_aes256_gcm_siv_decrypt(SignalOwnedBuffer *out, SignalConstPointerAes256GcmSiv aes_gcm_siv, SignalBorrowedBuffer ctext, SignalBorrowedBuffer nonce, SignalBorrowedBuffer associated_data); +SignalFfiError *signal_aes256_gcm_siv_new(SignalAes256GcmSiv **out, SignalBorrowedBuffer key); -SignalFfiError *signal_aes256_gcm_siv_destroy(SignalMutPointerAes256GcmSiv p); +SignalFfiError *signal_aes256_gcm_siv_encrypt(SignalOwnedBuffer *out, const SignalAes256GcmSiv *aes_gcm_siv_obj, SignalBorrowedBuffer ptext, SignalBorrowedBuffer nonce, SignalBorrowedBuffer associated_data); -SignalFfiError *signal_aes256_gcm_siv_encrypt(SignalOwnedBuffer *out, SignalConstPointerAes256GcmSiv aes_gcm_siv_obj, SignalBorrowedBuffer ptext, SignalBorrowedBuffer nonce, SignalBorrowedBuffer associated_data); +SignalFfiError *signal_aes256_gcm_siv_decrypt(SignalOwnedBuffer *out, const SignalAes256GcmSiv *aes_gcm_siv, SignalBorrowedBuffer ctext, SignalBorrowedBuffer nonce, SignalBorrowedBuffer associated_data); -SignalFfiError *signal_aes256_gcm_siv_new(SignalMutPointerAes256GcmSiv *out, SignalBorrowedBuffer key); +SignalFfiError *signal_ciphertext_message_destroy(SignalCiphertextMessage *p); + +SignalFfiError *signal_decryption_error_message_destroy(SignalDecryptionErrorMessage *p); + +SignalFfiError *signal_decryption_error_message_clone(SignalDecryptionErrorMessage **new_obj, const SignalDecryptionErrorMessage *obj); + +SignalFfiError *signal_fingerprint_destroy(SignalFingerprint *p); + +SignalFfiError *signal_fingerprint_clone(SignalFingerprint **new_obj, const SignalFingerprint *obj); + +SignalFfiError *signal_plaintext_content_destroy(SignalPlaintextContent *p); + +SignalFfiError *signal_plaintext_content_clone(SignalPlaintextContent **new_obj, const SignalPlaintextContent *obj); + +SignalFfiError *signal_pre_key_bundle_destroy(SignalPreKeyBundle *p); + +SignalFfiError *signal_pre_key_bundle_clone(SignalPreKeyBundle **new_obj, const SignalPreKeyBundle *obj); + +SignalFfiError *signal_pre_key_record_destroy(SignalPreKeyRecord *p); + +SignalFfiError *signal_pre_key_record_clone(SignalPreKeyRecord **new_obj, const SignalPreKeyRecord *obj); + +SignalFfiError *signal_pre_key_signal_message_destroy(SignalPreKeySignalMessage *p); + +SignalFfiError *signal_pre_key_signal_message_clone(SignalPreKeySignalMessage **new_obj, const SignalPreKeySignalMessage *obj); + +SignalFfiError *signal_privatekey_destroy(SignalPrivateKey *p); + +SignalFfiError *signal_privatekey_clone(SignalPrivateKey **new_obj, const SignalPrivateKey *obj); + +SignalFfiError *signal_address_destroy(SignalProtocolAddress *p); + +SignalFfiError *signal_address_clone(SignalProtocolAddress **new_obj, const SignalProtocolAddress *obj); + +SignalFfiError *signal_publickey_destroy(SignalPublicKey *p); + +SignalFfiError *signal_publickey_clone(SignalPublicKey **new_obj, const SignalPublicKey *obj); + +SignalFfiError *signal_sender_certificate_destroy(SignalSenderCertificate *p); + +SignalFfiError *signal_sender_certificate_clone(SignalSenderCertificate **new_obj, const SignalSenderCertificate *obj); + +SignalFfiError *signal_sender_key_distribution_message_destroy(SignalSenderKeyDistributionMessage *p); + +SignalFfiError *signal_sender_key_distribution_message_clone(SignalSenderKeyDistributionMessage **new_obj, const SignalSenderKeyDistributionMessage *obj); + +SignalFfiError *signal_sender_key_message_destroy(SignalSenderKeyMessage *p); + +SignalFfiError *signal_sender_key_message_clone(SignalSenderKeyMessage **new_obj, const SignalSenderKeyMessage *obj); + +SignalFfiError *signal_sender_key_record_destroy(SignalSenderKeyRecord *p); + +SignalFfiError *signal_sender_key_record_clone(SignalSenderKeyRecord **new_obj, const SignalSenderKeyRecord *obj); + +SignalFfiError *signal_server_certificate_destroy(SignalServerCertificate *p); + +SignalFfiError *signal_server_certificate_clone(SignalServerCertificate **new_obj, const SignalServerCertificate *obj); + +SignalFfiError *signal_session_record_destroy(SignalSessionRecord *p); + +SignalFfiError *signal_session_record_clone(SignalSessionRecord **new_obj, const SignalSessionRecord *obj); + +SignalFfiError *signal_message_destroy(SignalMessage *p); + +SignalFfiError *signal_message_clone(SignalMessage **new_obj, const SignalMessage *obj); + +SignalFfiError *signal_signed_pre_key_record_destroy(SignalSignedPreKeyRecord *p); + +SignalFfiError *signal_signed_pre_key_record_clone(SignalSignedPreKeyRecord **new_obj, const SignalSignedPreKeyRecord *obj); + +SignalFfiError *signal_kyber_pre_key_record_destroy(SignalKyberPreKeyRecord *p); + +SignalFfiError *signal_kyber_pre_key_record_clone(SignalKyberPreKeyRecord **new_obj, const SignalKyberPreKeyRecord *obj); + +SignalFfiError *signal_unidentified_sender_message_content_destroy(SignalUnidentifiedSenderMessageContent *p); + +SignalFfiError *signal_kyber_key_pair_destroy(SignalKyberKeyPair *p); + +SignalFfiError *signal_kyber_key_pair_clone(SignalKyberKeyPair **new_obj, const SignalKyberKeyPair *obj); + +SignalFfiError *signal_kyber_public_key_destroy(SignalKyberPublicKey *p); + +SignalFfiError *signal_kyber_public_key_clone(SignalKyberPublicKey **new_obj, const SignalKyberPublicKey *obj); + +SignalFfiError *signal_kyber_secret_key_destroy(SignalKyberSecretKey *p); + +SignalFfiError *signal_kyber_secret_key_clone(SignalKyberSecretKey **new_obj, const SignalKyberSecretKey *obj); + +SignalFfiError *signal_hkdf_derive(SignalBorrowedMutableBuffer output, SignalBorrowedBuffer ikm, SignalBorrowedBuffer label, SignalBorrowedBuffer salt); + +SignalFfiError *signal_service_id_service_id_binary(SignalOwnedBuffer *out, const SignalServiceIdFixedWidthBinaryBytes *value); + +SignalFfiError *signal_service_id_service_id_string(const char **out, const SignalServiceIdFixedWidthBinaryBytes *value); + +SignalFfiError *signal_service_id_service_id_log(const char **out, const SignalServiceIdFixedWidthBinaryBytes *value); + +SignalFfiError *signal_service_id_parse_from_service_id_binary(SignalServiceIdFixedWidthBinaryBytes *out, SignalBorrowedBuffer input); + +SignalFfiError *signal_service_id_parse_from_service_id_string(SignalServiceIdFixedWidthBinaryBytes *out, const char *input); + +SignalFfiError *signal_address_new(SignalProtocolAddress **out, const char *name, uint32_t device_id); + +SignalFfiError *signal_publickey_deserialize(SignalPublicKey **out, SignalBorrowedBuffer data); + +SignalFfiError *signal_publickey_serialize(SignalOwnedBuffer *out, const SignalPublicKey *obj); + +SignalFfiError *signal_publickey_get_public_key_bytes(SignalOwnedBuffer *out, const SignalPublicKey *obj); + +SignalFfiError *signal_address_get_device_id(uint32_t *out, const SignalProtocolAddress *obj); + +SignalFfiError *signal_address_get_name(const char **out, const SignalProtocolAddress *obj); + +SignalFfiError *signal_publickey_equals(bool *out, const SignalPublicKey *lhs, const SignalPublicKey *rhs); + +SignalFfiError *signal_publickey_compare(int32_t *out, const SignalPublicKey *key1, const SignalPublicKey *key2); + +SignalFfiError *signal_publickey_verify(bool *out, const SignalPublicKey *key, SignalBorrowedBuffer message, SignalBorrowedBuffer signature); + +SignalFfiError *signal_privatekey_deserialize(SignalPrivateKey **out, SignalBorrowedBuffer data); + +SignalFfiError *signal_privatekey_serialize(SignalOwnedBuffer *out, const SignalPrivateKey *obj); + +SignalFfiError *signal_privatekey_generate(SignalPrivateKey **out); + +SignalFfiError *signal_privatekey_get_public_key(SignalPublicKey **out, const SignalPrivateKey *k); + +SignalFfiError *signal_privatekey_sign(SignalOwnedBuffer *out, const SignalPrivateKey *key, SignalBorrowedBuffer message); + +SignalFfiError *signal_privatekey_agree(SignalOwnedBuffer *out, const SignalPrivateKey *private_key, const SignalPublicKey *public_key); + +SignalFfiError *signal_kyber_public_key_serialize(SignalOwnedBuffer *out, const SignalKyberPublicKey *obj); + +SignalFfiError *signal_kyber_public_key_deserialize(SignalKyberPublicKey **out, SignalBorrowedBuffer data); + +SignalFfiError *signal_kyber_secret_key_serialize(SignalOwnedBuffer *out, const SignalKyberSecretKey *obj); + +SignalFfiError *signal_kyber_secret_key_deserialize(SignalKyberSecretKey **out, SignalBorrowedBuffer data); + +SignalFfiError *signal_kyber_public_key_equals(bool *out, const SignalKyberPublicKey *lhs, const SignalKyberPublicKey *rhs); + +SignalFfiError *signal_kyber_key_pair_generate(SignalKyberKeyPair **out); + +SignalFfiError *signal_kyber_key_pair_get_public_key(SignalKyberPublicKey **out, const SignalKyberKeyPair *key_pair); + +SignalFfiError *signal_kyber_key_pair_get_secret_key(SignalKyberSecretKey **out, const SignalKyberKeyPair *key_pair); + +SignalFfiError *signal_identitykeypair_serialize(SignalOwnedBuffer *out, const SignalPublicKey *public_key, const SignalPrivateKey *private_key); + +SignalFfiError *signal_identitykeypair_sign_alternate_identity(SignalOwnedBuffer *out, const SignalPublicKey *public_key, const SignalPrivateKey *private_key, const SignalPublicKey *other_identity); + +SignalFfiError *signal_identitykey_verify_alternate_identity(bool *out, const SignalPublicKey *public_key, const SignalPublicKey *other_identity, SignalBorrowedBuffer signature); + +SignalFfiError *signal_fingerprint_new(SignalFingerprint **out, uint32_t iterations, uint32_t version, SignalBorrowedBuffer local_identifier, const SignalPublicKey *local_key, SignalBorrowedBuffer remote_identifier, const SignalPublicKey *remote_key); + +SignalFfiError *signal_fingerprint_scannable_encoding(SignalOwnedBuffer *out, const SignalFingerprint *obj); + +SignalFfiError *signal_fingerprint_display_string(const char **out, const SignalFingerprint *obj); + +SignalFfiError *signal_fingerprint_compare(bool *out, SignalBorrowedBuffer fprint1, SignalBorrowedBuffer fprint2); + +SignalFfiError *signal_message_deserialize(SignalMessage **out, SignalBorrowedBuffer data); + +SignalFfiError *signal_message_get_body(SignalOwnedBuffer *out, const SignalMessage *obj); + +SignalFfiError *signal_message_get_serialized(SignalOwnedBuffer *out, const SignalMessage *obj); + +SignalFfiError *signal_message_get_counter(uint32_t *out, const SignalMessage *obj); + +SignalFfiError *signal_message_get_message_version(uint32_t *out, const SignalMessage *obj); + +SignalFfiError *signal_message_new(SignalMessage **out, uint8_t message_version, SignalBorrowedBuffer mac_key, const SignalPublicKey *sender_ratchet_key, uint32_t counter, uint32_t previous_counter, SignalBorrowedBuffer ciphertext, const SignalPublicKey *sender_identity_key, const SignalPublicKey *receiver_identity_key); + +SignalFfiError *signal_message_verify_mac(bool *out, const SignalMessage *msg, const SignalPublicKey *sender_identity_key, const SignalPublicKey *receiver_identity_key, SignalBorrowedBuffer mac_key); + +SignalFfiError *signal_message_get_sender_ratchet_key(SignalPublicKey **out, const SignalMessage *m); + +SignalFfiError *signal_pre_key_signal_message_new(SignalPreKeySignalMessage **out, uint8_t message_version, uint32_t registration_id, uint32_t pre_key_id, uint32_t signed_pre_key_id, const SignalPublicKey *base_key, const SignalPublicKey *identity_key, const SignalMessage *signal_message); + +SignalFfiError *signal_pre_key_signal_message_get_base_key(SignalPublicKey **out, const SignalPreKeySignalMessage *m); + +SignalFfiError *signal_pre_key_signal_message_get_identity_key(SignalPublicKey **out, const SignalPreKeySignalMessage *m); + +SignalFfiError *signal_pre_key_signal_message_get_signal_message(SignalMessage **out, const SignalPreKeySignalMessage *m); + +SignalFfiError *signal_pre_key_signal_message_deserialize(SignalPreKeySignalMessage **out, SignalBorrowedBuffer data); + +SignalFfiError *signal_pre_key_signal_message_serialize(SignalOwnedBuffer *out, const SignalPreKeySignalMessage *obj); + +SignalFfiError *signal_pre_key_signal_message_get_registration_id(uint32_t *out, const SignalPreKeySignalMessage *obj); + +SignalFfiError *signal_pre_key_signal_message_get_signed_pre_key_id(uint32_t *out, const SignalPreKeySignalMessage *obj); + +SignalFfiError *signal_pre_key_signal_message_get_pre_key_id(uint32_t *out, const SignalPreKeySignalMessage *obj); + +SignalFfiError *signal_pre_key_signal_message_get_version(uint32_t *out, const SignalPreKeySignalMessage *obj); + +SignalFfiError *signal_sender_key_message_deserialize(SignalSenderKeyMessage **out, SignalBorrowedBuffer data); + +SignalFfiError *signal_sender_key_message_get_cipher_text(SignalOwnedBuffer *out, const SignalSenderKeyMessage *obj); + +SignalFfiError *signal_sender_key_message_serialize(SignalOwnedBuffer *out, const SignalSenderKeyMessage *obj); + +SignalFfiError *signal_sender_key_message_get_distribution_id(uint8_t (*out)[16], const SignalSenderKeyMessage *obj); + +SignalFfiError *signal_sender_key_message_get_chain_id(uint32_t *out, const SignalSenderKeyMessage *obj); + +SignalFfiError *signal_sender_key_message_get_iteration(uint32_t *out, const SignalSenderKeyMessage *obj); + +SignalFfiError *signal_sender_key_message_new(SignalSenderKeyMessage **out, uint8_t message_version, const uint8_t (*distribution_id)[16], uint32_t chain_id, uint32_t iteration, SignalBorrowedBuffer ciphertext, const SignalPrivateKey *pk); + +SignalFfiError *signal_sender_key_message_verify_signature(bool *out, const SignalSenderKeyMessage *skm, const SignalPublicKey *pubkey); + +SignalFfiError *signal_sender_key_distribution_message_deserialize(SignalSenderKeyDistributionMessage **out, SignalBorrowedBuffer data); + +SignalFfiError *signal_sender_key_distribution_message_get_chain_key(SignalOwnedBuffer *out, const SignalSenderKeyDistributionMessage *obj); + +SignalFfiError *signal_sender_key_distribution_message_serialize(SignalOwnedBuffer *out, const SignalSenderKeyDistributionMessage *obj); + +SignalFfiError *signal_sender_key_distribution_message_get_distribution_id(uint8_t (*out)[16], const SignalSenderKeyDistributionMessage *obj); + +SignalFfiError *signal_sender_key_distribution_message_get_chain_id(uint32_t *out, const SignalSenderKeyDistributionMessage *obj); + +SignalFfiError *signal_sender_key_distribution_message_get_iteration(uint32_t *out, const SignalSenderKeyDistributionMessage *obj); + +SignalFfiError *signal_sender_key_distribution_message_new(SignalSenderKeyDistributionMessage **out, uint8_t message_version, const uint8_t (*distribution_id)[16], uint32_t chain_id, uint32_t iteration, SignalBorrowedBuffer chainkey, const SignalPublicKey *pk); + +SignalFfiError *signal_sender_key_distribution_message_get_signature_key(SignalPublicKey **out, const SignalSenderKeyDistributionMessage *m); + +SignalFfiError *signal_decryption_error_message_deserialize(SignalDecryptionErrorMessage **out, SignalBorrowedBuffer data); + +SignalFfiError *signal_decryption_error_message_get_timestamp(uint64_t *out, const SignalDecryptionErrorMessage *obj); + +SignalFfiError *signal_decryption_error_message_get_device_id(uint32_t *out, const SignalDecryptionErrorMessage *obj); + +SignalFfiError *signal_decryption_error_message_serialize(SignalOwnedBuffer *out, const SignalDecryptionErrorMessage *obj); + +SignalFfiError *signal_decryption_error_message_get_ratchet_key(SignalPublicKey **out, const SignalDecryptionErrorMessage *m); + +SignalFfiError *signal_decryption_error_message_for_original_message(SignalDecryptionErrorMessage **out, SignalBorrowedBuffer original_bytes, uint8_t original_type, uint64_t original_timestamp, uint32_t original_sender_device_id); + +SignalFfiError *signal_decryption_error_message_extract_from_serialized_content(SignalDecryptionErrorMessage **out, SignalBorrowedBuffer bytes); + +SignalFfiError *signal_plaintext_content_deserialize(SignalPlaintextContent **out, SignalBorrowedBuffer data); + +SignalFfiError *signal_plaintext_content_serialize(SignalOwnedBuffer *out, const SignalPlaintextContent *obj); + +SignalFfiError *signal_plaintext_content_get_body(SignalOwnedBuffer *out, const SignalPlaintextContent *obj); + +SignalFfiError *signal_plaintext_content_from_decryption_error_message(SignalPlaintextContent **out, const SignalDecryptionErrorMessage *m); + +SignalFfiError *signal_pre_key_bundle_new(SignalPreKeyBundle **out, uint32_t registration_id, uint32_t device_id, uint32_t prekey_id, const SignalPublicKey *prekey, uint32_t signed_prekey_id, const SignalPublicKey *signed_prekey, SignalBorrowedBuffer signed_prekey_signature, const SignalPublicKey *identity_key, uint32_t kyber_prekey_id, const SignalKyberPublicKey *kyber_prekey, SignalBorrowedBuffer kyber_prekey_signature); + +SignalFfiError *signal_pre_key_bundle_get_identity_key(SignalPublicKey **out, const SignalPreKeyBundle *p); + +SignalFfiError *signal_pre_key_bundle_get_signed_pre_key_signature(SignalOwnedBuffer *out, const SignalPreKeyBundle *obj); + +SignalFfiError *signal_pre_key_bundle_get_registration_id(uint32_t *out, const SignalPreKeyBundle *obj); + +SignalFfiError *signal_pre_key_bundle_get_device_id(uint32_t *out, const SignalPreKeyBundle *obj); + +SignalFfiError *signal_pre_key_bundle_get_signed_pre_key_id(uint32_t *out, const SignalPreKeyBundle *obj); + +SignalFfiError *signal_pre_key_bundle_get_pre_key_id(uint32_t *out, const SignalPreKeyBundle *obj); + +SignalFfiError *signal_pre_key_bundle_get_pre_key_public(SignalPublicKey **out, const SignalPreKeyBundle *obj); + +SignalFfiError *signal_pre_key_bundle_get_signed_pre_key_public(SignalPublicKey **out, const SignalPreKeyBundle *obj); + +SignalFfiError *signal_pre_key_bundle_get_kyber_pre_key_public(SignalKyberPublicKey **out, const SignalPreKeyBundle *bundle); + +SignalFfiError *signal_pre_key_bundle_get_kyber_pre_key_signature(SignalOwnedBuffer *out, const SignalPreKeyBundle *bundle); + +SignalFfiError *signal_signed_pre_key_record_deserialize(SignalSignedPreKeyRecord **out, SignalBorrowedBuffer data); + +SignalFfiError *signal_signed_pre_key_record_get_signature(SignalOwnedBuffer *out, const SignalSignedPreKeyRecord *obj); + +SignalFfiError *signal_signed_pre_key_record_serialize(SignalOwnedBuffer *out, const SignalSignedPreKeyRecord *obj); + +SignalFfiError *signal_signed_pre_key_record_get_id(uint32_t *out, const SignalSignedPreKeyRecord *obj); + +SignalFfiError *signal_signed_pre_key_record_get_timestamp(uint64_t *out, const SignalSignedPreKeyRecord *obj); + +SignalFfiError *signal_signed_pre_key_record_get_public_key(SignalPublicKey **out, const SignalSignedPreKeyRecord *obj); + +SignalFfiError *signal_signed_pre_key_record_get_private_key(SignalPrivateKey **out, const SignalSignedPreKeyRecord *obj); + +SignalFfiError *signal_kyber_pre_key_record_deserialize(SignalKyberPreKeyRecord **out, SignalBorrowedBuffer data); + +SignalFfiError *signal_kyber_pre_key_record_get_signature(SignalOwnedBuffer *out, const SignalKyberPreKeyRecord *obj); + +SignalFfiError *signal_kyber_pre_key_record_serialize(SignalOwnedBuffer *out, const SignalKyberPreKeyRecord *obj); + +SignalFfiError *signal_kyber_pre_key_record_get_id(uint32_t *out, const SignalKyberPreKeyRecord *obj); + +SignalFfiError *signal_kyber_pre_key_record_get_timestamp(uint64_t *out, const SignalKyberPreKeyRecord *obj); + +SignalFfiError *signal_kyber_pre_key_record_get_public_key(SignalKyberPublicKey **out, const SignalKyberPreKeyRecord *obj); + +SignalFfiError *signal_kyber_pre_key_record_get_secret_key(SignalKyberSecretKey **out, const SignalKyberPreKeyRecord *obj); + +SignalFfiError *signal_kyber_pre_key_record_get_key_pair(SignalKyberKeyPair **out, const SignalKyberPreKeyRecord *obj); + +SignalFfiError *signal_signed_pre_key_record_new(SignalSignedPreKeyRecord **out, uint32_t id, uint64_t timestamp, const SignalPublicKey *pub_key, const SignalPrivateKey *priv_key, SignalBorrowedBuffer signature); + +SignalFfiError *signal_kyber_pre_key_record_new(SignalKyberPreKeyRecord **out, uint32_t id, uint64_t timestamp, const SignalKyberKeyPair *key_pair, SignalBorrowedBuffer signature); + +SignalFfiError *signal_pre_key_record_deserialize(SignalPreKeyRecord **out, SignalBorrowedBuffer data); + +SignalFfiError *signal_pre_key_record_serialize(SignalOwnedBuffer *out, const SignalPreKeyRecord *obj); + +SignalFfiError *signal_pre_key_record_get_id(uint32_t *out, const SignalPreKeyRecord *obj); + +SignalFfiError *signal_pre_key_record_get_public_key(SignalPublicKey **out, const SignalPreKeyRecord *obj); + +SignalFfiError *signal_pre_key_record_get_private_key(SignalPrivateKey **out, const SignalPreKeyRecord *obj); + +SignalFfiError *signal_pre_key_record_new(SignalPreKeyRecord **out, uint32_t id, const SignalPublicKey *pub_key, const SignalPrivateKey *priv_key); + +SignalFfiError *signal_sender_key_record_deserialize(SignalSenderKeyRecord **out, SignalBorrowedBuffer data); + +SignalFfiError *signal_sender_key_record_serialize(SignalOwnedBuffer *out, const SignalSenderKeyRecord *obj); + +SignalFfiError *signal_server_certificate_deserialize(SignalServerCertificate **out, SignalBorrowedBuffer data); + +SignalFfiError *signal_server_certificate_get_serialized(SignalOwnedBuffer *out, const SignalServerCertificate *obj); + +SignalFfiError *signal_server_certificate_get_certificate(SignalOwnedBuffer *out, const SignalServerCertificate *obj); + +SignalFfiError *signal_server_certificate_get_signature(SignalOwnedBuffer *out, const SignalServerCertificate *obj); + +SignalFfiError *signal_server_certificate_get_key_id(uint32_t *out, const SignalServerCertificate *obj); + +SignalFfiError *signal_server_certificate_get_key(SignalPublicKey **out, const SignalServerCertificate *obj); + +SignalFfiError *signal_server_certificate_new(SignalServerCertificate **out, uint32_t key_id, const SignalPublicKey *server_key, const SignalPrivateKey *trust_root); + +SignalFfiError *signal_sender_certificate_deserialize(SignalSenderCertificate **out, SignalBorrowedBuffer data); + +SignalFfiError *signal_sender_certificate_get_serialized(SignalOwnedBuffer *out, const SignalSenderCertificate *obj); + +SignalFfiError *signal_sender_certificate_get_certificate(SignalOwnedBuffer *out, const SignalSenderCertificate *obj); + +SignalFfiError *signal_sender_certificate_get_signature(SignalOwnedBuffer *out, const SignalSenderCertificate *obj); + +SignalFfiError *signal_sender_certificate_get_sender_uuid(const char **out, const SignalSenderCertificate *obj); + +SignalFfiError *signal_sender_certificate_get_sender_e164(const char **out, const SignalSenderCertificate *obj); + +SignalFfiError *signal_sender_certificate_get_expiration(uint64_t *out, const SignalSenderCertificate *obj); + +SignalFfiError *signal_sender_certificate_get_device_id(uint32_t *out, const SignalSenderCertificate *obj); + +SignalFfiError *signal_sender_certificate_get_key(SignalPublicKey **out, const SignalSenderCertificate *obj); + +SignalFfiError *signal_sender_certificate_validate(bool *out, const SignalSenderCertificate *cert, const SignalPublicKey *key, uint64_t time); + +SignalFfiError *signal_sender_certificate_get_server_certificate(SignalServerCertificate **out, const SignalSenderCertificate *cert); + +SignalFfiError *signal_sender_certificate_new(SignalSenderCertificate **out, const char *sender_uuid, const char *sender_e164, uint32_t sender_device_id, const SignalPublicKey *sender_key, uint64_t expiration, const SignalServerCertificate *signer_cert, const SignalPrivateKey *signer_key); + +SignalFfiError *signal_unidentified_sender_message_content_deserialize(SignalUnidentifiedSenderMessageContent **out, SignalBorrowedBuffer data); + +SignalFfiError *signal_unidentified_sender_message_content_serialize(SignalOwnedBuffer *out, const SignalUnidentifiedSenderMessageContent *obj); + +SignalFfiError *signal_unidentified_sender_message_content_get_contents(SignalOwnedBuffer *out, const SignalUnidentifiedSenderMessageContent *obj); + +SignalFfiError *signal_unidentified_sender_message_content_get_group_id_or_empty(SignalOwnedBuffer *out, const SignalUnidentifiedSenderMessageContent *m); + +SignalFfiError *signal_unidentified_sender_message_content_get_sender_cert(SignalSenderCertificate **out, const SignalUnidentifiedSenderMessageContent *m); + +SignalFfiError *signal_unidentified_sender_message_content_get_msg_type(uint8_t *out, const SignalUnidentifiedSenderMessageContent *m); + +SignalFfiError *signal_unidentified_sender_message_content_get_content_hint(uint32_t *out, const SignalUnidentifiedSenderMessageContent *m); + +SignalFfiError *signal_unidentified_sender_message_content_new(SignalUnidentifiedSenderMessageContent **out, const SignalCiphertextMessage *message, const SignalSenderCertificate *sender, uint32_t content_hint, SignalBorrowedBuffer group_id); + +SignalFfiError *signal_ciphertext_message_type(uint8_t *out, const SignalCiphertextMessage *msg); + +SignalFfiError *signal_ciphertext_message_serialize(SignalOwnedBuffer *out, const SignalCiphertextMessage *obj); + +SignalFfiError *signal_ciphertext_message_from_plaintext_content(SignalCiphertextMessage **out, const SignalPlaintextContent *m); + +SignalFfiError *signal_session_record_archive_current_state(SignalSessionRecord *session_record); + +SignalFfiError *signal_session_record_has_usable_sender_chain(bool *out, const SignalSessionRecord *s, uint64_t now); + +SignalFfiError *signal_session_record_current_ratchet_key_matches(bool *out, const SignalSessionRecord *s, const SignalPublicKey *key); + +SignalFfiError *signal_session_record_deserialize(SignalSessionRecord **out, SignalBorrowedBuffer data); + +SignalFfiError *signal_session_record_serialize(SignalOwnedBuffer *out, const SignalSessionRecord *obj); + +SignalFfiError *signal_session_record_get_local_registration_id(uint32_t *out, const SignalSessionRecord *obj); + +SignalFfiError *signal_session_record_get_remote_registration_id(uint32_t *out, const SignalSessionRecord *obj); + +SignalFfiError *signal_process_prekey_bundle(const SignalPreKeyBundle *bundle, const SignalProtocolAddress *protocol_address, const SignalSessionStore *session_store, const SignalIdentityKeyStore *identity_key_store, uint64_t now); + +SignalFfiError *signal_encrypt_message(SignalCiphertextMessage **out, SignalBorrowedBuffer ptext, const SignalProtocolAddress *protocol_address, const SignalSessionStore *session_store, const SignalIdentityKeyStore *identity_key_store, uint64_t now); + +SignalFfiError *signal_decrypt_message(SignalOwnedBuffer *out, const SignalMessage *message, const SignalProtocolAddress *protocol_address, const SignalSessionStore *session_store, const SignalIdentityKeyStore *identity_key_store); + +SignalFfiError *signal_decrypt_pre_key_message(SignalOwnedBuffer *out, const SignalPreKeySignalMessage *message, const SignalProtocolAddress *protocol_address, const SignalSessionStore *session_store, const SignalIdentityKeyStore *identity_key_store, const SignalPreKeyStore *prekey_store, const SignalSignedPreKeyStore *signed_prekey_store, const SignalKyberPreKeyStore *kyber_prekey_store); + +SignalFfiError *signal_sealed_session_cipher_encrypt(SignalOwnedBuffer *out, const SignalProtocolAddress *destination, const SignalUnidentifiedSenderMessageContent *content, const SignalIdentityKeyStore *identity_key_store); + +SignalFfiError *signal_sealed_sender_multi_recipient_encrypt(SignalOwnedBuffer *out, SignalBorrowedSliceOfProtocolAddress recipients, SignalBorrowedSliceOfSessionRecord recipient_sessions, const SignalUnidentifiedSenderMessageContent *content, const SignalIdentityKeyStore *identity_key_store); + +SignalFfiError *signal_sealed_sender_multi_recipient_message_for_single_recipient(SignalOwnedBuffer *out, SignalBorrowedBuffer encoded_multi_recipient_message); + +SignalFfiError *signal_sealed_session_cipher_decrypt_to_usmc(SignalUnidentifiedSenderMessageContent **out, SignalBorrowedBuffer ctext, const SignalIdentityKeyStore *identity_store); + +SignalFfiError *signal_sender_key_distribution_message_create(SignalSenderKeyDistributionMessage **out, const SignalProtocolAddress *sender, const uint8_t (*distribution_id)[16], const SignalSenderKeyStore *store); + +SignalFfiError *signal_process_sender_key_distribution_message(const SignalProtocolAddress *sender, const SignalSenderKeyDistributionMessage *sender_key_distribution_message, const SignalSenderKeyStore *store); + +SignalFfiError *signal_group_encrypt_message(SignalCiphertextMessage **out, const SignalProtocolAddress *sender, const uint8_t (*distribution_id)[16], SignalBorrowedBuffer message, const SignalSenderKeyStore *store); + +SignalFfiError *signal_group_decrypt_message(SignalOwnedBuffer *out, const SignalProtocolAddress *sender, SignalBorrowedBuffer message, const SignalSenderKeyStore *store); + +SignalFfiError *signal_device_transfer_generate_private_key(SignalOwnedBuffer *out); + +SignalFfiError *signal_device_transfer_generate_private_key_with_format(SignalOwnedBuffer *out, uint8_t key_format); + +SignalFfiError *signal_device_transfer_generate_certificate(SignalOwnedBuffer *out, SignalBorrowedBuffer private_key, const char *name, uint32_t days_to_expire); + +SignalFfiError *signal_cds2_client_state_new(SignalSgxClientState **out, SignalBorrowedBuffer mrenclave, SignalBorrowedBuffer attestation_msg, uint64_t current_timestamp); + +SignalFfiError *signal_sgx_client_state_destroy(SignalSgxClientState *p); + +SignalFfiError *signal_sgx_client_state_initial_request(SignalOwnedBuffer *out, const SignalSgxClientState *obj); + +SignalFfiError *signal_sgx_client_state_complete_handshake(SignalSgxClientState *cli, SignalBorrowedBuffer handshake_received); + +SignalFfiError *signal_sgx_client_state_established_send(SignalOwnedBuffer *out, SignalSgxClientState *cli, SignalBorrowedBuffer plaintext_to_send); + +SignalFfiError *signal_sgx_client_state_established_recv(SignalOwnedBuffer *out, SignalSgxClientState *cli, SignalBorrowedBuffer received_ciphertext); + +SignalFfiError *signal_hsm_enclave_client_destroy(SignalHsmEnclaveClient *p); + +SignalFfiError *signal_hsm_enclave_client_new(SignalHsmEnclaveClient **out, SignalBorrowedBuffer trusted_public_key, SignalBorrowedBuffer trusted_code_hashes); + +SignalFfiError *signal_hsm_enclave_client_initial_request(SignalOwnedBuffer *out, const SignalHsmEnclaveClient *obj); + +SignalFfiError *signal_hsm_enclave_client_complete_handshake(SignalHsmEnclaveClient *cli, SignalBorrowedBuffer handshake_received); + +SignalFfiError *signal_hsm_enclave_client_established_send(SignalOwnedBuffer *out, SignalHsmEnclaveClient *cli, SignalBorrowedBuffer plaintext_to_send); + +SignalFfiError *signal_hsm_enclave_client_established_recv(SignalOwnedBuffer *out, SignalHsmEnclaveClient *cli, SignalBorrowedBuffer received_ciphertext); + +SignalFfiError *signal_auth_credential_check_valid_contents(SignalBorrowedBuffer buffer); + +SignalFfiError *signal_auth_credential_response_check_valid_contents(SignalBorrowedBuffer buffer); + +SignalFfiError *signal_auth_credential_with_pni_check_valid_contents(SignalBorrowedBuffer buffer); + +SignalFfiError *signal_auth_credential_with_pni_response_check_valid_contents(SignalBorrowedBuffer buffer); + +SignalFfiError *signal_expiring_profile_key_credential_check_valid_contents(SignalBorrowedBuffer buffer); + +SignalFfiError *signal_expiring_profile_key_credential_response_check_valid_contents(SignalBorrowedBuffer buffer); + +SignalFfiError *signal_group_master_key_check_valid_contents(SignalBorrowedBuffer buffer); + +SignalFfiError *signal_group_public_params_check_valid_contents(SignalBorrowedBuffer buffer); + +SignalFfiError *signal_group_secret_params_check_valid_contents(SignalBorrowedBuffer buffer); + +SignalFfiError *signal_profile_key_check_valid_contents(SignalBorrowedBuffer buffer); + +SignalFfiError *signal_profile_key_ciphertext_check_valid_contents(SignalBorrowedBuffer buffer); + +SignalFfiError *signal_profile_key_commitment_check_valid_contents(SignalBorrowedBuffer buffer); + +SignalFfiError *signal_profile_key_credential_request_check_valid_contents(SignalBorrowedBuffer buffer); + +SignalFfiError *signal_profile_key_credential_request_context_check_valid_contents(SignalBorrowedBuffer buffer); + +SignalFfiError *signal_receipt_credential_check_valid_contents(SignalBorrowedBuffer buffer); + +SignalFfiError *signal_receipt_credential_presentation_check_valid_contents(SignalBorrowedBuffer buffer); + +SignalFfiError *signal_receipt_credential_request_check_valid_contents(SignalBorrowedBuffer buffer); + +SignalFfiError *signal_receipt_credential_request_context_check_valid_contents(SignalBorrowedBuffer buffer); + +SignalFfiError *signal_receipt_credential_response_check_valid_contents(SignalBorrowedBuffer buffer); + +SignalFfiError *signal_server_public_params_check_valid_contents(SignalBorrowedBuffer buffer); + +SignalFfiError *signal_server_secret_params_check_valid_contents(SignalBorrowedBuffer buffer); + +SignalFfiError *signal_uuid_ciphertext_check_valid_contents(SignalBorrowedBuffer buffer); + +SignalFfiError *signal_profile_key_get_commitment(unsigned char (*out)[SignalPROFILE_KEY_COMMITMENT_LEN], const unsigned char (*profile_key)[SignalPROFILE_KEY_LEN], const SignalServiceIdFixedWidthBinaryBytes *user_id); + +SignalFfiError *signal_profile_key_get_profile_key_version(uint8_t (*out)[SignalPROFILE_KEY_VERSION_ENCODED_LEN], const unsigned char (*profile_key)[SignalPROFILE_KEY_LEN], const SignalServiceIdFixedWidthBinaryBytes *user_id); + +SignalFfiError *signal_profile_key_derive_access_key(uint8_t (*out)[SignalACCESS_KEY_LEN], const unsigned char (*profile_key)[SignalPROFILE_KEY_LEN]); + +SignalFfiError *signal_group_secret_params_generate_deterministic(unsigned char (*out)[SignalGROUP_SECRET_PARAMS_LEN], const uint8_t (*randomness)[SignalRANDOMNESS_LEN]); + +SignalFfiError *signal_group_secret_params_derive_from_master_key(unsigned char (*out)[SignalGROUP_SECRET_PARAMS_LEN], const unsigned char (*master_key)[SignalGROUP_MASTER_KEY_LEN]); + +SignalFfiError *signal_group_secret_params_get_master_key(unsigned char (*out)[SignalGROUP_MASTER_KEY_LEN], const unsigned char (*params)[SignalGROUP_SECRET_PARAMS_LEN]); + +SignalFfiError *signal_group_secret_params_get_public_params(unsigned char (*out)[SignalGROUP_PUBLIC_PARAMS_LEN], const unsigned char (*params)[SignalGROUP_SECRET_PARAMS_LEN]); + +SignalFfiError *signal_group_secret_params_encrypt_service_id(unsigned char (*out)[SignalUUID_CIPHERTEXT_LEN], const unsigned char (*params)[SignalGROUP_SECRET_PARAMS_LEN], const SignalServiceIdFixedWidthBinaryBytes *service_id); + +SignalFfiError *signal_group_secret_params_decrypt_service_id(SignalServiceIdFixedWidthBinaryBytes *out, const unsigned char (*params)[SignalGROUP_SECRET_PARAMS_LEN], const unsigned char (*ciphertext)[SignalUUID_CIPHERTEXT_LEN]); + +SignalFfiError *signal_group_secret_params_encrypt_profile_key(unsigned char (*out)[SignalPROFILE_KEY_CIPHERTEXT_LEN], const unsigned char (*params)[SignalGROUP_SECRET_PARAMS_LEN], const unsigned char (*profile_key)[SignalPROFILE_KEY_LEN], const SignalServiceIdFixedWidthBinaryBytes *user_id); + +SignalFfiError *signal_group_secret_params_decrypt_profile_key(unsigned char (*out)[SignalPROFILE_KEY_LEN], const unsigned char (*params)[SignalGROUP_SECRET_PARAMS_LEN], const unsigned char (*profile_key)[SignalPROFILE_KEY_CIPHERTEXT_LEN], const SignalServiceIdFixedWidthBinaryBytes *user_id); + +SignalFfiError *signal_group_secret_params_encrypt_blob_with_padding_deterministic(SignalOwnedBuffer *out, const unsigned char (*params)[SignalGROUP_SECRET_PARAMS_LEN], const uint8_t (*randomness)[SignalRANDOMNESS_LEN], SignalBorrowedBuffer plaintext, uint32_t padding_len); + +SignalFfiError *signal_group_secret_params_decrypt_blob_with_padding(SignalOwnedBuffer *out, const unsigned char (*params)[SignalGROUP_SECRET_PARAMS_LEN], SignalBorrowedBuffer ciphertext); + +SignalFfiError *signal_server_secret_params_generate_deterministic(unsigned char (*out)[SignalSERVER_SECRET_PARAMS_LEN], const uint8_t (*randomness)[SignalRANDOMNESS_LEN]); + +SignalFfiError *signal_server_secret_params_get_public_params(unsigned char (*out)[SignalSERVER_PUBLIC_PARAMS_LEN], const unsigned char (*params)[SignalSERVER_SECRET_PARAMS_LEN]); + +SignalFfiError *signal_server_secret_params_sign_deterministic(uint8_t (*out)[SignalSIGNATURE_LEN], const unsigned char (*params)[SignalSERVER_SECRET_PARAMS_LEN], const uint8_t (*randomness)[SignalRANDOMNESS_LEN], SignalBorrowedBuffer message); + +SignalFfiError *signal_server_public_params_receive_auth_credential(unsigned char (*out)[SignalAUTH_CREDENTIAL_LEN], const unsigned char (*params)[SignalSERVER_PUBLIC_PARAMS_LEN], const SignalServiceIdFixedWidthBinaryBytes *aci, uint32_t redemption_time, const unsigned char (*response)[SignalAUTH_CREDENTIAL_RESPONSE_LEN]); + +SignalFfiError *signal_server_public_params_receive_auth_credential_with_pni_as_service_id(unsigned char (*out)[SignalAUTH_CREDENTIAL_WITH_PNI_LEN], const unsigned char (*params)[SignalSERVER_PUBLIC_PARAMS_LEN], const SignalServiceIdFixedWidthBinaryBytes *aci, const SignalServiceIdFixedWidthBinaryBytes *pni, uint64_t redemption_time, const unsigned char (*response)[SignalAUTH_CREDENTIAL_WITH_PNI_RESPONSE_LEN]); + +SignalFfiError *signal_server_public_params_receive_auth_credential_with_pni_as_aci(unsigned char (*out)[SignalAUTH_CREDENTIAL_WITH_PNI_LEN], const unsigned char (*params)[SignalSERVER_PUBLIC_PARAMS_LEN], const SignalServiceIdFixedWidthBinaryBytes *aci, const SignalServiceIdFixedWidthBinaryBytes *pni, uint64_t redemption_time, const unsigned char (*response)[SignalAUTH_CREDENTIAL_WITH_PNI_RESPONSE_LEN]); + +SignalFfiError *signal_server_public_params_create_auth_credential_presentation_deterministic(SignalOwnedBuffer *out, const unsigned char (*server_public_params)[SignalSERVER_PUBLIC_PARAMS_LEN], const uint8_t (*randomness)[SignalRANDOMNESS_LEN], const unsigned char (*group_secret_params)[SignalGROUP_SECRET_PARAMS_LEN], const unsigned char (*auth_credential)[SignalAUTH_CREDENTIAL_LEN]); + +SignalFfiError *signal_server_public_params_create_auth_credential_with_pni_presentation_deterministic(SignalOwnedBuffer *out, const unsigned char (*server_public_params)[SignalSERVER_PUBLIC_PARAMS_LEN], const uint8_t (*randomness)[SignalRANDOMNESS_LEN], const unsigned char (*group_secret_params)[SignalGROUP_SECRET_PARAMS_LEN], const unsigned char (*auth_credential)[SignalAUTH_CREDENTIAL_WITH_PNI_LEN]); + +SignalFfiError *signal_server_public_params_create_profile_key_credential_request_context_deterministic(unsigned char (*out)[SignalPROFILE_KEY_CREDENTIAL_REQUEST_CONTEXT_LEN], const unsigned char (*server_public_params)[SignalSERVER_PUBLIC_PARAMS_LEN], const uint8_t (*randomness)[SignalRANDOMNESS_LEN], const SignalServiceIdFixedWidthBinaryBytes *user_id, const unsigned char (*profile_key)[SignalPROFILE_KEY_LEN]); + +SignalFfiError *signal_server_public_params_receive_expiring_profile_key_credential(unsigned char (*out)[SignalEXPIRING_PROFILE_KEY_CREDENTIAL_LEN], const unsigned char (*server_public_params)[SignalSERVER_PUBLIC_PARAMS_LEN], const unsigned char (*request_context)[SignalPROFILE_KEY_CREDENTIAL_REQUEST_CONTEXT_LEN], const unsigned char (*response)[SignalEXPIRING_PROFILE_KEY_CREDENTIAL_RESPONSE_LEN], uint64_t current_time_in_seconds); + +SignalFfiError *signal_server_public_params_create_expiring_profile_key_credential_presentation_deterministic(SignalOwnedBuffer *out, const unsigned char (*server_public_params)[SignalSERVER_PUBLIC_PARAMS_LEN], const uint8_t (*randomness)[SignalRANDOMNESS_LEN], const unsigned char (*group_secret_params)[SignalGROUP_SECRET_PARAMS_LEN], const unsigned char (*profile_key_credential)[SignalEXPIRING_PROFILE_KEY_CREDENTIAL_LEN]); + +SignalFfiError *signal_server_public_params_create_receipt_credential_request_context_deterministic(unsigned char (*out)[SignalRECEIPT_CREDENTIAL_REQUEST_CONTEXT_LEN], const unsigned char (*server_public_params)[SignalSERVER_PUBLIC_PARAMS_LEN], const uint8_t (*randomness)[SignalRANDOMNESS_LEN], const uint8_t (*receipt_serial)[SignalRECEIPT_SERIAL_LEN]); + +SignalFfiError *signal_server_public_params_receive_receipt_credential(unsigned char (*out)[SignalRECEIPT_CREDENTIAL_LEN], const unsigned char (*server_public_params)[SignalSERVER_PUBLIC_PARAMS_LEN], const unsigned char (*request_context)[SignalRECEIPT_CREDENTIAL_REQUEST_CONTEXT_LEN], const unsigned char (*response)[SignalRECEIPT_CREDENTIAL_RESPONSE_LEN]); + +SignalFfiError *signal_server_public_params_create_receipt_credential_presentation_deterministic(unsigned char (*out)[SignalRECEIPT_CREDENTIAL_PRESENTATION_LEN], const unsigned char (*server_public_params)[SignalSERVER_PUBLIC_PARAMS_LEN], const uint8_t (*randomness)[SignalRANDOMNESS_LEN], const unsigned char (*receipt_credential)[SignalRECEIPT_CREDENTIAL_LEN]); + +SignalFfiError *signal_server_secret_params_issue_auth_credential_deterministic(unsigned char (*out)[SignalAUTH_CREDENTIAL_RESPONSE_LEN], const unsigned char (*server_secret_params)[SignalSERVER_SECRET_PARAMS_LEN], const uint8_t (*randomness)[SignalRANDOMNESS_LEN], const SignalServiceIdFixedWidthBinaryBytes *aci, uint32_t redemption_time); + +SignalFfiError *signal_server_secret_params_issue_auth_credential_with_pni_as_service_id_deterministic(unsigned char (*out)[SignalAUTH_CREDENTIAL_WITH_PNI_RESPONSE_LEN], const unsigned char (*server_secret_params)[SignalSERVER_SECRET_PARAMS_LEN], const uint8_t (*randomness)[SignalRANDOMNESS_LEN], const SignalServiceIdFixedWidthBinaryBytes *aci, const SignalServiceIdFixedWidthBinaryBytes *pni, uint64_t redemption_time); + +SignalFfiError *signal_server_secret_params_issue_auth_credential_with_pni_as_aci_deterministic(unsigned char (*out)[SignalAUTH_CREDENTIAL_WITH_PNI_RESPONSE_LEN], const unsigned char (*server_secret_params)[SignalSERVER_SECRET_PARAMS_LEN], const uint8_t (*randomness)[SignalRANDOMNESS_LEN], const SignalServiceIdFixedWidthBinaryBytes *aci, const SignalServiceIdFixedWidthBinaryBytes *pni, uint64_t redemption_time); + +SignalFfiError *signal_server_secret_params_verify_auth_credential_presentation(const unsigned char (*server_secret_params)[SignalSERVER_SECRET_PARAMS_LEN], const unsigned char (*group_public_params)[SignalGROUP_PUBLIC_PARAMS_LEN], SignalBorrowedBuffer presentation_bytes, uint64_t current_time_in_seconds); + +SignalFfiError *signal_server_secret_params_issue_expiring_profile_key_credential_deterministic(unsigned char (*out)[SignalEXPIRING_PROFILE_KEY_CREDENTIAL_RESPONSE_LEN], const unsigned char (*server_secret_params)[SignalSERVER_SECRET_PARAMS_LEN], const uint8_t (*randomness)[SignalRANDOMNESS_LEN], const unsigned char (*request)[SignalPROFILE_KEY_CREDENTIAL_REQUEST_LEN], const SignalServiceIdFixedWidthBinaryBytes *user_id, const unsigned char (*commitment)[SignalPROFILE_KEY_COMMITMENT_LEN], uint64_t expiration_in_seconds); + +SignalFfiError *signal_server_secret_params_verify_profile_key_credential_presentation(const unsigned char (*server_secret_params)[SignalSERVER_SECRET_PARAMS_LEN], const unsigned char (*group_public_params)[SignalGROUP_PUBLIC_PARAMS_LEN], SignalBorrowedBuffer presentation_bytes, uint64_t current_time_in_seconds); + +SignalFfiError *signal_server_secret_params_issue_receipt_credential_deterministic(unsigned char (*out)[SignalRECEIPT_CREDENTIAL_RESPONSE_LEN], const unsigned char (*server_secret_params)[SignalSERVER_SECRET_PARAMS_LEN], const uint8_t (*randomness)[SignalRANDOMNESS_LEN], const unsigned char (*request)[SignalRECEIPT_CREDENTIAL_REQUEST_LEN], uint64_t receipt_expiration_time, uint64_t receipt_level); + +SignalFfiError *signal_server_secret_params_verify_receipt_credential_presentation(const unsigned char (*server_secret_params)[SignalSERVER_SECRET_PARAMS_LEN], const unsigned char (*presentation)[SignalRECEIPT_CREDENTIAL_PRESENTATION_LEN]); + +SignalFfiError *signal_group_public_params_get_group_identifier(uint8_t (*out)[SignalGROUP_IDENTIFIER_LEN], const unsigned char (*group_public_params)[SignalGROUP_PUBLIC_PARAMS_LEN]); + +SignalFfiError *signal_server_public_params_verify_signature(const unsigned char (*server_public_params)[SignalSERVER_PUBLIC_PARAMS_LEN], SignalBorrowedBuffer message, const uint8_t (*notary_signature)[SignalSIGNATURE_LEN]); SignalFfiError *signal_auth_credential_presentation_check_valid_contents(SignalBorrowedBuffer presentation_bytes); -SignalFfiError *signal_auth_credential_presentation_get_pni_ciphertext(unsigned char (*out)[SignalUUID_CIPHERTEXT_LEN], SignalBorrowedBuffer presentation_bytes); +SignalFfiError *signal_auth_credential_presentation_get_uuid_ciphertext(unsigned char (*out)[SignalUUID_CIPHERTEXT_LEN], SignalBorrowedBuffer presentation_bytes); + +SignalFfiError *signal_auth_credential_presentation_get_pni_ciphertext_or_empty(SignalOwnedBuffer *out, SignalBorrowedBuffer presentation_bytes); SignalFfiError *signal_auth_credential_presentation_get_redemption_time(uint64_t *out, SignalBorrowedBuffer presentation_bytes); -SignalFfiError *signal_auth_credential_presentation_get_uuid_ciphertext(unsigned char (*out)[SignalUUID_CIPHERTEXT_LEN], SignalBorrowedBuffer presentation_bytes); +SignalFfiError *signal_profile_key_credential_request_context_get_request(unsigned char (*out)[SignalPROFILE_KEY_CREDENTIAL_REQUEST_LEN], const unsigned char (*context)[SignalPROFILE_KEY_CREDENTIAL_REQUEST_CONTEXT_LEN]); -SignalFfiError *signal_auth_credential_with_pni_check_valid_contents(SignalBorrowedBuffer bytes); +SignalFfiError *signal_expiring_profile_key_credential_get_expiration_time(uint64_t *out, const unsigned char (*credential)[SignalEXPIRING_PROFILE_KEY_CREDENTIAL_LEN]); -SignalFfiError *signal_auth_credential_with_pni_response_check_valid_contents(SignalBorrowedBuffer bytes); +SignalFfiError *signal_profile_key_credential_presentation_check_valid_contents(SignalBorrowedBuffer presentation_bytes); -SignalFfiError *signal_authenticated_chat_connection_connect(SignalCPromiseMutPointerAuthenticatedChatConnection *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerConnectionManager connection_manager, const char *username, const char *password, bool receive_stories, SignalBorrowedBytestringArray languages); +SignalFfiError *signal_profile_key_credential_presentation_get_uuid_ciphertext(unsigned char (*out)[SignalUUID_CIPHERTEXT_LEN], SignalBorrowedBuffer presentation_bytes); -SignalFfiError *signal_authenticated_chat_connection_destroy(SignalMutPointerAuthenticatedChatConnection p); +SignalFfiError *signal_profile_key_credential_presentation_get_profile_key_ciphertext(unsigned char (*out)[SignalPROFILE_KEY_CIPHERTEXT_LEN], SignalBorrowedBuffer presentation_bytes); -SignalFfiError *signal_authenticated_chat_connection_disconnect(SignalCPromisebool *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerAuthenticatedChatConnection chat); +SignalFfiError *signal_receipt_credential_request_context_get_request(unsigned char (*out)[SignalRECEIPT_CREDENTIAL_REQUEST_LEN], const unsigned char (*request_context)[SignalRECEIPT_CREDENTIAL_REQUEST_CONTEXT_LEN]); -SignalFfiError *signal_authenticated_chat_connection_get_upload_form(SignalCPromiseFfiUploadForm *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerAuthenticatedChatConnection chat, uint64_t upload_length); +SignalFfiError *signal_receipt_credential_get_receipt_expiration_time(uint64_t *out, const unsigned char (*receipt_credential)[SignalRECEIPT_CREDENTIAL_LEN]); -SignalFfiError *signal_authenticated_chat_connection_info(SignalMutPointerChatConnectionInfo *out, SignalConstPointerAuthenticatedChatConnection chat); +SignalFfiError *signal_receipt_credential_get_receipt_level(uint64_t *out, const unsigned char (*receipt_credential)[SignalRECEIPT_CREDENTIAL_LEN]); -SignalFfiError *signal_authenticated_chat_connection_init_listener(SignalConstPointerAuthenticatedChatConnection chat, SignalConstPointerFfiChatListenerStruct listener); +SignalFfiError *signal_receipt_credential_presentation_get_receipt_expiration_time(uint64_t *out, const unsigned char (*presentation)[SignalRECEIPT_CREDENTIAL_PRESENTATION_LEN]); -SignalFfiError *signal_authenticated_chat_connection_preconnect(SignalCPromisebool *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerConnectionManager connection_manager); +SignalFfiError *signal_receipt_credential_presentation_get_receipt_level(uint64_t *out, const unsigned char (*presentation)[SignalRECEIPT_CREDENTIAL_PRESENTATION_LEN]); -SignalFfiError *signal_authenticated_chat_connection_send(SignalCPromiseFfiChatResponse *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerAuthenticatedChatConnection chat, SignalConstPointerHttpRequest http_request, uint32_t timeout_millis); +SignalFfiError *signal_receipt_credential_presentation_get_receipt_serial(uint8_t (*out)[SignalRECEIPT_SERIAL_LEN], const unsigned char (*presentation)[SignalRECEIPT_CREDENTIAL_PRESENTATION_LEN]); -SignalFfiError *signal_authenticated_chat_connection_send_message(SignalCPromisebool *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerAuthenticatedChatConnection chat, const SignalServiceIdFixedWidthBinaryBytes *destination, uint64_t timestamp, SignalBorrowedSliceOfu32 device_ids, SignalBorrowedSliceOfu32 registration_ids, SignalBorrowedSliceOfConstPointerCiphertextMessage contents, bool online_only, bool is_urgent); +SignalFfiError *signal_generic_server_secret_params_check_valid_contents(SignalBorrowedBuffer params_bytes); -SignalFfiError *signal_authenticated_chat_connection_send_sync_message(SignalCPromisebool *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerAuthenticatedChatConnection chat, uint64_t timestamp, SignalBorrowedSliceOfu32 device_ids, SignalBorrowedSliceOfu32 registration_ids, SignalBorrowedSliceOfConstPointerCiphertextMessage contents, bool is_urgent); +SignalFfiError *signal_generic_server_secret_params_generate_deterministic(SignalOwnedBuffer *out, const uint8_t (*randomness)[SignalRANDOMNESS_LEN]); -SignalFfiError *signal_backup_auth_credential_check_valid_contents(SignalBorrowedBuffer params_bytes); +SignalFfiError *signal_generic_server_secret_params_get_public_params(SignalOwnedBuffer *out, SignalBorrowedBuffer params_bytes); -SignalFfiError *signal_backup_auth_credential_get_backup_id(uint8_t (*out)[16], SignalBorrowedBuffer credential_bytes); - -SignalFfiError *signal_backup_auth_credential_get_backup_level(uint8_t *out, SignalBorrowedBuffer credential_bytes); - -SignalFfiError *signal_backup_auth_credential_get_type(uint8_t *out, SignalBorrowedBuffer credential_bytes); - -SignalFfiError *signal_backup_auth_credential_present_deterministic(SignalOwnedBuffer *out, SignalBorrowedBuffer credential_bytes, SignalBorrowedBuffer server_params_bytes, const uint8_t (*randomness)[SignalRANDOMNESS_LEN]); - -SignalFfiError *signal_backup_auth_credential_presentation_check_valid_contents(SignalBorrowedBuffer presentation_bytes); - -SignalFfiError *signal_backup_auth_credential_presentation_verify(SignalBorrowedBuffer presentation_bytes, uint64_t now, SignalBorrowedBuffer server_params_bytes); - -SignalFfiError *signal_backup_auth_credential_request_check_valid_contents(SignalBorrowedBuffer request_bytes); - -SignalFfiError *signal_backup_auth_credential_request_context_check_valid_contents(SignalBorrowedBuffer context_bytes); - -SignalFfiError *signal_backup_auth_credential_request_context_get_request(SignalOwnedBuffer *out, SignalBorrowedBuffer context_bytes); - -SignalFfiError *signal_backup_auth_credential_request_context_new(SignalOwnedBuffer *out, const uint8_t (*backup_key)[32], SignalUuid uuid); - -SignalFfiError *signal_backup_auth_credential_request_context_receive_response(SignalOwnedBuffer *out, SignalBorrowedBuffer context_bytes, SignalBorrowedBuffer response_bytes, uint64_t expected_redemption_time, SignalBorrowedBuffer params_bytes); - -SignalFfiError *signal_backup_auth_credential_request_issue_deterministic(SignalOwnedBuffer *out, SignalBorrowedBuffer request_bytes, uint64_t redemption_time, uint8_t backup_level, uint8_t credential_type, SignalBorrowedBuffer params_bytes, const uint8_t (*randomness)[SignalRANDOMNESS_LEN]); - -SignalFfiError *signal_backup_auth_credential_response_check_valid_contents(SignalBorrowedBuffer response_bytes); - -SignalFfiError *signal_backup_key_derive_backup_id(uint8_t (*out)[16], const uint8_t (*backup_key)[SignalBACKUP_KEY_LEN], const SignalServiceIdFixedWidthBinaryBytes *aci); - -SignalFfiError *signal_backup_key_derive_ec_key(SignalMutPointerPrivateKey *out, const uint8_t (*backup_key)[SignalBACKUP_KEY_LEN], const SignalServiceIdFixedWidthBinaryBytes *aci); - -SignalFfiError *signal_backup_key_derive_local_backup_metadata_key(uint8_t (*out)[SignalLOCAL_BACKUP_METADATA_KEY_LEN], const uint8_t (*backup_key)[SignalBACKUP_KEY_LEN]); - -SignalFfiError *signal_backup_key_derive_media_encryption_key(uint8_t (*out)[SignalMEDIA_ENCRYPTION_KEY_LEN], const uint8_t (*backup_key)[SignalBACKUP_KEY_LEN], const uint8_t (*media_id)[SignalMEDIA_ID_LEN]); - -SignalFfiError *signal_backup_key_derive_media_id(uint8_t (*out)[SignalMEDIA_ID_LEN], const uint8_t (*backup_key)[SignalBACKUP_KEY_LEN], const char *media_name); - -SignalFfiError *signal_backup_key_derive_thumbnail_transit_encryption_key(uint8_t (*out)[SignalMEDIA_ENCRYPTION_KEY_LEN], const uint8_t (*backup_key)[SignalBACKUP_KEY_LEN], const uint8_t (*media_id)[SignalMEDIA_ID_LEN]); - -SignalFfiError *signal_backup_restore_response_destroy(SignalMutPointerBackupRestoreResponse p); - -SignalFfiError *signal_backup_restore_response_get_forward_secrecy_token(uint8_t (*out)[SignalBACKUP_FORWARD_SECRECY_TOKEN_LEN], SignalConstPointerBackupRestoreResponse response); - -SignalFfiError *signal_backup_restore_response_get_next_backup_secret_data(SignalOwnedBuffer *out, SignalConstPointerBackupRestoreResponse response); - -SignalFfiError *signal_backup_store_response_destroy(SignalMutPointerBackupStoreResponse p); - -SignalFfiError *signal_backup_store_response_get_forward_secrecy_token(uint8_t (*out)[SignalBACKUP_FORWARD_SECRECY_TOKEN_LEN], SignalConstPointerBackupStoreResponse response); - -SignalFfiError *signal_backup_store_response_get_next_backup_secret_data(SignalOwnedBuffer *out, SignalConstPointerBackupStoreResponse response); - -SignalFfiError *signal_backup_store_response_get_opaque_metadata(SignalOwnedBuffer *out, SignalConstPointerBackupStoreResponse response); - -SignalFfiError *signal_bridged_string_map_clone(SignalMutPointerBridgedStringMap *new_obj, SignalConstPointerBridgedStringMap obj); - -SignalFfiError *signal_bridged_string_map_destroy(SignalMutPointerBridgedStringMap p); - -SignalFfiError *signal_bridged_string_map_insert(SignalMutPointerBridgedStringMap map, const char *key, const char *value); - -SignalFfiError *signal_bridged_string_map_new(SignalMutPointerBridgedStringMap *out, uint32_t initial_capacity); - -SignalFfiError *signal_call_link_auth_credential_check_valid_contents(SignalBorrowedBuffer credential_bytes); - -SignalFfiError *signal_call_link_auth_credential_present_deterministic(SignalOwnedBuffer *out, SignalBorrowedBuffer credential_bytes, const SignalServiceIdFixedWidthBinaryBytes *user_id, uint64_t redemption_time, SignalBorrowedBuffer server_params_bytes, SignalBorrowedBuffer call_link_params_bytes, const uint8_t (*randomness)[SignalRANDOMNESS_LEN]); - -SignalFfiError *signal_call_link_auth_credential_presentation_check_valid_contents(SignalBorrowedBuffer presentation_bytes); - -SignalFfiError *signal_call_link_auth_credential_presentation_get_user_id(unsigned char (*out)[SignalUUID_CIPHERTEXT_LEN], SignalBorrowedBuffer presentation_bytes); - -SignalFfiError *signal_call_link_auth_credential_presentation_verify(SignalBorrowedBuffer presentation_bytes, uint64_t now, SignalBorrowedBuffer server_params_bytes, SignalBorrowedBuffer call_link_params_bytes); - -SignalFfiError *signal_call_link_auth_credential_response_check_valid_contents(SignalBorrowedBuffer response_bytes); - -SignalFfiError *signal_call_link_auth_credential_response_issue_deterministic(SignalOwnedBuffer *out, const SignalServiceIdFixedWidthBinaryBytes *user_id, uint64_t redemption_time, SignalBorrowedBuffer params_bytes, const uint8_t (*randomness)[SignalRANDOMNESS_LEN]); - -SignalFfiError *signal_call_link_auth_credential_response_receive(SignalOwnedBuffer *out, SignalBorrowedBuffer response_bytes, const SignalServiceIdFixedWidthBinaryBytes *user_id, uint64_t redemption_time, SignalBorrowedBuffer params_bytes); - -SignalFfiError *signal_call_link_public_params_check_valid_contents(SignalBorrowedBuffer params_bytes); +SignalFfiError *signal_generic_server_public_params_check_valid_contents(SignalBorrowedBuffer params_bytes); SignalFfiError *signal_call_link_secret_params_check_valid_contents(SignalBorrowedBuffer params_bytes); -SignalFfiError *signal_call_link_secret_params_decrypt_user_id(SignalServiceIdFixedWidthBinaryBytes *out, SignalBorrowedBuffer params_bytes, const unsigned char (*user_id)[SignalUUID_CIPHERTEXT_LEN]); - SignalFfiError *signal_call_link_secret_params_derive_from_root_key(SignalOwnedBuffer *out, SignalBorrowedBuffer root_key); -SignalFfiError *signal_call_link_secret_params_encrypt_user_id(unsigned char (*out)[SignalUUID_CIPHERTEXT_LEN], SignalBorrowedBuffer params_bytes, const SignalServiceIdFixedWidthBinaryBytes *user_id); - SignalFfiError *signal_call_link_secret_params_get_public_params(SignalOwnedBuffer *out, SignalBorrowedBuffer params_bytes); -SignalFfiError *signal_cds2_client_state_new(SignalMutPointerSgxClientState *out, SignalBorrowedBuffer mrenclave, SignalBorrowedBuffer attestation_msg, uint64_t current_timestamp); +SignalFfiError *signal_call_link_secret_params_decrypt_user_id(SignalServiceIdFixedWidthBinaryBytes *out, SignalBorrowedBuffer params_bytes, const unsigned char (*user_id)[SignalUUID_CIPHERTEXT_LEN]); -SignalFfiError *signal_cdsi_lookup_complete(SignalCPromiseFfiCdsiLookupResponse *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerCdsiLookup lookup); +SignalFfiError *signal_call_link_public_params_check_valid_contents(SignalBorrowedBuffer params_bytes); -SignalFfiError *signal_cdsi_lookup_destroy(SignalMutPointerCdsiLookup p); +SignalFfiError *signal_create_call_link_credential_request_context_check_valid_contents(SignalBorrowedBuffer context_bytes); -SignalFfiError *signal_cdsi_lookup_new(SignalCPromiseMutPointerCdsiLookup *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerConnectionManager connection_manager, const char *username, const char *password, SignalConstPointerLookupRequest request); +SignalFfiError *signal_create_call_link_credential_request_context_new_deterministic(SignalOwnedBuffer *out, SignalBorrowedBuffer room_id, const uint8_t (*randomness)[SignalRANDOMNESS_LEN]); -SignalFfiError *signal_cdsi_lookup_token(SignalOwnedBuffer *out, SignalConstPointerCdsiLookup lookup); +SignalFfiError *signal_create_call_link_credential_request_context_get_request(SignalOwnedBuffer *out, SignalBorrowedBuffer context_bytes); -SignalFfiError *signal_chat_connection_info_description(const char **out, SignalConstPointerChatConnectionInfo connection_info); +SignalFfiError *signal_create_call_link_credential_request_check_valid_contents(SignalBorrowedBuffer request_bytes); -SignalFfiError *signal_chat_connection_info_ip_version(uint8_t *out, SignalConstPointerChatConnectionInfo connection_info); +SignalFfiError *signal_create_call_link_credential_request_issue_deterministic(SignalOwnedBuffer *out, SignalBorrowedBuffer request_bytes, const SignalServiceIdFixedWidthBinaryBytes *user_id, uint64_t timestamp, SignalBorrowedBuffer params_bytes, const uint8_t (*randomness)[SignalRANDOMNESS_LEN]); -SignalFfiError *signal_chat_connection_info_local_port(uint16_t *out, SignalConstPointerChatConnectionInfo connection_info); +SignalFfiError *signal_create_call_link_credential_response_check_valid_contents(SignalBorrowedBuffer response_bytes); -SignalFfiError *signal_ciphertext_message_destroy(SignalMutPointerCiphertextMessage p); - -SignalFfiError *signal_ciphertext_message_from_plaintext_content(SignalMutPointerCiphertextMessage *out, SignalConstPointerPlaintextContent m); - -SignalFfiError *signal_ciphertext_message_serialize(SignalOwnedBuffer *out, SignalConstPointerCiphertextMessage obj); - -SignalFfiError *signal_ciphertext_message_type(uint8_t *out, SignalConstPointerCiphertextMessage msg); - -SignalFfiError *signal_connection_info_destroy(SignalMutPointerConnectionInfo p); - -SignalFfiError *signal_connection_manager_clear_proxy(SignalConstPointerConnectionManager connection_manager); - -SignalFfiError *signal_connection_manager_destroy(SignalMutPointerConnectionManager p); - -SignalFfiError *signal_connection_manager_new(SignalMutPointerConnectionManager *out, uint8_t environment, const char *user_agent, SignalMutPointerBridgedStringMap remote_config, uint8_t build_variant); - -SignalFfiError *signal_connection_manager_on_network_change(SignalConstPointerConnectionManager connection_manager); - -SignalFfiError *signal_connection_manager_set_censorship_circumvention_enabled(SignalConstPointerConnectionManager connection_manager, bool enabled); - -SignalFfiError *signal_connection_manager_set_invalid_proxy(SignalConstPointerConnectionManager connection_manager); - -SignalFfiError *signal_connection_manager_set_proxy(SignalConstPointerConnectionManager connection_manager, SignalConstPointerConnectionProxyConfig proxy); - -SignalFfiError *signal_connection_manager_set_remote_config(SignalConstPointerConnectionManager connection_manager, SignalMutPointerBridgedStringMap remote_config, uint8_t build_variant); - -SignalFfiError *signal_connection_proxy_config_clone(SignalMutPointerConnectionProxyConfig *new_obj, SignalConstPointerConnectionProxyConfig obj); - -SignalFfiError *signal_connection_proxy_config_destroy(SignalMutPointerConnectionProxyConfig p); - -SignalFfiError *signal_connection_proxy_config_new(SignalMutPointerConnectionProxyConfig *out, const char *scheme, const char *host, int32_t port, const char *username, const char *password); +SignalFfiError *signal_create_call_link_credential_request_context_receive_response(SignalOwnedBuffer *out, SignalBorrowedBuffer context_bytes, SignalBorrowedBuffer response_bytes, const SignalServiceIdFixedWidthBinaryBytes *user_id, SignalBorrowedBuffer params_bytes); SignalFfiError *signal_create_call_link_credential_check_valid_contents(SignalBorrowedBuffer params_bytes); @@ -1886,951 +1136,184 @@ SignalFfiError *signal_create_call_link_credential_presentation_check_valid_cont SignalFfiError *signal_create_call_link_credential_presentation_verify(SignalBorrowedBuffer presentation_bytes, SignalBorrowedBuffer room_id, uint64_t now, SignalBorrowedBuffer server_params_bytes, SignalBorrowedBuffer call_link_params_bytes); -SignalFfiError *signal_create_call_link_credential_request_check_valid_contents(SignalBorrowedBuffer request_bytes); +SignalFfiError *signal_call_link_auth_credential_response_check_valid_contents(SignalBorrowedBuffer response_bytes); -SignalFfiError *signal_create_call_link_credential_request_context_check_valid_contents(SignalBorrowedBuffer context_bytes); +SignalFfiError *signal_call_link_auth_credential_response_issue_deterministic(SignalOwnedBuffer *out, const SignalServiceIdFixedWidthBinaryBytes *user_id, uint64_t redemption_time, SignalBorrowedBuffer params_bytes, const uint8_t (*randomness)[SignalRANDOMNESS_LEN]); -SignalFfiError *signal_create_call_link_credential_request_context_get_request(SignalOwnedBuffer *out, SignalBorrowedBuffer context_bytes); +SignalFfiError *signal_call_link_auth_credential_response_receive(SignalOwnedBuffer *out, SignalBorrowedBuffer response_bytes, const SignalServiceIdFixedWidthBinaryBytes *user_id, uint64_t redemption_time, SignalBorrowedBuffer params_bytes); -SignalFfiError *signal_create_call_link_credential_request_context_new_deterministic(SignalOwnedBuffer *out, SignalBorrowedBuffer room_id, const uint8_t (*randomness)[SignalRANDOMNESS_LEN]); +SignalFfiError *signal_call_link_auth_credential_check_valid_contents(SignalBorrowedBuffer credential_bytes); -SignalFfiError *signal_create_call_link_credential_request_context_receive_response(SignalOwnedBuffer *out, SignalBorrowedBuffer context_bytes, SignalBorrowedBuffer response_bytes, const SignalServiceIdFixedWidthBinaryBytes *user_id, SignalBorrowedBuffer params_bytes); +SignalFfiError *signal_call_link_auth_credential_present_deterministic(SignalOwnedBuffer *out, SignalBorrowedBuffer credential_bytes, const SignalServiceIdFixedWidthBinaryBytes *user_id, uint64_t redemption_time, SignalBorrowedBuffer server_params_bytes, SignalBorrowedBuffer call_link_params_bytes, const uint8_t (*randomness)[SignalRANDOMNESS_LEN]); -SignalFfiError *signal_create_call_link_credential_request_issue_deterministic(SignalOwnedBuffer *out, SignalBorrowedBuffer request_bytes, const SignalServiceIdFixedWidthBinaryBytes *user_id, uint64_t timestamp, SignalBorrowedBuffer params_bytes, const uint8_t (*randomness)[SignalRANDOMNESS_LEN]); +SignalFfiError *signal_call_link_auth_credential_presentation_check_valid_contents(SignalBorrowedBuffer presentation_bytes); -SignalFfiError *signal_create_call_link_credential_response_check_valid_contents(SignalBorrowedBuffer response_bytes); +SignalFfiError *signal_call_link_auth_credential_presentation_verify(SignalBorrowedBuffer presentation_bytes, uint64_t now, SignalBorrowedBuffer server_params_bytes, SignalBorrowedBuffer call_link_params_bytes); -SignalFfiError *signal_decrypt_message(SignalOwnedBuffer *out, SignalConstPointerSignalMessage message, SignalConstPointerProtocolAddress protocol_address, SignalConstPointerProtocolAddress local_address, SignalConstPointerFfiSessionStoreStruct session_store, SignalConstPointerFfiIdentityKeyStoreStruct identity_key_store); +SignalFfiError *signal_call_link_auth_credential_presentation_get_user_id(unsigned char (*out)[SignalUUID_CIPHERTEXT_LEN], SignalBorrowedBuffer presentation_bytes); -SignalFfiError *signal_decrypt_pre_key_message(SignalOwnedBuffer *out, SignalConstPointerPreKeySignalMessage message, SignalConstPointerProtocolAddress protocol_address, SignalConstPointerProtocolAddress local_address, SignalConstPointerFfiSessionStoreStruct session_store, SignalConstPointerFfiIdentityKeyStoreStruct identity_key_store, SignalConstPointerFfiPreKeyStoreStruct prekey_store, SignalConstPointerFfiSignedPreKeyStoreStruct signed_prekey_store, SignalConstPointerFfiKyberPreKeyStoreStruct kyber_prekey_store); +SignalFfiError *signal_backup_auth_credential_request_context_new(SignalOwnedBuffer *out, const uint8_t (*backup_key)[32], const uint8_t (*uuid)[16]); -SignalFfiError *signal_decryption_error_message_clone(SignalMutPointerDecryptionErrorMessage *new_obj, SignalConstPointerDecryptionErrorMessage obj); +SignalFfiError *signal_backup_auth_credential_request_context_check_valid_contents(SignalBorrowedBuffer context_bytes); -SignalFfiError *signal_decryption_error_message_deserialize(SignalMutPointerDecryptionErrorMessage *out, SignalBorrowedBuffer data); +SignalFfiError *signal_backup_auth_credential_request_context_get_request(SignalOwnedBuffer *out, SignalBorrowedBuffer context_bytes); -SignalFfiError *signal_decryption_error_message_destroy(SignalMutPointerDecryptionErrorMessage p); +SignalFfiError *signal_backup_auth_credential_request_check_valid_contents(SignalBorrowedBuffer request_bytes); -SignalFfiError *signal_decryption_error_message_extract_from_serialized_content(SignalMutPointerDecryptionErrorMessage *out, SignalBorrowedBuffer bytes); +SignalFfiError *signal_backup_auth_credential_request_issue_deterministic(SignalOwnedBuffer *out, SignalBorrowedBuffer request_bytes, uint64_t redemption_time, uint64_t receipt_level, SignalBorrowedBuffer params_bytes, const uint8_t (*randomness)[SignalRANDOMNESS_LEN]); -SignalFfiError *signal_decryption_error_message_for_original_message(SignalMutPointerDecryptionErrorMessage *out, SignalBorrowedBuffer original_bytes, uint8_t original_type, uint64_t original_timestamp, uint32_t original_sender_device_id); +SignalFfiError *signal_backup_auth_credential_response_check_valid_contents(SignalBorrowedBuffer response_bytes); -SignalFfiError *signal_decryption_error_message_get_device_id(uint32_t *out, SignalConstPointerDecryptionErrorMessage obj); +SignalFfiError *signal_backup_auth_credential_request_context_receive_response(SignalOwnedBuffer *out, SignalBorrowedBuffer context_bytes, SignalBorrowedBuffer response_bytes, SignalBorrowedBuffer params_bytes, uint64_t expected_receipt_level); -SignalFfiError *signal_decryption_error_message_get_ratchet_key(SignalMutPointerPublicKey *out, SignalConstPointerDecryptionErrorMessage m); +SignalFfiError *signal_backup_auth_credential_check_valid_contents(SignalBorrowedBuffer params_bytes); -SignalFfiError *signal_decryption_error_message_get_timestamp(uint64_t *out, SignalConstPointerDecryptionErrorMessage obj); +SignalFfiError *signal_backup_auth_credential_get_backup_id(uint8_t (*out)[16], SignalBorrowedBuffer credential_bytes); -SignalFfiError *signal_decryption_error_message_serialize(SignalOwnedBuffer *out, SignalConstPointerDecryptionErrorMessage obj); +SignalFfiError *signal_backup_auth_credential_present_deterministic(SignalOwnedBuffer *out, SignalBorrowedBuffer credential_bytes, SignalBorrowedBuffer server_params_bytes, const uint8_t (*randomness)[SignalRANDOMNESS_LEN]); -SignalFfiError *signal_device_transfer_generate_certificate(SignalOwnedBuffer *out, SignalBorrowedBuffer private_key, const char *name, uint32_t days_to_expire); +SignalFfiError *signal_backup_auth_credential_presentation_check_valid_contents(SignalBorrowedBuffer presentation_bytes); -SignalFfiError *signal_device_transfer_generate_private_key(SignalOwnedBuffer *out); +SignalFfiError *signal_backup_auth_credential_presentation_verify(SignalBorrowedBuffer presentation_bytes, uint64_t now, SignalBorrowedBuffer server_params_bytes); -SignalFfiError *signal_device_transfer_generate_private_key_with_format(SignalOwnedBuffer *out, uint8_t key_format); +SignalFfiError *signal_verify_signature(bool *out, SignalBorrowedBuffer cert_pem, SignalBorrowedBuffer body, SignalBorrowedBuffer signature, uint64_t current_timestamp); -SignalFfiError *signal_encrypt_message(SignalMutPointerCiphertextMessage *out, SignalBorrowedBuffer ptext, SignalConstPointerProtocolAddress protocol_address, SignalConstPointerProtocolAddress local_address, SignalConstPointerFfiSessionStoreStruct session_store, SignalConstPointerFfiIdentityKeyStoreStruct identity_key_store, uint64_t now); +SignalFfiError *signal_pin_hash_destroy(SignalPinHash *p); -void signal_error_free(SignalFfiError *err); +SignalFfiError *signal_pin_hash_clone(SignalPinHash **new_obj, const SignalPinHash *obj); -SignalFfiError *signal_error_get_address(SignalMutPointerProtocolAddress *out, SignalUnwindSafeArgSignalFfiError err); +SignalFfiError *signal_pin_hash_encryption_key(uint8_t (*out)[32], const SignalPinHash *ph); -SignalFfiError *signal_error_get_invalid_protocol_address(SignalPairOfc_charu32 *out, SignalUnwindSafeArgSignalFfiError err); +SignalFfiError *signal_pin_hash_access_key(uint8_t (*out)[32], const SignalPinHash *ph); -SignalFfiError *signal_error_get_message(const char **out, SignalUnwindSafeArgSignalFfiError err); +SignalFfiError *signal_pin_hash_from_salt(SignalPinHash **out, SignalBorrowedBuffer pin, const uint8_t (*salt)[32]); -SignalFfiError *signal_error_get_mismatched_device_errors(SignalOwnedBufferOfFfiMismatchedDevicesError *out, SignalUnwindSafeArgSignalFfiError err); - -SignalFfiError *signal_error_get_our_fingerprint_version(uint32_t *out, SignalUnwindSafeArgSignalFfiError err); - -SignalFfiError *signal_error_get_rate_limit_challenge(SignalPairOfPairOfc_charOwnedBufferOfc_uchari64 *out, SignalUnwindSafeArgSignalFfiError err); - -SignalFfiError *signal_error_get_registration_error_not_deliverable(SignalPairOfc_charbool *out, SignalUnwindSafeArgSignalFfiError err); - -SignalFfiError *signal_error_get_registration_lock(uint64_t *out_time_remaining_seconds, const char **out_svr2_username, const char **out_svr2_password, const SignalFfiError *err); - -SignalFfiError *signal_error_get_retry_after_seconds(uint32_t *out, SignalUnwindSafeArgSignalFfiError err); - -SignalFfiError *signal_error_get_their_fingerprint_version(uint32_t *out, SignalUnwindSafeArgSignalFfiError err); - -SignalFfiError *signal_error_get_tries_remaining(uint32_t *out, SignalUnwindSafeArgSignalFfiError err); - -uint32_t signal_error_get_type(const SignalFfiError *err); - -SignalFfiError *signal_error_get_unknown_fields(SignalStringArray *out, SignalUnwindSafeArgSignalFfiError err); - -SignalFfiError *signal_error_get_uuid(SignalUuid *out, SignalUnwindSafeArgSignalFfiError err); - -SignalFfiError *signal_expiring_profile_key_credential_check_valid_contents(SignalBorrowedBuffer buffer); - -SignalFfiError *signal_expiring_profile_key_credential_get_expiration_time(uint64_t *out, const unsigned char (*credential)[SignalEXPIRING_PROFILE_KEY_CREDENTIAL_LEN]); - -SignalFfiError *signal_expiring_profile_key_credential_response_check_valid_contents(SignalBorrowedBuffer buffer); - -SignalFfiError *signal_fingerprint_clone(SignalMutPointerFingerprint *new_obj, SignalConstPointerFingerprint obj); - -SignalFfiError *signal_fingerprint_compare(bool *out, SignalBorrowedBuffer fprint1, SignalBorrowedBuffer fprint2); - -SignalFfiError *signal_fingerprint_destroy(SignalMutPointerFingerprint p); - -SignalFfiError *signal_fingerprint_display_string(const char **out, SignalConstPointerFingerprint obj); - -SignalFfiError *signal_fingerprint_new(SignalMutPointerFingerprint *out, uint32_t iterations, uint32_t version, SignalBorrowedBuffer local_identifier, SignalConstPointerPublicKey local_key, SignalBorrowedBuffer remote_identifier, SignalConstPointerPublicKey remote_key); - -SignalFfiError *signal_fingerprint_scannable_encoding(SignalOwnedBuffer *out, SignalConstPointerFingerprint obj); - -void signal_free_buffer(const unsigned char *buf, size_t buf_len); - -void signal_free_bytestring_array(SignalBytestringArray array); - -void signal_free_list_of_mismatched_device_errors(SignalOwnedBufferOfFfiMismatchedDevicesError buffer); - -void signal_free_list_of_register_response_badges(SignalOwnedBufferOfFfiRegisterResponseBadge buffer); - -void signal_free_list_of_service_ids(SignalOwnedBufferOfServiceIdFixedWidthBinaryBytes buffer); - -void signal_free_list_of_strings(SignalOwnedBufferOfCStringPtr buffer); - -void signal_free_lookup_response_entry_list(SignalOwnedBufferOfFfiCdsiLookupResponseEntry buffer); - -/** - * This frees a buffer of PreKeyBundle pointers, and _does not_ free the - * pointers within the buffer. This _only_ frees the buffer containing - * the pointers. - */ -void signal_free_outer_buffer_list_of_prekey_bundles(SignalOwnedBufferOfMutPointerPreKeyBundle buffer); - -void signal_free_string(const char *buf); - -SignalFfiError *signal_generic_server_public_params_check_valid_contents(SignalBorrowedBuffer params_bytes); - -SignalFfiError *signal_generic_server_secret_params_check_valid_contents(SignalBorrowedBuffer params_bytes); - -SignalFfiError *signal_generic_server_secret_params_generate_deterministic(SignalOwnedBuffer *out, const uint8_t (*randomness)[SignalRANDOMNESS_LEN]); - -SignalFfiError *signal_generic_server_secret_params_get_public_params(SignalOwnedBuffer *out, SignalBorrowedBuffer params_bytes); - -SignalFfiError *signal_group_decrypt_message(SignalOwnedBuffer *out, SignalConstPointerProtocolAddress sender, SignalBorrowedBuffer message, SignalConstPointerFfiSenderKeyStoreStruct store); - -SignalFfiError *signal_group_encrypt_message(SignalMutPointerCiphertextMessage *out, SignalConstPointerProtocolAddress sender, SignalUuid distribution_id, SignalBorrowedBuffer message, SignalConstPointerFfiSenderKeyStoreStruct store); - -SignalFfiError *signal_group_master_key_check_valid_contents(SignalBorrowedBuffer buffer); - -SignalFfiError *signal_group_public_params_check_valid_contents(SignalBorrowedBuffer buffer); - -SignalFfiError *signal_group_public_params_get_group_identifier(uint8_t (*out)[SignalGROUP_IDENTIFIER_LEN], const unsigned char (*group_public_params)[SignalGROUP_PUBLIC_PARAMS_LEN]); - -SignalFfiError *signal_group_secret_params_check_valid_contents(SignalBorrowedBuffer buffer); - -SignalFfiError *signal_group_secret_params_decrypt_blob_with_padding(SignalOwnedBuffer *out, const unsigned char (*params)[SignalGROUP_SECRET_PARAMS_LEN], SignalBorrowedBuffer ciphertext); - -SignalFfiError *signal_group_secret_params_decrypt_profile_key(unsigned char (*out)[SignalPROFILE_KEY_LEN], const unsigned char (*params)[SignalGROUP_SECRET_PARAMS_LEN], const unsigned char (*profile_key)[SignalPROFILE_KEY_CIPHERTEXT_LEN], const SignalServiceIdFixedWidthBinaryBytes *user_id); - -SignalFfiError *signal_group_secret_params_decrypt_service_id(SignalServiceIdFixedWidthBinaryBytes *out, const unsigned char (*params)[SignalGROUP_SECRET_PARAMS_LEN], const unsigned char (*ciphertext)[SignalUUID_CIPHERTEXT_LEN]); - -SignalFfiError *signal_group_secret_params_derive_from_master_key(unsigned char (*out)[SignalGROUP_SECRET_PARAMS_LEN], const unsigned char (*master_key)[SignalGROUP_MASTER_KEY_LEN]); - -SignalFfiError *signal_group_secret_params_encrypt_blob_with_padding_deterministic(SignalOwnedBuffer *out, const unsigned char (*params)[SignalGROUP_SECRET_PARAMS_LEN], const uint8_t (*randomness)[SignalRANDOMNESS_LEN], SignalBorrowedBuffer plaintext, uint32_t padding_len); - -SignalFfiError *signal_group_secret_params_encrypt_profile_key(unsigned char (*out)[SignalPROFILE_KEY_CIPHERTEXT_LEN], const unsigned char (*params)[SignalGROUP_SECRET_PARAMS_LEN], const unsigned char (*profile_key)[SignalPROFILE_KEY_LEN], const SignalServiceIdFixedWidthBinaryBytes *user_id); - -SignalFfiError *signal_group_secret_params_encrypt_service_id(unsigned char (*out)[SignalUUID_CIPHERTEXT_LEN], const unsigned char (*params)[SignalGROUP_SECRET_PARAMS_LEN], const SignalServiceIdFixedWidthBinaryBytes *service_id); - -SignalFfiError *signal_group_secret_params_generate_deterministic(unsigned char (*out)[SignalGROUP_SECRET_PARAMS_LEN], const uint8_t (*randomness)[SignalRANDOMNESS_LEN]); - -SignalFfiError *signal_group_secret_params_get_master_key(unsigned char (*out)[SignalGROUP_MASTER_KEY_LEN], const unsigned char (*params)[SignalGROUP_SECRET_PARAMS_LEN]); - -SignalFfiError *signal_group_secret_params_get_public_params(unsigned char (*out)[SignalGROUP_PUBLIC_PARAMS_LEN], const unsigned char (*params)[SignalGROUP_SECRET_PARAMS_LEN]); - -SignalFfiError *signal_group_send_derived_key_pair_check_valid_contents(SignalBorrowedBuffer bytes); - -SignalFfiError *signal_group_send_derived_key_pair_for_expiration(SignalOwnedBuffer *out, uint64_t expiration, SignalConstPointerServerSecretParams server_params); - -SignalFfiError *signal_group_send_endorsement_call_link_params_to_token(SignalOwnedBuffer *out, SignalBorrowedBuffer endorsement, SignalBorrowedBuffer call_link_secret_params_serialized); - -SignalFfiError *signal_group_send_endorsement_check_valid_contents(SignalBorrowedBuffer bytes); - -SignalFfiError *signal_group_send_endorsement_combine(SignalOwnedBuffer *out, SignalBorrowedSliceOfBuffers endorsements); - -SignalFfiError *signal_group_send_endorsement_remove(SignalOwnedBuffer *out, SignalBorrowedBuffer endorsement, SignalBorrowedBuffer to_remove); - -SignalFfiError *signal_group_send_endorsement_to_token(SignalOwnedBuffer *out, SignalBorrowedBuffer endorsement, const unsigned char (*group_params)[SignalGROUP_SECRET_PARAMS_LEN]); - -SignalFfiError *signal_group_send_endorsements_response_check_valid_contents(SignalBorrowedBuffer bytes); - -SignalFfiError *signal_group_send_endorsements_response_get_expiration(uint64_t *out, SignalBorrowedBuffer response_bytes); - -SignalFfiError *signal_group_send_endorsements_response_issue_deterministic(SignalOwnedBuffer *out, SignalBorrowedBuffer concatenated_group_member_ciphertexts, SignalBorrowedBuffer key_pair, const uint8_t (*randomness)[SignalRANDOMNESS_LEN]); - -SignalFfiError *signal_group_send_endorsements_response_receive_and_combine_with_ciphertexts(SignalBytestringArray *out, SignalBorrowedBuffer response_bytes, SignalBorrowedBuffer concatenated_group_member_ciphertexts, SignalBorrowedBuffer local_user_ciphertext, uint64_t now, SignalConstPointerServerPublicParams server_params); - -SignalFfiError *signal_group_send_endorsements_response_receive_and_combine_with_service_ids(SignalBytestringArray *out, SignalBorrowedBuffer response_bytes, SignalBorrowedBuffer group_members, const SignalServiceIdFixedWidthBinaryBytes *local_user, uint64_t now, const unsigned char (*group_params)[SignalGROUP_SECRET_PARAMS_LEN], SignalConstPointerServerPublicParams server_params); - -SignalFfiError *signal_group_send_full_token_check_valid_contents(SignalBorrowedBuffer bytes); - -SignalFfiError *signal_group_send_full_token_get_expiration(uint64_t *out, SignalBorrowedBuffer token); - -SignalFfiError *signal_group_send_full_token_verify(SignalBorrowedBuffer token, SignalBorrowedBuffer user_ids, uint64_t now, SignalBorrowedBuffer key_pair); - -SignalFfiError *signal_group_send_token_check_valid_contents(SignalBorrowedBuffer bytes); - -SignalFfiError *signal_group_send_token_to_full_token(SignalOwnedBuffer *out, SignalBorrowedBuffer token, uint64_t expiration); - -SignalFfiError *signal_hex_encode(SignalBorrowedMutableBuffer output, SignalBorrowedBuffer input); - -SignalFfiError *signal_hkdf_derive(SignalBorrowedMutableBuffer output, SignalBorrowedBuffer ikm, SignalBorrowedBuffer label, SignalBorrowedBuffer salt); - -SignalFfiError *signal_hsm_enclave_client_complete_handshake(SignalMutPointerHsmEnclaveClient cli, SignalBorrowedBuffer handshake_received); - -SignalFfiError *signal_hsm_enclave_client_destroy(SignalMutPointerHsmEnclaveClient p); - -SignalFfiError *signal_hsm_enclave_client_established_recv(SignalOwnedBuffer *out, SignalMutPointerHsmEnclaveClient cli, SignalBorrowedBuffer received_ciphertext); - -SignalFfiError *signal_hsm_enclave_client_established_send(SignalOwnedBuffer *out, SignalMutPointerHsmEnclaveClient cli, SignalBorrowedBuffer plaintext_to_send); - -SignalFfiError *signal_hsm_enclave_client_initial_request(SignalOwnedBuffer *out, SignalConstPointerHsmEnclaveClient obj); - -SignalFfiError *signal_hsm_enclave_client_new(SignalMutPointerHsmEnclaveClient *out, SignalBorrowedBuffer trusted_public_key, SignalBorrowedBuffer trusted_code_hashes); - -SignalFfiError *signal_http_request_add_header(SignalConstPointerHttpRequest request, const char *name, const char *value); - -SignalFfiError *signal_http_request_destroy(SignalMutPointerHttpRequest p); - -SignalFfiError *signal_http_request_new_with_body(SignalMutPointerHttpRequest *out, const char *method, const char *path, SignalBorrowedBuffer body_as_slice); - -SignalFfiError *signal_http_request_new_without_body(SignalMutPointerHttpRequest *out, const char *method, const char *path); - -SignalFfiError *signal_identitykey_verify_alternate_identity(bool *out, SignalConstPointerPublicKey public_key, SignalConstPointerPublicKey other_identity, SignalBorrowedBuffer signature); - -SignalFfiError *signal_identitykeypair_deserialize(SignalPairOfMutPointerPublicKeyMutPointerPrivateKey *out, SignalBorrowedBuffer input); - -SignalFfiError *signal_identitykeypair_serialize(SignalOwnedBuffer *out, SignalConstPointerPublicKey public_key, SignalConstPointerPrivateKey private_key); - -SignalFfiError *signal_identitykeypair_sign_alternate_identity(SignalOwnedBuffer *out, SignalConstPointerPublicKey public_key, SignalConstPointerPrivateKey private_key, SignalConstPointerPublicKey other_identity); - -SignalFfiError *signal_incremental_mac_calculate_chunk_size(uint32_t *out, uint32_t data_size); - -SignalFfiError *signal_incremental_mac_destroy(SignalMutPointerIncrementalMac p); - -SignalFfiError *signal_incremental_mac_finalize(SignalOwnedBuffer *out, SignalMutPointerIncrementalMac mac); - -SignalFfiError *signal_incremental_mac_initialize(SignalMutPointerIncrementalMac *out, SignalBorrowedBuffer key, uint32_t chunk_size); - -SignalFfiError *signal_incremental_mac_update(SignalOwnedBuffer *out, SignalMutPointerIncrementalMac mac, SignalBorrowedBuffer bytes, uint32_t offset, uint32_t length); - -bool signal_init_logger(SignalLogLevel max_level, SignalFfiLoggerStruct logger); - -SignalFfiError *signal_key_transparency_aci_search_key(SignalOwnedBuffer *out, const SignalServiceIdFixedWidthBinaryBytes *aci); - -SignalFfiError *signal_key_transparency_check(SignalCPromisePairOfOwnedBufferOfc_ucharOwnedBufferOfc_uchar *promise, SignalConstPointerTokioAsyncContext async_runtime, uint8_t environment, SignalConstPointerUnauthenticatedChatConnection chat_connection, const SignalServiceIdFixedWidthBinaryBytes *aci, SignalConstPointerPublicKey aci_identity_key, const char *e164, SignalOptionalBorrowedSliceOfc_uchar unidentified_access_key, SignalOptionalBorrowedSliceOfc_uchar username_hash, SignalOptionalBorrowedSliceOfc_uchar account_data, SignalOptionalBorrowedSliceOfc_uchar last_distinguished_tree_head, bool is_self_check, bool is_e164_discoverable); - -SignalFfiError *signal_key_transparency_e164_search_key(SignalOwnedBuffer *out, const char *e164); - -SignalFfiError *signal_key_transparency_username_hash_search_key(SignalOwnedBuffer *out, SignalBorrowedBuffer hash); - -SignalFfiError *signal_kyber_key_pair_clone(SignalMutPointerKyberKeyPair *new_obj, SignalConstPointerKyberKeyPair obj); - -SignalFfiError *signal_kyber_key_pair_destroy(SignalMutPointerKyberKeyPair p); - -SignalFfiError *signal_kyber_key_pair_generate(SignalMutPointerKyberKeyPair *out); - -SignalFfiError *signal_kyber_key_pair_get_public_key(SignalMutPointerKyberPublicKey *out, SignalConstPointerKyberKeyPair key_pair); - -SignalFfiError *signal_kyber_key_pair_get_secret_key(SignalMutPointerKyberSecretKey *out, SignalConstPointerKyberKeyPair key_pair); - -SignalFfiError *signal_kyber_pre_key_record_clone(SignalMutPointerKyberPreKeyRecord *new_obj, SignalConstPointerKyberPreKeyRecord obj); - -SignalFfiError *signal_kyber_pre_key_record_deserialize(SignalMutPointerKyberPreKeyRecord *out, SignalBorrowedBuffer data); - -SignalFfiError *signal_kyber_pre_key_record_destroy(SignalMutPointerKyberPreKeyRecord p); - -SignalFfiError *signal_kyber_pre_key_record_get_id(uint32_t *out, SignalConstPointerKyberPreKeyRecord obj); - -SignalFfiError *signal_kyber_pre_key_record_get_key_pair(SignalMutPointerKyberKeyPair *out, SignalConstPointerKyberPreKeyRecord obj); - -SignalFfiError *signal_kyber_pre_key_record_get_public_key(SignalMutPointerKyberPublicKey *out, SignalConstPointerKyberPreKeyRecord obj); - -SignalFfiError *signal_kyber_pre_key_record_get_secret_key(SignalMutPointerKyberSecretKey *out, SignalConstPointerKyberPreKeyRecord obj); - -SignalFfiError *signal_kyber_pre_key_record_get_signature(SignalOwnedBuffer *out, SignalConstPointerKyberPreKeyRecord obj); - -SignalFfiError *signal_kyber_pre_key_record_get_timestamp(uint64_t *out, SignalConstPointerKyberPreKeyRecord obj); - -SignalFfiError *signal_kyber_pre_key_record_new(SignalMutPointerKyberPreKeyRecord *out, uint32_t id, uint64_t timestamp, SignalConstPointerKyberKeyPair key_pair, SignalBorrowedBuffer signature); - -SignalFfiError *signal_kyber_pre_key_record_serialize(SignalOwnedBuffer *out, SignalConstPointerKyberPreKeyRecord obj); - -SignalFfiError *signal_kyber_public_key_clone(SignalMutPointerKyberPublicKey *new_obj, SignalConstPointerKyberPublicKey obj); - -SignalFfiError *signal_kyber_public_key_deserialize(SignalMutPointerKyberPublicKey *out, SignalBorrowedBuffer data); - -SignalFfiError *signal_kyber_public_key_destroy(SignalMutPointerKyberPublicKey p); - -SignalFfiError *signal_kyber_public_key_equals(bool *out, SignalConstPointerKyberPublicKey lhs, SignalConstPointerKyberPublicKey rhs); - -SignalFfiError *signal_kyber_public_key_serialize(SignalOwnedBuffer *out, SignalConstPointerKyberPublicKey obj); - -SignalFfiError *signal_kyber_secret_key_clone(SignalMutPointerKyberSecretKey *new_obj, SignalConstPointerKyberSecretKey obj); - -SignalFfiError *signal_kyber_secret_key_deserialize(SignalMutPointerKyberSecretKey *out, SignalBorrowedBuffer data); - -SignalFfiError *signal_kyber_secret_key_destroy(SignalMutPointerKyberSecretKey p); - -SignalFfiError *signal_kyber_secret_key_serialize(SignalOwnedBuffer *out, SignalConstPointerKyberSecretKey obj); - -SignalFfiError *signal_lookup_request_add_aci_and_access_key(SignalConstPointerLookupRequest request, const SignalServiceIdFixedWidthBinaryBytes *aci, SignalBorrowedBuffer access_key); - -SignalFfiError *signal_lookup_request_add_e164(SignalConstPointerLookupRequest request, const char *e164); - -SignalFfiError *signal_lookup_request_add_previous_e164(SignalConstPointerLookupRequest request, const char *e164); - -SignalFfiError *signal_lookup_request_destroy(SignalMutPointerLookupRequest p); - -SignalFfiError *signal_lookup_request_new(SignalMutPointerLookupRequest *out); - -SignalFfiError *signal_lookup_request_set_token(SignalConstPointerLookupRequest request, SignalBorrowedBuffer token); - -SignalFfiError *signal_message_backup_key_destroy(SignalMutPointerMessageBackupKey p); - -SignalFfiError *signal_message_backup_key_from_account_entropy_pool(SignalMutPointerMessageBackupKey *out, const char *account_entropy, const SignalServiceIdFixedWidthBinaryBytes *aci, const uint8_t (*forward_secrecy_token)[SignalBACKUP_FORWARD_SECRECY_TOKEN_LEN]); - -SignalFfiError *signal_message_backup_key_from_backup_key_and_backup_id(SignalMutPointerMessageBackupKey *out, const uint8_t (*backup_key)[32], const uint8_t (*backup_id)[16], const uint8_t (*forward_secrecy_token)[SignalBACKUP_FORWARD_SECRECY_TOKEN_LEN]); - -SignalFfiError *signal_message_backup_key_get_aes_key(uint8_t (*out)[32], SignalConstPointerMessageBackupKey key); - -SignalFfiError *signal_message_backup_key_get_hmac_key(uint8_t (*out)[32], SignalConstPointerMessageBackupKey key); - -SignalFfiError *signal_message_backup_validation_outcome_destroy(SignalMutPointerMessageBackupValidationOutcome p); - -SignalFfiError *signal_message_backup_validation_outcome_get_error_message(const char **out, SignalConstPointerMessageBackupValidationOutcome outcome); - -SignalFfiError *signal_message_backup_validation_outcome_get_unknown_fields(SignalStringArray *out, SignalConstPointerMessageBackupValidationOutcome outcome); - -SignalFfiError *signal_message_backup_validator_validate(SignalMutPointerMessageBackupValidationOutcome *out, SignalConstPointerMessageBackupKey key, SignalConstPointerFfiInputStreamStruct first_stream, SignalConstPointerFfiInputStreamStruct second_stream, uint64_t len, uint8_t purpose); - -SignalFfiError *signal_message_clone(SignalMutPointerSignalMessage *new_obj, SignalConstPointerSignalMessage obj); - -SignalFfiError *signal_message_deserialize(SignalMutPointerSignalMessage *out, SignalBorrowedBuffer data); - -SignalFfiError *signal_message_destroy(SignalMutPointerSignalMessage p); - -SignalFfiError *signal_message_get_body(SignalOwnedBuffer *out, SignalConstPointerSignalMessage obj); - -SignalFfiError *signal_message_get_counter(uint32_t *out, SignalConstPointerSignalMessage obj); - -SignalFfiError *signal_message_get_message_version(uint32_t *out, SignalConstPointerSignalMessage obj); - -SignalFfiError *signal_message_get_pq_ratchet(SignalOwnedBuffer *out, SignalConstPointerSignalMessage msg); - -SignalFfiError *signal_message_get_sender_ratchet_key(SignalMutPointerPublicKey *out, SignalConstPointerSignalMessage m); - -SignalFfiError *signal_message_get_serialized(SignalOwnedBuffer *out, SignalConstPointerSignalMessage obj); - -SignalFfiError *signal_message_new(SignalMutPointerSignalMessage *out, uint8_t message_version, SignalBorrowedBuffer mac_key, SignalConstPointerPublicKey sender_ratchet_key, uint32_t counter, uint32_t previous_counter, SignalBorrowedBuffer ciphertext, SignalConstPointerPublicKey sender_identity_key, SignalConstPointerPublicKey receiver_identity_key, SignalBorrowedBuffer pq_ratchet); - -SignalFfiError *signal_message_verify_mac(bool *out, SignalConstPointerSignalMessage msg, SignalConstPointerPublicKey sender_identity_key, SignalConstPointerPublicKey receiver_identity_key, SignalBorrowedBuffer mac_key); - -SignalFfiError *signal_mp4_sanitizer_sanitize(SignalMutPointerSanitizedMetadata *out, SignalConstPointerFfiInputStreamStruct input, uint64_t len); - -SignalFfiError *signal_online_backup_validator_add_frame(SignalMutPointerOnlineBackupValidator backup, SignalBorrowedBuffer frame); - -SignalFfiError *signal_online_backup_validator_destroy(SignalMutPointerOnlineBackupValidator p); - -SignalFfiError *signal_online_backup_validator_finalize(SignalMutPointerOnlineBackupValidator backup); - -SignalFfiError *signal_online_backup_validator_new(SignalMutPointerOnlineBackupValidator *out, SignalBorrowedBuffer backup_info_frame, uint8_t purpose); - -SignalFfiError *signal_pin_hash_access_key(uint8_t (*out)[32], SignalConstPointerPinHash ph); - -SignalFfiError *signal_pin_hash_clone(SignalMutPointerPinHash *new_obj, SignalConstPointerPinHash obj); - -SignalFfiError *signal_pin_hash_destroy(SignalMutPointerPinHash p); - -SignalFfiError *signal_pin_hash_encryption_key(uint8_t (*out)[32], SignalConstPointerPinHash ph); - -SignalFfiError *signal_pin_hash_from_salt(SignalMutPointerPinHash *out, SignalBorrowedBuffer pin, const uint8_t (*salt)[32]); - -SignalFfiError *signal_pin_hash_from_username_mrenclave(SignalMutPointerPinHash *out, SignalBorrowedBuffer pin, const char *username, SignalBorrowedBuffer mrenclave); +SignalFfiError *signal_pin_hash_from_username_mrenclave(SignalPinHash **out, SignalBorrowedBuffer pin, const char *username, SignalBorrowedBuffer mrenclave); SignalFfiError *signal_pin_local_hash(const char **out, SignalBorrowedBuffer pin); SignalFfiError *signal_pin_verify_local_hash(bool *out, const char *encoded_hash, SignalBorrowedBuffer pin); -SignalFfiError *signal_plaintext_content_clone(SignalMutPointerPlaintextContent *new_obj, SignalConstPointerPlaintextContent obj); +SignalFfiError *signal_svr2_client_new(SignalSgxClientState **out, SignalBorrowedBuffer mrenclave, SignalBorrowedBuffer attestation_msg, uint64_t current_timestamp); -SignalFfiError *signal_plaintext_content_deserialize(SignalMutPointerPlaintextContent *out, SignalBorrowedBuffer data); +SignalFfiError *signal_incremental_mac_calculate_chunk_size(uint32_t *out, uint32_t data_size); -SignalFfiError *signal_plaintext_content_destroy(SignalMutPointerPlaintextContent p); +SignalFfiError *signal_incremental_mac_destroy(SignalIncrementalMac *p); -SignalFfiError *signal_plaintext_content_from_decryption_error_message(SignalMutPointerPlaintextContent *out, SignalConstPointerDecryptionErrorMessage m); +SignalFfiError *signal_incremental_mac_initialize(SignalIncrementalMac **out, SignalBorrowedBuffer key, uint32_t chunk_size); -SignalFfiError *signal_plaintext_content_get_body(SignalOwnedBuffer *out, SignalConstPointerPlaintextContent obj); +SignalFfiError *signal_incremental_mac_update(SignalOwnedBuffer *out, SignalIncrementalMac *mac, SignalBorrowedBuffer bytes, uint32_t offset, uint32_t length); -SignalFfiError *signal_plaintext_content_serialize(SignalOwnedBuffer *out, SignalConstPointerPlaintextContent obj); +SignalFfiError *signal_incremental_mac_finalize(SignalOwnedBuffer *out, SignalIncrementalMac *mac); -SignalFfiError *signal_pre_key_bundle_clone(SignalMutPointerPreKeyBundle *new_obj, SignalConstPointerPreKeyBundle obj); +SignalFfiError *signal_validating_mac_destroy(SignalValidatingMac *p); -SignalFfiError *signal_pre_key_bundle_destroy(SignalMutPointerPreKeyBundle p); +SignalFfiError *signal_validating_mac_initialize(SignalValidatingMac **out, SignalBorrowedBuffer key, uint32_t chunk_size, SignalBorrowedBuffer digests); -SignalFfiError *signal_pre_key_bundle_get_device_id(uint32_t *out, SignalConstPointerPreKeyBundle obj); +SignalFfiError *signal_validating_mac_update(int32_t *out, SignalValidatingMac *mac, SignalBorrowedBuffer bytes, uint32_t offset, uint32_t length); -SignalFfiError *signal_pre_key_bundle_get_identity_key(SignalMutPointerPublicKey *out, SignalConstPointerPreKeyBundle p); - -SignalFfiError *signal_pre_key_bundle_get_kyber_pre_key_id(uint32_t *out, SignalConstPointerPreKeyBundle obj); - -SignalFfiError *signal_pre_key_bundle_get_kyber_pre_key_public(SignalMutPointerKyberPublicKey *out, SignalConstPointerPreKeyBundle bundle); - -SignalFfiError *signal_pre_key_bundle_get_kyber_pre_key_signature(SignalOwnedBuffer *out, SignalConstPointerPreKeyBundle obj); - -SignalFfiError *signal_pre_key_bundle_get_pre_key_id(uint32_t *out, SignalConstPointerPreKeyBundle obj); - -SignalFfiError *signal_pre_key_bundle_get_pre_key_public(SignalMutPointerPublicKey *out, SignalConstPointerPreKeyBundle obj); - -SignalFfiError *signal_pre_key_bundle_get_registration_id(uint32_t *out, SignalConstPointerPreKeyBundle obj); - -SignalFfiError *signal_pre_key_bundle_get_signed_pre_key_id(uint32_t *out, SignalConstPointerPreKeyBundle obj); - -SignalFfiError *signal_pre_key_bundle_get_signed_pre_key_public(SignalMutPointerPublicKey *out, SignalConstPointerPreKeyBundle obj); - -SignalFfiError *signal_pre_key_bundle_get_signed_pre_key_signature(SignalOwnedBuffer *out, SignalConstPointerPreKeyBundle obj); - -SignalFfiError *signal_pre_key_bundle_new(SignalMutPointerPreKeyBundle *out, uint32_t registration_id, uint32_t device_id, uint32_t prekey_id, SignalConstPointerPublicKey prekey, uint32_t signed_prekey_id, SignalConstPointerPublicKey signed_prekey, SignalBorrowedBuffer signed_prekey_signature, SignalConstPointerPublicKey identity_key, uint32_t kyber_prekey_id, SignalConstPointerKyberPublicKey kyber_prekey, SignalBorrowedBuffer kyber_prekey_signature); - -SignalFfiError *signal_pre_key_record_clone(SignalMutPointerPreKeyRecord *new_obj, SignalConstPointerPreKeyRecord obj); - -SignalFfiError *signal_pre_key_record_deserialize(SignalMutPointerPreKeyRecord *out, SignalBorrowedBuffer data); - -SignalFfiError *signal_pre_key_record_destroy(SignalMutPointerPreKeyRecord p); - -SignalFfiError *signal_pre_key_record_get_id(uint32_t *out, SignalConstPointerPreKeyRecord obj); - -SignalFfiError *signal_pre_key_record_get_private_key(SignalMutPointerPrivateKey *out, SignalConstPointerPreKeyRecord obj); - -SignalFfiError *signal_pre_key_record_get_public_key(SignalMutPointerPublicKey *out, SignalConstPointerPreKeyRecord obj); - -SignalFfiError *signal_pre_key_record_new(SignalMutPointerPreKeyRecord *out, uint32_t id, SignalConstPointerPublicKey pub_key, SignalConstPointerPrivateKey priv_key); - -SignalFfiError *signal_pre_key_record_serialize(SignalOwnedBuffer *out, SignalConstPointerPreKeyRecord obj); - -SignalFfiError *signal_pre_key_signal_message_clone(SignalMutPointerPreKeySignalMessage *new_obj, SignalConstPointerPreKeySignalMessage obj); - -SignalFfiError *signal_pre_key_signal_message_deserialize(SignalMutPointerPreKeySignalMessage *out, SignalBorrowedBuffer data); - -SignalFfiError *signal_pre_key_signal_message_destroy(SignalMutPointerPreKeySignalMessage p); - -SignalFfiError *signal_pre_key_signal_message_get_base_key(SignalMutPointerPublicKey *out, SignalConstPointerPreKeySignalMessage m); - -SignalFfiError *signal_pre_key_signal_message_get_identity_key(SignalMutPointerPublicKey *out, SignalConstPointerPreKeySignalMessage m); - -SignalFfiError *signal_pre_key_signal_message_get_pre_key_id(uint32_t *out, SignalConstPointerPreKeySignalMessage obj); - -SignalFfiError *signal_pre_key_signal_message_get_registration_id(uint32_t *out, SignalConstPointerPreKeySignalMessage obj); - -SignalFfiError *signal_pre_key_signal_message_get_signal_message(SignalMutPointerSignalMessage *out, SignalConstPointerPreKeySignalMessage m); - -SignalFfiError *signal_pre_key_signal_message_get_signed_pre_key_id(uint32_t *out, SignalConstPointerPreKeySignalMessage obj); - -SignalFfiError *signal_pre_key_signal_message_get_version(uint32_t *out, SignalConstPointerPreKeySignalMessage obj); - -SignalFfiError *signal_pre_key_signal_message_new(SignalMutPointerPreKeySignalMessage *out, uint8_t message_version, uint32_t registration_id, uint32_t pre_key_id, uint32_t signed_pre_key_id, SignalConstPointerPublicKey base_key, SignalConstPointerPublicKey identity_key, SignalConstPointerSignalMessage signal_message); - -SignalFfiError *signal_pre_key_signal_message_serialize(SignalOwnedBuffer *out, SignalConstPointerPreKeySignalMessage obj); - -void signal_print_ptr(const void *p); - -SignalFfiError *signal_privatekey_agree(SignalOwnedBuffer *out, SignalConstPointerPrivateKey private_key, SignalConstPointerPublicKey public_key); - -SignalFfiError *signal_privatekey_clone(SignalMutPointerPrivateKey *new_obj, SignalConstPointerPrivateKey obj); - -SignalFfiError *signal_privatekey_deserialize(SignalMutPointerPrivateKey *out, SignalBorrowedBuffer data); - -SignalFfiError *signal_privatekey_destroy(SignalMutPointerPrivateKey p); - -SignalFfiError *signal_privatekey_generate(SignalMutPointerPrivateKey *out); - -SignalFfiError *signal_privatekey_get_public_key(SignalMutPointerPublicKey *out, SignalConstPointerPrivateKey k); - -SignalFfiError *signal_privatekey_hpke_open(SignalOwnedBuffer *out, SignalConstPointerPrivateKey sk, SignalBorrowedBuffer ciphertext, SignalBorrowedBuffer info, SignalBorrowedBuffer associated_data); - -SignalFfiError *signal_privatekey_serialize(SignalOwnedBuffer *out, SignalConstPointerPrivateKey obj); - -SignalFfiError *signal_privatekey_sign(SignalOwnedBuffer *out, SignalConstPointerPrivateKey key, SignalBorrowedBuffer message); - -SignalFfiError *signal_process_prekey_bundle(SignalConstPointerPreKeyBundle bundle, SignalConstPointerProtocolAddress protocol_address, SignalConstPointerProtocolAddress local_address, SignalConstPointerFfiSessionStoreStruct session_store, SignalConstPointerFfiIdentityKeyStoreStruct identity_key_store, uint64_t now); - -SignalFfiError *signal_process_sender_key_distribution_message(SignalConstPointerProtocolAddress sender, SignalConstPointerSenderKeyDistributionMessage sender_key_distribution_message, SignalConstPointerFfiSenderKeyStoreStruct store); - -SignalFfiError *signal_profile_key_check_valid_contents(SignalBorrowedBuffer buffer); - -SignalFfiError *signal_profile_key_ciphertext_check_valid_contents(SignalBorrowedBuffer buffer); - -SignalFfiError *signal_profile_key_commitment_check_valid_contents(SignalBorrowedBuffer buffer); - -SignalFfiError *signal_profile_key_credential_presentation_check_valid_contents(SignalBorrowedBuffer presentation_bytes); - -SignalFfiError *signal_profile_key_credential_presentation_get_profile_key_ciphertext(unsigned char (*out)[SignalPROFILE_KEY_CIPHERTEXT_LEN], SignalBorrowedBuffer presentation_bytes); - -SignalFfiError *signal_profile_key_credential_presentation_get_uuid_ciphertext(unsigned char (*out)[SignalUUID_CIPHERTEXT_LEN], SignalBorrowedBuffer presentation_bytes); - -SignalFfiError *signal_profile_key_credential_request_check_valid_contents(SignalBorrowedBuffer buffer); - -SignalFfiError *signal_profile_key_credential_request_context_check_valid_contents(SignalBorrowedBuffer buffer); - -SignalFfiError *signal_profile_key_credential_request_context_get_request(unsigned char (*out)[SignalPROFILE_KEY_CREDENTIAL_REQUEST_LEN], const unsigned char (*context)[SignalPROFILE_KEY_CREDENTIAL_REQUEST_CONTEXT_LEN]); - -SignalFfiError *signal_profile_key_derive_access_key(uint8_t (*out)[SignalACCESS_KEY_LEN], const unsigned char (*profile_key)[SignalPROFILE_KEY_LEN]); - -SignalFfiError *signal_profile_key_get_commitment(unsigned char (*out)[SignalPROFILE_KEY_COMMITMENT_LEN], const unsigned char (*profile_key)[SignalPROFILE_KEY_LEN], const SignalServiceIdFixedWidthBinaryBytes *user_id); - -SignalFfiError *signal_profile_key_get_profile_key_version(uint8_t (*out)[SignalPROFILE_KEY_VERSION_ENCODED_LEN], const unsigned char (*profile_key)[SignalPROFILE_KEY_LEN], const SignalServiceIdFixedWidthBinaryBytes *user_id); - -SignalFfiError *signal_provisioning_chat_connection_connect(SignalCPromiseMutPointerProvisioningChatConnection *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerConnectionManager connection_manager); - -SignalFfiError *signal_provisioning_chat_connection_destroy(SignalMutPointerProvisioningChatConnection p); - -SignalFfiError *signal_provisioning_chat_connection_disconnect(SignalCPromisebool *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerProvisioningChatConnection chat); - -SignalFfiError *signal_provisioning_chat_connection_info(SignalMutPointerChatConnectionInfo *out, SignalConstPointerProvisioningChatConnection chat); - -SignalFfiError *signal_provisioning_chat_connection_init_listener(SignalConstPointerProvisioningChatConnection chat, SignalConstPointerFfiProvisioningListenerStruct listener); - -SignalFfiError *signal_publickey_clone(SignalMutPointerPublicKey *new_obj, SignalConstPointerPublicKey obj); - -SignalFfiError *signal_publickey_deserialize(SignalMutPointerPublicKey *out, SignalBorrowedBuffer data); - -SignalFfiError *signal_publickey_destroy(SignalMutPointerPublicKey p); - -SignalFfiError *signal_publickey_equals(bool *out, SignalConstPointerPublicKey lhs, SignalConstPointerPublicKey rhs); - -SignalFfiError *signal_publickey_get_public_key_bytes(SignalOwnedBuffer *out, SignalConstPointerPublicKey obj); - -SignalFfiError *signal_publickey_hpke_seal(SignalOwnedBuffer *out, SignalConstPointerPublicKey pk, SignalBorrowedBuffer plaintext, SignalBorrowedBuffer info, SignalBorrowedBuffer associated_data); - -SignalFfiError *signal_publickey_serialize(SignalOwnedBuffer *out, SignalConstPointerPublicKey obj); - -SignalFfiError *signal_publickey_verify(bool *out, SignalConstPointerPublicKey key, SignalBorrowedBuffer message, SignalBorrowedBuffer signature); - -SignalFfiError *signal_receipt_credential_check_valid_contents(SignalBorrowedBuffer buffer); - -SignalFfiError *signal_receipt_credential_get_receipt_expiration_time(uint64_t *out, const unsigned char (*receipt_credential)[SignalRECEIPT_CREDENTIAL_LEN]); - -SignalFfiError *signal_receipt_credential_get_receipt_level(uint64_t *out, const unsigned char (*receipt_credential)[SignalRECEIPT_CREDENTIAL_LEN]); - -SignalFfiError *signal_receipt_credential_presentation_check_valid_contents(SignalBorrowedBuffer buffer); - -SignalFfiError *signal_receipt_credential_presentation_get_receipt_expiration_time(uint64_t *out, const unsigned char (*presentation)[SignalRECEIPT_CREDENTIAL_PRESENTATION_LEN]); - -SignalFfiError *signal_receipt_credential_presentation_get_receipt_level(uint64_t *out, const unsigned char (*presentation)[SignalRECEIPT_CREDENTIAL_PRESENTATION_LEN]); - -SignalFfiError *signal_receipt_credential_presentation_get_receipt_serial(uint8_t (*out)[SignalRECEIPT_SERIAL_LEN], const unsigned char (*presentation)[SignalRECEIPT_CREDENTIAL_PRESENTATION_LEN]); - -SignalFfiError *signal_receipt_credential_request_check_valid_contents(SignalBorrowedBuffer buffer); - -SignalFfiError *signal_receipt_credential_request_context_check_valid_contents(SignalBorrowedBuffer buffer); - -SignalFfiError *signal_receipt_credential_request_context_get_request(unsigned char (*out)[SignalRECEIPT_CREDENTIAL_REQUEST_LEN], const unsigned char (*request_context)[SignalRECEIPT_CREDENTIAL_REQUEST_CONTEXT_LEN]); - -SignalFfiError *signal_receipt_credential_response_check_valid_contents(SignalBorrowedBuffer buffer); - -SignalFfiError *signal_register_account_request_create(SignalMutPointerRegisterAccountRequest *out); - -SignalFfiError *signal_register_account_request_destroy(SignalMutPointerRegisterAccountRequest p); - -SignalFfiError *signal_register_account_request_set_account_password(SignalConstPointerRegisterAccountRequest register_account, const char *account_password); - -SignalFfiError *signal_register_account_request_set_apn_push_token(SignalConstPointerRegisterAccountRequest register_account, const char *apn_push_token); - -SignalFfiError *signal_register_account_request_set_identity_pq_last_resort_pre_key(SignalConstPointerRegisterAccountRequest register_account, uint8_t identity_type, SignalFfiSignedPublicPreKey pq_last_resort_pre_key); - -SignalFfiError *signal_register_account_request_set_identity_public_key(SignalConstPointerRegisterAccountRequest register_account, uint8_t identity_type, SignalConstPointerPublicKey identity_key); - -SignalFfiError *signal_register_account_request_set_identity_signed_pre_key(SignalConstPointerRegisterAccountRequest register_account, uint8_t identity_type, SignalFfiSignedPublicPreKey signed_pre_key); - -SignalFfiError *signal_register_account_request_set_skip_device_transfer(SignalConstPointerRegisterAccountRequest register_account); - -SignalFfiError *signal_register_account_response_destroy(SignalMutPointerRegisterAccountResponse p); - -SignalFfiError *signal_register_account_response_get_entitlement_backup_expiration_seconds(uint64_t *out, SignalConstPointerRegisterAccountResponse response); - -SignalFfiError *signal_register_account_response_get_entitlement_backup_level(uint64_t *out, SignalConstPointerRegisterAccountResponse response); - -SignalFfiError *signal_register_account_response_get_entitlement_badges(SignalOwnedBufferOfFfiRegisterResponseBadge *out, SignalConstPointerRegisterAccountResponse response); - -SignalFfiError *signal_register_account_response_get_identity(SignalServiceIdFixedWidthBinaryBytes *out, SignalConstPointerRegisterAccountResponse response, uint8_t identity_type); - -SignalFfiError *signal_register_account_response_get_number(const char **out, SignalConstPointerRegisterAccountResponse response); - -SignalFfiError *signal_register_account_response_get_reregistration(bool *out, SignalConstPointerRegisterAccountResponse response); - -SignalFfiError *signal_register_account_response_get_storage_capable(bool *out, SignalConstPointerRegisterAccountResponse response); - -SignalFfiError *signal_register_account_response_get_username_hash(SignalOwnedBuffer *out, SignalConstPointerRegisterAccountResponse response); - -SignalFfiError *signal_register_account_response_get_username_link_handle(SignalOptionalUuid *out, SignalConstPointerRegisterAccountResponse response); - -SignalFfiError *signal_registration_account_attributes_create(SignalMutPointerRegistrationAccountAttributes *out, SignalBorrowedBuffer recovery_password, uint16_t aci_registration_id, uint16_t pni_registration_id, const char *registration_lock, const uint8_t (*unidentified_access_key)[16], bool unrestricted_unidentified_access, SignalBorrowedBytestringArray capabilities, bool discoverable_by_phone_number); - -SignalFfiError *signal_registration_account_attributes_destroy(SignalMutPointerRegistrationAccountAttributes p); - -SignalFfiError *signal_registration_service_check_svr2_credentials(SignalCPromiseFfiCheckSvr2CredentialsResponse *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerRegistrationService service, SignalBorrowedBytestringArray svr_tokens); - -SignalFfiError *signal_registration_service_create_session(SignalCPromiseMutPointerRegistrationService *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalFfiRegistrationCreateSessionRequest create_session, SignalConstPointerFfiConnectChatBridgeStruct connect_chat); - -SignalFfiError *signal_registration_service_destroy(SignalMutPointerRegistrationService p); - -SignalFfiError *signal_registration_service_register_account(SignalCPromiseMutPointerRegisterAccountResponse *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerRegistrationService service, SignalConstPointerRegisterAccountRequest register_account, SignalConstPointerRegistrationAccountAttributes account_attributes); - -SignalFfiError *signal_registration_service_registration_session(SignalMutPointerRegistrationSession *out, SignalConstPointerRegistrationService service); - -SignalFfiError *signal_registration_service_request_push_challenge(SignalCPromisebool *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerRegistrationService service, const char *push_token); - -SignalFfiError *signal_registration_service_request_verification_code(SignalCPromisebool *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerRegistrationService service, const char *transport, const char *client, SignalBorrowedBytestringArray languages); - -SignalFfiError *signal_registration_service_reregister_account(SignalCPromiseMutPointerRegisterAccountResponse *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerFfiConnectChatBridgeStruct connect_chat, const char *number, SignalConstPointerRegisterAccountRequest register_account, SignalConstPointerRegistrationAccountAttributes account_attributes); - -SignalFfiError *signal_registration_service_resume_session(SignalCPromiseMutPointerRegistrationService *promise, SignalConstPointerTokioAsyncContext async_runtime, const char *session_id, const char *number, SignalConstPointerFfiConnectChatBridgeStruct connect_chat); - -SignalFfiError *signal_registration_service_session_id(const char **out, SignalConstPointerRegistrationService service); - -SignalFfiError *signal_registration_service_submit_captcha(SignalCPromisebool *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerRegistrationService service, const char *captcha_value); - -SignalFfiError *signal_registration_service_submit_push_challenge(SignalCPromisebool *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerRegistrationService service, const char *push_challenge); - -SignalFfiError *signal_registration_service_submit_verification_code(SignalCPromisebool *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerRegistrationService service, const char *code); - -SignalFfiError *signal_registration_session_destroy(SignalMutPointerRegistrationSession p); - -SignalFfiError *signal_registration_session_get_allowed_to_request_code(bool *out, SignalConstPointerRegistrationSession session); - -SignalFfiError *signal_registration_session_get_next_call_seconds(uint32_t *out, SignalConstPointerRegistrationSession session); - -SignalFfiError *signal_registration_session_get_next_sms_seconds(uint32_t *out, SignalConstPointerRegistrationSession session); - -SignalFfiError *signal_registration_session_get_next_verification_attempt_seconds(uint32_t *out, SignalConstPointerRegistrationSession session); - -SignalFfiError *signal_registration_session_get_requested_information(SignalOwnedBuffer *out, SignalConstPointerRegistrationSession session); - -SignalFfiError *signal_registration_session_get_verified(bool *out, SignalConstPointerRegistrationSession session); - -SignalFfiError *signal_sanitized_metadata_clone(SignalMutPointerSanitizedMetadata *new_obj, SignalConstPointerSanitizedMetadata obj); - -SignalFfiError *signal_sanitized_metadata_destroy(SignalMutPointerSanitizedMetadata p); - -SignalFfiError *signal_sanitized_metadata_get_data_len(uint64_t *out, SignalConstPointerSanitizedMetadata sanitized); - -SignalFfiError *signal_sanitized_metadata_get_data_offset(uint64_t *out, SignalConstPointerSanitizedMetadata sanitized); - -SignalFfiError *signal_sanitized_metadata_get_metadata(SignalOwnedBuffer *out, SignalConstPointerSanitizedMetadata sanitized); - -SignalFfiError *signal_sealed_sender_multi_recipient_encrypt(SignalOwnedBuffer *out, SignalBorrowedSliceOfConstPointerProtocolAddress recipients, SignalBorrowedSliceOfConstPointerSessionRecord recipient_sessions, SignalBorrowedBuffer excluded_recipients, SignalConstPointerUnidentifiedSenderMessageContent content, SignalConstPointerFfiIdentityKeyStoreStruct identity_key_store); - -SignalFfiError *signal_sealed_sender_multi_recipient_message_for_single_recipient(SignalOwnedBuffer *out, SignalBorrowedBuffer encoded_multi_recipient_message); - -SignalFfiError *signal_sealed_session_cipher_decrypt_to_usmc(SignalMutPointerUnidentifiedSenderMessageContent *out, SignalBorrowedBuffer ctext, SignalConstPointerFfiIdentityKeyStoreStruct identity_store); - -SignalFfiError *signal_sealed_session_cipher_encrypt(SignalOwnedBuffer *out, SignalConstPointerProtocolAddress destination, SignalConstPointerUnidentifiedSenderMessageContent content, SignalConstPointerFfiIdentityKeyStoreStruct identity_key_store); - -SignalFfiError *signal_secure_value_recovery_for_backups_create_new_backup_chain(SignalOwnedBuffer *out, uint8_t environment, const SignalBackupKeyBytes *backup_key); - -SignalFfiError *signal_secure_value_recovery_for_backups_remove_backup(SignalCPromisebool *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerConnectionManager connection_manager, const char *username, const char *password); - -SignalFfiError *signal_secure_value_recovery_for_backups_restore_backup_from_server(SignalCPromiseMutPointerBackupRestoreResponse *promise, SignalConstPointerTokioAsyncContext async_runtime, const SignalBackupKeyBytes *backup_key, SignalBorrowedBuffer metadata, SignalConstPointerConnectionManager connection_manager, const char *username, const char *password); - -SignalFfiError *signal_secure_value_recovery_for_backups_store_backup(SignalCPromiseMutPointerBackupStoreResponse *promise, SignalConstPointerTokioAsyncContext async_runtime, const SignalBackupKeyBytes *backup_key, SignalBorrowedBuffer previous_secret_data, SignalConstPointerConnectionManager connection_manager, const char *username, const char *password); - -SignalFfiError *signal_sender_certificate_clone(SignalMutPointerSenderCertificate *new_obj, SignalConstPointerSenderCertificate obj); - -SignalFfiError *signal_sender_certificate_deserialize(SignalMutPointerSenderCertificate *out, SignalBorrowedBuffer data); - -SignalFfiError *signal_sender_certificate_destroy(SignalMutPointerSenderCertificate p); - -SignalFfiError *signal_sender_certificate_get_certificate(SignalOwnedBuffer *out, SignalConstPointerSenderCertificate obj); - -SignalFfiError *signal_sender_certificate_get_device_id(uint32_t *out, SignalConstPointerSenderCertificate obj); - -SignalFfiError *signal_sender_certificate_get_expiration(uint64_t *out, SignalConstPointerSenderCertificate obj); - -SignalFfiError *signal_sender_certificate_get_key(SignalMutPointerPublicKey *out, SignalConstPointerSenderCertificate obj); - -SignalFfiError *signal_sender_certificate_get_sender_e164(const char **out, SignalConstPointerSenderCertificate obj); - -SignalFfiError *signal_sender_certificate_get_sender_uuid(const char **out, SignalConstPointerSenderCertificate obj); - -SignalFfiError *signal_sender_certificate_get_serialized(SignalOwnedBuffer *out, SignalConstPointerSenderCertificate obj); - -SignalFfiError *signal_sender_certificate_get_server_certificate(SignalMutPointerServerCertificate *out, SignalConstPointerSenderCertificate cert); - -SignalFfiError *signal_sender_certificate_get_signature(SignalOwnedBuffer *out, SignalConstPointerSenderCertificate obj); - -SignalFfiError *signal_sender_certificate_new(SignalMutPointerSenderCertificate *out, const char *sender_uuid, const char *sender_e164, uint32_t sender_device_id, SignalConstPointerPublicKey sender_key, uint64_t expiration, SignalConstPointerServerCertificate signer_cert, SignalConstPointerPrivateKey signer_key); - -SignalFfiError *signal_sender_certificate_validate(bool *out, SignalConstPointerSenderCertificate cert, SignalBorrowedSliceOfConstPointerPublicKey trust_roots, uint64_t time); - -SignalFfiError *signal_sender_key_distribution_message_clone(SignalMutPointerSenderKeyDistributionMessage *new_obj, SignalConstPointerSenderKeyDistributionMessage obj); - -SignalFfiError *signal_sender_key_distribution_message_create(SignalMutPointerSenderKeyDistributionMessage *out, SignalConstPointerProtocolAddress sender, SignalUuid distribution_id, SignalConstPointerFfiSenderKeyStoreStruct store); - -SignalFfiError *signal_sender_key_distribution_message_deserialize(SignalMutPointerSenderKeyDistributionMessage *out, SignalBorrowedBuffer data); - -SignalFfiError *signal_sender_key_distribution_message_destroy(SignalMutPointerSenderKeyDistributionMessage p); - -SignalFfiError *signal_sender_key_distribution_message_get_chain_id(uint32_t *out, SignalConstPointerSenderKeyDistributionMessage obj); - -SignalFfiError *signal_sender_key_distribution_message_get_chain_key(SignalOwnedBuffer *out, SignalConstPointerSenderKeyDistributionMessage obj); - -SignalFfiError *signal_sender_key_distribution_message_get_distribution_id(SignalUuid *out, SignalConstPointerSenderKeyDistributionMessage obj); - -SignalFfiError *signal_sender_key_distribution_message_get_iteration(uint32_t *out, SignalConstPointerSenderKeyDistributionMessage obj); - -SignalFfiError *signal_sender_key_distribution_message_get_signature_key(SignalMutPointerPublicKey *out, SignalConstPointerSenderKeyDistributionMessage m); - -SignalFfiError *signal_sender_key_distribution_message_new(SignalMutPointerSenderKeyDistributionMessage *out, uint8_t message_version, SignalUuid distribution_id, uint32_t chain_id, uint32_t iteration, SignalBorrowedBuffer chainkey, SignalConstPointerPublicKey pk); - -SignalFfiError *signal_sender_key_distribution_message_serialize(SignalOwnedBuffer *out, SignalConstPointerSenderKeyDistributionMessage obj); - -SignalFfiError *signal_sender_key_message_clone(SignalMutPointerSenderKeyMessage *new_obj, SignalConstPointerSenderKeyMessage obj); - -SignalFfiError *signal_sender_key_message_deserialize(SignalMutPointerSenderKeyMessage *out, SignalBorrowedBuffer data); - -SignalFfiError *signal_sender_key_message_destroy(SignalMutPointerSenderKeyMessage p); - -SignalFfiError *signal_sender_key_message_get_chain_id(uint32_t *out, SignalConstPointerSenderKeyMessage obj); - -SignalFfiError *signal_sender_key_message_get_cipher_text(SignalOwnedBuffer *out, SignalConstPointerSenderKeyMessage obj); - -SignalFfiError *signal_sender_key_message_get_distribution_id(SignalUuid *out, SignalConstPointerSenderKeyMessage obj); - -SignalFfiError *signal_sender_key_message_get_iteration(uint32_t *out, SignalConstPointerSenderKeyMessage obj); - -SignalFfiError *signal_sender_key_message_new(SignalMutPointerSenderKeyMessage *out, uint8_t message_version, SignalUuid distribution_id, uint32_t chain_id, uint32_t iteration, SignalBorrowedBuffer ciphertext, SignalConstPointerPrivateKey pk); - -SignalFfiError *signal_sender_key_message_serialize(SignalOwnedBuffer *out, SignalConstPointerSenderKeyMessage obj); - -SignalFfiError *signal_sender_key_message_verify_signature(bool *out, SignalConstPointerSenderKeyMessage skm, SignalConstPointerPublicKey pubkey); - -SignalFfiError *signal_sender_key_record_clone(SignalMutPointerSenderKeyRecord *new_obj, SignalConstPointerSenderKeyRecord obj); - -SignalFfiError *signal_sender_key_record_deserialize(SignalMutPointerSenderKeyRecord *out, SignalBorrowedBuffer data); - -SignalFfiError *signal_sender_key_record_destroy(SignalMutPointerSenderKeyRecord p); - -SignalFfiError *signal_sender_key_record_serialize(SignalOwnedBuffer *out, SignalConstPointerSenderKeyRecord obj); - -SignalFfiError *signal_server_certificate_clone(SignalMutPointerServerCertificate *new_obj, SignalConstPointerServerCertificate obj); - -SignalFfiError *signal_server_certificate_deserialize(SignalMutPointerServerCertificate *out, SignalBorrowedBuffer data); - -SignalFfiError *signal_server_certificate_destroy(SignalMutPointerServerCertificate p); - -SignalFfiError *signal_server_certificate_get_certificate(SignalOwnedBuffer *out, SignalConstPointerServerCertificate obj); - -SignalFfiError *signal_server_certificate_get_key(SignalMutPointerPublicKey *out, SignalConstPointerServerCertificate obj); - -SignalFfiError *signal_server_certificate_get_key_id(uint32_t *out, SignalConstPointerServerCertificate obj); - -SignalFfiError *signal_server_certificate_get_serialized(SignalOwnedBuffer *out, SignalConstPointerServerCertificate obj); - -SignalFfiError *signal_server_certificate_get_signature(SignalOwnedBuffer *out, SignalConstPointerServerCertificate obj); - -SignalFfiError *signal_server_certificate_new(SignalMutPointerServerCertificate *out, uint32_t key_id, SignalConstPointerPublicKey server_key, SignalConstPointerPrivateKey trust_root); - -SignalFfiError *signal_server_message_ack_destroy(SignalMutPointerServerMessageAck p); - -SignalFfiError *signal_server_message_ack_send(SignalConstPointerServerMessageAck ack); - -SignalFfiError *signal_server_public_params_create_auth_credential_with_pni_presentation_deterministic(SignalOwnedBuffer *out, SignalConstPointerServerPublicParams server_public_params, const uint8_t (*randomness)[SignalRANDOMNESS_LEN], const unsigned char (*group_secret_params)[SignalGROUP_SECRET_PARAMS_LEN], SignalBorrowedBuffer auth_credential_with_pni_bytes); - -SignalFfiError *signal_server_public_params_create_expiring_profile_key_credential_presentation_deterministic(SignalOwnedBuffer *out, SignalConstPointerServerPublicParams server_public_params, const uint8_t (*randomness)[SignalRANDOMNESS_LEN], const unsigned char (*group_secret_params)[SignalGROUP_SECRET_PARAMS_LEN], const unsigned char (*profile_key_credential)[SignalEXPIRING_PROFILE_KEY_CREDENTIAL_LEN]); - -SignalFfiError *signal_server_public_params_create_profile_key_credential_request_context_deterministic(unsigned char (*out)[SignalPROFILE_KEY_CREDENTIAL_REQUEST_CONTEXT_LEN], SignalConstPointerServerPublicParams server_public_params, const uint8_t (*randomness)[SignalRANDOMNESS_LEN], const SignalServiceIdFixedWidthBinaryBytes *user_id, const unsigned char (*profile_key)[SignalPROFILE_KEY_LEN]); - -SignalFfiError *signal_server_public_params_create_receipt_credential_presentation_deterministic(unsigned char (*out)[SignalRECEIPT_CREDENTIAL_PRESENTATION_LEN], SignalConstPointerServerPublicParams server_public_params, const uint8_t (*randomness)[SignalRANDOMNESS_LEN], const unsigned char (*receipt_credential)[SignalRECEIPT_CREDENTIAL_LEN]); - -SignalFfiError *signal_server_public_params_create_receipt_credential_request_context_deterministic(unsigned char (*out)[SignalRECEIPT_CREDENTIAL_REQUEST_CONTEXT_LEN], SignalConstPointerServerPublicParams server_public_params, const uint8_t (*randomness)[SignalRANDOMNESS_LEN], const uint8_t (*receipt_serial)[SignalRECEIPT_SERIAL_LEN]); - -SignalFfiError *signal_server_public_params_deserialize(SignalMutPointerServerPublicParams *out, SignalBorrowedBuffer buffer); - -SignalFfiError *signal_server_public_params_destroy(SignalMutPointerServerPublicParams p); - -SignalFfiError *signal_server_public_params_get_endorsement_public_key(SignalOwnedBuffer *out, SignalConstPointerServerPublicParams params); - -SignalFfiError *signal_server_public_params_receive_auth_credential_with_pni_as_service_id(SignalOwnedBuffer *out, SignalConstPointerServerPublicParams params, const SignalServiceIdFixedWidthBinaryBytes *aci, const SignalServiceIdFixedWidthBinaryBytes *pni, uint64_t redemption_time, SignalBorrowedBuffer auth_credential_with_pni_response_bytes); - -SignalFfiError *signal_server_public_params_receive_expiring_profile_key_credential(unsigned char (*out)[SignalEXPIRING_PROFILE_KEY_CREDENTIAL_LEN], SignalConstPointerServerPublicParams server_public_params, const unsigned char (*request_context)[SignalPROFILE_KEY_CREDENTIAL_REQUEST_CONTEXT_LEN], const unsigned char (*response)[SignalEXPIRING_PROFILE_KEY_CREDENTIAL_RESPONSE_LEN], uint64_t current_time_in_seconds); - -SignalFfiError *signal_server_public_params_receive_receipt_credential(unsigned char (*out)[SignalRECEIPT_CREDENTIAL_LEN], SignalConstPointerServerPublicParams server_public_params, const unsigned char (*request_context)[SignalRECEIPT_CREDENTIAL_REQUEST_CONTEXT_LEN], const unsigned char (*response)[SignalRECEIPT_CREDENTIAL_RESPONSE_LEN]); - -SignalFfiError *signal_server_public_params_serialize(SignalOwnedBuffer *out, SignalConstPointerServerPublicParams handle); - -SignalFfiError *signal_server_public_params_verify_signature(SignalConstPointerServerPublicParams server_public_params, SignalBorrowedBuffer message, const uint8_t (*notary_signature)[SignalSIGNATURE_LEN]); - -SignalFfiError *signal_server_secret_params_deserialize(SignalMutPointerServerSecretParams *out, SignalBorrowedBuffer buffer); - -SignalFfiError *signal_server_secret_params_destroy(SignalMutPointerServerSecretParams p); - -SignalFfiError *signal_server_secret_params_generate_deterministic(SignalMutPointerServerSecretParams *out, const uint8_t (*randomness)[SignalRANDOMNESS_LEN]); - -SignalFfiError *signal_server_secret_params_get_public_params(SignalMutPointerServerPublicParams *out, SignalConstPointerServerSecretParams params); - -SignalFfiError *signal_server_secret_params_issue_auth_credential_with_pni_zkc_deterministic(SignalOwnedBuffer *out, SignalConstPointerServerSecretParams server_secret_params, const uint8_t (*randomness)[SignalRANDOMNESS_LEN], const SignalServiceIdFixedWidthBinaryBytes *aci, const SignalServiceIdFixedWidthBinaryBytes *pni, uint64_t redemption_time); - -SignalFfiError *signal_server_secret_params_issue_expiring_profile_key_credential_deterministic(unsigned char (*out)[SignalEXPIRING_PROFILE_KEY_CREDENTIAL_RESPONSE_LEN], SignalConstPointerServerSecretParams server_secret_params, const uint8_t (*randomness)[SignalRANDOMNESS_LEN], const unsigned char (*request)[SignalPROFILE_KEY_CREDENTIAL_REQUEST_LEN], const SignalServiceIdFixedWidthBinaryBytes *user_id, const unsigned char (*commitment)[SignalPROFILE_KEY_COMMITMENT_LEN], uint64_t expiration_in_seconds); - -SignalFfiError *signal_server_secret_params_issue_receipt_credential_deterministic(unsigned char (*out)[SignalRECEIPT_CREDENTIAL_RESPONSE_LEN], SignalConstPointerServerSecretParams server_secret_params, const uint8_t (*randomness)[SignalRANDOMNESS_LEN], const unsigned char (*request)[SignalRECEIPT_CREDENTIAL_REQUEST_LEN], uint64_t receipt_expiration_time, uint64_t receipt_level); - -SignalFfiError *signal_server_secret_params_serialize(SignalOwnedBuffer *out, SignalConstPointerServerSecretParams handle); - -SignalFfiError *signal_server_secret_params_sign_deterministic(uint8_t (*out)[SignalSIGNATURE_LEN], SignalConstPointerServerSecretParams params, const uint8_t (*randomness)[SignalRANDOMNESS_LEN], SignalBorrowedBuffer message); - -SignalFfiError *signal_server_secret_params_verify_auth_credential_presentation(SignalConstPointerServerSecretParams server_secret_params, const unsigned char (*group_public_params)[SignalGROUP_PUBLIC_PARAMS_LEN], SignalBorrowedBuffer presentation_bytes, uint64_t current_time_in_seconds); - -SignalFfiError *signal_server_secret_params_verify_profile_key_credential_presentation(SignalConstPointerServerSecretParams server_secret_params, const unsigned char (*group_public_params)[SignalGROUP_PUBLIC_PARAMS_LEN], SignalBorrowedBuffer presentation_bytes, uint64_t current_time_in_seconds); - -SignalFfiError *signal_server_secret_params_verify_receipt_credential_presentation(SignalConstPointerServerSecretParams server_secret_params, const unsigned char (*presentation)[SignalRECEIPT_CREDENTIAL_PRESENTATION_LEN]); - -SignalFfiError *signal_service_id_parse_from_service_id_binary(SignalServiceIdFixedWidthBinaryBytes *out, SignalBorrowedBuffer input); - -SignalFfiError *signal_service_id_parse_from_service_id_string(SignalServiceIdFixedWidthBinaryBytes *out, const char *input); - -SignalFfiError *signal_service_id_service_id_binary(SignalOwnedBuffer *out, const SignalServiceIdFixedWidthBinaryBytes *value); - -SignalFfiError *signal_service_id_service_id_log(const char **out, const SignalServiceIdFixedWidthBinaryBytes *value); - -SignalFfiError *signal_service_id_service_id_string(const char **out, const SignalServiceIdFixedWidthBinaryBytes *value); - -SignalFfiError *signal_session_record_archive_current_state(SignalMutPointerSessionRecord session_record); - -SignalFfiError *signal_session_record_clone(SignalMutPointerSessionRecord *new_obj, SignalConstPointerSessionRecord obj); - -SignalFfiError *signal_session_record_current_ratchet_key_matches(bool *out, SignalConstPointerSessionRecord s, SignalConstPointerPublicKey key); - -SignalFfiError *signal_session_record_deserialize(SignalMutPointerSessionRecord *out, SignalBorrowedBuffer data); - -SignalFfiError *signal_session_record_destroy(SignalMutPointerSessionRecord p); - -SignalFfiError *signal_session_record_get_local_registration_id(uint32_t *out, SignalConstPointerSessionRecord obj); - -SignalFfiError *signal_session_record_get_remote_registration_id(uint32_t *out, SignalConstPointerSessionRecord obj); - -SignalFfiError *signal_session_record_has_usable_sender_chain(bool *out, SignalConstPointerSessionRecord s, uint64_t now); - -SignalFfiError *signal_session_record_serialize(SignalOwnedBuffer *out, SignalConstPointerSessionRecord obj); - -SignalFfiError *signal_sgx_client_state_complete_handshake(SignalMutPointerSgxClientState cli, SignalBorrowedBuffer handshake_received); - -SignalFfiError *signal_sgx_client_state_destroy(SignalMutPointerSgxClientState p); - -SignalFfiError *signal_sgx_client_state_established_recv(SignalOwnedBuffer *out, SignalMutPointerSgxClientState cli, SignalBorrowedBuffer received_ciphertext); - -SignalFfiError *signal_sgx_client_state_established_send(SignalOwnedBuffer *out, SignalMutPointerSgxClientState cli, SignalBorrowedBuffer plaintext_to_send); - -SignalFfiError *signal_sgx_client_state_initial_request(SignalOwnedBuffer *out, SignalConstPointerSgxClientState obj); - -SignalFfiError *signal_signal_media_check_available(void); - -SignalFfiError *signal_signed_pre_key_record_clone(SignalMutPointerSignedPreKeyRecord *new_obj, SignalConstPointerSignedPreKeyRecord obj); - -SignalFfiError *signal_signed_pre_key_record_deserialize(SignalMutPointerSignedPreKeyRecord *out, SignalBorrowedBuffer data); - -SignalFfiError *signal_signed_pre_key_record_destroy(SignalMutPointerSignedPreKeyRecord p); - -SignalFfiError *signal_signed_pre_key_record_get_id(uint32_t *out, SignalConstPointerSignedPreKeyRecord obj); - -SignalFfiError *signal_signed_pre_key_record_get_private_key(SignalMutPointerPrivateKey *out, SignalConstPointerSignedPreKeyRecord obj); - -SignalFfiError *signal_signed_pre_key_record_get_public_key(SignalMutPointerPublicKey *out, SignalConstPointerSignedPreKeyRecord obj); - -SignalFfiError *signal_signed_pre_key_record_get_signature(SignalOwnedBuffer *out, SignalConstPointerSignedPreKeyRecord obj); - -SignalFfiError *signal_signed_pre_key_record_get_timestamp(uint64_t *out, SignalConstPointerSignedPreKeyRecord obj); - -SignalFfiError *signal_signed_pre_key_record_new(SignalMutPointerSignedPreKeyRecord *out, uint32_t id, uint64_t timestamp, SignalConstPointerPublicKey pub_key, SignalConstPointerPrivateKey priv_key, SignalBorrowedBuffer signature); - -SignalFfiError *signal_signed_pre_key_record_serialize(SignalOwnedBuffer *out, SignalConstPointerSignedPreKeyRecord obj); - -SignalFfiError *signal_svr2_client_new(SignalMutPointerSgxClientState *out, SignalBorrowedBuffer mrenclave, SignalBorrowedBuffer attestation_msg, uint64_t current_timestamp); - -SignalFfiError *signal_tokio_async_context_cancel(SignalConstPointerTokioAsyncContext context, uint64_t raw_cancellation_id); - -SignalFfiError *signal_tokio_async_context_destroy(SignalMutPointerTokioAsyncContext p); - -SignalFfiError *signal_tokio_async_context_new(SignalMutPointerTokioAsyncContext *out); - -SignalFfiError *signal_unauthenticated_chat_connection_account_exists(SignalCPromisebool *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerUnauthenticatedChatConnection chat, const SignalServiceIdFixedWidthBinaryBytes *account); - -SignalFfiError *signal_unauthenticated_chat_connection_backup_get_media_upload_form(SignalCPromiseFfiUploadForm *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerUnauthenticatedChatConnection chat, SignalBorrowedBuffer credential, SignalBorrowedBuffer server_keys, SignalConstPointerPrivateKey signing_key, uint64_t upload_size, int64_t rng); - -SignalFfiError *signal_unauthenticated_chat_connection_backup_get_upload_form(SignalCPromiseFfiUploadForm *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerUnauthenticatedChatConnection chat, SignalBorrowedBuffer credential, SignalBorrowedBuffer server_keys, SignalConstPointerPrivateKey signing_key, uint64_t upload_size, int64_t rng); - -SignalFfiError *signal_unauthenticated_chat_connection_connect(SignalCPromiseMutPointerUnauthenticatedChatConnection *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerConnectionManager connection_manager, SignalBorrowedBytestringArray languages); - -SignalFfiError *signal_unauthenticated_chat_connection_destroy(SignalMutPointerUnauthenticatedChatConnection p); - -SignalFfiError *signal_unauthenticated_chat_connection_disconnect(SignalCPromisebool *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerUnauthenticatedChatConnection chat); - -SignalFfiError *signal_unauthenticated_chat_connection_get_pre_keys_access_key_auth(SignalCPromiseFfiPreKeysResponse *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerUnauthenticatedChatConnection chat, const uint8_t (*auth)[16], const SignalServiceIdFixedWidthBinaryBytes *target, int32_t device); - -SignalFfiError *signal_unauthenticated_chat_connection_get_pre_keys_group_auth(SignalCPromiseFfiPreKeysResponse *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerUnauthenticatedChatConnection chat, SignalBorrowedBuffer auth, const SignalServiceIdFixedWidthBinaryBytes *target, int32_t device); - -SignalFfiError *signal_unauthenticated_chat_connection_get_pre_keys_unrestricted_auth(SignalCPromiseFfiPreKeysResponse *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerUnauthenticatedChatConnection chat, const SignalServiceIdFixedWidthBinaryBytes *target, int32_t device); - -SignalFfiError *signal_unauthenticated_chat_connection_info(SignalMutPointerChatConnectionInfo *out, SignalConstPointerUnauthenticatedChatConnection chat); - -SignalFfiError *signal_unauthenticated_chat_connection_init_listener(SignalConstPointerUnauthenticatedChatConnection chat, SignalConstPointerFfiChatListenerStruct listener); - -SignalFfiError *signal_unauthenticated_chat_connection_look_up_username_hash(SignalCPromiseOptionalUuid *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerUnauthenticatedChatConnection chat, SignalBorrowedBuffer hash); - -SignalFfiError *signal_unauthenticated_chat_connection_look_up_username_link(SignalCPromiseOptionalPairOfc_charu832 *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerUnauthenticatedChatConnection chat, SignalUuid uuid, SignalBorrowedBuffer entropy); - -SignalFfiError *signal_unauthenticated_chat_connection_send(SignalCPromiseFfiChatResponse *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerUnauthenticatedChatConnection chat, SignalConstPointerHttpRequest http_request, uint32_t timeout_millis); - -SignalFfiError *signal_unauthenticated_chat_connection_send_message(SignalCPromisebool *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerUnauthenticatedChatConnection chat, const SignalServiceIdFixedWidthBinaryBytes *destination, uint64_t timestamp, SignalBorrowedSliceOfu32 device_ids, SignalBorrowedSliceOfu32 registration_ids, SignalBorrowedSliceOfBuffers contents, uint8_t auth_kind, SignalOptionalBorrowedSliceOfc_uchar auth_buffer, bool online_only, bool is_urgent); - -SignalFfiError *signal_unauthenticated_chat_connection_send_multi_recipient_message(SignalCPromiseOwnedBufferOfServiceIdFixedWidthBinaryBytes *promise, SignalConstPointerTokioAsyncContext async_runtime, SignalConstPointerUnauthenticatedChatConnection chat, SignalBorrowedBuffer payload, uint64_t timestamp, SignalBorrowedBuffer auth, bool online_only, bool is_urgent); - -SignalFfiError *signal_unidentified_sender_message_content_deserialize(SignalMutPointerUnidentifiedSenderMessageContent *out, SignalBorrowedBuffer data); - -SignalFfiError *signal_unidentified_sender_message_content_destroy(SignalMutPointerUnidentifiedSenderMessageContent p); - -SignalFfiError *signal_unidentified_sender_message_content_get_content_hint(uint32_t *out, SignalConstPointerUnidentifiedSenderMessageContent m); - -SignalFfiError *signal_unidentified_sender_message_content_get_contents(SignalOwnedBuffer *out, SignalConstPointerUnidentifiedSenderMessageContent obj); - -SignalFfiError *signal_unidentified_sender_message_content_get_group_id_or_empty(SignalOwnedBuffer *out, SignalConstPointerUnidentifiedSenderMessageContent m); - -SignalFfiError *signal_unidentified_sender_message_content_get_msg_type(uint8_t *out, SignalConstPointerUnidentifiedSenderMessageContent m); - -SignalFfiError *signal_unidentified_sender_message_content_get_sender_cert(SignalMutPointerSenderCertificate *out, SignalConstPointerUnidentifiedSenderMessageContent m); - -SignalFfiError *signal_unidentified_sender_message_content_new(SignalMutPointerUnidentifiedSenderMessageContent *out, SignalConstPointerCiphertextMessage message, SignalConstPointerSenderCertificate sender, uint32_t content_hint, SignalBorrowedBuffer group_id); - -SignalFfiError *signal_unidentified_sender_message_content_new_from_content_and_type(SignalMutPointerUnidentifiedSenderMessageContent *out, SignalBorrowedBuffer message_content, uint8_t message_type, SignalConstPointerSenderCertificate sender, uint32_t content_hint, SignalBorrowedBuffer group_id); - -SignalFfiError *signal_unidentified_sender_message_content_serialize(SignalOwnedBuffer *out, SignalConstPointerUnidentifiedSenderMessageContent obj); - -SignalFfiError *signal_username_candidates_from(SignalStringArray *out, const char *nickname, uint32_t min_len, uint32_t max_len); +SignalFfiError *signal_validating_mac_finalize(int32_t *out, SignalValidatingMac *mac); SignalFfiError *signal_username_hash(uint8_t (*out)[32], const char *username); -SignalFfiError *signal_username_hash_from_parts(uint8_t (*out)[32], const char *nickname, const char *discriminator, uint32_t min_len, uint32_t max_len); +SignalFfiError *signal_username_proof(SignalOwnedBuffer *out, const char *username, SignalBorrowedBuffer randomness); + +SignalFfiError *signal_username_verify(SignalBorrowedBuffer proof, SignalBorrowedBuffer hash); + +SignalFfiError *signal_username_candidates_from(const char **out, const char *nickname, uint32_t min_len, uint32_t max_len); SignalFfiError *signal_username_link_create(SignalOwnedBuffer *out, const char *username, SignalBorrowedBuffer entropy); SignalFfiError *signal_username_link_decrypt_username(const char **out, SignalBorrowedBuffer entropy, SignalBorrowedBuffer encrypted_username); -SignalFfiError *signal_username_proof(SignalOwnedBuffer *out, const char *username, const uint8_t (*randomness)[32]); +#if defined(SIGNAL_MEDIA_SUPPORTED) +SignalFfiError *signal_signal_media_check_available(void); +#endif -SignalFfiError *signal_username_verify(SignalBorrowedBuffer proof, SignalBorrowedBuffer hash); +#if defined(SIGNAL_MEDIA_SUPPORTED) +SignalFfiError *signal_mp4_sanitizer_sanitize(SignalSanitizedMetadata **out, const SignalInputStream *input, uint64_t len); +#endif -SignalFfiError *signal_uuid_ciphertext_check_valid_contents(SignalBorrowedBuffer buffer); +#if defined(SIGNAL_MEDIA_SUPPORTED) +SignalFfiError *signal_webp_sanitizer_sanitize(bool *out, const SignalSyncInputStream *input, uint64_t len); +#endif -SignalFfiError *signal_validating_mac_destroy(SignalMutPointerValidatingMac p); +#if defined(SIGNAL_MEDIA_SUPPORTED) +SignalFfiError *signal_sanitized_metadata_destroy(SignalSanitizedMetadata *p); +#endif -SignalFfiError *signal_validating_mac_finalize(int32_t *out, SignalMutPointerValidatingMac mac); +#if defined(SIGNAL_MEDIA_SUPPORTED) +SignalFfiError *signal_sanitized_metadata_clone(SignalSanitizedMetadata **new_obj, const SignalSanitizedMetadata *obj); +#endif -SignalFfiError *signal_validating_mac_initialize(SignalMutPointerValidatingMac *out, SignalBorrowedBuffer key, uint32_t chunk_size, SignalBorrowedBuffer digests); +#if defined(SIGNAL_MEDIA_SUPPORTED) +SignalFfiError *signal_sanitized_metadata_get_metadata(SignalOwnedBuffer *out, const SignalSanitizedMetadata *sanitized); +#endif -SignalFfiError *signal_validating_mac_update(int32_t *out, SignalMutPointerValidatingMac mac, SignalBorrowedBuffer bytes, uint32_t offset, uint32_t length); +#if defined(SIGNAL_MEDIA_SUPPORTED) +SignalFfiError *signal_sanitized_metadata_get_data_offset(uint64_t *out, const SignalSanitizedMetadata *sanitized); +#endif -SignalFfiError *signal_webp_sanitizer_sanitize(SignalConstPointerFfiSyncInputStreamStruct input); +#if defined(SIGNAL_MEDIA_SUPPORTED) +SignalFfiError *signal_sanitized_metadata_get_data_len(uint64_t *out, const SignalSanitizedMetadata *sanitized); +#endif -#endif /* SIGNAL_FFI_H_ */ +SignalFfiError *signal_testing_NonSuspendingBackgroundThreadRuntime_destroy(SignalNonSuspendingBackgroundThreadRuntime *p); + +SignalFfiError *signal_testing_future_success(SignalCPromisei32 promise, const void *promise_context, const SignalNonSuspendingBackgroundThreadRuntime *async_runtime, uint8_t input); + +SignalFfiError *signal_testing_future_failure(SignalCPromisei32 promise, const void *promise_context, const SignalNonSuspendingBackgroundThreadRuntime *async_runtime, uint8_t _input); + +SignalFfiError *signal_testing_handle_type_destroy(SignalTestingHandleType *p); + +SignalFfiError *signal_testing_handle_type_clone(SignalTestingHandleType **new_obj, const SignalTestingHandleType *obj); + +SignalFfiError *signal_testing_testing_handle_type_get_value(uint8_t *out, const SignalTestingHandleType *handle); + +SignalFfiError *signal_testing_future_produces_pointer_type(SignalCPromiseTestingHandleType promise, const void *promise_context, const SignalNonSuspendingBackgroundThreadRuntime *async_runtime, uint8_t input); + +SignalFfiError *signal_other_testing_handle_type_destroy(SignalOtherTestingHandleType *p); + +SignalFfiError *signal_other_testing_handle_type_clone(SignalOtherTestingHandleType **new_obj, const SignalOtherTestingHandleType *obj); + +SignalFfiError *signal_testing_other_testing_handle_type_get_value(const char **out, const SignalOtherTestingHandleType *handle); + +SignalFfiError *signal_testing_future_produces_other_pointer_type(SignalCPromiseOtherTestingHandleType promise, const void *promise_context, const SignalNonSuspendingBackgroundThreadRuntime *async_runtime, const char *input); + +SignalFfiError *signal_testing_panic_on_borrow_sync(const void *_input); + +SignalFfiError *signal_testing_panic_on_borrow_async(const void *_input); + +SignalFfiError *signal_testing_panic_on_borrow_io(SignalCPromisebool promise, const void *promise_context, const SignalNonSuspendingBackgroundThreadRuntime *async_runtime, const void *_input); + +SignalFfiError *signal_testing_error_on_borrow_sync(const void *_input); + +SignalFfiError *signal_testing_error_on_borrow_async(const void *_input); + +SignalFfiError *signal_testing_error_on_borrow_io(SignalCPromisebool promise, const void *promise_context, const SignalNonSuspendingBackgroundThreadRuntime *async_runtime, const void *_input); + +SignalFfiError *signal_testing_panic_on_load_sync(const void *_needs_cleanup, const void *_input); + +SignalFfiError *signal_testing_panic_on_load_async(const void *_needs_cleanup, const void *_input); + +SignalFfiError *signal_testing_panic_on_load_io(SignalCPromisebool promise, const void *promise_context, const SignalNonSuspendingBackgroundThreadRuntime *async_runtime, const void *_needs_cleanup, const void *_input); + +SignalFfiError *signal_testing_panic_in_body_sync(const void *_input); + +SignalFfiError *signal_testing_panic_in_body_async(const void *_input); + +SignalFfiError *signal_testing_panic_in_body_io(SignalCPromisebool promise, const void *promise_context, const SignalNonSuspendingBackgroundThreadRuntime *async_runtime, const void *_input); + +SignalFfiError *signal_testing_panic_on_return_sync(const void **out, const void *_needs_cleanup); + +SignalFfiError *signal_testing_panic_on_return_async(const void **out, const void *_needs_cleanup); + +SignalFfiError *signal_testing_panic_on_return_io(SignalCPromiseRawPointer promise, const void *promise_context, const SignalNonSuspendingBackgroundThreadRuntime *async_runtime, const void *_needs_cleanup); + +SignalFfiError *signal_testing_error_on_return_sync(const void **out, const void *_needs_cleanup); + +SignalFfiError *signal_testing_error_on_return_async(const void **out, const void *_needs_cleanup); + +SignalFfiError *signal_testing_error_on_return_io(SignalCPromiseRawPointer promise, const void *promise_context, const SignalNonSuspendingBackgroundThreadRuntime *async_runtime, const void *_needs_cleanup); + +#endif /* SIGNAL_FFI_H_ */ diff --git a/pkg/libsignalgo/logging.go b/pkg/libsignalgo/logging.go index 1926c23..2fcf8ba 100644 --- a/pkg/libsignalgo/logging.go +++ b/pkg/libsignalgo/logging.go @@ -17,35 +17,33 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include <./libsignal-ffi.h> -extern void signal_log_callback(void *ctx, SignalLogLevel level, char *file, uint32_t line, char *message); -extern void signal_log_flush_callback(void *ctx); -extern void signal_log_destroy_callback(void *ctx); +extern bool signal_log_enabled_callback(char *target, SignalLogLevel level); +extern void signal_log_callback(char *target, SignalLogLevel level, char *file, uint32_t line, char *message); +extern void signal_log_flush_callback(); */ import "C" -import ( - "unsafe" -) // ffiLogger is the global logger object. var ffiLogger Logger +//export signal_log_enabled_callback +func signal_log_enabled_callback(target *C.char, level C.SignalLogLevel) C.bool { + return C.bool(ffiLogger.Enabled(C.GoString(target), LogLevel(int(level)))) +} + //export signal_log_callback -func signal_log_callback(ctx unsafe.Pointer, level C.SignalLogLevel, file *C.char, line C.uint32_t, message *C.char) { - ffiLogger.Log(LogLevel(int(level)), C.GoString(file), uint(line), C.GoString(message)) +func signal_log_callback(target *C.char, level C.SignalLogLevel, file *C.char, line C.uint32_t, message *C.char) { + ffiLogger.Log(C.GoString(target), LogLevel(int(level)), C.GoString(file), uint(line), C.GoString(message)) } //export signal_log_flush_callback -func signal_log_flush_callback(ctx unsafe.Pointer) { +func signal_log_flush_callback() { ffiLogger.Flush() } -//export signal_log_destroy_callback -func signal_log_destroy_callback(ctx unsafe.Pointer) { - ffiLogger.Destroy() -} - type LogLevel int const ( @@ -57,16 +55,16 @@ const ( ) type Logger interface { - Log(level LogLevel, file string, line uint, message string) + Enabled(target string, level LogLevel) bool + Log(target string, level LogLevel, file string, line uint, message string) Flush() - Destroy() } func InitLogger(level LogLevel, logger Logger) { ffiLogger = logger - C.signal_init_logger(C.SignalLogLevel(level), C.SignalFfiLoggerStruct{ - log: C.SignalFfiLoggerLog(C.signal_log_callback), - flush: C.SignalFfiLoggerFlush(C.signal_log_flush_callback), - destroy: C.SignalFfiLoggerDestroy(C.signal_log_destroy_callback), + C.signal_init_logger(C.SignalLogLevel(level), C.SignalFfiLogger{ + enabled: C.SignalLogEnabledCallback(C.signal_log_enabled_callback), + log: C.SignalLogCallback(C.signal_log_callback), + flush: C.SignalLogFlushCallback(C.signal_log_flush_callback), }) } diff --git a/pkg/libsignalgo/message.go b/pkg/libsignalgo/message.go index 6cba873..dffcb03 100644 --- a/pkg/libsignalgo/message.go +++ b/pkg/libsignalgo/message.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Sumner Evans -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,53 +17,25 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" import ( - "context" "runtime" - "time" ) -func Encrypt(ctx context.Context, plaintext []byte, forAddress, localAddress *Address, sessionStore SessionStore, identityKeyStore IdentityKeyStore) (*CiphertextMessage, error) { - var ciphertextMessage C.SignalMutPointerCiphertextMessage - var now C.uint64_t = C.uint64_t(time.Now().Unix()) - callbackCtx := NewCallbackContext(ctx) - defer callbackCtx.Unref() - signalFfiError := C.signal_encrypt_message( - &ciphertextMessage, - BytesToBuffer(plaintext), - forAddress.constPtr(), - localAddress.constPtr(), - callbackCtx.wrapSessionStore(sessionStore), - callbackCtx.wrapIdentityKeyStore(identityKeyStore), - now, - ) - runtime.KeepAlive(plaintext) - runtime.KeepAlive(forAddress) - if signalFfiError != nil { - return nil, callbackCtx.wrapError(signalFfiError) - } - return wrapCiphertextMessage(ciphertextMessage.raw), nil -} - -func Decrypt(ctx context.Context, message *Message, fromAddress, localAddress *Address, sessionStore SessionStore, identityStore IdentityKeyStore) ([]byte, error) { - callbackCtx := NewCallbackContext(ctx) - defer callbackCtx.Unref() +func Decrypt(message *Message, fromAddress *Address, sessionStore SessionStore, identityStore IdentityKeyStore, ctx *CallbackContext) ([]byte, error) { var decrypted C.SignalOwnedBuffer = C.SignalOwnedBuffer{} signalFfiError := C.signal_decrypt_message( &decrypted, - message.constPtr(), - fromAddress.constPtr(), - localAddress.constPtr(), - callbackCtx.wrapSessionStore(sessionStore), - callbackCtx.wrapIdentityKeyStore(identityStore), + message.ptr, + fromAddress.ptr, + wrapSessionStore(sessionStore), + wrapIdentityKeyStore(identityStore), ) - runtime.KeepAlive(message) - runtime.KeepAlive(fromAddress) if signalFfiError != nil { - return nil, callbackCtx.wrapError(signalFfiError) + return nil, wrapCallbackError(signalFfiError, ctx) } return CopySignalOwnedBufferToBytes(decrypted), nil } @@ -81,36 +52,26 @@ func wrapMessage(ptr *C.SignalMessage) *Message { } func DeserializeMessage(serialized []byte) (*Message, error) { - var m C.SignalMutPointerSignalMessage + var m *C.SignalMessage signalFfiError := C.signal_message_deserialize(&m, BytesToBuffer(serialized)) - runtime.KeepAlive(serialized) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapMessage(m.raw), nil -} - -func (m *Message) mutPtr() C.SignalMutPointerSignalMessage { - return C.SignalMutPointerSignalMessage{m.ptr} -} - -func (m *Message) constPtr() C.SignalConstPointerSignalMessage { - return C.SignalConstPointerSignalMessage{m.ptr} + return wrapMessage(m), nil } func (m *Message) Clone() (*Message, error) { - var cloned C.SignalMutPointerSignalMessage - signalFfiError := C.signal_message_clone(&cloned, m.constPtr()) - runtime.KeepAlive(m) + var cloned *C.SignalMessage + signalFfiError := C.signal_message_clone(&cloned, m.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapMessage(cloned.raw), nil + return wrapMessage(cloned), nil } func (m *Message) Destroy() error { m.CancelFinalizer() - return wrapError(C.signal_message_destroy(m.mutPtr())) + return wrapError(C.signal_message_destroy(m.ptr)) } func (m *Message) CancelFinalizer() { @@ -119,8 +80,7 @@ func (m *Message) CancelFinalizer() { func (m *Message) GetBody() ([]byte, error) { var body C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_message_get_body(&body, m.constPtr()) - runtime.KeepAlive(m) + signalFfiError := C.signal_message_get_body(&body, m.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -129,8 +89,7 @@ func (m *Message) GetBody() ([]byte, error) { func (m *Message) Serialize() ([]byte, error) { var serialized C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_message_get_serialized(&serialized, m.constPtr()) - runtime.KeepAlive(m) + signalFfiError := C.signal_message_get_serialized(&serialized, m.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -139,8 +98,7 @@ func (m *Message) Serialize() ([]byte, error) { func (m *Message) GetMessageVersion() (uint32, error) { var messageVersion C.uint32_t - signalFfiError := C.signal_message_get_message_version(&messageVersion, m.constPtr()) - runtime.KeepAlive(m) + signalFfiError := C.signal_message_get_message_version(&messageVersion, m.ptr) if signalFfiError != nil { return 0, wrapError(signalFfiError) } @@ -149,8 +107,7 @@ func (m *Message) GetMessageVersion() (uint32, error) { func (m *Message) GetCounter() (uint32, error) { var counter C.uint32_t - signalFfiError := C.signal_message_get_counter(&counter, m.constPtr()) - runtime.KeepAlive(m) + signalFfiError := C.signal_message_get_counter(&counter, m.ptr) if signalFfiError != nil { return 0, wrapError(signalFfiError) } @@ -159,17 +116,7 @@ func (m *Message) GetCounter() (uint32, error) { func (m *Message) VerifyMAC(sender, receiver *PublicKey, macKey []byte) (bool, error) { var result C.bool - signalFfiError := C.signal_message_verify_mac( - &result, - m.constPtr(), - sender.constPtr(), - receiver.constPtr(), - BytesToBuffer(macKey), - ) - runtime.KeepAlive(m) - runtime.KeepAlive(sender) - runtime.KeepAlive(receiver) - runtime.KeepAlive(macKey) + signalFfiError := C.signal_message_verify_mac(&result, m.ptr, sender.ptr, receiver.ptr, BytesToBuffer(macKey)) if signalFfiError != nil { return false, wrapError(signalFfiError) } diff --git a/pkg/libsignalgo/messagebackupkey.go b/pkg/libsignalgo/messagebackupkey.go deleted file mode 100644 index 65b4136..0000000 --- a/pkg/libsignalgo/messagebackupkey.go +++ /dev/null @@ -1,105 +0,0 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2025 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package libsignalgo - -/* -#include "./libsignal-ffi.h" -*/ -import "C" -import ( - "runtime" - "unsafe" -) - -type MessageBackupKey struct { - nc noCopy - ptr *C.SignalMessageBackupKey -} - -func wrapMessageBackupKey(ptr *C.SignalMessageBackupKey) *MessageBackupKey { - backupKey := &MessageBackupKey{ptr: ptr} - runtime.SetFinalizer(backupKey, (*MessageBackupKey).Destroy) - return backupKey -} - -func MessageBackupKeyFromAccountEntropyPool(aep AccountEntropyPool, aci ServiceID) (*MessageBackupKey, error) { - var bk C.SignalMutPointerMessageBackupKey - signalFfiError := C.signal_message_backup_key_from_account_entropy_pool( - &bk, - C.CString(string(aep)), - aci.CFixedBytes(), - nil, // TODO what's a forward secrecy token? - ) - runtime.KeepAlive(aep) - if signalFfiError != nil { - return nil, wrapError(signalFfiError) - } - return wrapMessageBackupKey(bk.raw), nil -} - -func MessageBackupKeyFromBackupKeyAndID(backupKey *BackupKey, backupID *BackupID) (*MessageBackupKey, error) { - var bk C.SignalMutPointerMessageBackupKey - signalFfiError := C.signal_message_backup_key_from_backup_key_and_backup_id( - &bk, - (*[C.SignalBACKUP_KEY_LEN]C.uint8_t)(unsafe.Pointer(backupKey)), - (*[BackupIDLength]C.uint8_t)(unsafe.Pointer(backupID)), - nil, // TODO what's a forward secrecy token? - ) - runtime.KeepAlive(backupKey) - runtime.KeepAlive(backupID) - if signalFfiError != nil { - return nil, wrapError(signalFfiError) - } - return wrapMessageBackupKey(bk.raw), nil -} - -func (bk *MessageBackupKey) mutPtr() C.SignalMutPointerMessageBackupKey { - return C.SignalMutPointerMessageBackupKey{bk.ptr} -} - -func (bk *MessageBackupKey) constPtr() C.SignalConstPointerMessageBackupKey { - return C.SignalConstPointerMessageBackupKey{bk.ptr} -} - -func (bk *MessageBackupKey) Destroy() error { - runtime.SetFinalizer(bk, nil) - return wrapError(C.signal_message_backup_key_destroy(bk.mutPtr())) -} - -func (bk *MessageBackupKey) GetHMACKey() ([32]byte, error) { - var out [32]byte - signalFfiError := C.signal_message_backup_key_get_hmac_key( - (*[32]C.uint8_t)(unsafe.Pointer(&out)), - bk.constPtr(), - ) - if signalFfiError != nil { - return out, wrapError(signalFfiError) - } - return out, nil -} - -func (bk *MessageBackupKey) GetAESKey() ([32]byte, error) { - var out [32]byte - signalFfiError := C.signal_message_backup_key_get_aes_key( - (*[32]C.uint8_t)(unsafe.Pointer(&out)), - bk.constPtr(), - ) - if signalFfiError != nil { - return out, wrapError(signalFfiError) - } - return out, nil -} diff --git a/pkg/libsignalgo/plaintextcontent.go b/pkg/libsignalgo/plaintextcontent.go index 346f0c9..19d4818 100644 --- a/pkg/libsignalgo/plaintextcontent.go +++ b/pkg/libsignalgo/plaintextcontent.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Sumner Evans -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,6 +17,7 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" @@ -35,52 +35,35 @@ func wrapPlaintextContent(ptr *C.SignalPlaintextContent) *PlaintextContent { } func PlaintextContentFromDecryptionErrorMessage(message *DecryptionErrorMessage) (*PlaintextContent, error) { - var pc C.SignalMutPointerPlaintextContent - signalFfiError := C.signal_plaintext_content_from_decryption_error_message( - &pc, - message.constPtr(), - ) - runtime.KeepAlive(message) + var pc *C.SignalPlaintextContent + signalFfiError := C.signal_plaintext_content_from_decryption_error_message(&pc, message.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapPlaintextContent(pc.raw), nil + return wrapPlaintextContent(pc), nil } func DeserializePlaintextContent(plaintextContentBytes []byte) (*PlaintextContent, error) { - var pc C.SignalMutPointerPlaintextContent + var pc *C.SignalPlaintextContent signalFfiError := C.signal_plaintext_content_deserialize(&pc, BytesToBuffer(plaintextContentBytes)) - runtime.KeepAlive(plaintextContentBytes) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapPlaintextContent(pc.raw), nil -} - -func (pc *PlaintextContent) mutPtr() C.SignalMutPointerPlaintextContent { - return C.SignalMutPointerPlaintextContent{pc.ptr} -} - -func (pc *PlaintextContent) constPtr() C.SignalConstPointerPlaintextContent { - return C.SignalConstPointerPlaintextContent{pc.ptr} + return wrapPlaintextContent(pc), nil } func (pc *PlaintextContent) Clone() (*PlaintextContent, error) { - var cloned C.SignalMutPointerPlaintextContent - signalFfiError := C.signal_plaintext_content_clone( - &cloned, - pc.constPtr(), - ) - runtime.KeepAlive(pc) + var cloned *C.SignalPlaintextContent + signalFfiError := C.signal_plaintext_content_clone(&cloned, pc.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapPlaintextContent(cloned.raw), nil + return wrapPlaintextContent(cloned), nil } func (pc *PlaintextContent) Destroy() error { pc.CancelFinalizer() - return wrapError(C.signal_plaintext_content_destroy(pc.mutPtr())) + return wrapError(C.signal_plaintext_content_destroy(pc.ptr)) } func (pc *PlaintextContent) CancelFinalizer() { @@ -89,8 +72,7 @@ func (pc *PlaintextContent) CancelFinalizer() { func (pc *PlaintextContent) Serialize() ([]byte, error) { var serialized C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_plaintext_content_serialize(&serialized, pc.constPtr()) - runtime.KeepAlive(pc) + signalFfiError := C.signal_plaintext_content_serialize(&serialized, pc.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -99,8 +81,7 @@ func (pc *PlaintextContent) Serialize() ([]byte, error) { func (pc *PlaintextContent) GetBody() ([]byte, error) { var body C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_plaintext_content_get_body(&body, pc.constPtr()) - runtime.KeepAlive(pc) + signalFfiError := C.signal_plaintext_content_get_body(&body, pc.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } diff --git a/pkg/libsignalgo/prekey.go b/pkg/libsignalgo/prekey.go index 29e640e..db137ae 100644 --- a/pkg/libsignalgo/prekey.go +++ b/pkg/libsignalgo/prekey.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Sumner Evans -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,33 +17,28 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" import ( - "context" "runtime" ) -func DecryptPreKey(ctx context.Context, preKeyMessage *PreKeyMessage, fromAddress, localAddress *Address, sessionStore SessionStore, identityStore IdentityKeyStore, preKeyStore PreKeyStore, signedPreKeyStore SignedPreKeyStore, kyberPreKeyStore KyberPreKeyStore) ([]byte, error) { - callbackCtx := NewCallbackContext(ctx) - defer callbackCtx.Unref() +func DecryptPreKey(preKeyMessage *PreKeyMessage, fromAddress *Address, sessionStore SessionStore, identityStore IdentityKeyStore, preKeyStore PreKeyStore, signedPreKeyStore SignedPreKeyStore, kyberPreKeyStore KyberPreKeyStore, ctx *CallbackContext) ([]byte, error) { var decrypted C.SignalOwnedBuffer = C.SignalOwnedBuffer{} signalFfiError := C.signal_decrypt_pre_key_message( &decrypted, - preKeyMessage.constPtr(), - fromAddress.constPtr(), - localAddress.constPtr(), - callbackCtx.wrapSessionStore(sessionStore), - callbackCtx.wrapIdentityKeyStore(identityStore), - callbackCtx.wrapPreKeyStore(preKeyStore), - callbackCtx.wrapSignedPreKeyStore(signedPreKeyStore), - callbackCtx.wrapKyberPreKeyStore(kyberPreKeyStore), + preKeyMessage.ptr, + fromAddress.ptr, + wrapSessionStore(sessionStore), + wrapIdentityKeyStore(identityStore), + wrapPreKeyStore(preKeyStore), + wrapSignedPreKeyStore(signedPreKeyStore), + wrapKyberPreKeyStore(kyberPreKeyStore), // TODO: *actually* support Kyber prekeys I guess, this is a stub right now ) - runtime.KeepAlive(preKeyMessage) - runtime.KeepAlive(fromAddress) if signalFfiError != nil { - return nil, callbackCtx.wrapError(signalFfiError) + return nil, wrapCallbackError(signalFfiError, ctx) } return CopySignalOwnedBufferToBytes(decrypted), nil } @@ -61,19 +55,12 @@ func wrapPreKeyRecord(ptr *C.SignalPreKeyRecord) *PreKeyRecord { } func NewPreKeyRecord(id uint32, publicKey *PublicKey, privateKey *PrivateKey) (*PreKeyRecord, error) { - var pkr C.SignalMutPointerPreKeyRecord - signalFfiError := C.signal_pre_key_record_new( - &pkr, - C.uint32_t(id), - publicKey.constPtr(), - privateKey.constPtr(), - ) - runtime.KeepAlive(publicKey) - runtime.KeepAlive(privateKey) + var pkr *C.SignalPreKeyRecord + signalFfiError := C.signal_pre_key_record_new(&pkr, C.uint32_t(id), publicKey.ptr, privateKey.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapPreKeyRecord(pkr.raw), nil + return wrapPreKeyRecord(pkr), nil } func NewPreKeyRecordFromPrivateKey(id uint32, privateKey *PrivateKey) (*PreKeyRecord, error) { @@ -85,36 +72,26 @@ func NewPreKeyRecordFromPrivateKey(id uint32, privateKey *PrivateKey) (*PreKeyRe } func DeserializePreKeyRecord(serialized []byte) (*PreKeyRecord, error) { - var pkr C.SignalMutPointerPreKeyRecord + var pkr *C.SignalPreKeyRecord signalFfiError := C.signal_pre_key_record_deserialize(&pkr, BytesToBuffer(serialized)) - runtime.KeepAlive(serialized) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapPreKeyRecord(pkr.raw), nil -} - -func (pkr *PreKeyRecord) mutPtr() C.SignalMutPointerPreKeyRecord { - return C.SignalMutPointerPreKeyRecord{pkr.ptr} -} - -func (pkr *PreKeyRecord) constPtr() C.SignalConstPointerPreKeyRecord { - return C.SignalConstPointerPreKeyRecord{pkr.ptr} + return wrapPreKeyRecord(pkr), nil } func (pkr *PreKeyRecord) Clone() (*PreKeyRecord, error) { - var cloned C.SignalMutPointerPreKeyRecord - signalFfiError := C.signal_pre_key_record_clone(&cloned, pkr.constPtr()) - runtime.KeepAlive(pkr) + var cloned *C.SignalPreKeyRecord + signalFfiError := C.signal_pre_key_record_clone(&cloned, pkr.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapPreKeyRecord(cloned.raw), nil + return wrapPreKeyRecord(cloned), nil } func (pkr *PreKeyRecord) Destroy() error { pkr.CancelFinalizer() - return wrapError(C.signal_pre_key_record_destroy(pkr.mutPtr())) + return wrapError(C.signal_pre_key_record_destroy(pkr.ptr)) } func (pkr *PreKeyRecord) CancelFinalizer() { @@ -123,40 +100,36 @@ func (pkr *PreKeyRecord) CancelFinalizer() { func (pkr *PreKeyRecord) Serialize() ([]byte, error) { var serialized C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_pre_key_record_serialize(&serialized, pkr.constPtr()) - runtime.KeepAlive(pkr) + signalFfiError := C.signal_pre_key_record_serialize(&serialized, pkr.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } return CopySignalOwnedBufferToBytes(serialized), nil } -func (pkr *PreKeyRecord) GetID() (uint32, error) { +func (pkr *PreKeyRecord) GetID() (uint, error) { var id C.uint32_t - signalFfiError := C.signal_pre_key_record_get_id(&id, pkr.constPtr()) - runtime.KeepAlive(pkr) + signalFfiError := C.signal_pre_key_record_get_id(&id, pkr.ptr) if signalFfiError != nil { return 0, wrapError(signalFfiError) } - return uint32(id), nil + return uint(id), nil } func (pkr *PreKeyRecord) GetPublicKey() (*PublicKey, error) { - var pub C.SignalMutPointerPublicKey - signalFfiError := C.signal_pre_key_record_get_public_key(&pub, pkr.constPtr()) - runtime.KeepAlive(pkr) + var pub *C.SignalPublicKey + signalFfiError := C.signal_pre_key_record_get_public_key(&pub, pkr.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapPublicKey(pub.raw), nil + return wrapPublicKey(pub), nil } func (pkr *PreKeyRecord) GetPrivateKey() (*PrivateKey, error) { - var priv C.SignalMutPointerPrivateKey - signalFfiError := C.signal_pre_key_record_get_private_key(&priv, pkr.constPtr()) - runtime.KeepAlive(pkr) + var priv *C.SignalPrivateKey + signalFfiError := C.signal_pre_key_record_get_private_key(&priv, pkr.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapPrivateKey(priv.raw), nil + return wrapPrivateKey(priv), nil } diff --git a/pkg/libsignalgo/prekeybundle.go b/pkg/libsignalgo/prekeybundle.go index 8a6fcaa..bee2434 100644 --- a/pkg/libsignalgo/prekeybundle.go +++ b/pkg/libsignalgo/prekeybundle.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Sumner Evans -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,30 +17,25 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" import ( - "context" "runtime" "time" ) -func ProcessPreKeyBundle(ctx context.Context, bundle *PreKeyBundle, forAddress, localAddress *Address, sessionStore SessionStore, identityStore IdentityKeyStore) error { - callbackCtx := NewCallbackContext(ctx) - defer callbackCtx.Unref() +func ProcessPreKeyBundle(bundle *PreKeyBundle, forAddress *Address, sessionStore SessionStore, identityStore IdentityKeyStore, ctx *CallbackContext) error { var now C.uint64_t = C.uint64_t(time.Now().Unix()) signalFfiError := C.signal_process_prekey_bundle( - bundle.constPtr(), - forAddress.constPtr(), - localAddress.constPtr(), - callbackCtx.wrapSessionStore(sessionStore), - callbackCtx.wrapIdentityKeyStore(identityStore), + bundle.ptr, + forAddress.ptr, + wrapSessionStore(sessionStore), + wrapIdentityKeyStore(identityStore), now, ) - runtime.KeepAlive(bundle) - runtime.KeepAlive(forAddress) - return callbackCtx.wrapError(signalFfiError) + return wrapCallbackError(signalFfiError, ctx) } type PreKeyBundle struct { @@ -68,7 +62,7 @@ func NewPreKeyBundle( kyberPreKeySignature []byte, identityKey *IdentityKey, ) (*PreKeyBundle, error) { - var pkb C.SignalMutPointerPreKeyBundle + var pkb *C.SignalPreKeyBundle var zero uint32 = 0 var kyberSignatureBuffer = EmptyBorrowedBuffer() if preKey == nil { @@ -86,48 +80,33 @@ func NewPreKeyBundle( C.uint32_t(registrationID), C.uint32_t(deviceID), C.uint32_t(preKeyID), - preKey.constPtr(), + preKey.ptr, C.uint32_t(signedPreKeyID), - signedPreKey.constPtr(), + signedPreKey.ptr, BytesToBuffer(signedPreKeySignature), - identityKey.publicKey.constPtr(), + identityKey.publicKey.ptr, C.uint32_t(kyberPreKeyID), - kyberPreKey.constPtr(), + kyberPreKey.ptr, kyberSignatureBuffer, ) - runtime.KeepAlive(preKey) - runtime.KeepAlive(signedPreKey) - runtime.KeepAlive(signedPreKeySignature) - runtime.KeepAlive(kyberPreKey) - runtime.KeepAlive(kyberPreKeySignature) - runtime.KeepAlive(identityKey) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapPreKeyBundle(pkb.raw), nil -} - -func (pkb *PreKeyBundle) mutPtr() C.SignalMutPointerPreKeyBundle { - return C.SignalMutPointerPreKeyBundle{pkb.ptr} -} - -func (pkb *PreKeyBundle) constPtr() C.SignalConstPointerPreKeyBundle { - return C.SignalConstPointerPreKeyBundle{pkb.ptr} + return wrapPreKeyBundle(pkb), nil } func (pkb *PreKeyBundle) Clone() (*PreKeyBundle, error) { - var cloned C.SignalMutPointerPreKeyBundle - signalFfiError := C.signal_pre_key_bundle_clone(&cloned, pkb.constPtr()) + var cloned *C.SignalPreKeyBundle + signalFfiError := C.signal_pre_key_bundle_clone(&cloned, pkb.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - runtime.KeepAlive(pkb) - return wrapPreKeyBundle(cloned.raw), nil + return wrapPreKeyBundle(cloned), nil } func (pkb *PreKeyBundle) Destroy() error { pkb.CancelFinalizer() - return wrapError(C.signal_pre_key_bundle_destroy(pkb.mutPtr())) + return wrapError(C.signal_pre_key_bundle_destroy(pkb.ptr)) } func (pkb *PreKeyBundle) CancelFinalizer() { @@ -135,11 +114,10 @@ func (pkb *PreKeyBundle) CancelFinalizer() { } func (pkb *PreKeyBundle) GetIdentityKey() (*IdentityKey, error) { - var pk C.SignalMutPointerPublicKey - signalFfiError := C.signal_pre_key_bundle_get_identity_key(&pk, pkb.constPtr()) + var pk *C.SignalPublicKey + signalFfiError := C.signal_pre_key_bundle_get_identity_key(&pk, pkb.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - runtime.KeepAlive(pkb) - return NewIdentityKeyFromPublicKey(wrapPublicKey(pk.raw)) + return NewIdentityKeyFromPublicKey(wrapPublicKey(pk)) } diff --git a/pkg/libsignalgo/prekeymessage.go b/pkg/libsignalgo/prekeymessage.go index 7261933..388cbf8 100644 --- a/pkg/libsignalgo/prekeymessage.go +++ b/pkg/libsignalgo/prekeymessage.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Sumner Evans -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,6 +17,7 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" @@ -35,36 +35,26 @@ func wrapPreKeyMessage(ptr *C.SignalPreKeySignalMessage) *PreKeyMessage { } func DeserializePreKeyMessage(serialized []byte) (*PreKeyMessage, error) { - var m C.SignalMutPointerPreKeySignalMessage + var m *C.SignalPreKeySignalMessage signalFfiError := C.signal_pre_key_signal_message_deserialize(&m, BytesToBuffer(serialized)) - runtime.KeepAlive(serialized) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapPreKeyMessage(m.raw), nil -} - -func (m *PreKeyMessage) mutPtr() C.SignalMutPointerPreKeySignalMessage { - return C.SignalMutPointerPreKeySignalMessage{m.ptr} -} - -func (m *PreKeyMessage) constPtr() C.SignalConstPointerPreKeySignalMessage { - return C.SignalConstPointerPreKeySignalMessage{m.ptr} + return wrapPreKeyMessage(m), nil } func (m *PreKeyMessage) Clone() (*PreKeyMessage, error) { - var cloned C.SignalMutPointerPreKeySignalMessage - signalFfiError := C.signal_pre_key_signal_message_clone(&cloned, m.constPtr()) - runtime.KeepAlive(m) + var cloned *C.SignalPreKeySignalMessage + signalFfiError := C.signal_pre_key_signal_message_clone(&cloned, m.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapPreKeyMessage(cloned.raw), nil + return wrapPreKeyMessage(cloned), nil } func (m *PreKeyMessage) Destroy() error { m.CancelFinalizer() - return wrapError(C.signal_pre_key_signal_message_destroy(m.mutPtr())) + return wrapError(C.signal_pre_key_signal_message_destroy(m.ptr)) } func (m *PreKeyMessage) CancelFinalizer() { @@ -73,8 +63,7 @@ func (m *PreKeyMessage) CancelFinalizer() { func (m *PreKeyMessage) Serialize() ([]byte, error) { var serialized C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_pre_key_signal_message_serialize(&serialized, m.constPtr()) - runtime.KeepAlive(m) + signalFfiError := C.signal_pre_key_signal_message_serialize(&serialized, m.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -83,8 +72,7 @@ func (m *PreKeyMessage) Serialize() ([]byte, error) { func (m *PreKeyMessage) GetVersion() (uint32, error) { var version C.uint - signalFfiError := C.signal_pre_key_signal_message_get_version(&version, m.constPtr()) - runtime.KeepAlive(m) + signalFfiError := C.signal_pre_key_signal_message_get_version(&version, m.ptr) if signalFfiError != nil { return 0, wrapError(signalFfiError) } @@ -93,8 +81,7 @@ func (m *PreKeyMessage) GetVersion() (uint32, error) { func (m *PreKeyMessage) GetRegistrationID() (uint32, error) { var registrationID C.uint - signalFfiError := C.signal_pre_key_signal_message_get_registration_id(®istrationID, m.constPtr()) - runtime.KeepAlive(m) + signalFfiError := C.signal_pre_key_signal_message_get_registration_id(®istrationID, m.ptr) if signalFfiError != nil { return 0, wrapError(signalFfiError) } @@ -103,8 +90,7 @@ func (m *PreKeyMessage) GetRegistrationID() (uint32, error) { func (m *PreKeyMessage) GetPreKeyID() (*uint32, error) { var preKeyID C.uint - signalFfiError := C.signal_pre_key_signal_message_get_pre_key_id(&preKeyID, m.constPtr()) - runtime.KeepAlive(m) + signalFfiError := C.signal_pre_key_signal_message_get_pre_key_id(&preKeyID, m.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -116,8 +102,7 @@ func (m *PreKeyMessage) GetPreKeyID() (*uint32, error) { func (m *PreKeyMessage) GetSignedPreKeyID() (uint32, error) { var signedPreKeyID C.uint - signalFfiError := C.signal_pre_key_signal_message_get_signed_pre_key_id(&signedPreKeyID, m.constPtr()) - runtime.KeepAlive(m) + signalFfiError := C.signal_pre_key_signal_message_get_signed_pre_key_id(&signedPreKeyID, m.ptr) if signalFfiError != nil { return 0, wrapError(signalFfiError) } @@ -125,31 +110,28 @@ func (m *PreKeyMessage) GetSignedPreKeyID() (uint32, error) { } func (m *PreKeyMessage) GetBaseKey() (*PublicKey, error) { - var publicKey C.SignalMutPointerPublicKey - signalFfiError := C.signal_pre_key_signal_message_get_base_key(&publicKey, m.constPtr()) - runtime.KeepAlive(m) + var publicKey *C.SignalPublicKey + signalFfiError := C.signal_pre_key_signal_message_get_base_key(&publicKey, m.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapPublicKey(publicKey.raw), nil + return wrapPublicKey(publicKey), nil } func (m *PreKeyMessage) GetIdentityKey() (*IdentityKey, error) { - var publicKey C.SignalMutPointerPublicKey - signalFfiError := C.signal_pre_key_signal_message_get_identity_key(&publicKey, m.constPtr()) - runtime.KeepAlive(m) + var publicKey *C.SignalPublicKey + signalFfiError := C.signal_pre_key_signal_message_get_identity_key(&publicKey, m.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return &IdentityKey{wrapPublicKey(publicKey.raw)}, nil + return &IdentityKey{wrapPublicKey(publicKey)}, nil } func (m *PreKeyMessage) GetSignalMessage() (*Message, error) { - var message C.SignalMutPointerSignalMessage - signalFfiError := C.signal_pre_key_signal_message_get_signal_message(&message, m.constPtr()) - runtime.KeepAlive(m) + var message *C.SignalMessage + signalFfiError := C.signal_pre_key_signal_message_get_signal_message(&message, m.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapMessage(message.raw), nil + return wrapMessage(message), nil } diff --git a/pkg/libsignalgo/prekeystore.go b/pkg/libsignalgo/prekeystore.go index 8c3c36f..f216bb5 100644 --- a/pkg/libsignalgo/prekeystore.go +++ b/pkg/libsignalgo/prekeystore.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Sumner Evans -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,67 +17,66 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" -extern int signal_load_pre_key_callback(void *store_ctx, SignalMutPointerPreKeyRecord *recordp, uint32_t id); -extern int signal_store_pre_key_callback(void *store_ctx, uint32_t id, SignalMutPointerPreKeyRecord record); -extern int signal_remove_pre_key_callback(void *store_ctx, uint32_t id); -extern void signal_destroy_pre_key_store_callback(void *store_ctx); +typedef const SignalPreKeyRecord const_pre_key_record; + +extern int signal_load_pre_key_callback(void *store_ctx, SignalPreKeyRecord **recordp, uint32_t id, void *ctx); +extern int signal_store_pre_key_callback(void *store_ctx, uint32_t id, const_pre_key_record *record, void *ctx); +extern int signal_remove_pre_key_callback(void *store_ctx, uint32_t id, void *ctx); */ import "C" import ( "context" "unsafe" + + gopointer "github.com/mattn/go-pointer" ) type PreKeyStore interface { - LoadPreKey(ctx context.Context, id uint32) (*PreKeyRecord, error) - StorePreKey(ctx context.Context, id uint32, preKeyRecord *PreKeyRecord) error - RemovePreKey(ctx context.Context, id uint32) error + LoadPreKey(id uint32, ctx context.Context) (*PreKeyRecord, error) + StorePreKey(id uint32, preKeyRecord *PreKeyRecord, ctx context.Context) error + RemovePreKey(id uint32, ctx context.Context) error } //export signal_load_pre_key_callback -func signal_load_pre_key_callback(storeCtx unsafe.Pointer, keyp *C.SignalMutPointerPreKeyRecord, id C.uint32_t) C.int { - return wrapStoreCallback(storeCtx, func(store PreKeyStore, ctx context.Context) error { - key, err := store.LoadPreKey(ctx, uint32(id)) +func signal_load_pre_key_callback(storeCtx unsafe.Pointer, keyp **C.SignalPreKeyRecord, id C.uint32_t, ctxPtr unsafe.Pointer) C.int { + return wrapStoreCallback(storeCtx, ctxPtr, func(store PreKeyStore, ctx context.Context) error { + key, err := store.LoadPreKey(uint32(id), ctx) if err == nil && key != nil { key.CancelFinalizer() - keyp.raw = key.ptr + *keyp = key.ptr } return err }) } //export signal_store_pre_key_callback -func signal_store_pre_key_callback(storeCtx unsafe.Pointer, id C.uint32_t, preKeyRecord C.SignalMutPointerPreKeyRecord) C.int { - return wrapStoreCallback(storeCtx, func(store PreKeyStore, ctx context.Context) error { - record := PreKeyRecord{ptr: preKeyRecord.raw} +func signal_store_pre_key_callback(storeCtx unsafe.Pointer, id C.uint32_t, preKeyRecord *C.const_pre_key_record, ctxPtr unsafe.Pointer) C.int { + return wrapStoreCallback(storeCtx, ctxPtr, func(store PreKeyStore, ctx context.Context) error { + record := PreKeyRecord{ptr: (*C.SignalPreKeyRecord)(unsafe.Pointer(preKeyRecord))} cloned, err := record.Clone() if err != nil { return err } - return store.StorePreKey(ctx, uint32(id), cloned) + return store.StorePreKey(uint32(id), cloned, ctx) }) } //export signal_remove_pre_key_callback -func signal_remove_pre_key_callback(storeCtx unsafe.Pointer, id C.uint32_t) C.int { - return wrapStoreCallback(storeCtx, func(store PreKeyStore, ctx context.Context) error { - return store.RemovePreKey(ctx, uint32(id)) +func signal_remove_pre_key_callback(storeCtx unsafe.Pointer, id C.uint32_t, ctxPtr unsafe.Pointer) C.int { + return wrapStoreCallback(storeCtx, ctxPtr, func(store PreKeyStore, ctx context.Context) error { + return store.RemovePreKey(uint32(id), ctx) }) } -//export signal_destroy_pre_key_store_callback -func signal_destroy_pre_key_store_callback(storeCtx unsafe.Pointer) { - // No-op: Go's garbage collector handles cleanup -} - -func (ctx *CallbackContext) wrapPreKeyStore(store PreKeyStore) C.SignalConstPointerFfiPreKeyStoreStruct { - return C.SignalConstPointerFfiPreKeyStoreStruct{&C.SignalPreKeyStore{ - ctx: wrapStore(ctx, store), - load_pre_key: C.SignalFfiPreKeyStoreLoadPreKey(C.signal_load_pre_key_callback), - store_pre_key: C.SignalFfiPreKeyStoreStorePreKey(C.signal_store_pre_key_callback), - remove_pre_key: C.SignalFfiPreKeyStoreRemovePreKey(C.signal_remove_pre_key_callback), - destroy: C.SignalFfiPreKeyStoreDestroy(C.signal_destroy_pre_key_store_callback), - }} +func wrapPreKeyStore(store PreKeyStore) *C.SignalPreKeyStore { + // TODO: This is probably a memory leak + return &C.SignalPreKeyStore{ + ctx: gopointer.Save(store), + load_pre_key: C.SignalLoadPreKey(C.signal_load_pre_key_callback), + store_pre_key: C.SignalStorePreKey(C.signal_store_pre_key_callback), + remove_pre_key: C.SignalRemovePreKey(C.signal_remove_pre_key_callback), + } } diff --git a/pkg/libsignalgo/privatekey.go b/pkg/libsignalgo/privatekey.go index 829d3f0..8887f3b 100644 --- a/pkg/libsignalgo/privatekey.go +++ b/pkg/libsignalgo/privatekey.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Sumner Evans -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,6 +17,7 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" @@ -35,45 +35,35 @@ func wrapPrivateKey(ptr *C.SignalPrivateKey) *PrivateKey { } func GeneratePrivateKey() (*PrivateKey, error) { - var pk C.SignalMutPointerPrivateKey + var pk *C.SignalPrivateKey signalFfiError := C.signal_privatekey_generate(&pk) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapPrivateKey(pk.raw), nil + return wrapPrivateKey(pk), nil } func DeserializePrivateKey(keyData []byte) (*PrivateKey, error) { - var pk C.SignalMutPointerPrivateKey + var pk *C.SignalPrivateKey signalFfiError := C.signal_privatekey_deserialize(&pk, BytesToBuffer(keyData)) - runtime.KeepAlive(keyData) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapPrivateKey(pk.raw), nil -} - -func (pk *PrivateKey) mutPtr() C.SignalMutPointerPrivateKey { - return C.SignalMutPointerPrivateKey{pk.ptr} -} - -func (pk *PrivateKey) constPtr() C.SignalConstPointerPrivateKey { - return C.SignalConstPointerPrivateKey{pk.ptr} + return wrapPrivateKey(pk), nil } func (pk *PrivateKey) Clone() (*PrivateKey, error) { - var cloned C.SignalMutPointerPrivateKey - signalFfiError := C.signal_privatekey_clone(&cloned, pk.constPtr()) - runtime.KeepAlive(pk) + var cloned *C.SignalPrivateKey + signalFfiError := C.signal_privatekey_clone(&cloned, pk.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapPrivateKey(cloned.raw), nil + return wrapPrivateKey(cloned), nil } func (pk *PrivateKey) Destroy() error { pk.CancelFinalizer() - return wrapError(C.signal_privatekey_destroy(pk.mutPtr())) + return wrapError(C.signal_privatekey_destroy(pk.ptr)) } func (pk *PrivateKey) CancelFinalizer() { @@ -81,19 +71,17 @@ func (pk *PrivateKey) CancelFinalizer() { } func (pk *PrivateKey) GetPublicKey() (*PublicKey, error) { - var pub C.SignalMutPointerPublicKey - signalFfiError := C.signal_privatekey_get_public_key(&pub, pk.constPtr()) - runtime.KeepAlive(pk) + var pub *C.SignalPublicKey + signalFfiError := C.signal_privatekey_get_public_key(&pub, pk.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapPublicKey(pub.raw), nil + return wrapPublicKey(pub), nil } func (pk *PrivateKey) Serialize() ([]byte, error) { var serialized C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_privatekey_serialize(&serialized, pk.constPtr()) - runtime.KeepAlive(pk) + signalFfiError := C.signal_privatekey_serialize(&serialized, pk.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -102,9 +90,7 @@ func (pk *PrivateKey) Serialize() ([]byte, error) { func (pk *PrivateKey) Sign(message []byte) ([]byte, error) { var signed C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_privatekey_sign(&signed, pk.constPtr(), BytesToBuffer(message)) - runtime.KeepAlive(pk) - runtime.KeepAlive(message) + signalFfiError := C.signal_privatekey_sign(&signed, pk.ptr, BytesToBuffer(message)) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -113,9 +99,7 @@ func (pk *PrivateKey) Sign(message []byte) ([]byte, error) { func (pk *PrivateKey) Agree(publicKey *PublicKey) ([]byte, error) { var agreed C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_privatekey_agree(&agreed, pk.constPtr(), publicKey.constPtr()) - runtime.KeepAlive(pk) - runtime.KeepAlive(publicKey) + signalFfiError := C.signal_privatekey_agree(&agreed, pk.ptr, publicKey.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } diff --git a/pkg/libsignalgo/profilekey.go b/pkg/libsignalgo/profilekey.go index e49801a..9a05a75 100644 --- a/pkg/libsignalgo/profilekey.go +++ b/pkg/libsignalgo/profilekey.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Scott Weber -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,83 +17,49 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" #include */ import "C" import ( - "encoding/base64" - "errors" - "runtime" + "crypto/rand" + "fmt" "unsafe" "github.com/google/uuid" - "go.mau.fi/util/random" ) -const ProfileKeyLength = C.SignalPROFILE_KEY_LEN - -type ProfileKey [ProfileKeyLength]byte +type ProfileKey [C.SignalPROFILE_KEY_LEN]byte type ProfileKeyCommitment [C.SignalPROFILE_KEY_COMMITMENT_LEN]byte type ProfileKeyVersion [C.SignalPROFILE_KEY_VERSION_ENCODED_LEN]byte type AccessKey [C.SignalACCESS_KEY_LEN]byte -func DeserializeProfileKey(bytes []byte) (*ProfileKey, error) { - if len(bytes) == 0 { - return nil, nil - } else if len(bytes) != ProfileKeyLength { - return nil, errors.New("invalid profile key length") - } - key := ProfileKey(bytes) - return &key, nil -} - -var blankProfileKey ProfileKey - -func (pk *ProfileKey) IsEmpty() bool { - return pk == nil || *pk == blankProfileKey +func (ak *AccessKey) String() string { + return string((*ak)[:]) } func (pv *ProfileKeyVersion) String() string { - return string(pv[:]) + return string((*pv)[:]) } func (pk *ProfileKey) Slice() []byte { - if pk.IsEmpty() { - return nil - } - return pk[:] -} - -func (ak *AccessKey) Xor(other *AccessKey) *AccessKey { - if ak == nil { - return other - } else if other == nil { - return ak - } - var result AccessKey - for i := 0; i < C.SignalACCESS_KEY_LEN; i++ { - result[i] = ak[i] ^ other[i] - } - return &result -} - -func (ak *AccessKey) String() string { - return base64.StdEncoding.EncodeToString(ak[:]) + return (*pk)[:] } func (pk *ProfileKey) GetCommitment(u uuid.UUID) (*ProfileKeyCommitment, error) { c_result := [C.SignalPROFILE_KEY_COMMITMENT_LEN]C.uchar{} c_profileKey := (*[C.SignalPROFILE_KEY_LEN]C.uchar)(unsafe.Pointer(pk)) - c_uuid := NewACIServiceID(u).CFixedBytes() + c_uuid, err := SignalServiceIDFromUUID(u) + if err != nil { + return nil, err + } signalFfiError := C.signal_profile_key_get_commitment( &c_result, c_profileKey, c_uuid, ) - runtime.KeepAlive(pk) - runtime.KeepAlive(u) if signalFfiError != nil { return nil, wrapError(signalFfiError) @@ -108,15 +73,16 @@ func (pk *ProfileKey) GetCommitment(u uuid.UUID) (*ProfileKeyCommitment, error) func (pk *ProfileKey) GetProfileKeyVersion(u uuid.UUID) (*ProfileKeyVersion, error) { c_result := [C.SignalPROFILE_KEY_VERSION_ENCODED_LEN]C.uchar{} c_profileKey := (*[C.SignalPROFILE_KEY_LEN]C.uchar)(unsafe.Pointer(pk)) - c_uuid := NewACIServiceID(u).CFixedBytes() + c_uuid, err := SignalServiceIDFromUUID(u) + if err != nil { + return nil, err + } signalFfiError := C.signal_profile_key_get_profile_key_version( &c_result, c_profileKey, c_uuid, ) - runtime.KeepAlive(pk) - runtime.KeepAlive(u) if signalFfiError != nil { return nil, wrapError(signalFfiError) @@ -135,7 +101,6 @@ func (pk *ProfileKey) DeriveAccessKey() (*AccessKey, error) { &c_result, c_profileKey, ) - runtime.KeepAlive(pk) if signalFfiError != nil { return nil, wrapError(signalFfiError) @@ -146,30 +111,39 @@ func (pk *ProfileKey) DeriveAccessKey() (*AccessKey, error) { return &result, nil } +func randBytes(length int) []byte { + buf := make([]byte, length) + if n, err := rand.Read(buf); err != nil { + fmt.Printf("rand.Read() failed: %v\n n: %v\n", err, n) + panic(err) + } + return buf +} + type ProfileKeyCredentialRequestContext [C.SignalPROFILE_KEY_CREDENTIAL_REQUEST_CONTEXT_LEN]byte type ProfileKeyCredentialRequest [C.SignalPROFILE_KEY_CREDENTIAL_REQUEST_LEN]byte type ProfileKeyCredentialResponse []byte type ProfileKeyCredentialPresentation []byte -type ExpiringProfileKeyCredential [C.SignalEXPIRING_PROFILE_KEY_CREDENTIAL_LEN]byte -type ExpiringProfileKeyCredentialResponse [C.SignalEXPIRING_PROFILE_KEY_CREDENTIAL_RESPONSE_LEN]byte +type ServerPublicParams [C.SignalSERVER_PUBLIC_PARAMS_LEN]byte -func CreateProfileKeyCredentialRequestContext(serverPublicParams *ServerPublicParams, u uuid.UUID, profileKey ProfileKey) (*ProfileKeyCredentialRequestContext, error) { +func CreateProfileKeyCredentialRequestContext(serverPublicParams ServerPublicParams, u uuid.UUID, profileKey ProfileKey) (*ProfileKeyCredentialRequestContext, error) { c_result := [C.SignalPROFILE_KEY_CREDENTIAL_REQUEST_CONTEXT_LEN]C.uchar{} - randBytes := [32]byte(random.Bytes(32)) - c_random := (*[32]C.uchar)(unsafe.Pointer(&randBytes[0])) + c_serverPublicParams := (*[C.SignalSERVER_PUBLIC_PARAMS_LEN]C.uchar)(unsafe.Pointer(&serverPublicParams[0])) + random := [32]byte(randBytes(32)) + c_random := (*[32]C.uchar)(unsafe.Pointer(&random[0])) c_profileKey := (*[C.SignalPROFILE_KEY_LEN]C.uchar)(unsafe.Pointer(&profileKey[0])) - c_uuid := NewACIServiceID(u).CFixedBytes() + c_uuid, err := SignalServiceIDFromUUID(u) + if err != nil { + return nil, err + } signalFfiError := C.signal_server_public_params_create_profile_key_credential_request_context_deterministic( &c_result, - C.SignalConstPointerServerPublicParams{serverPublicParams}, + c_serverPublicParams, c_random, c_uuid, c_profileKey, ) - runtime.KeepAlive(u) - runtime.KeepAlive(profileKey) - runtime.KeepAlive(randBytes) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -185,7 +159,6 @@ func (p *ProfileKeyCredentialRequestContext) ProfileKeyCredentialRequestContextG &c_result, c_context, ) - runtime.KeepAlive(p) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -193,63 +166,36 @@ func (p *ProfileKeyCredentialRequestContext) ProfileKeyCredentialRequestContextG return &result, nil } -func NewExpiringProfileKeyCredentialResponse(b []byte) (*ExpiringProfileKeyCredentialResponse, error) { +func NewProfileKeyCredentialResponse(b []byte) (ProfileKeyCredentialResponse, error) { borrowedBuffer := BytesToBuffer(b) signalFfiError := C.signal_expiring_profile_key_credential_response_check_valid_contents(borrowedBuffer) - runtime.KeepAlive(b) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - response := ExpiringProfileKeyCredentialResponse(b) - return &response, nil + return ProfileKeyCredentialResponse(b), nil } -func ReceiveExpiringProfileKeyCredential(spp *ServerPublicParams, requestContext *ProfileKeyCredentialRequestContext, response *ExpiringProfileKeyCredentialResponse, currentTimeInSeconds uint64) (*ExpiringProfileKeyCredential, error) { - c_credential := [C.SignalEXPIRING_PROFILE_KEY_CREDENTIAL_LEN]C.uchar{} - signalFfiError := C.signal_server_public_params_receive_expiring_profile_key_credential( - &c_credential, - C.SignalConstPointerServerPublicParams{spp}, - (*[C.SignalPROFILE_KEY_CREDENTIAL_REQUEST_CONTEXT_LEN]C.uchar)(unsafe.Pointer(requestContext)), - (*[C.SignalEXPIRING_PROFILE_KEY_CREDENTIAL_RESPONSE_LEN]C.uchar)(unsafe.Pointer(response)), - (C.uint64_t)(currentTimeInSeconds), - ) - runtime.KeepAlive(requestContext) - runtime.KeepAlive(response) - runtime.KeepAlive(currentTimeInSeconds) - if signalFfiError != nil { - return nil, wrapError(signalFfiError) - } - credential := ExpiringProfileKeyCredential{} - copy(credential[:], C.GoBytes(unsafe.Pointer(&c_credential), C.int(C.SignalEXPIRING_PROFILE_KEY_CREDENTIAL_LEN))) - return &credential, nil -} - -func (a ProfileKeyCredentialPresentation) CheckValidContents() error { - signalFfiError := C.signal_profile_key_credential_presentation_check_valid_contents(BytesToBuffer(a)) - runtime.KeepAlive(a) - return wrapError(signalFfiError) -} - -func (a ProfileKeyCredentialPresentation) UUIDCiphertext() (UUIDCiphertext, error) { - out := [C.SignalUUID_CIPHERTEXT_LEN]C.uchar{} - signalFfiError := C.signal_profile_key_credential_presentation_get_uuid_ciphertext(&out, BytesToBuffer(a)) - runtime.KeepAlive(a) - if signalFfiError != nil { - return UUIDCiphertext{}, wrapError(signalFfiError) - } - var result UUIDCiphertext - copy(result[:], C.GoBytes(unsafe.Pointer(&out), C.int(C.SignalUUID_CIPHERTEXT_LEN))) - return result, nil -} - -func (a ProfileKeyCredentialPresentation) ProfileKeyCiphertext() (ProfileKeyCiphertext, error) { - out := [C.SignalPROFILE_KEY_CIPHERTEXT_LEN]C.uchar{} - signalFfiError := C.signal_profile_key_credential_presentation_get_profile_key_ciphertext(&out, BytesToBuffer(a)) - runtime.KeepAlive(a) - if signalFfiError != nil { - return ProfileKeyCiphertext{}, wrapError(signalFfiError) - } - var result ProfileKeyCiphertext - copy(result[:], C.GoBytes(unsafe.Pointer(&out), C.int(C.SignalPROFILE_KEY_CIPHERTEXT_LEN))) - return result, nil -} +//func NewProfileKeyCredentialPresentation(b []byte) (ProfileKeyCredentialPresentation, error) { +// C.signal_profile_key_credential_presentation_check_valid_contents(cBytes(b), cLen(b)) +// if res := C.FFI_ProfileKeyCredentialPresentation_checkValidContents(cBytes(b), cLen(b)); res != C.FFI_RETURN_OK { +// return nil, errFromCode(res) +// } +// return ProfileKeyCredentialPresentation(b), nil +//} +// +//func (a ProfileKeyCredentialPresentation) UUIDCiphertext() ([]byte, error) { +// out := make([]byte, C.UUID_CIPHERTEXT_LEN) +// if res := C.FFI_ProfileKeyCredentialPresentation_getUuidCiphertext(cBytes(a), cLen(a), cBytes(out), cLen(out)); res != C.FFI_RETURN_OK { +// return nil, errFromCode(res) +// } +// return out, nil +//} +// +//func (a ProfileKeyCredentialPresentation) ProfileKeyCiphertext() ([]byte, error) { +// out := make([]byte, C.PROFILE_KEY_CIPHERTEXT_LEN) +// if res := C.FFI_ProfileKeyCredentialPresentation_getProfileKeyCiphertext(cBytes(a), cLen(a), cBytes(out), cLen(out)); res != C.FFI_RETURN_OK { +// return nil, errFromCode(res) +// } +// return out, nil +//} +// diff --git a/pkg/libsignalgo/accountentropy.go b/pkg/libsignalgo/protocol.go similarity index 52% rename from pkg/libsignalgo/accountentropy.go rename to pkg/libsignalgo/protocol.go index d1ffe35..d0cc1c3 100644 --- a/pkg/libsignalgo/accountentropy.go +++ b/pkg/libsignalgo/protocol.go @@ -1,5 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2024 Tulir Asokan +// Copyright (C) 2023 Sumner Evans // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -17,38 +17,25 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" -import ( - "runtime" - "unsafe" -) +import "time" -type AccountEntropyPool string - -func (aep AccountEntropyPool) DeriveSVRKey() ([]byte, error) { - var out [C.SignalSVR_KEY_LEN]byte - signalFfiError := C.signal_account_entropy_pool_derive_svr_key( - (*[C.SignalSVR_KEY_LEN]C.uint8_t)(unsafe.Pointer(&out)), - C.CString(string(aep)), +func Encrypt(plaintext []byte, forAddress *Address, sessionStore SessionStore, identityKeyStore IdentityKeyStore, ctx *CallbackContext) (*CiphertextMessage, error) { + var ciphertextMessage *C.SignalCiphertextMessage + var now C.uint64_t = C.uint64_t(time.Now().Unix()) + signalFfiError := C.signal_encrypt_message( + &ciphertextMessage, + BytesToBuffer(plaintext), + forAddress.ptr, + wrapSessionStore(sessionStore), + wrapIdentityKeyStore(identityKeyStore), + now, ) - runtime.KeepAlive(aep) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return out[:], nil -} - -func (aep AccountEntropyPool) DeriveBackupKey() ([]byte, error) { - var out [C.SignalBACKUP_KEY_LEN]byte - signalFfiError := C.signal_account_entropy_pool_derive_backup_key( - (*[C.SignalBACKUP_KEY_LEN]C.uint8_t)(unsafe.Pointer(&out)), - C.CString(string(aep)), - ) - runtime.KeepAlive(aep) - if signalFfiError != nil { - return nil, wrapError(signalFfiError) - } - return out[:], nil + return wrapCiphertextMessage(ciphertextMessage), nil } diff --git a/pkg/libsignalgo/publickey.go b/pkg/libsignalgo/publickey.go index fdd76e5..1400070 100644 --- a/pkg/libsignalgo/publickey.go +++ b/pkg/libsignalgo/publickey.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Sumner Evans -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,6 +17,7 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" @@ -29,46 +29,32 @@ type PublicKey struct { } func wrapPublicKey(ptr *C.SignalPublicKey) *PublicKey { - if ptr == nil { - return nil - } publicKey := &PublicKey{ptr: ptr} runtime.SetFinalizer(publicKey, (*PublicKey).Destroy) return publicKey } -func (pk *PublicKey) mutPtr() C.SignalMutPointerPublicKey { - return C.SignalMutPointerPublicKey{pk.ptr} -} - -func (pk *PublicKey) constPtr() C.SignalConstPointerPublicKey { - return C.SignalConstPointerPublicKey{pk.ptr} -} - func (pk *PublicKey) Clone() (*PublicKey, error) { - var cloned C.SignalMutPointerPublicKey - signalFfiError := C.signal_publickey_clone(&cloned, pk.constPtr()) - runtime.KeepAlive(pk) + var cloned *C.SignalPublicKey + signalFfiError := C.signal_publickey_clone(&cloned, pk.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapPublicKey(cloned.raw), nil + return wrapPublicKey(cloned), nil } func DeserializePublicKey(keyData []byte) (*PublicKey, error) { - var pk C.SignalMutPointerPublicKey + var pk *C.SignalPublicKey signalFfiError := C.signal_publickey_deserialize(&pk, BytesToBuffer(keyData)) - runtime.KeepAlive(keyData) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapPublicKey(pk.raw), nil + return wrapPublicKey(pk), nil } func (pk *PublicKey) Serialize() ([]byte, error) { var serialized C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_publickey_serialize(&serialized, pk.constPtr()) - runtime.KeepAlive(pk) + signalFfiError := C.signal_publickey_serialize(&serialized, pk.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -77,28 +63,25 @@ func (pk *PublicKey) Serialize() ([]byte, error) { func (k *PublicKey) Destroy() error { k.CancelFinalizer() - return wrapError(C.signal_publickey_destroy(k.mutPtr())) + return wrapError(C.signal_publickey_destroy(k.ptr)) } func (k *PublicKey) CancelFinalizer() { runtime.SetFinalizer(k, nil) } -func (k *PublicKey) Equal(other *PublicKey) (bool, error) { - var comparison C.bool - signalFfiError := C.signal_publickey_equals(&comparison, k.constPtr(), other.constPtr()) - runtime.KeepAlive(k) - runtime.KeepAlive(other) +func (k *PublicKey) Compare(other *PublicKey) (int, error) { + var comparison C.int + signalFfiError := C.signal_publickey_compare(&comparison, k.ptr, other.ptr) if signalFfiError != nil { - return false, wrapError(signalFfiError) + return 0, wrapError(signalFfiError) } - return bool(comparison), nil + return int(comparison), nil } func (k *PublicKey) Bytes() ([]byte, error) { var pub C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_publickey_get_public_key_bytes(&pub, k.constPtr()) - runtime.KeepAlive(k) + signalFfiError := C.signal_publickey_get_public_key_bytes(&pub, k.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -107,15 +90,7 @@ func (k *PublicKey) Bytes() ([]byte, error) { func (k *PublicKey) Verify(message, signature []byte) (bool, error) { var verify C.bool - signalFfiError := C.signal_publickey_verify( - &verify, - k.constPtr(), - BytesToBuffer(message), - BytesToBuffer(signature), - ) - runtime.KeepAlive(k) - runtime.KeepAlive(message) - runtime.KeepAlive(signature) + signalFfiError := C.signal_publickey_verify(&verify, k.ptr, BytesToBuffer(message), BytesToBuffer(signature)) if signalFfiError != nil { return false, wrapError(signalFfiError) } diff --git a/pkg/libsignalgo/sealedsender.go b/pkg/libsignalgo/sealedsender.go index 84ff254..928be27 100644 --- a/pkg/libsignalgo/sealedsender.go +++ b/pkg/libsignalgo/sealedsender.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Scott Weber -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,14 +17,13 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" import ( - "context" - "fmt" "runtime" - "unsafe" + "time" "github.com/google/uuid" ) @@ -44,17 +42,8 @@ func NewSealedSenderAddress(e164 string, uuid uuid.UUID, deviceID uint32) *Seale } } -func SealedSenderEncryptPlaintext( - ctx context.Context, - message []byte, - contentHint UnidentifiedSenderMessageContentHint, - forAddress, localAddress *Address, - fromSenderCert *SenderCertificate, - sessionStore SessionStore, - identityStore IdentityKeyStore, - groupID *GroupIdentifier, -) ([]byte, error) { - ciphertextMessage, err := Encrypt(ctx, message, forAddress, localAddress, sessionStore, identityStore) +func SealedSenderEncryptPlaintext(message []byte, forAddress *Address, fromSenderCert *SenderCertificate, sessionStore SessionStore, identityStore IdentityKeyStore, ctx *CallbackContext) ([]byte, error) { + ciphertextMessage, err := Encrypt(message, forAddress, sessionStore, identityStore, ctx) if err != nil { return nil, err } @@ -62,78 +51,31 @@ func SealedSenderEncryptPlaintext( usmc, err := NewUnidentifiedSenderMessageContent( ciphertextMessage, fromSenderCert, - contentHint, - groupID, + UnidentifiedSenderMessageContentHintDefault, + nil, ) if err != nil { return nil, err } - return SealedSenderEncrypt(ctx, usmc, forAddress, identityStore) + return SealedSenderEncrypt(usmc, forAddress, identityStore, ctx) } -func SealedSenderEncrypt(ctx context.Context, usmc *UnidentifiedSenderMessageContent, forRecipient *Address, identityStore IdentityKeyStore) ([]byte, error) { +func SealedSenderEncrypt(messageContent *UnidentifiedSenderMessageContent, forRecipient *Address, identityStore IdentityKeyStore, ctx *CallbackContext) ([]byte, error) { var encrypted C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - callbackCtx := NewCallbackContext(ctx) - defer callbackCtx.Unref() signalFfiError := C.signal_sealed_session_cipher_encrypt( &encrypted, - forRecipient.constPtr(), - usmc.constPtr(), - callbackCtx.wrapIdentityKeyStore(identityStore), + forRecipient.ptr, + messageContent.ptr, + wrapIdentityKeyStore(identityStore), ) - runtime.KeepAlive(usmc) - runtime.KeepAlive(forRecipient) if signalFfiError != nil { - return nil, callbackCtx.wrapError(signalFfiError) + return nil, wrapCallbackError(signalFfiError, ctx) } return CopySignalOwnedBufferToBytes(encrypted), nil } -type SessionAddressTuple struct { - ServiceID ServiceID - DeviceID int - Address *Address - Record *SessionRecord -} - -func SealedSenderMultiRecipientEncrypt( - ctx context.Context, - usmc *UnidentifiedSenderMessageContent, - recipients []SessionAddressTuple, - identityStore IdentityKeyStore, -) ([]byte, error) { - var encrypted C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - callbackCtx := NewCallbackContext(ctx) - defer callbackCtx.Unref() - recipientAddresses := make([]C.SignalConstPointerProtocolAddress, len(recipients)) - recipientSessions := make([]C.SignalConstPointerSessionRecord, len(recipients)) - - for i, recipient := range recipients { - recipientAddresses[i] = recipient.Address.constPtr() - recipientSessions[i] = recipient.Record.constPtr() - } - signalFfiError := C.signal_sealed_sender_multi_recipient_encrypt( - &encrypted, - C.SignalBorrowedSliceOfConstPointerProtocolAddress{ - base: unsafe.SliceData(recipientAddresses), - length: C.size_t(len(recipientAddresses)), - }, - C.SignalBorrowedSliceOfConstPointerSessionRecord{ - base: unsafe.SliceData(recipientSessions), - length: C.size_t(len(recipientSessions)), - }, - BytesToBuffer(nil), - usmc.constPtr(), - callbackCtx.wrapIdentityKeyStore(identityStore), - ) - runtime.KeepAlive(usmc) - runtime.KeepAlive(recipients) - runtime.KeepAlive(recipientAddresses) - runtime.KeepAlive(recipientSessions) - if signalFfiError != nil { - return nil, callbackCtx.wrapError(signalFfiError) - } - return CopySignalOwnedBufferToBytes(encrypted), nil +func SealedSenderMultiRecipientEncrypt(messageContent *UnidentifiedSenderMessageContent, forRecipients []*Address, identityStore IdentityKeyStore, sessionStore SessionStore, ctx *CallbackContext) ([]byte, error) { + panic("not implemented") } type SealedSenderResult struct { @@ -142,23 +84,70 @@ type SealedSenderResult struct { } func SealedSenderDecryptToUSMC( - ctx context.Context, ciphertext []byte, identityStore IdentityKeyStore, + ctx *CallbackContext, ) (*UnidentifiedSenderMessageContent, error) { - callbackCtx := NewCallbackContext(ctx) - defer callbackCtx.Unref() - var usmc C.SignalMutPointerUnidentifiedSenderMessageContent + var usmc *C.SignalUnidentifiedSenderMessageContent = nil signalFfiError := C.signal_sealed_session_cipher_decrypt_to_usmc( &usmc, BytesToBuffer(ciphertext), - callbackCtx.wrapIdentityKeyStore(identityStore), + wrapIdentityKeyStore(identityStore), ) - runtime.KeepAlive(ciphertext) if signalFfiError != nil { - return nil, callbackCtx.wrapError(signalFfiError) + return nil, wrapError(signalFfiError) } - return wrapUnidentifiedSenderMessageContent(usmc.raw), nil + return wrapUnidentifiedSenderMessageContent(usmc), nil +} + +func SealedSenderDecrypt( + ciphertext []byte, + localAddress *SealedSenderAddress, + trustRoot *PublicKey, + timestamp time.Time, + sessionStore SessionStore, + identityStore IdentityKeyStore, + preKeyStore PreKeyStore, + signedPreKeyStore SignedPreKeyStore, + ctx *CallbackContext, +) (result SealedSenderResult, err error) { + var decrypted C.SignalOwnedBuffer = C.SignalOwnedBuffer{} + var senderE164 *C.char + var senderUUID *C.char + var senderDeviceID C.uint32_t + + signalFfiError := C.signal_sealed_session_cipher_decrypt( + &decrypted, + &senderE164, + &senderUUID, + &senderDeviceID, + BytesToBuffer(ciphertext), + trustRoot.ptr, + C.uint64_t(timestamp.UnixMilli()), + C.CString(localAddress.E164), + C.CString(localAddress.UUID.String()), + C.uint32_t(localAddress.DeviceID), + wrapSessionStore(sessionStore), + wrapIdentityKeyStore(identityStore), + wrapPreKeyStore(preKeyStore), + wrapSignedPreKeyStore(signedPreKeyStore), + ) + if signalFfiError != nil { + err = wrapCallbackError(signalFfiError, ctx) + return + } + + defer C.signal_free_string(senderE164) + defer C.signal_free_string(senderUUID) + + return SealedSenderResult{ + Message: CopySignalOwnedBufferToBytes(decrypted), + Sender: SealedSenderAddress{ + E164: C.GoString(senderE164), + UUID: uuid.MustParse(C.GoString(senderUUID)), + DeviceID: uint32(senderDeviceID), + }, + }, nil } type UnidentifiedSenderMessageContentHint uint32 @@ -180,26 +169,13 @@ func wrapUnidentifiedSenderMessageContent(ptr *C.SignalUnidentifiedSenderMessage return messageContent } -func NewUnidentifiedSenderMessageContent(message *CiphertextMessage, senderCertificate *SenderCertificate, contentHint UnidentifiedSenderMessageContentHint, groupID *GroupIdentifier) (*UnidentifiedSenderMessageContent, error) { - var usmc C.SignalMutPointerUnidentifiedSenderMessageContent - var groupIDBytes []byte - if groupID != nil { - groupIDBytes = groupID[:] - } - signalFfiError := C.signal_unidentified_sender_message_content_new( - &usmc, - message.constPtr(), - senderCertificate.constPtr(), - C.uint32_t(contentHint), - BytesToBuffer(groupIDBytes), - ) - runtime.KeepAlive(message) - runtime.KeepAlive(senderCertificate) - runtime.KeepAlive(groupIDBytes) +func NewUnidentifiedSenderMessageContent(message *CiphertextMessage, senderCertificate *SenderCertificate, contentHint UnidentifiedSenderMessageContentHint, groupID []byte) (*UnidentifiedSenderMessageContent, error) { + var usmc *C.SignalUnidentifiedSenderMessageContent + signalFfiError := C.signal_unidentified_sender_message_content_new(&usmc, message.ptr, senderCertificate.ptr, C.uint32_t(contentHint), BytesToBuffer(groupID)) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapUnidentifiedSenderMessageContent(usmc.raw), nil + return wrapUnidentifiedSenderMessageContent(usmc), nil } //func NewUnidentifiedSenderMessageContentFromMessage(sealedSenderMessage []byte, identityStore IdentityKeyStore, ctx *CallbackContext) (*UnidentifiedSenderMessageContent, error) { @@ -221,26 +197,17 @@ func NewUnidentifiedSenderMessageContent(message *CiphertextMessage, senderCerti //} func DeserializeUnidentifiedSenderMessageContent(serialized []byte) (*UnidentifiedSenderMessageContent, error) { - var usmc C.SignalMutPointerUnidentifiedSenderMessageContent + var usmc *C.SignalUnidentifiedSenderMessageContent signalFfiError := C.signal_unidentified_sender_message_content_deserialize(&usmc, BytesToBuffer(serialized)) - runtime.KeepAlive(serialized) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapUnidentifiedSenderMessageContent(usmc.raw), nil -} - -func (usmc *UnidentifiedSenderMessageContent) mutPtr() C.SignalMutPointerUnidentifiedSenderMessageContent { - return C.SignalMutPointerUnidentifiedSenderMessageContent{usmc.ptr} -} - -func (usmc *UnidentifiedSenderMessageContent) constPtr() C.SignalConstPointerUnidentifiedSenderMessageContent { - return C.SignalConstPointerUnidentifiedSenderMessageContent{usmc.ptr} + return wrapUnidentifiedSenderMessageContent(usmc), nil } func (usmc *UnidentifiedSenderMessageContent) Destroy() error { usmc.CancelFinalizer() - return wrapError(C.signal_unidentified_sender_message_content_destroy(usmc.mutPtr())) + return wrapError(C.signal_unidentified_sender_message_content_destroy(usmc.ptr)) } func (usmc *UnidentifiedSenderMessageContent) CancelFinalizer() { @@ -249,8 +216,7 @@ func (usmc *UnidentifiedSenderMessageContent) CancelFinalizer() { func (usmc *UnidentifiedSenderMessageContent) Serialize() ([]byte, error) { var serialized C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_unidentified_sender_message_content_serialize(&serialized, usmc.constPtr()) - runtime.KeepAlive(usmc) + signalFfiError := C.signal_unidentified_sender_message_content_serialize(&serialized, usmc.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -259,44 +225,38 @@ func (usmc *UnidentifiedSenderMessageContent) Serialize() ([]byte, error) { func (usmc *UnidentifiedSenderMessageContent) GetContents() ([]byte, error) { var contents C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_unidentified_sender_message_content_get_contents(&contents, usmc.constPtr()) - runtime.KeepAlive(usmc) + signalFfiError := C.signal_unidentified_sender_message_content_get_contents(&contents, usmc.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } return CopySignalOwnedBufferToBytes(contents), nil } -func (usmc *UnidentifiedSenderMessageContent) GetGroupID() (*GroupIdentifier, error) { - var contents C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_unidentified_sender_message_content_get_group_id_or_empty(&contents, usmc.constPtr()) - runtime.KeepAlive(usmc) - if signalFfiError != nil { - return nil, wrapError(signalFfiError) - } - bytes := CopySignalOwnedBufferToBytes(contents) - if len(bytes) == 0 { - return nil, nil - } else if len(bytes) != GroupIdentifierLength { - return nil, fmt.Errorf("unexpected group ID length: %d", len(bytes)) - } - return (*GroupIdentifier)(bytes), nil -} +//func (usmc *UnidentifiedSenderMessageContent) GetGroupID() ([]byte, error) { +// var groupID *C.uchar +// var length C.ulong +// signalFfiError := C.signal_unidentified_sender_message_content_get_group_id(&groupID, &length, usmc.ptr) +// if signalFfiError != nil { +// return nil, wrapError(signalFfiError) +// } +// if groupID == nil { +// return nil, nil +// } +// return CopyBufferToBytes(groupID, length), nil +//} func (usmc *UnidentifiedSenderMessageContent) GetSenderCertificate() (*SenderCertificate, error) { - var senderCertificate C.SignalMutPointerSenderCertificate - signalFfiError := C.signal_unidentified_sender_message_content_get_sender_cert(&senderCertificate, usmc.constPtr()) - runtime.KeepAlive(usmc) + var senderCertificate *C.SignalSenderCertificate + signalFfiError := C.signal_unidentified_sender_message_content_get_sender_cert(&senderCertificate, usmc.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapSenderCertificate(senderCertificate.raw), nil + return wrapSenderCertificate(senderCertificate), nil } func (usmc *UnidentifiedSenderMessageContent) GetMessageType() (CiphertextMessageType, error) { var messageType C.uint8_t - signalFfiError := C.signal_unidentified_sender_message_content_get_msg_type(&messageType, usmc.constPtr()) - runtime.KeepAlive(usmc) + signalFfiError := C.signal_unidentified_sender_message_content_get_msg_type(&messageType, usmc.ptr) if signalFfiError != nil { return 0, wrapError(signalFfiError) } @@ -305,8 +265,7 @@ func (usmc *UnidentifiedSenderMessageContent) GetMessageType() (CiphertextMessag func (usmc *UnidentifiedSenderMessageContent) GetContentHint() (UnidentifiedSenderMessageContentHint, error) { var contentHint C.uint32_t - signalFfiError := C.signal_unidentified_sender_message_content_get_content_hint(&contentHint, usmc.constPtr()) - runtime.KeepAlive(usmc) + signalFfiError := C.signal_unidentified_sender_message_content_get_content_hint(&contentHint, usmc.ptr) if signalFfiError != nil { return 0, wrapError(signalFfiError) } diff --git a/pkg/libsignalgo/sendercertificate.go b/pkg/libsignalgo/sendercertificate.go index 47cf958..81af8f1 100644 --- a/pkg/libsignalgo/sendercertificate.go +++ b/pkg/libsignalgo/sendercertificate.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Sumner Evans -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,13 +17,13 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" import ( "runtime" "time" - "unsafe" "github.com/google/uuid" ) @@ -43,61 +42,35 @@ func wrapSenderCertificate(ptr *C.SignalSenderCertificate) *SenderCertificate { // NewSenderCertificate should only be used for testing (at least according to // the Swift bindings). func NewSenderCertificate(sender *SealedSenderAddress, publicKey *PublicKey, expiration time.Time, signerCertificate *ServerCertificate, signerKey *PrivateKey) (*SenderCertificate, error) { - var sc C.SignalMutPointerSenderCertificate - signalFfiError := C.signal_sender_certificate_new( - &sc, - C.CString(sender.UUID.String()), - C.CString(sender.E164), - C.uint32_t(sender.DeviceID), - publicKey.constPtr(), - C.uint64_t(expiration.UnixMilli()), - signerCertificate.constPtr(), - signerKey.constPtr(), - ) - runtime.KeepAlive(sender) - runtime.KeepAlive(publicKey) - runtime.KeepAlive(signerCertificate) - runtime.KeepAlive(signerKey) + var sc *C.SignalSenderCertificate + signalFfiError := C.signal_sender_certificate_new(&sc, C.CString(sender.UUID.String()), C.CString(sender.E164), C.uint32_t(sender.DeviceID), publicKey.ptr, C.uint64_t(expiration.UnixMilli()), signerCertificate.ptr, signerKey.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapSenderCertificate(sc.raw), nil + return wrapSenderCertificate(sc), nil } func DeserializeSenderCertificate(serialized []byte) (*SenderCertificate, error) { - var sc C.SignalMutPointerSenderCertificate + var sc *C.SignalSenderCertificate signalFfiError := C.signal_sender_certificate_deserialize(&sc, BytesToBuffer(serialized)) - runtime.KeepAlive(serialized) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapSenderCertificate(sc.raw), nil + return wrapSenderCertificate(sc), nil } func (sc *SenderCertificate) Clone() (*SenderCertificate, error) { - var cloned C.SignalMutPointerSenderCertificate - signalFfiError := C.signal_sender_certificate_clone( - &cloned, - sc.constPtr(), - ) - runtime.KeepAlive(sc) + var cloned *C.SignalSenderCertificate + signalFfiError := C.signal_sender_certificate_clone(&cloned, sc.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapSenderCertificate(cloned.raw), nil -} - -func (sc *SenderCertificate) mutPtr() C.SignalMutPointerSenderCertificate { - return C.SignalMutPointerSenderCertificate{sc.ptr} -} - -func (sc *SenderCertificate) constPtr() C.SignalConstPointerSenderCertificate { - return C.SignalConstPointerSenderCertificate{sc.ptr} + return wrapSenderCertificate(cloned), nil } func (sc *SenderCertificate) Destroy() error { sc.CancelFinalizer() - return wrapError(C.signal_sender_certificate_destroy(sc.mutPtr())) + return wrapError(C.signal_sender_certificate_destroy(sc.ptr)) } func (sc *SenderCertificate) CancelFinalizer() { @@ -106,8 +79,7 @@ func (sc *SenderCertificate) CancelFinalizer() { func (sc *SenderCertificate) Serialize() ([]byte, error) { var serialized C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_sender_certificate_get_serialized(&serialized, sc.constPtr()) - runtime.KeepAlive(sc) + signalFfiError := C.signal_sender_certificate_get_serialized(&serialized, sc.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -116,8 +88,7 @@ func (sc *SenderCertificate) Serialize() ([]byte, error) { func (sc *SenderCertificate) GetCertificate() ([]byte, error) { var certificate C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_sender_certificate_get_certificate(&certificate, sc.constPtr()) - runtime.KeepAlive(sc) + signalFfiError := C.signal_sender_certificate_get_certificate(&certificate, sc.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -126,8 +97,7 @@ func (sc *SenderCertificate) GetCertificate() ([]byte, error) { func (sc *SenderCertificate) GetSignature() ([]byte, error) { var signature C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_sender_certificate_get_signature(&signature, sc.constPtr()) - runtime.KeepAlive(sc) + signalFfiError := C.signal_sender_certificate_get_signature(&signature, sc.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -136,8 +106,7 @@ func (sc *SenderCertificate) GetSignature() ([]byte, error) { func (sc *SenderCertificate) GetSenderUUID() (uuid.UUID, error) { var rawUUID *C.char - signalFfiError := C.signal_sender_certificate_get_sender_uuid(&rawUUID, sc.constPtr()) - runtime.KeepAlive(sc) + signalFfiError := C.signal_sender_certificate_get_sender_uuid(&rawUUID, sc.ptr) if signalFfiError != nil { return uuid.UUID{}, wrapError(signalFfiError) } @@ -146,8 +115,7 @@ func (sc *SenderCertificate) GetSenderUUID() (uuid.UUID, error) { func (sc *SenderCertificate) GetSenderE164() (string, error) { var e164 *C.char - signalFfiError := C.signal_sender_certificate_get_sender_e164(&e164, sc.constPtr()) - runtime.KeepAlive(sc) + signalFfiError := C.signal_sender_certificate_get_sender_e164(&e164, sc.ptr) if signalFfiError != nil { return "", wrapError(signalFfiError) } @@ -159,8 +127,7 @@ func (sc *SenderCertificate) GetSenderE164() (string, error) { func (sc *SenderCertificate) GetExpiration() (time.Time, error) { var expiration C.uint64_t - signalFfiError := C.signal_sender_certificate_get_expiration(&expiration, sc.constPtr()) - runtime.KeepAlive(sc) + signalFfiError := C.signal_sender_certificate_get_expiration(&expiration, sc.ptr) if signalFfiError != nil { return time.Time{}, wrapError(signalFfiError) } @@ -169,8 +136,7 @@ func (sc *SenderCertificate) GetExpiration() (time.Time, error) { func (sc *SenderCertificate) GetDeviceID() (uint32, error) { var deviceID C.uint32_t - signalFfiError := C.signal_sender_certificate_get_device_id(&deviceID, sc.constPtr()) - runtime.KeepAlive(sc) + signalFfiError := C.signal_sender_certificate_get_device_id(&deviceID, sc.ptr) if signalFfiError != nil { return 0, wrapError(signalFfiError) } @@ -178,33 +144,17 @@ func (sc *SenderCertificate) GetDeviceID() (uint32, error) { } func (sc *SenderCertificate) GetKey() (*PublicKey, error) { - var key C.SignalMutPointerPublicKey - signalFfiError := C.signal_sender_certificate_get_key(&key, sc.constPtr()) - runtime.KeepAlive(sc) + var key *C.SignalPublicKey + signalFfiError := C.signal_sender_certificate_get_key(&key, sc.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapPublicKey(key.raw), nil + return wrapPublicKey(key), nil } -func (sc *SenderCertificate) Validate(trustRoots []*PublicKey, ts time.Time) (bool, error) { +func (sc *SenderCertificate) Validate(trustRoot *PublicKey, ts time.Time) (bool, error) { var valid C.bool - constRoots := make([]C.SignalConstPointerPublicKey, len(trustRoots)) - for i, root := range trustRoots { - constRoots[i] = root.constPtr() - } - signalFfiError := C.signal_sender_certificate_validate( - &valid, - sc.constPtr(), - // TODO this might not be correct - C.SignalBorrowedSliceOfConstPointerPublicKey{ - base: unsafe.SliceData(constRoots), - length: C.size_t(len(constRoots)), - }, - C.uint64_t(ts.UnixMilli()), - ) - runtime.KeepAlive(sc) - runtime.KeepAlive(constRoots) + signalFfiError := C.signal_sender_certificate_validate(&valid, sc.ptr, trustRoot.ptr, C.uint64_t(ts.UnixMilli())) if signalFfiError != nil { return false, wrapError(signalFfiError) } @@ -212,11 +162,10 @@ func (sc *SenderCertificate) Validate(trustRoots []*PublicKey, ts time.Time) (bo } func (sc *SenderCertificate) GetServerCertificate() (*ServerCertificate, error) { - var serverCertificate C.SignalMutPointerServerCertificate - signalFfiError := C.signal_sender_certificate_get_server_certificate(&serverCertificate, sc.constPtr()) - runtime.KeepAlive(sc) + var serverCertificate *C.SignalServerCertificate + signalFfiError := C.signal_sender_certificate_get_server_certificate(&serverCertificate, sc.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapServerCertificate(serverCertificate.raw), nil + return wrapServerCertificate(serverCertificate), nil } diff --git a/pkg/libsignalgo/senderkeydistributionmessage.go b/pkg/libsignalgo/senderkeydistributionmessage.go index c9f6099..8a1ed45 100644 --- a/pkg/libsignalgo/senderkeydistributionmessage.go +++ b/pkg/libsignalgo/senderkeydistributionmessage.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Sumner Evans -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,28 +17,24 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" import ( - "context" "runtime" "unsafe" "github.com/google/uuid" ) -func ProcessSenderKeyDistributionMessage(ctx context.Context, message *SenderKeyDistributionMessage, fromSender *Address, store SenderKeyStore) error { - callbackCtx := NewCallbackContext(ctx) - defer callbackCtx.Unref() +func ProcessSenderKeyDistributionMessage(message *SenderKeyDistributionMessage, fromSender *Address, store SenderKeyStore, ctx *CallbackContext) error { signalFfiError := C.signal_process_sender_key_distribution_message( - fromSender.constPtr(), - message.constPtr(), - callbackCtx.wrapSenderKeyStore(store), + fromSender.ptr, + message.ptr, + wrapSenderKeyStore(store), ) - runtime.KeepAlive(message) - runtime.KeepAlive(fromSender) - return callbackCtx.wrapError(signalFfiError) + return wrapCallbackError(signalFfiError, ctx) } type SenderKeyDistributionMessage struct { @@ -53,45 +48,32 @@ func wrapSenderKeyDistributionMessage(ptr *C.SignalSenderKeyDistributionMessage) return sc } -func NewSenderKeyDistributionMessage(ctx context.Context, sender *Address, distributionID uuid.UUID, store SenderKeyStore) (*SenderKeyDistributionMessage, error) { - callbackCtx := NewCallbackContext(ctx) - defer callbackCtx.Unref() - var skdm C.SignalMutPointerSenderKeyDistributionMessage +func NewSenderKeyDistributionMessage(sender *Address, distributionID uuid.UUID, store SenderKeyStore, ctx *CallbackContext) (*SenderKeyDistributionMessage, error) { + var skdm *C.SignalSenderKeyDistributionMessage signalFfiError := C.signal_sender_key_distribution_message_create( &skdm, - sender.constPtr(), - *(*C.SignalUuid)(unsafe.Pointer(&distributionID)), - callbackCtx.wrapSenderKeyStore(store), + sender.ptr, + (*[C.SignalUUID_LEN]C.uchar)(unsafe.Pointer(&distributionID)), + wrapSenderKeyStore(store), ) - runtime.KeepAlive(sender) - runtime.KeepAlive(distributionID) if signalFfiError != nil { - return nil, callbackCtx.wrapError(signalFfiError) + return nil, wrapCallbackError(signalFfiError, ctx) } - return wrapSenderKeyDistributionMessage(skdm.raw), nil + return wrapSenderKeyDistributionMessage(skdm), nil } func DeserializeSenderKeyDistributionMessage(serialized []byte) (*SenderKeyDistributionMessage, error) { - var skdm C.SignalMutPointerSenderKeyDistributionMessage + var skdm *C.SignalSenderKeyDistributionMessage signalFfiError := C.signal_sender_key_distribution_message_deserialize(&skdm, BytesToBuffer(serialized)) - runtime.KeepAlive(serialized) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapSenderKeyDistributionMessage(skdm.raw), nil -} - -func (sc *SenderKeyDistributionMessage) mutPtr() C.SignalMutPointerSenderKeyDistributionMessage { - return C.SignalMutPointerSenderKeyDistributionMessage{sc.ptr} -} - -func (sc *SenderKeyDistributionMessage) constPtr() C.SignalConstPointerSenderKeyDistributionMessage { - return C.SignalConstPointerSenderKeyDistributionMessage{sc.ptr} + return wrapSenderKeyDistributionMessage(skdm), nil } func (sc *SenderKeyDistributionMessage) Destroy() error { sc.CancelFinalizer() - return wrapError(C.signal_sender_key_distribution_message_destroy(sc.mutPtr())) + return wrapError(C.signal_sender_key_distribution_message_destroy(sc.ptr)) } func (sc *SenderKeyDistributionMessage) CancelFinalizer() { @@ -100,24 +82,21 @@ func (sc *SenderKeyDistributionMessage) CancelFinalizer() { func (sc *SenderKeyDistributionMessage) Serialize() ([]byte, error) { var serialized C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_sender_key_distribution_message_serialize(&serialized, sc.constPtr()) + signalFfiError := C.signal_sender_key_distribution_message_serialize(&serialized, sc.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } return CopySignalOwnedBufferToBytes(serialized), nil } -func (sc *SenderKeyDistributionMessage) Process(ctx context.Context, sender *Address, store SenderKeyStore) error { - callbackCtx := NewCallbackContext(ctx) - defer callbackCtx.Unref() +func (sc *SenderKeyDistributionMessage) Process(sender *Address, store SenderKeyStore, ctx *CallbackContext) error { signalFfiError := C.signal_process_sender_key_distribution_message( - sender.constPtr(), - sc.constPtr(), - callbackCtx.wrapSenderKeyStore(store), + sender.ptr, + sc.ptr, + wrapSenderKeyStore(store), ) - runtime.KeepAlive(sender) if signalFfiError != nil { - return callbackCtx.wrapError(signalFfiError) + return wrapCallbackError(signalFfiError, ctx) } return nil } diff --git a/pkg/libsignalgo/senderkeyrecord.go b/pkg/libsignalgo/senderkeyrecord.go index b40c46f..914c88d 100644 --- a/pkg/libsignalgo/senderkeyrecord.go +++ b/pkg/libsignalgo/senderkeyrecord.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Sumner Evans -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,6 +17,7 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" @@ -37,46 +37,35 @@ func wrapSenderKeyRecord(ptr *C.SignalSenderKeyRecord) *SenderKeyRecord { } func DeserializeSenderKeyRecord(serialized []byte) (*SenderKeyRecord, error) { - var sc C.SignalMutPointerSenderKeyRecord + var sc *C.SignalSenderKeyRecord signalFfiError := C.signal_sender_key_record_deserialize(&sc, BytesToBuffer(serialized)) - runtime.KeepAlive(serialized) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapSenderKeyRecord(sc.raw), nil + return wrapSenderKeyRecord(sc), nil } func (skr *SenderKeyRecord) Serialize() ([]byte, error) { var serialized C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_sender_key_record_serialize(&serialized, skr.constPtr()) - runtime.KeepAlive(skr) + signalFfiError := C.signal_sender_key_record_serialize(&serialized, skr.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } return CopySignalOwnedBufferToBytes(serialized), nil } -func (skr *SenderKeyRecord) mutPtr() C.SignalMutPointerSenderKeyRecord { - return C.SignalMutPointerSenderKeyRecord{skr.ptr} -} - -func (skr *SenderKeyRecord) constPtr() C.SignalConstPointerSenderKeyRecord { - return C.SignalConstPointerSenderKeyRecord{skr.ptr} -} - func (skr *SenderKeyRecord) Clone() (*SenderKeyRecord, error) { - var cloned C.SignalMutPointerSenderKeyRecord - signalFfiError := C.signal_sender_key_record_clone(&cloned, skr.constPtr()) - runtime.KeepAlive(skr) + var cloned *C.SignalSenderKeyRecord + signalFfiError := C.signal_sender_key_record_clone(&cloned, skr.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapSenderKeyRecord(cloned.raw), nil + return wrapSenderKeyRecord(cloned), nil } func (skr *SenderKeyRecord) Destroy() error { skr.CancelFinalizer() - return wrapError(C.signal_sender_key_record_destroy(skr.mutPtr())) + return wrapError(C.signal_sender_key_record_destroy(skr.ptr)) } func (skr *SenderKeyRecord) CancelFinalizer() { diff --git a/pkg/libsignalgo/senderkeystore.go b/pkg/libsignalgo/senderkeystore.go index 1649216..4d00956 100644 --- a/pkg/libsignalgo/senderkeystore.go +++ b/pkg/libsignalgo/senderkeystore.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Sumner Evans -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,11 +17,16 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" -extern int signal_load_sender_key_callback(void *store_ctx, SignalMutPointerSenderKeyRecord *out, SignalMutPointerProtocolAddress sender, SignalUuid distribution_id); -extern int signal_store_sender_key_callback(void *store_ctx, SignalMutPointerProtocolAddress sender, SignalUuid distribution_id, SignalMutPointerSenderKeyRecord record); -extern void signal_destroy_sender_key_store_callback(void *store_ctx); +typedef const SignalProtocolAddress const_address; + +typedef const SignalSenderKeyRecord const_sender_key_record; +typedef const uint8_t const_uuid_bytes[16]; + +extern int signal_load_sender_key_callback(void *store_ctx, SignalSenderKeyRecord**, const_address*, const_uuid_bytes*, void *ctx); +extern int signal_store_sender_key_callback(void *store_ctx, const_address*, const_uuid_bytes*, const_sender_key_record*, void *ctx); */ import "C" import ( @@ -30,48 +34,56 @@ import ( "unsafe" "github.com/google/uuid" + gopointer "github.com/mattn/go-pointer" ) type SenderKeyStore interface { - LoadSenderKey(ctx context.Context, sender *Address, distributionID uuid.UUID) (*SenderKeyRecord, error) - StoreSenderKey(ctx context.Context, sender *Address, distributionID uuid.UUID, record *SenderKeyRecord) error + LoadSenderKey(sender *Address, distributionID uuid.UUID, ctx context.Context) (*SenderKeyRecord, error) + StoreSenderKey(sender *Address, distributionID uuid.UUID, record *SenderKeyRecord, ctx context.Context) error +} + +func wrapSenderKeyStore(store SenderKeyStore) *C.SignalSenderKeyStore { + // TODO this is probably a memory leak since I'm never getting rid of the + // saved pointer. + return &C.SignalSenderKeyStore{ + ctx: gopointer.Save(store), + load_sender_key: C.SignalLoadSenderKey(C.signal_load_sender_key_callback), + store_sender_key: C.SignalStoreSenderKey(C.signal_store_sender_key_callback), + } } //export signal_load_sender_key_callback -func signal_load_sender_key_callback(storeCtx unsafe.Pointer, recordp *C.SignalMutPointerSenderKeyRecord, address C.SignalMutPointerProtocolAddress, distributionID C.SignalUuid) C.int { - return wrapStoreCallback(storeCtx, func(store SenderKeyStore, ctx context.Context) error { - record, err := store.LoadSenderKey(ctx, &Address{ptr: address.raw}, *(*uuid.UUID)(unsafe.Pointer(&distributionID))) +func signal_load_sender_key_callback(storeCtx unsafe.Pointer, recordp **C.SignalSenderKeyRecord, address *C.const_address, distributionIDBytes *C.const_uuid_bytes, ctxPtr unsafe.Pointer) C.int { + return wrapStoreCallback(storeCtx, ctxPtr, func(store SenderKeyStore, ctx context.Context) error { + distributionID := uuid.UUID(*(*[16]byte)(unsafe.Pointer(distributionIDBytes))) + record, err := store.LoadSenderKey( + &Address{ptr: (*C.SignalProtocolAddress)(unsafe.Pointer(address))}, + distributionID, + ctx, + ) if err == nil && record != nil { record.CancelFinalizer() - recordp.raw = record.ptr + *recordp = record.ptr } return err }) } //export signal_store_sender_key_callback -func signal_store_sender_key_callback(storeCtx unsafe.Pointer, address C.SignalMutPointerProtocolAddress, distributionID C.SignalUuid, senderKeyRecord C.SignalMutPointerSenderKeyRecord) C.int { - return wrapStoreCallback(storeCtx, func(store SenderKeyStore, ctx context.Context) error { - record := SenderKeyRecord{ptr: senderKeyRecord.raw} +func signal_store_sender_key_callback(storeCtx unsafe.Pointer, address *C.const_address, distributionIDBytes *C.const_uuid_bytes, senderKeyRecord *C.const_sender_key_record, ctxPtr unsafe.Pointer) C.int { + return wrapStoreCallback(storeCtx, ctxPtr, func(store SenderKeyStore, ctx context.Context) error { + distributionID := uuid.UUID(*(*[16]byte)(unsafe.Pointer(distributionIDBytes))) + record := SenderKeyRecord{ptr: (*C.SignalSenderKeyRecord)(unsafe.Pointer(senderKeyRecord))} cloned, err := record.Clone() if err != nil { return err } - return store.StoreSenderKey(ctx, &Address{ptr: address.raw}, *(*uuid.UUID)(unsafe.Pointer(&distributionID)), cloned) + return store.StoreSenderKey( + &Address{ptr: (*C.SignalProtocolAddress)(unsafe.Pointer(address))}, + distributionID, + cloned, + ctx, + ) }) } - -//export signal_destroy_sender_key_store_callback -func signal_destroy_sender_key_store_callback(storeCtx unsafe.Pointer) { - // No-op: Go's garbage collector handles cleanup -} - -func (ctx *CallbackContext) wrapSenderKeyStore(store SenderKeyStore) C.SignalConstPointerFfiSenderKeyStoreStruct { - return C.SignalConstPointerFfiSenderKeyStoreStruct{&C.SignalSenderKeyStore{ - ctx: wrapStore(ctx, store), - load_sender_key: C.SignalFfiSenderKeyStoreLoadSenderKey(C.signal_load_sender_key_callback), - store_sender_key: C.SignalFfiSenderKeyStoreStoreSenderKey(C.signal_store_sender_key_callback), - destroy: C.SignalFfiSenderKeyStoreDestroy(C.signal_destroy_sender_key_store_callback), - }} -} diff --git a/pkg/libsignalgo/servercertificate.go b/pkg/libsignalgo/servercertificate.go index bf46009..7628c79 100644 --- a/pkg/libsignalgo/servercertificate.go +++ b/pkg/libsignalgo/servercertificate.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Sumner Evans -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,6 +17,7 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" @@ -37,52 +37,35 @@ func wrapServerCertificate(ptr *C.SignalServerCertificate) *ServerCertificate { // NewServerCertificate should only be used for testing (at least according to // the Swift bindings). func NewServerCertificate(keyID uint32, publicKey *PublicKey, trustRoot *PrivateKey) (*ServerCertificate, error) { - var serverCertificate C.SignalMutPointerServerCertificate - signalFfiError := C.signal_server_certificate_new( - &serverCertificate, - C.uint32_t(keyID), - publicKey.constPtr(), - trustRoot.constPtr(), - ) - runtime.KeepAlive(publicKey) - runtime.KeepAlive(trustRoot) + var serverCertificate *C.SignalServerCertificate + signalFfiError := C.signal_server_certificate_new(&serverCertificate, C.uint32_t(keyID), publicKey.ptr, trustRoot.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapServerCertificate(serverCertificate.raw), nil + return wrapServerCertificate(serverCertificate), nil } func DeserializeServerCertificate(serialized []byte) (*ServerCertificate, error) { - var serverCertificate C.SignalMutPointerServerCertificate + var serverCertificate *C.SignalServerCertificate signalFfiError := C.signal_server_certificate_deserialize(&serverCertificate, BytesToBuffer(serialized)) - runtime.KeepAlive(serialized) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapServerCertificate(serverCertificate.raw), nil -} - -func (sc *ServerCertificate) mutPtr() C.SignalMutPointerServerCertificate { - return C.SignalMutPointerServerCertificate{sc.ptr} -} - -func (sc *ServerCertificate) constPtr() C.SignalConstPointerServerCertificate { - return C.SignalConstPointerServerCertificate{sc.ptr} + return wrapServerCertificate(serverCertificate), nil } func (sc *ServerCertificate) Clone() (*ServerCertificate, error) { - var cloned C.SignalMutPointerServerCertificate - signalFfiError := C.signal_server_certificate_clone(&cloned, sc.constPtr()) - runtime.KeepAlive(sc) + var cloned *C.SignalServerCertificate + signalFfiError := C.signal_server_certificate_clone(&cloned, sc.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapServerCertificate(cloned.raw), nil + return wrapServerCertificate(cloned), nil } func (sc *ServerCertificate) Destroy() error { sc.CancelFinalizer() - return wrapError(C.signal_server_certificate_destroy(sc.mutPtr())) + return wrapError(C.signal_server_certificate_destroy(sc.ptr)) } func (sc *ServerCertificate) CancelFinalizer() { @@ -91,8 +74,7 @@ func (sc *ServerCertificate) CancelFinalizer() { func (sc *ServerCertificate) Serialize() ([]byte, error) { var serialized C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_server_certificate_get_serialized(&serialized, sc.constPtr()) - runtime.KeepAlive(sc) + signalFfiError := C.signal_server_certificate_get_serialized(&serialized, sc.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -101,8 +83,7 @@ func (sc *ServerCertificate) Serialize() ([]byte, error) { func (sc *ServerCertificate) GetCertificate() ([]byte, error) { var certificate C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_server_certificate_get_certificate(&certificate, sc.constPtr()) - runtime.KeepAlive(sc) + signalFfiError := C.signal_server_certificate_get_certificate(&certificate, sc.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -111,8 +92,7 @@ func (sc *ServerCertificate) GetCertificate() ([]byte, error) { func (sc *ServerCertificate) GetSignature() ([]byte, error) { var signature C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_server_certificate_get_signature(&signature, sc.constPtr()) - runtime.KeepAlive(sc) + signalFfiError := C.signal_server_certificate_get_signature(&signature, sc.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -121,8 +101,7 @@ func (sc *ServerCertificate) GetSignature() ([]byte, error) { func (sc *ServerCertificate) GetKeyID() (uint32, error) { var keyID C.uint32_t - signalFfiError := C.signal_server_certificate_get_key_id(&keyID, sc.constPtr()) - runtime.KeepAlive(sc) + signalFfiError := C.signal_server_certificate_get_key_id(&keyID, sc.ptr) if signalFfiError != nil { return 0, wrapError(signalFfiError) } @@ -130,11 +109,10 @@ func (sc *ServerCertificate) GetKeyID() (uint32, error) { } func (sc *ServerCertificate) GetKey() (*PublicKey, error) { - var key C.SignalMutPointerPublicKey - signalFfiError := C.signal_server_certificate_get_key(&key, sc.constPtr()) - runtime.KeepAlive(sc) + var key *C.SignalPublicKey + signalFfiError := C.signal_server_certificate_get_key(&key, sc.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapPublicKey(key.raw), nil + return wrapPublicKey(key), nil } diff --git a/pkg/libsignalgo/serverpublicparams.go b/pkg/libsignalgo/serverpublicparams.go deleted file mode 100644 index c1de0cd..0000000 --- a/pkg/libsignalgo/serverpublicparams.go +++ /dev/null @@ -1,58 +0,0 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2024 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package libsignalgo - -/* -#include "./libsignal-ffi.h" -#include -*/ -import "C" -import ( - "fmt" - "runtime" - "unsafe" -) - -type ServerPublicParams = C.SignalServerPublicParams -type NotarySignature [C.SignalSIGNATURE_LEN]byte - -func DeserializeServerPublicParams(params []byte) (*ServerPublicParams, error) { - if len(params) != C.SignalSERVER_PUBLIC_PARAMS_LEN { - return nil, fmt.Errorf("invalid server public params length: %d (expected %d)", len(params), int(C.SignalSERVER_PUBLIC_PARAMS_LEN)) - } - var out C.SignalMutPointerServerPublicParams - signalFfiError := C.signal_server_public_params_deserialize(&out, BytesToBuffer(params[:])) - if signalFfiError != nil { - return nil, wrapError(signalFfiError) - } - return out.raw, nil -} - -func ServerPublicParamsVerifySignature( - serverPublicParams *ServerPublicParams, - messageBytes []byte, - NotarySignature NotarySignature, -) error { - c_notarySignature := (*[C.SignalSIGNATURE_LEN]C.uint8_t)(unsafe.Pointer(&NotarySignature[0])) - signalFfiError := C.signal_server_public_params_verify_signature( - C.SignalConstPointerServerPublicParams{serverPublicParams}, - BytesToBuffer(messageBytes), - c_notarySignature, - ) - runtime.KeepAlive(messageBytes) - return wrapError(signalFfiError) -} diff --git a/pkg/libsignalgo/serviceid.go b/pkg/libsignalgo/serviceid.go index 21d64b2..2626640 100644 --- a/pkg/libsignalgo/serviceid.go +++ b/pkg/libsignalgo/serviceid.go @@ -1,5 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2024 Tulir Asokan +// Copyright (C) 2023 Scott Weber // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -17,170 +17,54 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" #include */ import "C" import ( - "database/sql/driver" - "fmt" - "strings" + "errors" "unsafe" "github.com/google/uuid" - "github.com/rs/zerolog" ) -type ServiceIDType byte - -const ( - ServiceIDTypeACI ServiceIDType = 0 - ServiceIDTypePNI ServiceIDType = 1 -) - -func (st ServiceIDType) String() string { - switch st { - case ServiceIDTypeACI: - return "ACI" - case ServiceIDTypePNI: - return "PNI" - default: - panic(fmt.Sprintf("invalid ServiceIDType: %d", st)) +func init() { + if C.SignalUUID_LEN != 16 { + panic("libsignal-ffi uuid type size mismatch") } } -func (st ServiceIDType) GoString() string { - return fmt.Sprintf("libsignalgo.ServiceIDType%s", st.String()) -} - -type ServiceID struct { - Type ServiceIDType - UUID uuid.UUID -} - -var EmptyServiceID ServiceID - -func NewPNIServiceID(uuid uuid.UUID) ServiceID { - return ServiceID{ - Type: ServiceIDTypePNI, - UUID: uuid, +func SignalServiceIDFromUUID(uuid uuid.UUID) (cPNIType, error) { + var result C.SignalServiceIdFixedWidthBinaryBytes + signalFfiError := C.signal_service_id_parse_from_service_id_binary(&result, BytesToBuffer(uuid[:])) + if signalFfiError != nil { + return nil, wrapError(signalFfiError) } + return cPNIType(unsafe.Pointer(&result)), nil } -func NewACIServiceID(uuid uuid.UUID) ServiceID { - return ServiceID{ - Type: ServiceIDTypeACI, - UUID: uuid, +func SignalPNIServiceIDFromUUID(uuid uuid.UUID) (cPNIType, error) { + var result C.SignalServiceIdFixedWidthBinaryBytes + // Prepend a 0x01 to the UUID to indicate that it is a PNI UUID + pniUUID := append([]byte{0x01}, uuid[:]...) + signalFfiError := C.signal_service_id_parse_from_service_id_binary(&result, BytesToBuffer(pniUUID)) + if signalFfiError != nil { + return nil, wrapError(signalFfiError) } + return cPNIType(unsafe.Pointer(&result)), nil } -func (s ServiceID) ToACIAndPNI() (aci, pni uuid.UUID) { - if s.Type == ServiceIDTypeACI { - return s.UUID, uuid.Nil - } else { - return uuid.Nil, s.UUID +func SignalServiceIDToUUID(serviceId *C.SignalServiceIdFixedWidthBinaryBytes) (uuid.UUID, error) { + result := C.SignalOwnedBuffer{} + serviceIdBytes := cPNIType(unsafe.Pointer(serviceId)) // Hack around gcc bug, not needed for clang + signalFfiError := C.signal_service_id_service_id_binary(&result, serviceIdBytes) + if signalFfiError != nil { + return uuid.UUID{}, wrapError(signalFfiError) } -} - -func (s ServiceID) IsEmpty() bool { - return s.UUID == uuid.Nil -} - -func (s ServiceID) Address(deviceID uint) (*Address, error) { - if s.IsEmpty() { - return nil, fmt.Errorf("cannot create address from empty ServiceID") + uuidBytes := CopySignalOwnedBufferToBytes(result) + if len(uuidBytes) != 16 { + return uuid.UUID{}, errors.New("invalid UUID length") } - return newAddress(s.String(), deviceID) -} - -func (s ServiceID) Bytes() []byte { - if s.Type == ServiceIDTypeACI { - return s.UUID[:] - } - return append([]byte{byte(s.Type)}, s.UUID[:]...) -} - -func (s ServiceID) Value() (driver.Value, error) { - return s.String(), nil -} - -func (s ServiceID) String() string { - if s.Type == ServiceIDTypeACI { - return s.UUID.String() - } - return fmt.Sprintf("%s:%s", s.Type, s.UUID) -} - -func (s ServiceID) GoString() string { - return fmt.Sprintf(`libsignalgo.ServiceID{Type: %#v, UUID: uuid.MustParse("%s")}`, s.Type, s.UUID) -} - -func (s ServiceID) MarshalText() ([]byte, error) { - return []byte(s.String()), nil -} - -func (s *ServiceID) UnmarshalText(text []byte) error { - parsed, err := ServiceIDFromString(string(text)) - if err != nil { - return err - } - *s = parsed - return nil -} - -func (s ServiceID) MarshalZerologObject(e *zerolog.Event) { - e.Stringer("type", s.Type) - e.Stringer("uuid", s.UUID) -} - -type ServiceIDFixedBytes [17]byte - -func (s ServiceID) FixedBytes() *ServiceIDFixedBytes { - var result ServiceIDFixedBytes - result[0] = byte(s.Type) - copy(result[1:], s.UUID[:]) - return &result -} - -func ServiceIDFromString(val string) (ServiceID, error) { - if len(val) < 36 { - return EmptyServiceID, fmt.Errorf("invalid UUID string: %s", val) - } - if strings.ToUpper(val[:4]) == "PNI:" { - parsed, err := uuid.Parse(val[4:]) - if err != nil { - return EmptyServiceID, err - } - return NewPNIServiceID(parsed), nil - } else { - parsed, err := uuid.Parse(val) - if err != nil { - return EmptyServiceID, err - } - return NewACIServiceID(parsed), nil - } -} - -func ServiceIDFromBytes(bytes []byte) (ServiceID, error) { - if len(bytes) == 16 { - return NewACIServiceID(uuid.UUID(bytes)), nil - } else if len(bytes) == 17 { - return ServiceID{ - Type: ServiceIDType(bytes[0]), - UUID: uuid.UUID(bytes[1:]), - }, nil - } - return EmptyServiceID, fmt.Errorf("invalid ServiceID byte length: %d (expected 16 or 17)", len(bytes)) -} - -func ServiceIDFromCFixedBytes(serviceID *C.SignalServiceIdFixedWidthBinaryBytes) ServiceID { - var id ServiceID - fixedBytes := (*ServiceIDFixedBytes)(unsafe.Pointer(serviceID)) - id.Type = ServiceIDType(fixedBytes[0]) - copy(id.UUID[:], fixedBytes[1:]) - return id -} - -func (s ServiceID) CFixedBytes() cPNIType { - return cPNIType(unsafe.Pointer(s.FixedBytes())) + return uuid.UUID(uuidBytes), nil } diff --git a/pkg/libsignalgo/serviceid_clang.go b/pkg/libsignalgo/serviceid_clang.go index 89197b6..8de76b2 100644 --- a/pkg/libsignalgo/serviceid_clang.go +++ b/pkg/libsignalgo/serviceid_clang.go @@ -1,8 +1,9 @@ -//go:build darwin || android || ios || (windows && arm64) +//go:build darwin package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" #include */ diff --git a/pkg/libsignalgo/serviceid_gcc.go b/pkg/libsignalgo/serviceid_gcc.go index 0feb627..4152fba 100644 --- a/pkg/libsignalgo/serviceid_gcc.go +++ b/pkg/libsignalgo/serviceid_gcc.go @@ -1,8 +1,9 @@ -//go:build !(darwin || android || ios || (windows && arm64)) +//go:build !darwin package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" #include */ diff --git a/pkg/libsignalgo/session_test.go b/pkg/libsignalgo/session_test.go index dd05718..7cb3c92 100644 --- a/pkg/libsignalgo/session_test.go +++ b/pkg/libsignalgo/session_test.go @@ -18,8 +18,6 @@ package libsignalgo_test import ( "context" - "fmt" - "runtime" "testing" "time" @@ -30,7 +28,7 @@ import ( "go.mau.fi/mautrix-signal/pkg/libsignalgo" ) -func initializeSessions(t *testing.T, aliceStore, bobStore *InMemorySignalProtocolStore, bobAddress, aliceAddress *libsignalgo.Address) { +func initializeSessions(t *testing.T, aliceStore, bobStore *InMemorySignalProtocolStore, bobAddress *libsignalgo.Address) { ctx := context.TODO() bobPreKey, err := libsignalgo.GeneratePrivateKey() @@ -66,7 +64,7 @@ func initializeSessions(t *testing.T, aliceStore, bobStore *InMemorySignalProtoc var prekeyID uint32 = 4570 var signedPreKeyID uint32 = 3006 - var kyberPreKeyID uint32 = 8008 + var kyberPreKeyId uint32 = 8008 bobRegistrationID, err := bobStore.GetLocalRegistrationID(ctx) assert.NoError(t, err) @@ -78,7 +76,7 @@ func initializeSessions(t *testing.T, aliceStore, bobStore *InMemorySignalProtoc signedPreKeyID, bobSignedPreKeyPublicKey, bobSignedPreKeySignature, - kyberPreKeyID, + kyberPreKeyId, bobKyberPreKeyPublicKey, bobKyberPreKeySignature, bobIdentityKey, @@ -86,10 +84,10 @@ func initializeSessions(t *testing.T, aliceStore, bobStore *InMemorySignalProtoc assert.NoError(t, err) // Alice processes the bundle - err = libsignalgo.ProcessPreKeyBundle(ctx, bobBundle, bobAddress, aliceAddress, aliceStore, aliceStore) + err = libsignalgo.ProcessPreKeyBundle(bobBundle, bobAddress, aliceStore, aliceStore, libsignalgo.NewCallbackContext(ctx)) assert.NoError(t, err) - record, err := aliceStore.LoadSession(ctx, bobAddress) + record, err := aliceStore.LoadSession(bobAddress, ctx) assert.NoError(t, err) assert.NotNil(t, record) @@ -104,39 +102,36 @@ func initializeSessions(t *testing.T, aliceStore, bobStore *InMemorySignalProtoc // Bob processes the bundle preKeyRecord, err := libsignalgo.NewPreKeyRecordFromPrivateKey(prekeyID, bobPreKey) assert.NoError(t, err) - err = bobStore.StorePreKey(ctx, prekeyID, preKeyRecord) + err = bobStore.StorePreKey(prekeyID, preKeyRecord, ctx) assert.NoError(t, err) signedPreKeyRecord, err := libsignalgo.NewSignedPreKeyRecordFromPrivateKey(signedPreKeyID, time.UnixMilli(42000), bobSignedPreKey, bobSignedPreKeySignature) assert.NoError(t, err) - err = bobStore.StoreSignedPreKey(ctx, signedPreKeyID, signedPreKeyRecord) + err = bobStore.StoreSignedPreKey(signedPreKeyID, signedPreKeyRecord, ctx) require.NoError(t, err) - kyberPreKeyRecord, err := libsignalgo.NewKyberPreKeyRecord(kyberPreKeyID, time.UnixMilli(42000), bobKyberPreKey, bobKyberPreKeySignature) + kyberPreKeyRecord, err := libsignalgo.NewKyberPreKeyRecord(kyberPreKeyId, time.UnixMilli(42000), bobKyberPreKey, bobKyberPreKeySignature) require.NoError(t, err) - err = bobStore.StoreKyberPreKey(ctx, kyberPreKeyID, kyberPreKeyRecord) + err = bobStore.StoreKyberPreKey(kyberPreKeyId, kyberPreKeyRecord, ctx) require.NoError(t, err) } // From SessionTests.swift:testSessionCipher func TestSessionCipher(t *testing.T) { - ctx := context.TODO() - aliceACI := uuid.New() - bobACI := uuid.New() - - aliceAddress, err := libsignalgo.NewACIServiceID(aliceACI).Address(1) + ctx := libsignalgo.NewEmptyCallbackContext() + aliceAddress, err := libsignalgo.NewAddress("+14151111111", 1) assert.NoError(t, err) - bobAddress, err := libsignalgo.NewACIServiceID(bobACI).Address(1) + bobAddress, err := libsignalgo.NewAddress("+14151111112", 1) assert.NoError(t, err) aliceStore := NewInMemorySignalProtocolStore() bobStore := NewInMemorySignalProtocolStore() - initializeSessions(t, aliceStore, bobStore, bobAddress, aliceAddress) + initializeSessions(t, aliceStore, bobStore, bobAddress) alicePlaintext := []byte{8, 6, 7, 5, 3, 0, 9} - aliceCiphertext, err := libsignalgo.Encrypt(ctx, alicePlaintext, bobAddress, aliceAddress, aliceStore, aliceStore) + aliceCiphertext, err := libsignalgo.Encrypt(alicePlaintext, bobAddress, aliceStore, aliceStore, ctx) assert.NoError(t, err) aliceCiphertextMessageType, err := aliceCiphertext.MessageType() assert.NoError(t, err) @@ -147,13 +142,13 @@ func TestSessionCipher(t *testing.T) { bobCiphertext, err := libsignalgo.DeserializePreKeyMessage(aliceCiphertextSerialized) assert.NoError(t, err) - bobPlaintext, err := libsignalgo.DecryptPreKey(ctx, bobCiphertext, aliceAddress, bobAddress, bobStore, bobStore, bobStore, bobStore, bobStore) + bobPlaintext, err := libsignalgo.DecryptPreKey(bobCiphertext, aliceAddress, bobStore, bobStore, bobStore, bobStore, bobStore, ctx) assert.NoError(t, err) assert.Equal(t, alicePlaintext, bobPlaintext) bobPlaintext2 := []byte{23} - bobCiphertext2, err := libsignalgo.Encrypt(ctx, bobPlaintext2, aliceAddress, bobAddress, bobStore, bobStore) + bobCiphertext2, err := libsignalgo.Encrypt(bobPlaintext2, aliceAddress, bobStore, bobStore, ctx) assert.NoError(t, err) bobCiphertext2MessageType, err := bobCiphertext2.MessageType() assert.NoError(t, err) @@ -163,31 +158,27 @@ func TestSessionCipher(t *testing.T) { assert.NoError(t, err) aliceCiphertext2, err := libsignalgo.DeserializeMessage(bobCiphertext2Serialized) assert.NoError(t, err) - alicePlaintext2, err := libsignalgo.Decrypt(ctx, aliceCiphertext2, bobAddress, aliceAddress, aliceStore, aliceStore) + alicePlaintext2, err := libsignalgo.Decrypt(aliceCiphertext2, bobAddress, aliceStore, aliceStore, ctx) assert.NoError(t, err) assert.Equal(t, bobPlaintext2, alicePlaintext2) } // From SessionTests.swift:testSessionCipherWithBadStore func TestSessionCipherWithBadStore(t *testing.T) { - ctx := context.TODO() - - aliceACI := uuid.New() - bobACI := uuid.New() - - aliceAddress, err := libsignalgo.NewACIServiceID(aliceACI).Address(1) + ctx := libsignalgo.NewEmptyCallbackContext() + aliceAddress, err := libsignalgo.NewAddress("+14151111111", 1) assert.NoError(t, err) - bobAddress, err := libsignalgo.NewACIServiceID(bobACI).Address(1) + bobAddress, err := libsignalgo.NewAddress("+14151111112", 1) assert.NoError(t, err) aliceStore := NewInMemorySignalProtocolStore() bobStore := &BadInMemorySignalProtocolStore{NewInMemorySignalProtocolStore()} - initializeSessions(t, aliceStore, bobStore.InMemorySignalProtocolStore, bobAddress, aliceAddress) + initializeSessions(t, aliceStore, bobStore.InMemorySignalProtocolStore, bobAddress) alicePlaintext := []byte{8, 6, 7, 5, 3, 0, 9} - aliceCiphertext, err := libsignalgo.Encrypt(ctx, alicePlaintext, bobAddress, aliceAddress, aliceStore, aliceStore) + aliceCiphertext, err := libsignalgo.Encrypt(alicePlaintext, bobAddress, aliceStore, aliceStore, ctx) assert.NoError(t, err) aliceCiphertextMessageType, err := aliceCiphertext.MessageType() assert.NoError(t, err) @@ -198,25 +189,25 @@ func TestSessionCipherWithBadStore(t *testing.T) { bobCiphertext, err := libsignalgo.DeserializePreKeyMessage(aliceCiphertextSerialized) assert.NoError(t, err) t.Skip("This test is broken") // TODO fix - _, err = libsignalgo.DecryptPreKey(ctx, bobCiphertext, aliceAddress, bobAddress, bobStore, bobStore, bobStore, bobStore, bobStore) + _, err = libsignalgo.DecryptPreKey(bobCiphertext, aliceAddress, bobStore, bobStore, bobStore, bobStore, bobStore, ctx) require.Error(t, err) assert.Equal(t, "Test error", err.Error()) } -func TestSealedSenderEncrypt_Repeated(t *testing.T) { - ctx := context.TODO() - +// From SessionTests.swift:testSealedSenderSession +func TestSealedSenderSession(t *testing.T) { setupLogging() - aliceAddress, err := libsignalgo.NewUUIDAddressFromString("9d0652a3-dcc3-4d11-975f-74d61598733f", 1) + ctx := libsignalgo.NewEmptyCallbackContext() + aliceAddress, err := libsignalgo.NewAddress("9d0652a3-dcc3-4d11-975f-74d61598733f", 1) assert.NoError(t, err) - bobAddress, err := libsignalgo.NewUUIDAddressFromString("6838237D-02F6-4098-B110-698253D15961", 1) + bobAddress, err := libsignalgo.NewAddress("6838237D-02F6-4098-B110-698253D15961", 1) assert.NoError(t, err) aliceStore := NewInMemorySignalProtocolStore() bobStore := NewInMemorySignalProtocolStore() - initializeSessions(t, aliceStore, bobStore, bobAddress, aliceAddress) + initializeSessions(t, aliceStore, bobStore, bobAddress) trustRoot, err := libsignalgo.GenerateIdentityKeyPair() assert.NoError(t, err) @@ -228,44 +219,84 @@ func TestSealedSenderEncrypt_Repeated(t *testing.T) { assert.NoError(t, err) senderAddress := libsignalgo.NewSealedSenderAddress("+14151111111", uuid.MustParse(aliceName), 1) - aliceIdentityKeyPair, err := aliceStore.GetIdentityKeyPair(ctx) + aliceIdentityKeyPair, err := aliceStore.GetIdentityKeyPair(ctx.Ctx) require.NoError(t, err) senderCert, err := libsignalgo.NewSenderCertificate(senderAddress, aliceIdentityKeyPair.GetPublicKey(), time.UnixMilli(31337), serverCert, serverKeys.GetPrivateKey()) assert.NoError(t, err) - go func() { - for { - runtime.GC() - time.Sleep(500 * time.Microsecond) - } - }() - for i := 0; i < 100; i++ { - message := []byte(fmt.Sprintf("%04d vision", i)) - ciphertext, err := libsignalgo.SealedSenderEncryptPlaintext(ctx, message, libsignalgo.UnidentifiedSenderMessageContentHintDefault, bobAddress, aliceAddress, senderCert, aliceStore, aliceStore, nil) + message := []byte("2020 vision") + ciphertext, err := libsignalgo.SealedSenderEncryptPlaintext(message, bobAddress, senderCert, aliceStore, aliceStore, ctx) + require.NoError(t, err) + assert.NotNil(t, ciphertext) + + bobName, err := bobAddress.Name() + require.NoError(t, err) + recipientAddress := libsignalgo.NewSealedSenderAddress("", uuid.MustParse(bobName), 1) + + t.Skip("This test is broken") // TODO fix + + plaintext, err := libsignalgo.SealedSenderDecrypt( + ciphertext, + recipientAddress, + trustRoot.GetPublicKey(), + time.UnixMilli(31335), + bobStore, + bobStore, + bobStore, + bobStore, + ctx, + ) + require.NoError(t, err) + assert.Equal(t, message, plaintext.Message) + assert.Equal(t, senderAddress.DeviceID, plaintext.Sender.DeviceID) + assert.Equal(t, senderAddress.E164, plaintext.Sender.E164) + assert.Equal(t, senderAddress.UUID, plaintext.Sender.UUID) + + innerMessage, err := libsignalgo.Encrypt([]byte{}, bobAddress, aliceStore, aliceStore, ctx) + require.NoError(t, err) + + hints := []libsignalgo.UnidentifiedSenderMessageContentHint{ + 200, + libsignalgo.UnidentifiedSenderMessageContentHintDefault, + libsignalgo.UnidentifiedSenderMessageContentHintResendable, + libsignalgo.UnidentifiedSenderMessageContentHintImplicit, + } + + for _, hint := range hints { + content, err := libsignalgo.NewUnidentifiedSenderMessageContent( + innerMessage, + senderCert, + hint, + []byte{}, + ) require.NoError(t, err) - assert.NotNil(t, ciphertext) + + _, err = libsignalgo.SealedSenderEncrypt(content, bobAddress, aliceStore, ctx) + require.NoError(t, err) + + // decryptedContent, err := libsignalgo.NewUnidentifiedSenderMessageContent(ciphertext) + + // let decryptedContent = try UnidentifiedSenderMessageContent(message: ciphertext, + // identityStore: bob_store, + // context: NullContext()) + // XCTAssertEqual(decryptedContent.contentHint, hint) } } // From SessionTests.swift:testArchiveSession func TestArchiveSession(t *testing.T) { - ctx := context.TODO() setupLogging() + ctx := libsignalgo.NewEmptyCallbackContext() - aliceACI := uuid.New() - bobACI := uuid.New() - - aliceAddress, err := libsignalgo.NewACIServiceID(aliceACI).Address(1) - assert.NoError(t, err) - bobAddress, err := libsignalgo.NewACIServiceID(bobACI).Address(1) + bobAddress, err := libsignalgo.NewAddress("+14151111112", 1) assert.NoError(t, err) aliceStore := NewInMemorySignalProtocolStore() bobStore := NewInMemorySignalProtocolStore() - initializeSessions(t, aliceStore, bobStore, bobAddress, aliceAddress) + initializeSessions(t, aliceStore, bobStore, bobAddress) - session, err := aliceStore.LoadSession(ctx, bobAddress) + session, err := aliceStore.LoadSession(bobAddress, ctx.Ctx) assert.NoError(t, err) assert.NotNil(t, session) @@ -307,9 +338,9 @@ func TestSealedSenderGroupCipher(t *testing.T) { setupLogging() ctx := libsignalgo.NewEmptyCallbackContext() - aliceAddress, err := libsignalgo.NewUUIDAddressFromString("9d0652a3-dcc3-4d11-975f-74d61598733f", 1) + aliceAddress, err := libsignalgo.NewAddress("9d0652a3-dcc3-4d11-975f-74d61598733f", 1) assert.NoError(t, err) - bobAddress, err := libsignalgo.NewUUIDAddressFromString("6838237D-02F6-4098-B110-698253D15961", 1) + bobAddress, err := libsignalgo.NewAddress("6838237D-02F6-4098-B110-698253D15961", 1) assert.NoError(t, err) aliceStore := NewInMemorySignalProtocolStore() @@ -318,7 +349,7 @@ func TestSealedSenderGroupCipher(t *testing.T) { bobStore := NewInMemorySignalProtocolStore() - initializeSessions(t, aliceStore, bobStore, bobAddress, aliceAddress) + initializeSessions(t, aliceStore, bobStore, bobAddress) trustRoot, err := libsignalgo.GenerateIdentityKeyPair() assert.NoError(t, err) diff --git a/pkg/libsignalgo/sessionrecord.go b/pkg/libsignalgo/sessionrecord.go index b4f2afb..38a3ca2 100644 --- a/pkg/libsignalgo/sessionrecord.go +++ b/pkg/libsignalgo/sessionrecord.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Sumner Evans -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,6 +17,7 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" @@ -38,39 +38,26 @@ func wrapSessionRecord(ptr *C.SignalSessionRecord) *SessionRecord { } func DeserializeSessionRecord(serialized []byte) (*SessionRecord, error) { - var ptr C.SignalMutPointerSessionRecord + var ptr *C.SignalSessionRecord signalFfiError := C.signal_session_record_deserialize(&ptr, BytesToBuffer(serialized)) - runtime.KeepAlive(serialized) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapSessionRecord(ptr.raw), nil -} - -func (sr *SessionRecord) mutPtr() C.SignalMutPointerSessionRecord { - return C.SignalMutPointerSessionRecord{sr.ptr} -} - -func (sr *SessionRecord) constPtr() C.SignalConstPointerSessionRecord { - return C.SignalConstPointerSessionRecord{sr.ptr} + return wrapSessionRecord(ptr), nil } func (sr *SessionRecord) Clone() (*SessionRecord, error) { - var clone C.SignalMutPointerSessionRecord - signalFfiError := C.signal_session_record_clone( - &clone, - sr.constPtr(), - ) - runtime.KeepAlive(sr) + var clone *C.SignalSessionRecord + signalFfiError := C.signal_session_record_clone(&clone, sr.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapSessionRecord(clone.raw), nil + return wrapSessionRecord(clone), nil } func (sr *SessionRecord) Destroy() error { sr.CancelFinalizer() - return wrapError(C.signal_session_record_destroy(sr.mutPtr())) + return wrapError(C.signal_session_record_destroy(sr.ptr)) } func (sr *SessionRecord) CancelFinalizer() { @@ -78,22 +65,12 @@ func (sr *SessionRecord) CancelFinalizer() { } func (sr *SessionRecord) ArchiveCurrentState() error { - defer runtime.KeepAlive(sr) - return wrapError(C.signal_session_record_archive_current_state(sr.mutPtr())) + return wrapError(C.signal_session_record_archive_current_state(sr.ptr)) } func (sr *SessionRecord) CurrentRatchetKeyMatches(key *PublicKey) (bool, error) { - if sr == nil || key == nil { - return false, nil - } var result C.bool - signalFfiError := C.signal_session_record_current_ratchet_key_matches( - &result, - sr.constPtr(), - key.constPtr(), - ) - runtime.KeepAlive(sr) - runtime.KeepAlive(key) + signalFfiError := C.signal_session_record_current_ratchet_key_matches(&result, sr.ptr, key.ptr) if signalFfiError != nil { return false, wrapError(signalFfiError) } @@ -102,12 +79,7 @@ func (sr *SessionRecord) CurrentRatchetKeyMatches(key *PublicKey) (bool, error) func (sr *SessionRecord) HasCurrentState() (bool, error) { var result C.bool - signalFfiError := C.signal_session_record_has_usable_sender_chain( - &result, - sr.constPtr(), - C.uint64_t(time.Now().Unix()), - ) - runtime.KeepAlive(sr) + signalFfiError := C.signal_session_record_has_usable_sender_chain(&result, sr.ptr, C.uint64_t(time.Now().Unix())) if signalFfiError != nil { return false, wrapError(signalFfiError) } @@ -116,8 +88,7 @@ func (sr *SessionRecord) HasCurrentState() (bool, error) { func (sr *SessionRecord) Serialize() ([]byte, error) { var serialized C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_session_record_serialize(&serialized, sr.constPtr()) - runtime.KeepAlive(sr) + signalFfiError := C.signal_session_record_serialize(&serialized, sr.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -126,8 +97,7 @@ func (sr *SessionRecord) Serialize() ([]byte, error) { func (sr *SessionRecord) GetLocalRegistrationID() (uint32, error) { var result C.uint32_t - signalFfiError := C.signal_session_record_get_local_registration_id(&result, sr.constPtr()) - runtime.KeepAlive(sr) + signalFfiError := C.signal_session_record_get_local_registration_id(&result, sr.ptr) if signalFfiError != nil { return 0, wrapError(signalFfiError) } @@ -136,8 +106,7 @@ func (sr *SessionRecord) GetLocalRegistrationID() (uint32, error) { func (sr *SessionRecord) GetRemoteRegistrationID() (uint32, error) { var result C.uint32_t - signalFfiError := C.signal_session_record_get_remote_registration_id(&result, sr.constPtr()) - runtime.KeepAlive(sr) + signalFfiError := C.signal_session_record_get_remote_registration_id(&result, sr.ptr) if signalFfiError != nil { return 0, wrapError(signalFfiError) } diff --git a/pkg/libsignalgo/sessionstore.go b/pkg/libsignalgo/sessionstore.go index 99000e5..0db1f70 100644 --- a/pkg/libsignalgo/sessionstore.go +++ b/pkg/libsignalgo/sessionstore.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Sumner Evans -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,57 +17,63 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" -extern int signal_load_session_callback(void *store_ctx, SignalMutPointerSessionRecord *recordp, SignalMutPointerProtocolAddress address); -extern int signal_store_session_callback(void *store_ctx, SignalMutPointerProtocolAddress address, SignalMutPointerSessionRecord record); -extern void signal_destroy_session_store_callback(void *store_ctx); +typedef const SignalSessionRecord const_session_record; +typedef const SignalProtocolAddress const_address; + +extern int signal_load_session_callback(void *store_ctx, SignalSessionRecord **recordp, const_address *address, void *ctx); +extern int signal_store_session_callback(void *store_ctx, const_address *address, const_session_record *record, void *ctx); */ import "C" import ( "context" "unsafe" + + gopointer "github.com/mattn/go-pointer" ) type SessionStore interface { - LoadSession(ctx context.Context, address *Address) (*SessionRecord, error) - StoreSession(ctx context.Context, address *Address, record *SessionRecord) error + LoadSession(address *Address, ctx context.Context) (*SessionRecord, error) + StoreSession(address *Address, record *SessionRecord, ctx context.Context) error } //export signal_load_session_callback -func signal_load_session_callback(storeCtx unsafe.Pointer, recordp *C.SignalMutPointerSessionRecord, address C.SignalMutPointerProtocolAddress) C.int { - return wrapStoreCallback(storeCtx, func(store SessionStore, ctx context.Context) error { - record, err := store.LoadSession(ctx, &Address{ptr: address.raw}) +func signal_load_session_callback(storeCtx unsafe.Pointer, recordp **C.SignalSessionRecord, address *C.const_address, ctxPtr unsafe.Pointer) C.int { + return wrapStoreCallback(storeCtx, ctxPtr, func(store SessionStore, ctx context.Context) error { + record, err := store.LoadSession( + &Address{ptr: (*C.SignalProtocolAddress)(unsafe.Pointer(address))}, + ctx, + ) if err == nil && record != nil { record.CancelFinalizer() - recordp.raw = record.ptr + *recordp = record.ptr } return err }) } //export signal_store_session_callback -func signal_store_session_callback(storeCtx unsafe.Pointer, address C.SignalMutPointerProtocolAddress, sessionRecord C.SignalMutPointerSessionRecord) C.int { - return wrapStoreCallback(storeCtx, func(store SessionStore, ctx context.Context) error { - record := SessionRecord{ptr: sessionRecord.raw} +func signal_store_session_callback(storeCtx unsafe.Pointer, address *C.const_address, sessionRecord *C.const_session_record, ctxPtr unsafe.Pointer) C.int { + return wrapStoreCallback(storeCtx, ctxPtr, func(store SessionStore, ctx context.Context) error { + record := SessionRecord{ptr: (*C.SignalSessionRecord)(unsafe.Pointer(sessionRecord))} cloned, err := record.Clone() if err != nil { return err } - return store.StoreSession(ctx, &Address{ptr: address.raw}, cloned) + return store.StoreSession( + &Address{ptr: (*C.SignalProtocolAddress)(unsafe.Pointer(address))}, + cloned, + ctx, + ) }) } -//export signal_destroy_session_store_callback -func signal_destroy_session_store_callback(storeCtx unsafe.Pointer) { - // No-op: Go's garbage collector handles cleanup -} - -func (ctx *CallbackContext) wrapSessionStore(store SessionStore) C.SignalConstPointerFfiSessionStoreStruct { - return C.SignalConstPointerFfiSessionStoreStruct{&C.SignalSessionStore{ - ctx: wrapStore(ctx, store), - load_session: C.SignalFfiSessionStoreLoadSession(C.signal_load_session_callback), - store_session: C.SignalFfiSessionStoreStoreSession(C.signal_store_session_callback), - destroy: C.SignalFfiSessionStoreDestroy(C.signal_destroy_session_store_callback), - }} +func wrapSessionStore(store SessionStore) *C.SignalSessionStore { + return &C.SignalSessionStore{ + ctx: gopointer.Save(store), + load_session: C.SignalLoadSession(C.signal_load_session_callback), + store_session: C.SignalStoreSession(C.signal_store_session_callback), + } } diff --git a/pkg/libsignalgo/setup_test.go b/pkg/libsignalgo/setup_test.go index 47d7d77..397238b 100644 --- a/pkg/libsignalgo/setup_test.go +++ b/pkg/libsignalgo/setup_test.go @@ -29,7 +29,7 @@ type FFILogger struct{} func (FFILogger) Enabled(target string, level libsignalgo.LogLevel) bool { return true } -func (FFILogger) Log(level libsignalgo.LogLevel, file string, line uint, message string) { +func (FFILogger) Log(target string, level libsignalgo.LogLevel, file string, line uint, message string) { var evt *zerolog.Event switch level { case libsignalgo.LogLevelError: @@ -47,6 +47,7 @@ func (FFILogger) Log(level libsignalgo.LogLevel, file string, line uint, message } evt.Str("component", "libsignal"). + Str("target", target). Str("file", file). Uint("line", line). Msg(message) @@ -54,8 +55,6 @@ func (FFILogger) Log(level libsignalgo.LogLevel, file string, line uint, message func (FFILogger) Flush() {} -func (FFILogger) Destroy() {} - var loggingSetup = false func setupLogging() { diff --git a/pkg/libsignalgo/sgxclient.go b/pkg/libsignalgo/sgxclient.go deleted file mode 100644 index e2d817e..0000000 --- a/pkg/libsignalgo/sgxclient.go +++ /dev/null @@ -1,113 +0,0 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2024 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package libsignalgo - -/* -#include "./libsignal-ffi.h" -*/ -import "C" -import ( - "runtime" - "time" -) - -type SGXClientState struct { - nc noCopy - ptr *C.SignalSgxClientState -} - -func wrapSGXClientState(ptr *C.SignalSgxClientState) *SGXClientState { - cdsClientState := &SGXClientState{ptr: ptr} - runtime.SetFinalizer(cdsClientState, (*SGXClientState).Destroy) - return cdsClientState -} - -func NewCDS2ClientState(mrenclave, attestationMessage []byte, currentTime time.Time) (*SGXClientState, error) { - var cds C.SignalMutPointerSgxClientState - signalFfiError := C.signal_cds2_client_state_new( - &cds, - BytesToBuffer(mrenclave), - BytesToBuffer(attestationMessage), - C.uint64_t(currentTime.UnixMilli()), - ) - runtime.KeepAlive(mrenclave) - runtime.KeepAlive(attestationMessage) - if signalFfiError != nil { - return nil, wrapError(signalFfiError) - } - return wrapSGXClientState(cds.raw), nil -} - -func (cds *SGXClientState) mutPtr() C.SignalMutPointerSgxClientState { - return C.SignalMutPointerSgxClientState{cds.ptr} -} - -func (cds *SGXClientState) constPtr() C.SignalConstPointerSgxClientState { - return C.SignalConstPointerSgxClientState{cds.ptr} -} - -func (cds *SGXClientState) Destroy() error { - runtime.SetFinalizer(cds, nil) - return wrapError(C.signal_sgx_client_state_destroy(cds.mutPtr())) -} - -func (cds *SGXClientState) InitialRequest() ([]byte, error) { - var resp C.SignalOwnedBuffer - signalFfiError := C.signal_sgx_client_state_initial_request(&resp, cds.constPtr()) - runtime.KeepAlive(cds) - if signalFfiError != nil { - return nil, wrapError(signalFfiError) - } - return CopySignalOwnedBufferToBytes(resp), nil -} - -func (cds *SGXClientState) CompleteHandshake(handshakeReceived []byte) error { - signalFfiError := C.signal_sgx_client_state_complete_handshake(cds.mutPtr(), BytesToBuffer(handshakeReceived)) - runtime.KeepAlive(cds) - runtime.KeepAlive(handshakeReceived) - return wrapError(signalFfiError) -} - -func (cds *SGXClientState) EstablishedSend(plaintext []byte) ([]byte, error) { - var resp C.SignalOwnedBuffer - signalFfiError := C.signal_sgx_client_state_established_send( - &resp, - cds.mutPtr(), - BytesToBuffer(plaintext), - ) - runtime.KeepAlive(cds) - runtime.KeepAlive(plaintext) - if signalFfiError != nil { - return nil, wrapError(signalFfiError) - } - return CopySignalOwnedBufferToBytes(resp), nil -} - -func (cds *SGXClientState) EstablishedReceive(ciphertext []byte) ([]byte, error) { - var resp C.SignalOwnedBuffer - signalFfiError := C.signal_sgx_client_state_established_recv( - &resp, - cds.mutPtr(), - BytesToBuffer(ciphertext), - ) - runtime.KeepAlive(cds) - runtime.KeepAlive(ciphertext) - if signalFfiError != nil { - return nil, wrapError(signalFfiError) - } - return CopySignalOwnedBufferToBytes(resp), nil -} diff --git a/pkg/libsignalgo/signedprekey.go b/pkg/libsignalgo/signedprekey.go index 32afc37..8ffd68a 100644 --- a/pkg/libsignalgo/signedprekey.go +++ b/pkg/libsignalgo/signedprekey.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Sumner Evans -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,6 +17,7 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" @@ -38,22 +38,12 @@ func wrapSignedPreKeyRecord(ptr *C.SignalSignedPreKeyRecord) *SignedPreKeyRecord } func NewSignedPreKeyRecord(id uint32, timestamp time.Time, publicKey *PublicKey, privateKey *PrivateKey, signature []byte) (*SignedPreKeyRecord, error) { - var spkr C.SignalMutPointerSignedPreKeyRecord - signalFfiError := C.signal_signed_pre_key_record_new( - &spkr, - C.uint32_t(id), - C.uint64_t(timestamp.UnixMilli()), - publicKey.constPtr(), - privateKey.constPtr(), - BytesToBuffer(signature), - ) - runtime.KeepAlive(publicKey) - runtime.KeepAlive(privateKey) - runtime.KeepAlive(signature) + var spkr *C.SignalSignedPreKeyRecord + signalFfiError := C.signal_signed_pre_key_record_new(&spkr, C.uint32_t(id), C.uint64_t(timestamp.UnixMilli()), publicKey.ptr, privateKey.ptr, BytesToBuffer(signature)) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapSignedPreKeyRecord(spkr.raw), nil + return wrapSignedPreKeyRecord(spkr), nil } func NewSignedPreKeyRecordFromPrivateKey(id uint32, timestamp time.Time, privateKey *PrivateKey, signature []byte) (*SignedPreKeyRecord, error) { @@ -65,36 +55,26 @@ func NewSignedPreKeyRecordFromPrivateKey(id uint32, timestamp time.Time, private } func DeserializeSignedPreKeyRecord(serialized []byte) (*SignedPreKeyRecord, error) { - var spkr C.SignalMutPointerSignedPreKeyRecord + var spkr *C.SignalSignedPreKeyRecord signalFfiError := C.signal_signed_pre_key_record_deserialize(&spkr, BytesToBuffer(serialized)) - runtime.KeepAlive(serialized) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapSignedPreKeyRecord(spkr.raw), nil -} - -func (spkr *SignedPreKeyRecord) mutPtr() C.SignalMutPointerSignedPreKeyRecord { - return C.SignalMutPointerSignedPreKeyRecord{spkr.ptr} -} - -func (spkr *SignedPreKeyRecord) constPtr() C.SignalConstPointerSignedPreKeyRecord { - return C.SignalConstPointerSignedPreKeyRecord{spkr.ptr} + return wrapSignedPreKeyRecord(spkr), nil } func (spkr *SignedPreKeyRecord) Clone() (*SignedPreKeyRecord, error) { - var cloned C.SignalMutPointerSignedPreKeyRecord - signalFfiError := C.signal_signed_pre_key_record_clone(&cloned, spkr.constPtr()) - runtime.KeepAlive(spkr) + var cloned *C.SignalSignedPreKeyRecord + signalFfiError := C.signal_signed_pre_key_record_clone(&cloned, spkr.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapSignedPreKeyRecord(cloned.raw), nil + return wrapSignedPreKeyRecord(cloned), nil } func (spkr *SignedPreKeyRecord) Destroy() error { spkr.CancelFinalizer() - return wrapError(C.signal_signed_pre_key_record_destroy(spkr.mutPtr())) + return wrapError(C.signal_signed_pre_key_record_destroy(spkr.ptr)) } func (spkr *SignedPreKeyRecord) CancelFinalizer() { @@ -103,8 +83,7 @@ func (spkr *SignedPreKeyRecord) CancelFinalizer() { func (spkr *SignedPreKeyRecord) Serialize() ([]byte, error) { var serialized C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_signed_pre_key_record_serialize(&serialized, spkr.constPtr()) - runtime.KeepAlive(spkr) + signalFfiError := C.signal_signed_pre_key_record_serialize(&serialized, spkr.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } @@ -113,28 +92,25 @@ func (spkr *SignedPreKeyRecord) Serialize() ([]byte, error) { func (spkr *SignedPreKeyRecord) GetSignature() ([]byte, error) { var signature C.SignalOwnedBuffer = C.SignalOwnedBuffer{} - signalFfiError := C.signal_signed_pre_key_record_get_signature(&signature, spkr.constPtr()) - runtime.KeepAlive(spkr) + signalFfiError := C.signal_signed_pre_key_record_get_signature(&signature, spkr.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } return CopySignalOwnedBufferToBytes(signature), nil } -func (spkr *SignedPreKeyRecord) GetID() (uint32, error) { +func (spkr *SignedPreKeyRecord) GetID() (uint, error) { var id C.uint32_t - signalFfiError := C.signal_signed_pre_key_record_get_id(&id, spkr.constPtr()) - runtime.KeepAlive(spkr) + signalFfiError := C.signal_signed_pre_key_record_get_id(&id, spkr.ptr) if signalFfiError != nil { return 0, wrapError(signalFfiError) } - return uint32(id), nil + return uint(id), nil } func (spkr *SignedPreKeyRecord) GetTimestamp() (time.Time, error) { var ts C.uint64_t - signalFfiError := C.signal_signed_pre_key_record_get_timestamp(&ts, spkr.constPtr()) - runtime.KeepAlive(spkr) + signalFfiError := C.signal_signed_pre_key_record_get_timestamp(&ts, spkr.ptr) if signalFfiError != nil { return time.Time{}, wrapError(signalFfiError) } @@ -142,24 +118,19 @@ func (spkr *SignedPreKeyRecord) GetTimestamp() (time.Time, error) { } func (spkr *SignedPreKeyRecord) GetPublicKey() (*PublicKey, error) { - var pub C.SignalMutPointerPublicKey - signalFfiError := C.signal_signed_pre_key_record_get_public_key( - &pub, - spkr.constPtr(), - ) - runtime.KeepAlive(spkr) + var pub *C.SignalPublicKey + signalFfiError := C.signal_signed_pre_key_record_get_public_key(&pub, spkr.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapPublicKey(pub.raw), nil + return wrapPublicKey(pub), nil } func (spkr *SignedPreKeyRecord) GetPrivateKey() (*PrivateKey, error) { - var priv C.SignalMutPointerPrivateKey - signalFfiError := C.signal_signed_pre_key_record_get_private_key(&priv, spkr.constPtr()) - runtime.KeepAlive(spkr) + var priv *C.SignalPrivateKey + signalFfiError := C.signal_signed_pre_key_record_get_private_key(&priv, spkr.ptr) if signalFfiError != nil { return nil, wrapError(signalFfiError) } - return wrapPrivateKey(priv.raw), nil + return wrapPrivateKey(priv), nil } diff --git a/pkg/libsignalgo/signedprekeystore.go b/pkg/libsignalgo/signedprekeystore.go index b1306e2..19bdcd5 100644 --- a/pkg/libsignalgo/signedprekeystore.go +++ b/pkg/libsignalgo/signedprekeystore.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Sumner Evans -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,57 +17,56 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" -extern int signal_load_signed_pre_key_callback(void *store_ctx, SignalMutPointerSignedPreKeyRecord *recordp, uint32_t id); -extern int signal_store_signed_pre_key_callback(void *store_ctx, uint32_t id, SignalMutPointerSignedPreKeyRecord record); -extern void signal_destroy_signed_pre_key_store_callback(void *store_ctx); +typedef const SignalSignedPreKeyRecord const_signed_pre_key_record; + +extern int signal_load_signed_pre_key_callback(void *store_ctx, SignalSignedPreKeyRecord **recordp, uint32_t id, void *ctx); +extern int signal_store_signed_pre_key_callback(void *store_ctx, uint32_t id, const_signed_pre_key_record *record, void *ctx); */ import "C" import ( "context" "unsafe" + + gopointer "github.com/mattn/go-pointer" ) type SignedPreKeyStore interface { - LoadSignedPreKey(ctx context.Context, id uint32) (*SignedPreKeyRecord, error) - StoreSignedPreKey(ctx context.Context, id uint32, signedPreKeyRecord *SignedPreKeyRecord) error + LoadSignedPreKey(id uint32, context context.Context) (*SignedPreKeyRecord, error) + StoreSignedPreKey(id uint32, signedPreKeyRecord *SignedPreKeyRecord, context context.Context) error } //export signal_load_signed_pre_key_callback -func signal_load_signed_pre_key_callback(storeCtx unsafe.Pointer, keyp *C.SignalMutPointerSignedPreKeyRecord, id C.uint32_t) C.int { - return wrapStoreCallback(storeCtx, func(store SignedPreKeyStore, ctx context.Context) error { - key, err := store.LoadSignedPreKey(ctx, uint32(id)) +func signal_load_signed_pre_key_callback(storeCtx unsafe.Pointer, keyp **C.SignalSignedPreKeyRecord, id C.uint32_t, ctxPtr unsafe.Pointer) C.int { + return wrapStoreCallback(storeCtx, ctxPtr, func(store SignedPreKeyStore, ctx context.Context) error { + key, err := store.LoadSignedPreKey(uint32(id), ctx) if err == nil && key != nil { key.CancelFinalizer() - keyp.raw = key.ptr + *keyp = key.ptr } return err }) } //export signal_store_signed_pre_key_callback -func signal_store_signed_pre_key_callback(storeCtx unsafe.Pointer, id C.uint32_t, preKeyRecord C.SignalMutPointerSignedPreKeyRecord) C.int { - return wrapStoreCallback(storeCtx, func(store SignedPreKeyStore, ctx context.Context) error { - record := SignedPreKeyRecord{ptr: preKeyRecord.raw} +func signal_store_signed_pre_key_callback(storeCtx unsafe.Pointer, id C.uint32_t, preKeyRecord *C.const_signed_pre_key_record, ctxPtr unsafe.Pointer) C.int { + return wrapStoreCallback(storeCtx, ctxPtr, func(store SignedPreKeyStore, ctx context.Context) error { + record := SignedPreKeyRecord{ptr: (*C.SignalSignedPreKeyRecord)(unsafe.Pointer(preKeyRecord))} cloned, err := record.Clone() if err != nil { return err } - return store.StoreSignedPreKey(ctx, uint32(id), cloned) + return store.StoreSignedPreKey(uint32(id), cloned, ctx) }) } -//export signal_destroy_signed_pre_key_store_callback -func signal_destroy_signed_pre_key_store_callback(storeCtx unsafe.Pointer) { - // No-op: Go's garbage collector handles cleanup -} - -func (ctx *CallbackContext) wrapSignedPreKeyStore(store SignedPreKeyStore) C.SignalConstPointerFfiSignedPreKeyStoreStruct { - return C.SignalConstPointerFfiSignedPreKeyStoreStruct{&C.SignalSignedPreKeyStore{ - ctx: wrapStore(ctx, store), - load_signed_pre_key: C.SignalFfiSignedPreKeyStoreLoadSignedPreKey(C.signal_load_signed_pre_key_callback), - store_signed_pre_key: C.SignalFfiSignedPreKeyStoreStoreSignedPreKey(C.signal_store_signed_pre_key_callback), - destroy: C.SignalFfiSignedPreKeyStoreDestroy(C.signal_destroy_signed_pre_key_store_callback), - }} +func wrapSignedPreKeyStore(store SignedPreKeyStore) *C.SignalSignedPreKeyStore { + // TODO: This is probably a memory leak + return &C.SignalSignedPreKeyStore{ + ctx: gopointer.Save(store), + load_signed_pre_key: C.SignalLoadSignedPreKey(C.signal_load_signed_pre_key_callback), + store_signed_pre_key: C.SignalStoreSignedPreKey(C.signal_store_signed_pre_key_callback), + } } diff --git a/pkg/libsignalgo/storeutil.go b/pkg/libsignalgo/storeutil.go index 4041c9b..3c2b6e1 100644 --- a/pkg/libsignalgo/storeutil.go +++ b/pkg/libsignalgo/storeutil.go @@ -17,60 +17,40 @@ package libsignalgo /* +#cgo LDFLAGS: -lsignal_ffi -ldl -lm #include "./libsignal-ffi.h" */ import "C" import ( "context" - "errors" "unsafe" gopointer "github.com/mattn/go-pointer" ) -type WrappedStore[T any] struct { - Store T - Ctx *CallbackContext +type CallbackContext struct { + Error error + Ctx context.Context } -type CallbackContext struct { - Error error - Ctx context.Context - Unrefs []unsafe.Pointer +func NewEmptyCallbackContext() *CallbackContext { + return NewCallbackContext(context.TODO()) } func NewCallbackContext(ctx context.Context) *CallbackContext { - if ctx == nil { - panic(errors.New("nil context passed to NewCallbackContext")) - } return &CallbackContext{Ctx: ctx} } -func (ctx *CallbackContext) Unref() { - for _, ptr := range ctx.Unrefs { - gopointer.Unref(ptr) +func wrapStoreCallback[T any](storeCtx, ctxPtr unsafe.Pointer, callback func(store T, ctx context.Context) error) C.int { + store := gopointer.Restore(storeCtx).(T) + ctx := NewEmptyCallbackContext() + if ctxPtr != nil { + if restored := gopointer.Restore(ctxPtr); restored != nil { + ctx = restored.(*CallbackContext) + } } -} - -func wrapStore[T any](ctx *CallbackContext, store T) unsafe.Pointer { - wrappedStore := gopointer.Save(&WrappedStore[T]{Store: store, Ctx: ctx}) - ctx.Unrefs = append(ctx.Unrefs, wrappedStore) - return wrappedStore -} - -func wrapStoreCallbackCustomReturn[T any](storeCtx unsafe.Pointer, callback func(store T, ctx context.Context) (int, error)) C.int { - wrap := gopointer.Restore(storeCtx).(*WrappedStore[T]) - retVal, err := callback(wrap.Store, wrap.Ctx.Ctx) - if err != nil { - wrap.Ctx.Error = err - } - return C.int(retVal) -} - -func wrapStoreCallback[T any](storeCtx unsafe.Pointer, callback func(store T, ctx context.Context) error) C.int { - wrap := gopointer.Restore(storeCtx).(*WrappedStore[T]) - if err := callback(wrap.Store, wrap.Ctx.Ctx); err != nil { - wrap.Ctx.Error = err + if err := callback(store, ctx.Ctx); err != nil { + ctx.Error = err return -1 } return 0 diff --git a/pkg/libsignalgo/update-ffi-docker-inner.sh b/pkg/libsignalgo/update-ffi-docker-inner.sh deleted file mode 100755 index e343887..0000000 --- a/pkg/libsignalgo/update-ffi-docker-inner.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -cd /data -export RUSTFLAGS="-Ctarget-feature=-crt-static" RUSTC_WRAPPER="" -apk add --no-cache git make cmake protobuf-dev musl-dev g++ clang-dev cbindgen -cd libsignal -cargo build -p libsignal-ffi --release -cbindgen --profile release rust/bridge/ffi -o libsignal-ffi.h -cd .. -mv libsignal/target/release/libsignal_ffi.a . -mv libsignal/libsignal-ffi.h . -chown 1000:1000 libsignal_ffi.a libsignal-ffi.h version.go diff --git a/pkg/libsignalgo/update-ffi-docker.sh b/pkg/libsignalgo/update-ffi-docker.sh deleted file mode 100755 index 5fb6dda..0000000 --- a/pkg/libsignalgo/update-ffi-docker.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -docker run --rm -itv $(pwd):/data rust:1-alpine /data/update-ffi-docker-inner.sh - -echo "// Generated by update-ffi.sh; DO NOT EDIT." > version.go -echo >> version.go -echo "package libsignalgo" >> version.go -echo >> version.go -cd libsignal -echo "const Version = \"$(git describe --tags --always)\"" >> ../version.go diff --git a/pkg/libsignalgo/update-ffi.sh b/pkg/libsignalgo/update-ffi.sh index 7561b61..f0e617a 100755 --- a/pkg/libsignalgo/update-ffi.sh +++ b/pkg/libsignalgo/update-ffi.sh @@ -12,19 +12,12 @@ if [ ! -d "$LIBSIGNAL_DIRECTORY" ]; then exit 1 fi -echo "// Generated by update-ffi.sh; DO NOT EDIT." > version.go -echo >> version.go -echo "package libsignalgo" >> version.go -echo >> version.go - # Store the current working directory ORIGINAL_DIR="$(pwd)" # Navigate to libsignal directory cd "$LIBSIGNAL_DIRECTORY" -echo "const Version = \"$(git describe --tags --always)\"" >> ../version.go - # Build libsignal cargo build -p libsignal-ffi --release diff --git a/pkg/libsignalgo/version.go b/pkg/libsignalgo/version.go deleted file mode 100644 index 1f7e94d..0000000 --- a/pkg/libsignalgo/version.go +++ /dev/null @@ -1,5 +0,0 @@ -// Generated by update-ffi.sh; DO NOT EDIT. - -package libsignalgo - -const Version = "v0.93.2" diff --git a/pkg/msgconv/from-signal-backup.go b/pkg/msgconv/from-signal-backup.go deleted file mode 100644 index 978c6a6..0000000 --- a/pkg/msgconv/from-signal-backup.go +++ /dev/null @@ -1,256 +0,0 @@ -// mautrix-signal - A Matrix-Signal puppeting bridge. -// Copyright (C) 2025 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package msgconv - -import ( - "slices" - - "github.com/google/uuid" - "go.mau.fi/util/exslices" - "go.mau.fi/util/ptr" - - signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" - "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf/backuppb" -) - -func boolToInt(b bool) int { - if b { - return 1 - } - return 0 -} - -type AttachmentMap map[uuid.UUID]*backuppb.FilePointer_LocatorInfo - -func BackupToDataMessage(ci *backuppb.ChatItem, attMap AttachmentMap) (*signalpb.DataMessage, []*backuppb.Reaction) { - var dm signalpb.DataMessage - var reactions []*backuppb.Reaction - switch ti := ci.Item.(type) { - case *backuppb.ChatItem_StandardMessage: - reactions = ti.StandardMessage.Reactions - if text := ti.StandardMessage.Text; text != nil { - dm.Body = &text.Body - dm.BodyRanges = slices.DeleteFunc(exslices.CastFunc(text.BodyRanges, backupToSignalBodyRange), deleteNil) - } - dm.Attachments = make([]*signalpb.AttachmentPointer, 0, len(ti.StandardMessage.Attachments)+boolToInt(ti.StandardMessage.LongText != nil)) - if ti.StandardMessage.LongText != nil { - randomUUID := uuid.New() - dm.Attachments = append( - dm.Attachments, - backupToSignalAttachment(ti.StandardMessage.LongText, 0, randomUUID, attMap), - ) - } - for _, att := range ti.StandardMessage.Attachments { - var clientUUID uuid.UUID - if len(att.ClientUuid) == 16 { - clientUUID = uuid.UUID(att.ClientUuid) - } else { - clientUUID = uuid.New() - } - dm.Attachments = append( - dm.Attachments, - backupToSignalAttachment(att.Pointer, att.Flag, clientUUID, attMap), - ) - } - dm.Preview = exslices.CastFunc(ti.StandardMessage.LinkPreview, func(from *backuppb.LinkPreview) *signalpb.Preview { - return backupToSignalLinkPreview(from, attMap) - }) - case *backuppb.ChatItem_ContactMessage: - reactions = ti.ContactMessage.Reactions - dm.Contact = []*signalpb.DataMessage_Contact{backupToSignalContact(ti.ContactMessage.Contact, attMap)} - case *backuppb.ChatItem_StickerMessage: - reactions = ti.StickerMessage.Reactions - dm.Sticker = &signalpb.DataMessage_Sticker{ - PackId: ti.StickerMessage.Sticker.PackId, - PackKey: ti.StickerMessage.Sticker.PackKey, - StickerId: &ti.StickerMessage.Sticker.StickerId, - Emoji: ti.StickerMessage.Sticker.Emoji, - Data: backupToSignalAttachment(ti.StickerMessage.Sticker.Data, 0, uuid.New(), attMap), - } - case *backuppb.ChatItem_Poll: - dm.PollCreate = &signalpb.DataMessage_PollCreate{ - Question: &ti.Poll.Question, - AllowMultiple: &ti.Poll.AllowMultiple, - Options: exslices.CastFunc(ti.Poll.Options, func(from *backuppb.Poll_PollOption) string { - return from.Option - }), - } - // TODO handle votes - // TODO handle hasEnded somehow? - case *backuppb.ChatItem_RemoteDeletedMessage: - // TODO handle some other way? (also disappeared view-once messages) - return nil, nil - case *backuppb.ChatItem_PaymentNotification: - dm.Payment = &signalpb.DataMessage_Payment{ - Item: &signalpb.DataMessage_Payment_Notification_{ - Notification: &signalpb.DataMessage_Payment_Notification{ - Transaction: nil, - Note: ti.PaymentNotification.Note, - }, - }, - } - case *backuppb.ChatItem_GiftBadge: - dm.GiftBadge = &signalpb.DataMessage_GiftBadge{ - ReceiptCredentialPresentation: ti.GiftBadge.ReceiptCredentialPresentation, - } - case *backuppb.ChatItem_ViewOnceMessage: - reactions = ti.ViewOnceMessage.Reactions - if ti.ViewOnceMessage.Attachment == nil { - // TODO handle some other way? - return nil, reactions - } - dm.IsViewOnce = ptr.Ptr(true) - var clientUUID uuid.UUID - if len(ti.ViewOnceMessage.Attachment.ClientUuid) == 16 { - clientUUID = uuid.UUID(ti.ViewOnceMessage.Attachment.ClientUuid) - } else { - clientUUID = uuid.New() - } - dm.Attachments = []*signalpb.AttachmentPointer{backupToSignalAttachment( - ti.ViewOnceMessage.Attachment.Pointer, - ti.ViewOnceMessage.Attachment.Flag, - clientUUID, - attMap, - )} - } - return &dm, reactions -} - -func backupToSignalContact(from *backuppb.ContactAttachment, attMap AttachmentMap) *signalpb.DataMessage_Contact { - var contact signalpb.DataMessage_Contact - if from.Name != nil { - contact.Name = &signalpb.DataMessage_Contact_Name{ - GivenName: &from.Name.GivenName, - FamilyName: &from.Name.FamilyName, - Prefix: &from.Name.Prefix, - Suffix: &from.Name.Suffix, - MiddleName: &from.Name.MiddleName, - Nickname: &from.Name.Nickname, - } - } - contact.Number = exslices.CastFunc(from.Number, func(from *backuppb.ContactAttachment_Phone) *signalpb.DataMessage_Contact_Phone { - return &signalpb.DataMessage_Contact_Phone{ - Value: &from.Value, - Type: ptr.NonZero(signalpb.DataMessage_Contact_Phone_Type(from.Type)), - Label: &from.Label, - } - }) - contact.Email = exslices.CastFunc(from.Email, func(from *backuppb.ContactAttachment_Email) *signalpb.DataMessage_Contact_Email { - return &signalpb.DataMessage_Contact_Email{ - Value: &from.Value, - Type: ptr.NonZero(signalpb.DataMessage_Contact_Email_Type(from.Type)), - Label: &from.Label, - } - }) - contact.Address = exslices.CastFunc(from.Address, func(from *backuppb.ContactAttachment_PostalAddress) *signalpb.DataMessage_Contact_PostalAddress { - return &signalpb.DataMessage_Contact_PostalAddress{ - Type: ptr.NonZero(signalpb.DataMessage_Contact_PostalAddress_Type(from.Type)), - Label: &from.Label, - Street: &from.Street, - Pobox: &from.Pobox, - Neighborhood: &from.Neighborhood, - City: &from.City, - Region: &from.Region, - Postcode: &from.Postcode, - Country: &from.Country, - } - }) - if from.Avatar != nil { - contact.Avatar = &signalpb.DataMessage_Contact_Avatar{ - Avatar: backupToSignalAttachment(from.Avatar, 0, uuid.New(), attMap), - } - } - contact.Organization = ptr.NonZero(from.Organization) - return &contact -} - -func backupToSignalLinkPreview(from *backuppb.LinkPreview, attMap AttachmentMap) *signalpb.Preview { - var ap *signalpb.AttachmentPointer - if from.Image != nil { - ap = backupToSignalAttachment(from.Image, 0, uuid.New(), attMap) - } - return &signalpb.Preview{ - Url: &from.Url, - Title: from.Title, - Image: ap, - Description: from.Description, - Date: from.Date, - } -} - -func backupToSignalAttachment( - fp *backuppb.FilePointer, - flag backuppb.MessageAttachment_Flag, - clientUUID uuid.UUID, - atts AttachmentMap, -) *signalpb.AttachmentPointer { - sig := &signalpb.AttachmentPointer{ - //IncrementalMacChunkSize: fp.IncrementalMacChunkSize, - ContentType: fp.ContentType, - IncrementalMac: fp.IncrementalMac, - FileName: fp.FileName, - Flags: ptr.NonZero(uint32(backupToSignalAttachmentFlag(flag))), - Width: fp.Width, - Height: fp.Height, - Caption: nil, // is this field deprecated or something? - BlurHash: fp.BlurHash, - ClientUuid: clientUUID[:], - } - if fp.LocatorInfo != nil { - if fp.LocatorInfo.TransitCdnKey != nil { - sig.AttachmentIdentifier = &signalpb.AttachmentPointer_CdnKey{CdnKey: *fp.LocatorInfo.TransitCdnKey} - sig.Size = &fp.LocatorInfo.Size - sig.Digest = fp.LocatorInfo.GetEncryptedDigest() // Note: may be nil if plaintextHash is set instead - sig.CdnNumber = fp.LocatorInfo.TransitCdnNumber - } - sig.Key = fp.LocatorInfo.Key - atts[clientUUID] = fp.LocatorInfo - } - return sig -} - -func backupToSignalAttachmentFlag(flag backuppb.MessageAttachment_Flag) signalpb.AttachmentPointer_Flags { - switch flag { - case backuppb.MessageAttachment_VOICE_MESSAGE: - return signalpb.AttachmentPointer_VOICE_MESSAGE - case backuppb.MessageAttachment_BORDERLESS: - return signalpb.AttachmentPointer_BORDERLESS - case backuppb.MessageAttachment_GIF: - return signalpb.AttachmentPointer_GIF - case backuppb.MessageAttachment_NONE: - fallthrough - default: - return 0 - } -} - -func deleteNil(bodyRange *signalpb.BodyRange) bool { - return bodyRange == nil -} - -func backupToSignalBodyRange(from *backuppb.BodyRange) *signalpb.BodyRange { - var out signalpb.BodyRange - out.Start = &from.Start - out.Length = &from.Length - switch av := from.AssociatedValue.(type) { - case *backuppb.BodyRange_MentionAci: - out.AssociatedValue = &signalpb.BodyRange_MentionAciBinary{MentionAciBinary: av.MentionAci} - case *backuppb.BodyRange_Style_: - out.AssociatedValue = &signalpb.BodyRange_Style_{Style: signalpb.BodyRange_Style(av.Style)} - } - return &out -} diff --git a/pkg/msgconv/from-signal.go b/pkg/msgconv/from-signal.go deleted file mode 100644 index defbe44..0000000 --- a/pkg/msgconv/from-signal.go +++ /dev/null @@ -1,785 +0,0 @@ -// mautrix-signal - A Matrix-Signal puppeting bridge. -// Copyright (C) 2024 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package msgconv - -import ( - "bytes" - "context" - "encoding/base64" - "errors" - "fmt" - "io" - "net/http" - "os" - "strconv" - "strings" - "time" - - "github.com/emersion/go-vcard" - "github.com/google/uuid" - "github.com/rs/zerolog" - "go.mau.fi/util/exmime" - "go.mau.fi/util/ffmpeg" - "maunium.net/go/mautrix/bridgev2" - "maunium.net/go/mautrix/bridgev2/database" - "maunium.net/go/mautrix/bridgev2/networkid" - "maunium.net/go/mautrix/event" - - "go.mau.fi/mautrix-signal/pkg/msgconv/signalfmt" - "go.mau.fi/mautrix-signal/pkg/signalid" - "go.mau.fi/mautrix-signal/pkg/signalmeow" - signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" -) - -var ( - ErrAttachmentNotInBackup = errors.New("attachment not found in backup") - ErrBackupNotSupported = errors.New("downloading attachments from server-side backup is not yet supported") -) - -func calculateLength(dm *signalpb.DataMessage) int { - if dm.GetFlags()&uint32(signalpb.DataMessage_EXPIRATION_TIMER_UPDATE) != 0 { - return 1 - } - if dm.Sticker != nil || dm.PollVote != nil || dm.PollCreate != nil || dm.PollTerminate != nil { - return 1 - } - length := len(dm.Attachments) + len(dm.Contact) - if dm.Body != nil { - length++ - } - if dm.Payment != nil { - length++ - } - if dm.GiftBadge != nil { - length++ - } - if length == 0 && dm.GetRequiredProtocolVersion() > uint32(signalpb.DataMessage_CURRENT) { - length = 1 - } - return length -} - -func CanConvertSignal(dm *signalpb.DataMessage) bool { - return calculateLength(dm) > 0 -} - -const ViewOnceDisappearTimer = 5 * time.Minute -const matrixTextMaxLength = 30000 // approximate value to avoid hitting 64 KiB PDU size limit with HTML duplication - -func (mc *MessageConverter) ToMatrix( - ctx context.Context, - client *signalmeow.Client, - portal *bridgev2.Portal, - sender uuid.UUID, - intent bridgev2.MatrixAPI, - dm *signalpb.DataMessage, - attMap AttachmentMap, -) *bridgev2.ConvertedMessage { - ctx = context.WithValue(ctx, contextKeyClient, client) - ctx = context.WithValue(ctx, contextKeyPortal, portal) - ctx = context.WithValue(ctx, contextKeyIntent, intent) - cm := &bridgev2.ConvertedMessage{ - ReplyTo: nil, - ThreadRoot: nil, - Parts: make([]*bridgev2.ConvertedMessagePart, 0, calculateLength(dm)), - } - if dm.GetFlags()&uint32(signalpb.DataMessage_EXPIRATION_TIMER_UPDATE) != 0 { - cm.Parts = append(cm.Parts, mc.ConvertDisappearingTimerChangeToMatrix( - ctx, dm.GetExpireTimer(), dm.ExpireTimerVersion, time.UnixMilli(int64(dm.GetTimestamp())), attMap != nil, - )) - // Don't allow any other parts in a disappearing timer change message - return cm - } - if dm.GetExpireTimer() > 0 { - cm.Disappear.Type = event.DisappearingTypeAfterRead - cm.Disappear.Timer = time.Duration(dm.GetExpireTimer()) * time.Second - } - if dm.Sticker != nil { - cm.Parts = append(cm.Parts, mc.convertStickerToMatrix(ctx, dm.Sticker, attMap)) - // Don't allow any other parts in a sticker message - return cm - } - if dm.PollVote != nil { - cm.Parts = append(cm.Parts, mc.convertPollVoteToMatrix(ctx, dm.PollVote)) - return cm - } - if dm.PollCreate != nil { - cm.Parts = append(cm.Parts, mc.convertPollCreateToMatrix(dm.PollCreate)) - return cm - } - if dm.PollTerminate != nil { - cm.Parts = append(cm.Parts, mc.convertPollTerminateToMatrix(ctx, sender, dm.PollTerminate)) - return cm - } - for i, att := range dm.GetAttachments() { - if att.GetContentType() != "text/x-signal-plain" || att.GetSize() > matrixTextMaxLength { - cm.Parts = append(cm.Parts, mc.convertAttachmentToMatrix(ctx, i, att, attMap)) - } else { - longBody, err := mc.downloadSignalLongText(ctx, att, attMap) - if err == nil { - dm.Body = longBody - } else { - zerolog.Ctx(ctx).Err(err).Msg("Failed to download Signal long text") - } - } - } - for _, contact := range dm.GetContact() { - cm.Parts = append(cm.Parts, mc.convertContactToMatrix(ctx, contact, attMap)) - } - if dm.Payment != nil { - cm.Parts = append(cm.Parts, mc.convertPaymentToMatrix(ctx, dm.Payment)) - } - if dm.GiftBadge != nil { - cm.Parts = append(cm.Parts, mc.convertGiftBadgeToMatrix(ctx, dm.GiftBadge)) - } - if dm.Body != nil { - cm.Parts = append(cm.Parts, mc.convertTextToMatrix(ctx, dm, attMap)) - } - if len(cm.Parts) == 0 && dm.GetRequiredProtocolVersion() > uint32(signalpb.DataMessage_CURRENT) { - cm.Parts = append(cm.Parts, &bridgev2.ConvertedMessagePart{ - Type: event.EventMessage, - Content: &event.MessageEventContent{ - MsgType: event.MsgNotice, - Body: "The bridge does not support this message type yet.", - }, - }) - } - if dm.GetIsViewOnce() && mc.DisappearViewOnce && (cm.Disappear.Timer == 0 || cm.Disappear.Timer > ViewOnceDisappearTimer) { - cm.Disappear.Type = event.DisappearingTypeAfterRead - cm.Disappear.Timer = ViewOnceDisappearTimer - cm.Parts = append(cm.Parts, &bridgev2.ConvertedMessagePart{ - Type: event.EventMessage, - Content: &event.MessageEventContent{ - MsgType: event.MsgText, - Body: "This is a view-once message. It will disappear in 5 minutes.", - }, - }) - } - cm.MergeCaption() - for i, part := range cm.Parts { - part.ID = signalid.MakeMessagePartID(i) - part.DBMetadata = &signalid.MessageMetadata{ - ContainsAttachments: len(dm.GetAttachments()) > 0, - } - } - if dm.Quote != nil { - authorACI, err := signalmeow.ParseStringOrBinaryUUID(dm.Quote.GetAuthorAci(), dm.Quote.GetAuthorAciBinary()) - if err != nil { - zerolog.Ctx(ctx).Err(err). - Str("author_aci", dm.Quote.GetAuthorAci()). - Hex("author_aci_binary", dm.Quote.GetAuthorAciBinary()). - Msg("Failed to parse quote author ACI") - } else { - cm.ReplyTo = &networkid.MessageOptionalPartID{ - MessageID: signalid.MakeMessageID(authorACI, dm.Quote.GetId()), - } - } - } - return cm -} - -func (mc *MessageConverter) ConvertDisappearingTimerChangeToMatrix( - ctx context.Context, timer uint32, timerVersion *uint32, ts time.Time, isBackfill bool, -) *bridgev2.ConvertedMessagePart { - portal := getPortal(ctx) - setting := database.DisappearingSetting{ - Timer: time.Duration(timer) * time.Second, - Type: event.DisappearingTypeAfterRead, - } - if timer == 0 { - setting.Type = "" - } - part := &bridgev2.ConvertedMessagePart{ - Type: event.EventMessage, - Content: bridgev2.DisappearingMessageNotice(time.Duration(timer)*time.Second, false), - Extra: map[string]any{ - "com.beeper.action_message": map[string]any{ - "type": "disappearing_timer", - "timer": setting.Timer.Milliseconds(), - "timer_type": setting.Type, - "implicit": false, - "backfill": isBackfill, - }, - }, - DontBridge: setting == portal.Disappear, - } - if isBackfill { - return part - } - portalMeta := portal.Metadata.(*signalid.PortalMetadata) - if timerVersion != nil && portalMeta.ExpirationTimerVersion > *timerVersion { - zerolog.Ctx(ctx).Warn(). - Uint32("current_version", portalMeta.ExpirationTimerVersion). - Uint32("new_version", *timerVersion). - Msg("Ignoring outdated disappearing timer change") - part.Content.Body += " (change ignored)" - return part - } - if timerVersion != nil { - portalMeta.ExpirationTimerVersion = *timerVersion - } else { - portalMeta.ExpirationTimerVersion = 1 - } - portal.UpdateDisappearingSetting(ctx, setting, bridgev2.UpdateDisappearingSettingOpts{ - Sender: getIntent(ctx), - Timestamp: ts, - Save: true, - }) - return part -} - -func (mc *MessageConverter) convertTextToMatrix(ctx context.Context, dm *signalpb.DataMessage, attMap AttachmentMap) *bridgev2.ConvertedMessagePart { - content := signalfmt.Parse(ctx, dm.GetBody(), dm.GetBodyRanges(), mc.SignalFmtParams) - extra := map[string]any{} - if len(dm.Preview) > 0 { - content.BeeperLinkPreviews = mc.convertURLPreviewsToBeeper(ctx, dm.Preview, attMap) - } - return &bridgev2.ConvertedMessagePart{ - Type: event.EventMessage, - Content: content, - Extra: extra, - } -} - -func (mc *MessageConverter) convertPaymentToMatrix(_ context.Context, payment *signalpb.DataMessage_Payment) *bridgev2.ConvertedMessagePart { - return &bridgev2.ConvertedMessagePart{ - Type: event.EventMessage, - Content: &event.MessageEventContent{ - MsgType: event.MsgNotice, - Body: "Payments are not yet supported", - }, - Extra: map[string]any{ - "fi.mau.signal.payment": payment, - }, - } -} - -func (mc *MessageConverter) convertGiftBadgeToMatrix(_ context.Context, giftBadge *signalpb.DataMessage_GiftBadge) *bridgev2.ConvertedMessagePart { - return &bridgev2.ConvertedMessagePart{ - Type: event.EventMessage, - Content: &event.MessageEventContent{ - MsgType: event.MsgNotice, - Body: "Gift badges are not yet supported", - }, - Extra: map[string]any{ - "fi.mau.signal.gift_badge": giftBadge, - }, - } -} - -func (mc *MessageConverter) convertContactToVCard(ctx context.Context, contact *signalpb.DataMessage_Contact, attMap AttachmentMap) vcard.Card { - card := make(vcard.Card) - card.SetValue(vcard.FieldVersion, "4.0") - name := contact.GetName() - if name.GetFamilyName() != "" || name.GetGivenName() != "" { - card.SetName(&vcard.Name{ - FamilyName: name.GetFamilyName(), - GivenName: name.GetGivenName(), - AdditionalName: name.GetMiddleName(), - HonorificPrefix: name.GetPrefix(), - HonorificSuffix: name.GetSuffix(), - }) - } - if name.GetNickname() != "" { - card.SetValue(vcard.FieldNickname, name.GetNickname()) - } - if contact.GetOrganization() != "" { - card.SetValue(vcard.FieldOrganization, contact.GetOrganization()) - } - for _, addr := range contact.GetAddress() { - field := vcard.Field{ - Value: strings.Join([]string{ - addr.GetPobox(), - "", // extended address, - addr.GetStreet(), - addr.GetCity(), - addr.GetRegion(), - addr.GetPostcode(), - addr.GetCountry(), - // TODO put neighborhood somewhere? - }, ";"), - Params: make(vcard.Params), - } - if addr.GetLabel() != "" { - field.Params.Set("LABEL", addr.GetLabel()) - } - field.Params.Set(vcard.ParamType, strings.ToLower(addr.GetType().String())) - card.Add(vcard.FieldAddress, &field) - } - for _, email := range contact.GetEmail() { - field := vcard.Field{ - Value: email.GetValue(), - Params: make(vcard.Params), - } - field.Params.Set(vcard.ParamType, strings.ToLower(email.GetType().String())) - if email.GetLabel() != "" { - field.Params.Set("LABEL", email.GetLabel()) - } - card.Add(vcard.FieldEmail, &field) - } - for _, phone := range contact.GetNumber() { - field := vcard.Field{ - Value: phone.GetValue(), - Params: make(vcard.Params), - } - field.Params.Set(vcard.ParamType, strings.ToLower(phone.GetType().String())) - if phone.GetLabel() != "" { - field.Params.Set("LABEL", phone.GetLabel()) - } - card.Add(vcard.FieldTelephone, &field) - } - if contact.GetAvatar().GetAvatar() != nil { - avatarData, err := mc.downloadAttachment(ctx, contact.GetAvatar().GetAvatar(), attMap, nil) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to download contact avatar") - } else { - mimeType := contact.GetAvatar().GetAvatar().GetContentType() - if mimeType == "" { - mimeType = http.DetectContentType(avatarData) - } - card.SetValue(vcard.FieldPhoto, fmt.Sprintf("data:%s;base64,%s", mimeType, base64.StdEncoding.EncodeToString(avatarData))) - } - } - return card -} - -func (mc *MessageConverter) convertContactToMatrix(ctx context.Context, contact *signalpb.DataMessage_Contact, attMap AttachmentMap) *bridgev2.ConvertedMessagePart { - card := mc.convertContactToVCard(ctx, contact, attMap) - contact.Avatar = nil - extraData := map[string]any{ - "fi.mau.signal.contact": contact, - } - var buf bytes.Buffer - err := vcard.NewEncoder(&buf).Encode(card) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to encode vCard") - return &bridgev2.ConvertedMessagePart{ - Type: event.EventMessage, - Content: &event.MessageEventContent{ - MsgType: event.MsgNotice, - Body: "Failed to encode vCard", - }, - Extra: extraData, - } - } - data := buf.Bytes() - displayName := contact.GetName().GetNickname() - if displayName == "" { - displayName = contact.GetName().GetGivenName() - if contact.GetName().GetFamilyName() != "" { - if displayName != "" { - displayName += " " - } - displayName += contact.GetName().GetFamilyName() - } - } - if displayName == "" { - displayName = "contact" - } - content := &event.MessageEventContent{ - MsgType: event.MsgFile, - Body: displayName + ".vcf", - Info: &event.FileInfo{ - MimeType: "text/vcf", - Size: len(data), - }, - } - content.URL, content.File, err = getIntent(ctx).UploadMedia(ctx, getPortal(ctx).MXID, data, content.Info.MimeType, content.Body) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to upload vCard") - return &bridgev2.ConvertedMessagePart{ - Type: event.EventMessage, - Content: &event.MessageEventContent{ - MsgType: event.MsgNotice, - Body: "Failed to upload vCard", - }, - Extra: extraData, - } - } - return &bridgev2.ConvertedMessagePart{ - Type: event.EventMessage, - Content: content, - Extra: extraData, - } -} - -func (mc *MessageConverter) convertAttachmentToMatrix(ctx context.Context, index int, att *signalpb.AttachmentPointer, attMap AttachmentMap) *bridgev2.ConvertedMessagePart { - part, err := mc.reuploadAttachment(ctx, att, attMap) - if err != nil { - if (errors.Is(err, signalmeow.ErrAttachmentNotFound) || errors.Is(err, ErrAttachmentNotInBackup)) && attMap != nil { - return &bridgev2.ConvertedMessagePart{ - Type: event.EventMessage, - Content: &event.MessageEventContent{ - MsgType: event.MsgNotice, - Body: fmt.Sprintf("Attachment no longer available %s", att.GetFileName()), - }, - } - } else if errors.Is(err, ErrBackupNotSupported) { - return &bridgev2.ConvertedMessagePart{ - Type: event.EventMessage, - Content: &event.MessageEventContent{ - MsgType: event.MsgNotice, - Body: "Downloading attachments from backup is not yet supported", - }, - } - } - zerolog.Ctx(ctx).Err(err).Int("attachment_index", index).Msg("Failed to handle attachment") - return &bridgev2.ConvertedMessagePart{ - Type: event.EventMessage, - Content: &event.MessageEventContent{ - MsgType: event.MsgNotice, - Body: fmt.Sprintf("Failed to handle attachment %s: %v", att.GetFileName(), err), - }, - } - } - return part -} - -func (mc *MessageConverter) convertStickerToMatrix(ctx context.Context, sticker *signalpb.DataMessage_Sticker, attMap AttachmentMap) *bridgev2.ConvertedMessagePart { - converted, err := mc.reuploadAttachment(ctx, sticker.GetData(), attMap) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to handle sticker") - return &bridgev2.ConvertedMessagePart{ - Type: event.EventMessage, - Content: &event.MessageEventContent{ - MsgType: event.MsgNotice, - Body: fmt.Sprintf("Failed to handle sticker: %v", err), - }, - } - } - // Signal stickers are 512x512, so tell Matrix clients to render them as 200x200 to match Signal - // https://github.com/signalapp/Signal-Desktop/blob/v7.77.0-beta.1/ts/components/conversation/Message.dom.tsx#L135 - if converted.Content.Info.Width == 512 && converted.Content.Info.Height == 512 { - converted.Content.Info.Width = 200 - converted.Content.Info.Height = 200 - } - converted.Content.Body = sticker.GetEmoji() - if len(sticker.GetPackId()) == PackIDLength && len(sticker.GetPackKey()) == PackKeyLength && !bytes.Equal(sticker.GetPackId(), zeroPackID) { - converted.Content.Info.BridgedSticker = &event.BridgedSticker{ - Network: StickerSourceID, - ID: strconv.FormatUint(uint64(sticker.GetStickerId()), 10), - Emoji: sticker.GetEmoji(), - PackURL: fmt.Sprintf(PackURLFormat, sticker.GetPackId(), sticker.GetPackKey()), - } - } - converted.Type = event.EventSticker - converted.Content.MsgType = "" - return converted -} - -func (mc *MessageConverter) downloadSignalLongText(ctx context.Context, att *signalpb.AttachmentPointer, attMap AttachmentMap) (*string, error) { - data, err := mc.downloadAttachment(ctx, att, attMap, nil) - if err != nil { - return nil, err - } - longBody := string(data) - return &longBody, nil -} - -func checkIfAttachmentExists(att *signalpb.AttachmentPointer, attMap AttachmentMap) error { - if att.AttachmentIdentifier == nil { - if len(att.GetClientUuid()) != 16 { - return fmt.Errorf("no attachment identifier found") - } - target, ok := attMap[uuid.UUID(att.GetClientUuid())] - if !ok { - return fmt.Errorf("no attachment identifier and attachment not found in map") - } else if target == nil || target.MediaTierCdnNumber == nil { - return ErrAttachmentNotInBackup - } else { - // TODO add support for downloading attachments from backup - return ErrBackupNotSupported - } - } - return nil -} - -func (mc *MessageConverter) downloadAttachment( - ctx context.Context, att *signalpb.AttachmentPointer, attMap AttachmentMap, into *os.File, -) ([]byte, error) { - if err := checkIfAttachmentExists(att, attMap); err != nil { - return nil, err - } - var plaintextHash []byte - if len(att.GetClientUuid()) == 16 { - target, ok := attMap[uuid.UUID(att.GetClientUuid())] - if ok { - plaintextHash = target.GetPlaintextHash() - } - } - return signalmeow.DownloadAttachmentWithPointer(ctx, att, plaintextHash, into) -} - -func (mc *MessageConverter) reuploadAttachment(ctx context.Context, att *signalpb.AttachmentPointer, attMap AttachmentMap) (*bridgev2.ConvertedMessagePart, error) { - content := &event.MessageEventContent{ - Body: att.GetFileName(), - Info: &event.FileInfo{ - MimeType: att.GetContentType(), - Width: int(att.GetWidth()), - Height: int(att.GetHeight()), - Size: int(att.GetSize()), - }, - } - if err := checkIfAttachmentExists(att, attMap); err != nil { - return nil, err - } else if mc.DirectMedia { - digest := att.Digest - var plaintextDigest bool - if digest == nil && len(att.GetClientUuid()) == 16 { - locatorInfo, ok := attMap[uuid.UUID(att.GetClientUuid())] - if ok { - digest = locatorInfo.GetPlaintextHash() - plaintextDigest = true - } - } - mediaID, err := signalid.DirectMediaAttachment{ - CDNID: att.GetCdnId(), - CDNKey: att.GetCdnKey(), - CDNNumber: att.GetCdnNumber(), - Key: att.Key, - Digest: digest, - PlaintextDigest: plaintextDigest, - Size: att.GetSize(), - }.AsMediaID() - if err != nil { - return nil, err - } - content.URL, err = mc.Bridge.Matrix.GenerateContentURI(ctx, mediaID) - } else { - err = mc.actuallyReuploadAttachment(ctx, content, att, attMap) - if err != nil { - return nil, err - } - } - if att.GetBlurHash() != "" { - content.Info.Blurhash = att.GetBlurHash() - content.Info.AnoaBlurhash = att.GetBlurHash() - } - switch strings.Split(content.Info.MimeType, "/")[0] { - case "image": - content.MsgType = event.MsgImage - case "video": - content.MsgType = event.MsgVideo - case "audio": - content.MsgType = event.MsgAudio - default: - content.MsgType = event.MsgFile - } - var extra map[string]any - if att.GetFlags()&uint32(signalpb.AttachmentPointer_GIF) != 0 { - content.Info.MauGIF = true - extra = map[string]any{ - "info": map[string]any{ - "fi.mau.loop": true, - "fi.mau.autoplay": true, - "fi.mau.hide_controls": true, - "fi.mau.no_audio": true, - }, - } - } - if content.Body == "" { - content.Body = strings.TrimPrefix(string(content.MsgType), "m.") + exmime.ExtensionFromMimetype(content.Info.MimeType) - } - return &bridgev2.ConvertedMessagePart{ - Type: event.EventMessage, - Content: content, - Extra: extra, - }, nil -} - -func (mc *MessageConverter) actuallyReuploadAttachment( - ctx context.Context, - content *event.MessageEventContent, - att *signalpb.AttachmentPointer, - attMap AttachmentMap, -) (err error) { - convertVoice := att.GetFlags()&uint32(signalpb.AttachmentPointer_VOICE_MESSAGE) != 0 && ffmpeg.Supported() - requireFile := convertVoice - content.URL, content.File, err = getIntent(ctx).UploadMediaStream(ctx, getPortal(ctx).MXID, int64(att.GetSize()), requireFile, func(file io.Writer) (*bridgev2.FileStreamResult, error) { - osFile, ok := file.(*os.File) - inMemData, err := mc.downloadAttachment(ctx, att, attMap, osFile) - if err != nil { - return nil, err - } else if !ok { - if content.Info.MimeType == "" { - content.Info.MimeType = http.DetectContentType(inMemData) - } - _, err = file.Write(inMemData) - return &bridgev2.FileStreamResult{ - FileName: content.Body, - MimeType: content.Info.MimeType, - }, err - } - if content.Info.MimeType == "" { - header := make([]byte, 512) - _, err = osFile.ReadAt(header, 0) - if err != nil { - return nil, fmt.Errorf("failed to read file header for MIME type detection: %w", err) - } else { - content.Info.MimeType = http.DetectContentType(header) - } - } - var replFile string - if att.GetFlags()&uint32(signalpb.AttachmentPointer_VOICE_MESSAGE) != 0 && ffmpeg.Supported() { - replFile, err = ffmpeg.ConvertPath(ctx, osFile.Name(), ".ogg", []string{}, []string{"-c:a", "libopus"}, true) - if err != nil { - return nil, fmt.Errorf("failed to convert audio to ogg/opus: %w", err) - } - if content.Body == "" { - content.Body = "Voice message.ogg" - } else { - content.Body += ".ogg" - } - content.Info.MimeType = "audio/ogg" - content.MSC3245Voice = &event.MSC3245Voice{} - // TODO include duration here (and in info) if there's some easy way to extract it with ffmpeg - //content.MSC1767Audio = &event.MSC1767Audio{} - } - return &bridgev2.FileStreamResult{ - ReplacementFile: replFile, - FileName: content.Body, - MimeType: content.Info.MimeType, - }, nil - }) - return -} - -func (mc *MessageConverter) convertPollCreateToMatrix(create *signalpb.DataMessage_PollCreate) *bridgev2.ConvertedMessagePart { - evtType := event.EventMessage - if mc.ExtEvPolls { - evtType = event.EventUnstablePollStart - } - maxChoices := 1 - if create.GetAllowMultiple() { - maxChoices = len(create.GetOptions()) - } - msc3381Answers := make([]map[string]any, len(create.GetOptions())) - optionsListText := make([]string, len(create.GetOptions())) - optionsListHTML := make([]string, len(create.GetOptions())) - for i, option := range create.GetOptions() { - msc3381Answers[i] = map[string]any{ - "id": strconv.Itoa(i), - "org.matrix.msc1767.text": option, - } - optionsListText[i] = fmt.Sprintf("%d. %s\n", i+1, option) - optionsListHTML[i] = fmt.Sprintf("
  • %s
  • ", event.TextToHTML(option)) - } - body := fmt.Sprintf("%s\n\n%s\n\n(This message is a poll. Please open Signal to vote.)", create.GetQuestion(), strings.Join(optionsListText, "\n")) - formattedBody := fmt.Sprintf("

    %s

      %s

    (This message is a poll. Please open Signal to vote.)

    ", event.TextToHTML(create.GetQuestion()), strings.Join(optionsListHTML, "")) - return &bridgev2.ConvertedMessagePart{ - Type: evtType, - Content: &event.MessageEventContent{ - MsgType: event.MsgText, - Body: body, - Format: event.FormatHTML, - FormattedBody: formattedBody, - }, - Extra: map[string]any{ - "fi.mau.signal.poll": map[string]any{ - "question": create.GetQuestion(), - "allow_multiple": create.GetAllowMultiple(), - "options": create.GetOptions(), - }, - "org.matrix.msc1767.message": []map[string]any{ - {"mimetype": "text/html", "body": formattedBody}, - {"mimetype": "text/plain", "body": body}, - }, - "org.matrix.msc3381.poll.start": map[string]any{ - "kind": "org.matrix.msc3381.poll.disclosed", - "max_selections": maxChoices, - "question": map[string]any{ - "org.matrix.msc1767.text": create.GetQuestion(), - }, - "answers": msc3381Answers, - }, - }, - DBMetadata: nil, - DontBridge: false, - } -} - -func (mc *MessageConverter) convertPollTerminateToMatrix(ctx context.Context, senderACI uuid.UUID, terminate *signalpb.DataMessage_PollTerminate) *bridgev2.ConvertedMessagePart { - pollMessageID := signalid.MakeMessageID(senderACI, terminate.GetTargetSentTimestamp()) - pollMessage, err := mc.Bridge.DB.Message.GetPartByID(ctx, getPortal(ctx).Receiver, pollMessageID, "") - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to get poll terminate target message") - return &bridgev2.ConvertedMessagePart{ - Type: event.EventUnstablePollEnd, - Content: &event.MessageEventContent{}, - DontBridge: true, - } - } - return &bridgev2.ConvertedMessagePart{ - Type: event.EventUnstablePollEnd, - Content: &event.MessageEventContent{ - RelatesTo: &event.RelatesTo{ - Type: event.RelReference, - EventID: pollMessage.MXID, - }, - }, - Extra: map[string]any{ - "org.matrix.msc3381.poll.end": map[string]any{}, - }, - } -} - -var invalidPollVote = &bridgev2.ConvertedMessagePart{ - Type: event.EventUnstablePollResponse, - Content: &event.MessageEventContent{}, - DontBridge: true, -} - -func (mc *MessageConverter) convertPollVoteToMatrix(ctx context.Context, vote *signalpb.DataMessage_PollVote) *bridgev2.ConvertedMessagePart { - if len(vote.GetTargetAuthorAciBinary()) != 16 { - zerolog.Ctx(ctx).Debug(). - Str("author_aci_b64", base64.StdEncoding.EncodeToString(vote.GetTargetAuthorAciBinary())). - Msg("Invalid author ACI in poll vote") - return invalidPollVote - } - pollMessageID := signalid.MakeMessageID(uuid.UUID(vote.GetTargetAuthorAciBinary()), vote.GetTargetSentTimestamp()) - pollMessage, err := mc.Bridge.DB.Message.GetPartByID(ctx, getPortal(ctx).Receiver, pollMessageID, "") - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to get poll vote target message") - return invalidPollVote - } else if pollMessage == nil { - zerolog.Ctx(ctx).Warn().Msg("Poll vote target message not found") - return invalidPollVote - } - mxOptionIDs := pollMessage.Metadata.(*signalid.MessageMetadata).MatrixPollOptionIDs - optionIDs := make([]string, len(vote.GetOptionIndexes())) - for i, optionIndex := range vote.GetOptionIndexes() { - if int(optionIndex) < len(mxOptionIDs) { - optionIDs[i] = mxOptionIDs[optionIndex] - } else { - optionIDs[i] = strconv.Itoa(int(optionIndex)) - } - } - return &bridgev2.ConvertedMessagePart{ - Type: event.EventUnstablePollResponse, - Content: &event.MessageEventContent{ - RelatesTo: &event.RelatesTo{ - Type: event.RelReference, - EventID: pollMessage.MXID, - }, - }, - Extra: map[string]any{ - "org.matrix.msc3381.poll.response": map[string]any{ - "answers": optionIDs, - }, - }, - } -} diff --git a/pkg/msgconv/imagepack.go b/pkg/msgconv/imagepack.go deleted file mode 100644 index a2529af..0000000 --- a/pkg/msgconv/imagepack.go +++ /dev/null @@ -1,199 +0,0 @@ -// mautrix-signal - A Matrix-Signal puppeting bridge. -// Copyright (C) 2026 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package msgconv - -import ( - "bytes" - "context" - "encoding/hex" - "fmt" - "net/url" - "strconv" - "strings" - - "go.mau.fi/util/emojishortcodes" - "google.golang.org/protobuf/proto" - "maunium.net/go/mautrix" - "maunium.net/go/mautrix/bridgev2" - "maunium.net/go/mautrix/bridgev2/database" - "maunium.net/go/mautrix/event" - "maunium.net/go/mautrix/id" - - "go.mau.fi/mautrix-signal/pkg/signalid" - "go.mau.fi/mautrix-signal/pkg/signalmeow" - signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" -) - -const StickerSourceID = "signal" -const PackURLFormat = "https://signal.art/addstickers/#pack_id=%x&pack_key=%x" - -const PackIDLength = 16 -const PackKeyLength = 32 -const PackURLLength = len(PackURLFormat) - len("%x")*2 + PackIDLength*2 + PackKeyLength*2 - -var zeroPackID = make([]byte, PackIDLength) - -func ParseStickerMeta(info *event.BridgedSticker) *signalpb.DataMessage_Sticker { - if info == nil || info.Network != StickerSourceID || len(info.PackURL) != PackURLLength { - return nil - } - stickerID, err := strconv.ParseUint(info.ID, 10, 32) - if err != nil { - return nil - } - packID, packKey, err := parsePackURL(info.PackURL) - if err != nil || len(packID) != PackIDLength || len(packKey) != PackKeyLength || bytes.Equal(packID, zeroPackID) { - return nil - } - return &signalpb.DataMessage_Sticker{ - PackId: packID, - PackKey: packKey, - StickerId: proto.Uint32(uint32(stickerID)), - Emoji: &info.Emoji, - } -} - -func parsePackURL(rawURL string) (packID, packKey []byte, err error) { - parsed, err := url.Parse(rawURL) - if err != nil { - return nil, nil, fmt.Errorf("invalid URL: %w", err) - } else if parsed.Host != "signal.art" || !strings.HasPrefix(parsed.Path, "/addstickers") { - return nil, nil, fmt.Errorf("invalid host or path in URL") - } - q, err := url.ParseQuery(parsed.Fragment) - if err != nil { - return nil, nil, fmt.Errorf("invalid URL fragment: %w", err) - } - packID, err = hex.DecodeString(q.Get("pack_id")) - if err != nil { - return nil, nil, fmt.Errorf("invalid pack ID in URL: %w", err) - } - packKey, err = hex.DecodeString(q.Get("pack_key")) - if err != nil { - return nil, nil, fmt.Errorf("invalid pack key in URL: %w", err) - } - return -} - -func (mc *MessageConverter) DownloadImagePack(ctx context.Context, url string) (*bridgev2.ImportedImagePack, error) { - packID, packKey, err := parsePackURL(url) - if err != nil { - return nil, bridgev2.WrapRespErr(err, mautrix.MNotFound) - } - manifest, err := signalmeow.DownloadStickerPackManifest(ctx, packID, packKey) - if err != nil { - return nil, fmt.Errorf("failed to download sticker pack manifest: %w", err) - } - topLevelExtra := map[string]any{ - "fi.mau.signal.stickerpack": map[string]any{ - "pack_id": hex.EncodeToString(packID), - "pack_key": hex.EncodeToString(packKey), - }, - } - content := &event.ImagePackEventContent{ - Images: make(map[string]*event.ImagePackImage, len(manifest.Stickers)), - Metadata: event.ImagePackMetadata{ - DisplayName: manifest.GetTitle(), - AvatarURL: "", - Usage: []event.ImagePackUsage{event.ImagePackUsageSticker}, - Attribution: manifest.GetAuthor(), - BridgedPack: &event.BridgedStickerPack{ - Network: StickerSourceID, - URL: fmt.Sprintf(PackURLFormat, packID, packKey), - }, - }, - } - imagesByID := make(map[uint32]id.ContentURIString, len(manifest.Stickers)) - uploadImage := func(sticker *signalpb.Pack_Sticker) (id.ContentURIString, error) { - stickerID := sticker.GetId() - existing, ok := imagesByID[stickerID] - if ok { - return existing, nil - } - var mxc id.ContentURIString - if mc.DirectMedia { - mediaID, err := signalid.DirectMediaSticker{ - PackID: packID, - PackKey: packKey, - StickerID: stickerID, - }.AsMediaID() - if err != nil { - return "", fmt.Errorf("failed to create media ID for sticker %d: %w", stickerID, err) - } - mxc, err = mc.Bridge.Matrix.GenerateContentURI(ctx, mediaID) - if err != nil { - return "", fmt.Errorf("failed to generate content URI for sticker %d: %w", stickerID, err) - } - } else { - dbKey := database.Key(fmt.Sprintf("stickercache:%x:%d", packID, stickerID)) - if cached := mc.Bridge.DB.KV.Get(ctx, dbKey); cached != "" { - mxc = id.ContentURIString(cached) - imagesByID[stickerID] = mxc - return mxc, nil - } - data, err := signalmeow.DownloadStickerPackItem(ctx, packID, packKey, stickerID) - if err != nil { - return "", fmt.Errorf("failed to download sticker %d: %w", stickerID, err) - } - mxc, _, err = mc.Bridge.Bot.UploadMedia(ctx, "", data, "", sticker.GetContentType()) - if err != nil { - return "", fmt.Errorf("failed to upload sticker %d: %w", stickerID, err) - } - mc.Bridge.DB.KV.Set(ctx, dbKey, string(mxc)) - } - imagesByID[stickerID] = mxc - return mxc, nil - } - for _, sticker := range manifest.Stickers { - mxc, err := uploadImage(sticker) - if err != nil { - return nil, err - } - shortcode := emojishortcodes.Get(sticker.GetEmoji()) - realShortcode := shortcode - i := 2 - for _, alreadyExists := content.Images[realShortcode]; alreadyExists; i++ { - realShortcode = fmt.Sprintf("%s_%d", shortcode, i) - } - content.Images[realShortcode] = &event.ImagePackImage{ - URL: mxc, - Body: sticker.GetEmoji(), - Info: &event.FileInfo{ - MimeType: sticker.GetContentType(), - Width: 200, - Height: 200, - BridgedSticker: &event.BridgedSticker{ - Network: StickerSourceID, - ID: strconv.FormatUint(uint64(sticker.GetId()), 10), - Emoji: sticker.GetEmoji(), - PackURL: content.Metadata.BridgedPack.URL, - }, - }, - } - } - if manifest.Cover != nil { - content.Metadata.AvatarURL, err = uploadImage(manifest.Cover) - if err != nil { - return nil, fmt.Errorf("failed to upload sticker pack cover: %w", err) - } - } - return &bridgev2.ImportedImagePack{ - Content: content, - Extra: topLevelExtra, - Shortcode: hex.EncodeToString(packID), - }, nil -} diff --git a/pkg/msgconv/msgconv.go b/pkg/msgconv/msgconv.go deleted file mode 100644 index e312a1f..0000000 --- a/pkg/msgconv/msgconv.go +++ /dev/null @@ -1,110 +0,0 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2024 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package msgconv - -import ( - "context" - - "github.com/google/uuid" - "maunium.net/go/mautrix/bridgev2" - "maunium.net/go/mautrix/bridgev2/networkid" - "maunium.net/go/mautrix/id" - - "go.mau.fi/mautrix-signal/pkg/msgconv/matrixfmt" - "go.mau.fi/mautrix-signal/pkg/msgconv/signalfmt" - "go.mau.fi/mautrix-signal/pkg/signalid" - "go.mau.fi/mautrix-signal/pkg/signalmeow" -) - -type contextKey int - -const ( - contextKeyPortal contextKey = iota - contextKeyClient - contextKeyIntent -) - -type MessageConverter struct { - Bridge *bridgev2.Bridge - - SignalFmtParams *signalfmt.FormatParams - MatrixFmtParams *matrixfmt.HTMLParser - - MaxFileSize int64 - LocationFormat string - DisappearViewOnce bool - DirectMedia bool - ExtEvPolls bool -} - -func NewMessageConverter(br *bridgev2.Bridge) *MessageConverter { - return &MessageConverter{ - Bridge: br, - SignalFmtParams: &signalfmt.FormatParams{ - GetUserInfo: func(ctx context.Context, uuid uuid.UUID) signalfmt.UserInfo { - ghost, err := br.GetGhostByID(ctx, signalid.MakeUserID(uuid)) - if err != nil { - // TODO log? - return signalfmt.UserInfo{} - } - userInfo := signalfmt.UserInfo{ - MXID: ghost.Intent.GetMXID(), - Name: ghost.Name, - } - userLogin := br.GetCachedUserLoginByID(networkid.UserLoginID(uuid.String())) - portal := getPortal(ctx) - if userLogin != nil && (portal.Receiver == "" || portal.Receiver == userLogin.ID) { - userInfo.MXID = userLogin.UserMXID - // TODO find matrix user displayname? - } - return userInfo - }, - }, - MatrixFmtParams: &matrixfmt.HTMLParser{ - GetUUIDFromMXID: func(ctx context.Context, userID id.UserID) uuid.UUID { - parsed, ok := br.Matrix.ParseGhostMXID(userID) - if ok { - u, _ := signalid.ParseUserID(parsed) - return u - } - user, _ := br.GetExistingUserByMXID(ctx, userID) - // TODO log errors? - if user != nil { - preferredLogin, _, _ := getPortal(ctx).FindPreferredLogin(ctx, user, true) - if preferredLogin != nil { - u, _ := signalid.ParseUserLoginID(preferredLogin.ID) - return u - } - } - return uuid.Nil - }, - }, - MaxFileSize: 50 * 1024 * 1024, - } -} - -func getClient(ctx context.Context) *signalmeow.Client { - return ctx.Value(contextKeyClient).(*signalmeow.Client) -} - -func getPortal(ctx context.Context) *bridgev2.Portal { - return ctx.Value(contextKeyPortal).(*bridgev2.Portal) -} - -func getIntent(ctx context.Context) bridgev2.MatrixAPI { - return ctx.Value(contextKeyIntent).(bridgev2.MatrixAPI) -} diff --git a/pkg/msgconv/urlpreview.go b/pkg/msgconv/urlpreview.go deleted file mode 100644 index 66b186a..0000000 --- a/pkg/msgconv/urlpreview.go +++ /dev/null @@ -1,93 +0,0 @@ -// mautrix-signal - A Matrix-Signal puppeting bridge. -// Copyright (C) 2024 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package msgconv - -import ( - "context" - "time" - - "github.com/rs/zerolog" - "google.golang.org/protobuf/proto" - "maunium.net/go/mautrix/event" - - signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" -) - -func (mc *MessageConverter) convertURLPreviewsToBeeper(ctx context.Context, preview []*signalpb.Preview, attMap AttachmentMap) []*event.BeeperLinkPreview { - output := make([]*event.BeeperLinkPreview, len(preview)) - for i, p := range preview { - output[i] = mc.convertURLPreviewToBeeper(ctx, p, attMap) - } - return output -} - -func (mc *MessageConverter) convertURLPreviewToBeeper(ctx context.Context, preview *signalpb.Preview, attMap AttachmentMap) *event.BeeperLinkPreview { - output := &event.BeeperLinkPreview{ - MatchedURL: preview.GetUrl(), - LinkPreview: event.LinkPreview{ - CanonicalURL: preview.GetUrl(), - Title: preview.GetTitle(), - Description: preview.GetDescription(), - }, - } - if preview.Image != nil { - msg, err := mc.reuploadAttachment(ctx, preview.Image, attMap) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to reupload link preview image") - } else { - output.ImageURL = msg.Content.URL - output.ImageEncryption = msg.Content.File - output.ImageType = msg.Content.Info.MimeType - output.ImageSize = event.IntOrString(msg.Content.Info.Size) - output.ImageHeight = event.IntOrString(msg.Content.Info.Height) - output.ImageWidth = event.IntOrString(msg.Content.Info.Width) - } - } - return output -} - -func (mc *MessageConverter) convertURLPreviewToSignal(ctx context.Context, content *event.MessageEventContent) []*signalpb.Preview { - if len(content.BeeperLinkPreviews) == 0 { - return nil - } - output := make([]*signalpb.Preview, len(content.BeeperLinkPreviews)) - for i, preview := range content.BeeperLinkPreviews { - output[i] = &signalpb.Preview{ - Url: proto.String(preview.MatchedURL), - Title: proto.String(preview.Title), - Description: proto.String(preview.Description), - Date: proto.Uint64(uint64(time.Now().UnixMilli())), - } - if preview.ImageURL != "" || preview.ImageEncryption != nil { - data, err := mc.Bridge.Bot.DownloadMedia(ctx, preview.ImageURL, preview.ImageEncryption) - if err != nil { - zerolog.Ctx(ctx).Err(err).Int("preview_index", i).Msg("Failed to download URL preview image") - continue - } - uploaded, err := getClient(ctx).UploadAttachment(ctx, data) - if err != nil { - zerolog.Ctx(ctx).Err(err).Int("preview_index", i).Msg("Failed to reupload URL preview image") - continue - } - uploaded.ContentType = proto.String(preview.ImageType) - uploaded.Width = proto.Uint32(uint32(preview.ImageWidth)) - uploaded.Height = proto.Uint32(uint32(preview.ImageHeight)) - output[i].Image = uploaded - } - } - return output -} diff --git a/pkg/signalid/dbmeta.go b/pkg/signalid/dbmeta.go deleted file mode 100644 index 8f42e6f..0000000 --- a/pkg/signalid/dbmeta.go +++ /dev/null @@ -1,42 +0,0 @@ -// mautrix-signal - A Matrix-Signal puppeting bridge. -// Copyright (C) 2024 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package signalid - -import ( - "go.mau.fi/util/jsontime" -) - -type PortalMetadata struct { - Revision uint32 `json:"revision,omitempty"` - ExpirationTimerVersion uint32 `json:"expiration_timer_version,omitempty"` - // Lazy resync tracking - LastSync jsontime.Unix `json:"last_sync,omitempty"` -} - -type MessageMetadata struct { - ContainsAttachments bool `json:"contains_attachments,omitempty"` - MatrixPollOptionIDs []string `json:"matrix_poll_option_ids,omitempty"` -} - -type UserLoginMetadata struct { - ChatsSynced bool `json:"chats_synced,omitempty"` - LastContactSync jsontime.UnixMilli `json:"last_contact_sync,omitempty"` -} - -type GhostMetadata struct { - ProfileFetchedAt jsontime.UnixMilli `json:"profile_fetched_at"` -} diff --git a/pkg/signalid/ids.go b/pkg/signalid/ids.go deleted file mode 100644 index daa9200..0000000 --- a/pkg/signalid/ids.go +++ /dev/null @@ -1,139 +0,0 @@ -// mautrix-signal - A Matrix-Signal puppeting bridge. -// Copyright (C) 2024 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package signalid - -import ( - "fmt" - "strconv" - "strings" - - "github.com/google/uuid" - "maunium.net/go/mautrix/bridgev2" - "maunium.net/go/mautrix/bridgev2/networkid" - - "go.mau.fi/mautrix-signal/pkg/libsignalgo" - "go.mau.fi/mautrix-signal/pkg/signalmeow/types" -) - -func ParseUserID(userID networkid.UserID) (uuid.UUID, error) { - serviceID, err := ParseUserIDAsServiceID(userID) - if err != nil { - return uuid.Nil, err - } else if serviceID.Type != libsignalgo.ServiceIDTypeACI { - return uuid.Nil, fmt.Errorf("invalid user ID: expected ACI type") - } else { - return serviceID.UUID, nil - } -} - -func ParseUserLoginID(userLoginID networkid.UserLoginID) (uuid.UUID, error) { - userID, err := uuid.Parse(string(userLoginID)) - if err != nil { - return uuid.Nil, err - } - return userID, nil -} - -func toServiceID(id uuid.UUID, err error) (libsignalgo.ServiceID, error) { - if err != nil { - return libsignalgo.ServiceID{}, err - } - return libsignalgo.NewACIServiceID(id), nil -} - -func ParseGhostOrUserLoginID(ghostOrUserLogin bridgev2.GhostOrUserLogin) (libsignalgo.ServiceID, error) { - switch ghostOrUserLogin := ghostOrUserLogin.(type) { - case *bridgev2.UserLogin: - return toServiceID(ParseUserLoginID(ghostOrUserLogin.ID)) - case *bridgev2.Ghost: - return ParseUserIDAsServiceID(ghostOrUserLogin.ID) - default: - return libsignalgo.ServiceID{}, fmt.Errorf("cannot parse ID: unknown type: %T", ghostOrUserLogin) - } -} - -const pniUserIDPrefix = "pni_" -const pniServiceIDPrefix = "PNI:" - -func ParseUserIDAsServiceID(userID networkid.UserID) (libsignalgo.ServiceID, error) { - userIDStr := string(userID) - if strings.HasPrefix(userIDStr, pniUserIDPrefix) { - userIDStr = pniServiceIDPrefix + userIDStr[len(pniUserIDPrefix):] - } - return libsignalgo.ServiceIDFromString(userIDStr) -} - -func ParsePortalID(portalID networkid.PortalID) (userID libsignalgo.ServiceID, groupID types.GroupIdentifier, err error) { - if len(portalID) == 44 { - groupID = types.GroupIdentifier(portalID) - } else { - userID, err = libsignalgo.ServiceIDFromString(string(portalID)) - } - return -} - -func ParseMessageID(messageID networkid.MessageID) (sender uuid.UUID, timestamp uint64, err error) { - parts := strings.Split(string(messageID), "|") - if len(parts) != 2 { - err = fmt.Errorf("invalid message ID: expected two pipe-separated parts") - return - } - sender, err = uuid.Parse(parts[0]) - if err != nil { - return - } - timestamp, err = strconv.ParseUint(parts[1], 10, 64) - return -} - -func MakeGroupPortalID(groupID types.GroupIdentifier) networkid.PortalID { - return networkid.PortalID(groupID) -} - -func MakeDMPortalID(serviceID libsignalgo.ServiceID) networkid.PortalID { - return networkid.PortalID(serviceID.String()) -} - -func MakeMessageID(sender uuid.UUID, timestamp uint64) networkid.MessageID { - return networkid.MessageID(fmt.Sprintf("%s|%d", sender, timestamp)) -} - -func MakeUserID(user uuid.UUID) networkid.UserID { - return networkid.UserID(user.String()) -} - -func MakeUserIDFromServiceID(user libsignalgo.ServiceID) networkid.UserID { - switch user.Type { - case libsignalgo.ServiceIDTypeACI: - return MakeUserID(user.UUID) - case libsignalgo.ServiceIDTypePNI: - return networkid.UserID(pniUserIDPrefix + user.UUID.String()) - default: - panic(fmt.Errorf("invalid service ID type %d", user.Type)) - } -} - -func MakeUserLoginID(user uuid.UUID) networkid.UserLoginID { - return networkid.UserLoginID(user.String()) -} - -func MakeMessagePartID(index int) networkid.PartID { - if index == 0 { - return "" - } - return networkid.PartID(strconv.Itoa(index)) -} diff --git a/pkg/signalid/media.go b/pkg/signalid/media.go deleted file mode 100644 index a530c22..0000000 --- a/pkg/signalid/media.go +++ /dev/null @@ -1,278 +0,0 @@ -// mautrix-signal - A Matrix-Signal puppeting bridge. -// Copyright (C) 2025 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package signalid - -import ( - "bytes" - "crypto/sha256" - "encoding/binary" - "fmt" - "io" - - "github.com/google/uuid" - "maunium.net/go/mautrix/bridgev2/networkid" -) - -type directMediaType byte - -const ( - directMediaTypeAttachment directMediaType = 0 - directMediaTypeGroupAvatar directMediaType = 1 - directMediaTypeProfileAvatar directMediaType = 2 - directMediaTypePlaintextDigestAttachment directMediaType = 3 - directMediaTypeSticker directMediaType = 4 -) - -type DirectMediaInfo interface { - AsMediaID() (networkid.MediaID, error) -} - -var ( - _ DirectMediaInfo = (*DirectMediaAttachment)(nil) - _ DirectMediaInfo = (*DirectMediaGroupAvatar)(nil) - _ DirectMediaInfo = (*DirectMediaProfileAvatar)(nil) - _ DirectMediaInfo = (*DirectMediaSticker)(nil) -) - -type DirectMediaAttachment struct { - CDNID uint64 - CDNKey string - CDNNumber uint32 - Key []byte - PlaintextDigest bool - Digest []byte - Size uint32 -} - -func (m DirectMediaAttachment) AsMediaID() (mediaID networkid.MediaID, err error) { - buf := &bytes.Buffer{} - - attType := directMediaTypeAttachment - if m.PlaintextDigest { - attType = directMediaTypePlaintextDigestAttachment - } - - if err = binary.Write(buf, binary.BigEndian, attType); err != nil { - return - } else if err = writeUvarint(buf, m.CDNID); err != nil { - return - } else if err = writeByteSlice(buf, []byte(m.CDNKey)); err != nil { - return - } else if err = writeUvarint(buf, uint64(m.CDNNumber)); err != nil { - return - } else if err = writeByteSlice(buf, m.Key); err != nil { - return - } else if err = writeByteSlice(buf, m.Digest); err != nil { - return - } else if err = writeUvarint(buf, uint64(m.Size)); err != nil { - return - } - - return networkid.MediaID(buf.Bytes()), nil -} - -type DirectMediaGroupAvatar struct { - UserID uuid.UUID - GroupID [32]byte - GroupAvatarPath string -} - -func (m DirectMediaGroupAvatar) AsMediaID() (mediaID networkid.MediaID, err error) { - buf := &bytes.Buffer{} - - if err = binary.Write(buf, binary.BigEndian, directMediaTypeGroupAvatar); err != nil { - return - } else if err = binary.Write(buf, binary.BigEndian, m.UserID); err != nil { - return - } else if err = binary.Write(buf, binary.BigEndian, m.GroupID); err != nil { - return - } else if err = writeByteSlice(buf, []byte(m.GroupAvatarPath)); err != nil { - return - } - - return networkid.MediaID(buf.Bytes()), nil -} - -type DirectMediaProfileAvatar struct { - UserID uuid.UUID - ContactID uuid.UUID - ProfileAvatarPath string -} - -func (m DirectMediaProfileAvatar) AsMediaID() (mediaID networkid.MediaID, err error) { - buf := &bytes.Buffer{} - - if err = binary.Write(buf, binary.BigEndian, directMediaTypeProfileAvatar); err != nil { - return - } else if err = binary.Write(buf, binary.BigEndian, m.UserID); err != nil { - return - } else if err = binary.Write(buf, binary.BigEndian, m.ContactID); err != nil { - return - } else if err = writeByteSlice(buf, []byte(m.ProfileAvatarPath)); err != nil { - return - } - - return networkid.MediaID(buf.Bytes()), nil -} - -type DirectMediaSticker struct { - PackID []byte - PackKey []byte - StickerID uint32 -} - -const packIDLen = 16 -const packKeyLen = 32 -const directMediaStickerLen = 1 + packIDLen + packKeyLen + 4 - -func (m DirectMediaSticker) AsMediaID() (mediaID networkid.MediaID, err error) { - if len(m.PackID) != packIDLen { - return nil, fmt.Errorf("invalid pack ID length: %d", len(m.PackID)) - } else if len(m.PackKey) != packKeyLen { - return nil, fmt.Errorf("invalid pack key length: %d", len(m.PackKey)) - } - mediaID = make(networkid.MediaID, directMediaStickerLen) - mediaID[0] = byte(directMediaTypeSticker) - copy(mediaID[1:], m.PackID) - copy(mediaID[1+packIDLen:], m.PackKey) - binary.BigEndian.PutUint32(mediaID[1+packIDLen+packKeyLen:], m.StickerID) - return mediaID, nil -} - -func ParseDirectMediaInfo(mediaID networkid.MediaID) (_ DirectMediaInfo, err error) { - mediaIDLen := len(mediaID) - if mediaIDLen == 0 { - return nil, fmt.Errorf("empty media ID") - } - - buf := bytes.NewReader(mediaID) - - // type byte - var mediaType directMediaType - if err := binary.Read(buf, binary.BigEndian, &mediaType); err != nil { - return nil, fmt.Errorf("failed to read media type: %w", err) - } - - switch mediaType { - case directMediaTypeAttachment, directMediaTypePlaintextDigestAttachment: - var info DirectMediaAttachment - info.PlaintextDigest = mediaType == directMediaTypePlaintextDigestAttachment - - if info.CDNID, err = binary.ReadUvarint(buf); err != nil { - return info, fmt.Errorf("failed to read cdn id: %w", err) - } - if cdnKey, err := readByteSlice(buf, mediaIDLen); err != nil { - return info, fmt.Errorf("failed to read cdn key: %w", err) - } else { - info.CDNKey = string(cdnKey) - } - if cdnNumber, err := binary.ReadUvarint(buf); err != nil { - return info, fmt.Errorf("failed to read cdn number: %w", err) - } else { - info.CDNNumber = uint32(cdnNumber) - } - if info.Key, err = readByteSlice(buf, mediaIDLen); err != nil { - return info, fmt.Errorf("failed to read key: %w", err) - } else if info.Digest, err = readByteSlice(buf, mediaIDLen); err != nil { - return info, fmt.Errorf("failed to read digest: %w", err) - } - if size, err := binary.ReadUvarint(buf); err != nil { - return info, fmt.Errorf("failed to read cdn id: %w", err) - } else { - info.Size = uint32(size) - } - - return &info, nil - case directMediaTypeGroupAvatar: - var info DirectMediaGroupAvatar - - if err = binary.Read(buf, binary.BigEndian, &info.UserID); err != nil { - return info, fmt.Errorf("failed to read user id: %w", err) - } else if err = binary.Read(buf, binary.BigEndian, &info.GroupID); err != nil { - return info, fmt.Errorf("failed to read group id: %w", err) - } - if groupAvatarPath, err := readByteSlice(buf, mediaIDLen); err != nil { - return info, fmt.Errorf("failed to read group avatar path: %w", err) - } else { - info.GroupAvatarPath = string(groupAvatarPath) - } - - return &info, nil - case directMediaTypeProfileAvatar: - var info DirectMediaProfileAvatar - - if err = binary.Read(buf, binary.BigEndian, &info.UserID); err != nil { - return info, fmt.Errorf("failed to read user id: %w", err) - } else if err = binary.Read(buf, binary.BigEndian, &info.ContactID); err != nil { - return info, fmt.Errorf("failed to read contact id: %w", err) - } - if profileAvatarPath, err := readByteSlice(buf, mediaIDLen); err != nil { - return info, fmt.Errorf("failed to read profile avatar path: %w", err) - } else { - info.ProfileAvatarPath = string(profileAvatarPath) - } - return &info, nil - case directMediaTypeSticker: - var info DirectMediaSticker - if len(mediaID) != directMediaStickerLen { - return info, fmt.Errorf("invalid media ID length for sticker: %d", len(mediaID)) - } - info.PackID = mediaID[1 : 1+packIDLen] - info.PackKey = mediaID[1+packIDLen : 1+packIDLen+packKeyLen] - info.StickerID = binary.BigEndian.Uint32(mediaID[1+packIDLen+packKeyLen:]) - return &info, nil - } - - return nil, fmt.Errorf("invalid direct media type %d", mediaType) -} - -func HashMediaID(mediaID networkid.MediaID) [32]byte { - return sha256.Sum256(mediaID) -} - -func writeUvarint(w io.Writer, i uint64) error { - _, err := w.Write(binary.AppendUvarint(nil, i)) - return err -} - -func writeByteSlice(w io.Writer, b []byte) error { - if err := writeUvarint(w, uint64(len(b))); err != nil { - return err - } - _, err := w.Write(b) - return err -} - -type byteReader interface { - io.ByteReader - io.Reader -} - -func readByteSlice(r byteReader, maxLength int) ([]byte, error) { - length, err := binary.ReadUvarint(r) - if err != nil { - return nil, fmt.Errorf("reading uvarint failed: %w", err) - } else if int(length) > maxLength { - return nil, fmt.Errorf("byte slice size larger than expected: %d > %d", length, maxLength) - } else if length == 0 { - return nil, nil - } - - buf := make([]byte, length) - _, err = io.ReadFull(r, buf) - return buf, err -} diff --git a/pkg/signalmeow/attachments.go b/pkg/signalmeow/attachments.go index c091827..e8c9b99 100644 --- a/pkg/signalmeow/attachments.go +++ b/pkg/signalmeow/attachments.go @@ -23,237 +23,91 @@ import ( "crypto/cipher" "crypto/hmac" "crypto/sha256" - "encoding/base64" - "encoding/json" "errors" "fmt" "io" "math" - "mime/multipart" "net/http" - "os" "github.com/rs/zerolog" - "go.mau.fi/util/fallocate" - "go.mau.fi/util/pkcs7" "go.mau.fi/util/random" - "google.golang.org/protobuf/proto" - "go.mau.fi/mautrix-signal/pkg/libsignalgo" signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" - "go.mau.fi/mautrix-signal/pkg/signalmeow/types" "go.mau.fi/mautrix-signal/pkg/signalmeow/web" ) -const ( - attachmentKeyDownloadPath = "/attachments/%s" - attachmentIDDownloadPath = "/attachments/%d" -) +// *** Attachments! *** -func getAttachmentPath(id uint64, key string) string { +// Attachment represents an attachment received from a peer +type Attachment struct { + R io.Reader + MimeType string + FileName string +} + +func getAttachmentPath(id uint64, key string, cdnNumber uint32) (string, error) { + const ( + attachmentKeyDownloadPath = "/attachments/%s" + attachmentIDDownloadPath = "/attachments/%d" + ) if id != 0 { - return fmt.Sprintf(attachmentIDDownloadPath, id) + return fmt.Sprintf(attachmentIDDownloadPath, id), nil } - return fmt.Sprintf(attachmentKeyDownloadPath, key) + return fmt.Sprintf(attachmentKeyDownloadPath, key), nil } // ErrInvalidMACForAttachment signals that the downloaded attachment has an invalid MAC. var ErrInvalidMACForAttachment = errors.New("invalid MAC for attachment") var ErrInvalidDigestForAttachment = errors.New("invalid digest for attachment") -var ErrAttachmentNotFound = errors.New("attachment not found on server") -func DownloadAttachmentWithPointer(ctx context.Context, a *signalpb.AttachmentPointer, plaintextHash []byte, into *os.File) ([]byte, error) { - digest := a.GetDigest() - plaintextDigest := false - if digest == nil && plaintextHash != nil { - digest = plaintextHash - plaintextDigest = true - } - return DownloadAttachment( - ctx, a.GetCdnId(), a.GetCdnKey(), a.GetCdnNumber(), a.Key, digest, plaintextDigest, a.GetSize(), into, - ) -} - -func DownloadAttachment( - ctx context.Context, - cdnID uint64, - cdnKey string, - cdnNumber uint32, - key, digest []byte, - plaintextDigest bool, - size uint32, - into *os.File, -) ([]byte, error) { - resp, err := web.GetAttachment(ctx, getAttachmentPath(cdnID, cdnKey), cdnNumber) +func DownloadAttachment(ctx context.Context, a *signalpb.AttachmentPointer) ([]byte, error) { + path, err := getAttachmentPath(a.GetCdnId(), a.GetCdnKey(), a.GetCdnNumber()) if err != nil { return nil, err } - defer func() { - _ = resp.Body.Close() - }() - - var body []byte - var downloadedSize int64 - if resp.StatusCode > 400 { - body, err = io.ReadAll(io.LimitReader(resp.Body, 4096)) - } else if into == nil { - if resp.ContentLength > 0 { - body = make([]byte, resp.ContentLength) - _, err = io.ReadFull(resp.Body, body) - } else { - body, err = io.ReadAll(http.MaxBytesReader(nil, resp.Body, max(int64(size), 32*1024)*2)) - } - } else { - err = fallocate.Fallocate(into, int(resp.ContentLength)) - if err != nil { - return nil, fmt.Errorf("failed to pre-allocate file for attachment: %w", err) - } - downloadedSize, err = io.Copy(into, resp.Body) - } + resp, err := web.GetAttachment(ctx, path, a.GetCdnNumber(), nil) if err != nil { return nil, err } - if resp.StatusCode > 400 { - if json.Valid(body) && len(body) < 4096 { - zerolog.Ctx(ctx).Debug().RawJSON("response_data", body).Msg("Failed download response json") - } else if len(body) < 1024 { - zerolog.Ctx(ctx).Debug().Bytes("response_data", body).Msg("Failed download response data") - } - if resp.StatusCode == http.StatusNotFound { - return nil, ErrAttachmentNotFound - } - return nil, fmt.Errorf("unexpected status code %d", resp.StatusCode) + bodyReader := resp.Body + defer bodyReader.Close() + + body, err := io.ReadAll(bodyReader) + if err != nil { + return nil, err } - if into != nil { - if _, err = into.Seek(0, io.SeekStart); err != nil { - return nil, fmt.Errorf("failed to seek attachment file after downloading: %w", err) - } - return nil, decryptAttachmentFile(into, downloadedSize, key, digest, plaintextDigest, size) - } - return decryptAttachment(body, key, digest, plaintextDigest, size) + return decryptAttachment(body, a.Key, a.Digest, *a.Size) } -const MACLength = 32 -const IVLength = 16 - -func macAndAESDecrypt(body, key []byte) ([]byte, error) { - l := len(body) - MACLength - if !verifyMAC(key[MACLength:], body[:l], body[l:]) { +func decryptAttachment(body, key, digest []byte, size uint32) ([]byte, error) { + hash := sha256.Sum256(body) + if !hmac.Equal(hash[:], digest) { + return nil, ErrInvalidDigestForAttachment + } + l := len(body) - 32 + if !verifyMAC(key[32:], body[:l], body[l:]) { return nil, ErrInvalidMACForAttachment } - return aesDecrypt(key[:MACLength], body[:l]) -} - -func decryptAttachment(body, key, digest []byte, plaintextDigest bool, size uint32) ([]byte, error) { - if !plaintextDigest { - hash := sha256.Sum256(body) - if !hmac.Equal(hash[:], digest) { - return nil, ErrInvalidDigestForAttachment - } - } - decrypted, err := macAndAESDecrypt(body, key) + decrypted, err := aesDecrypt(key[:32], body[:l]) if err != nil { return nil, err } if len(decrypted) < int(size) { return nil, fmt.Errorf("decrypted attachment length %v < expected %v", len(decrypted), size) } - decrypted = decrypted[:size] - if plaintextDigest { - hash := sha256.Sum256(decrypted) - if !hmac.Equal(hash[:], digest) { - return nil, fmt.Errorf("%w (plaintext hash)", ErrInvalidDigestForAttachment) - } - } - return decrypted, nil + return decrypted[:size], nil } -func decryptAttachmentFile(file *os.File, downloadedSize int64, key, digest []byte, plaintextDigest bool, size uint32) error { - if !plaintextDigest { - hasher := sha256.New() - if _, err := io.Copy(hasher, file); err != nil { - return fmt.Errorf("failed to hash attachment file: %w", err) - } else if !hmac.Equal(hasher.Sum(nil), digest) { - return ErrInvalidDigestForAttachment - } else if _, err = file.Seek(0, io.SeekStart); err != nil { - return fmt.Errorf("failed to seek attachment file after hashing: %w", err) - } - } - mac := make([]byte, MACLength) - n, err := file.ReadAt(mac, downloadedSize-MACLength) - if err != nil { - return fmt.Errorf("failed to read MAC from attachment file: %w", err) - } else if n != MACLength { - return fmt.Errorf("unexpected MAC length read from attachment file: %d", n) - } - hasher := hmac.New(sha256.New, key[MACLength:]) - _, err = io.CopyN(hasher, file, downloadedSize-MACLength) - if err != nil { - return fmt.Errorf("failed to hash attachment file for MAC verification: %w", err) - } else if !hmac.Equal(hasher.Sum(nil), mac) { - return ErrInvalidMACForAttachment - } else if _, err = file.Seek(0, io.SeekStart); err != nil { - return fmt.Errorf("failed to seek attachment file after verifying mac: %w", err) - } - - decryptedSize, err := aesDecryptFile(key[:MACLength], file, downloadedSize-MACLength) - if err != nil { - return err - } else if decryptedSize < int64(size) { - return fmt.Errorf("decrypted attachment length %d < expected %d", decryptedSize, size) - } else if _, err = file.Seek(0, io.SeekStart); err != nil { - return fmt.Errorf("failed to seek attachment file after decrypting: %w", err) - } - err = file.Truncate(int64(size)) - if err != nil { - return fmt.Errorf("failed to truncate attachment file to expected size: %w", err) - } - if plaintextDigest { - hasher = sha256.New() - if _, err = io.Copy(hasher, file); err != nil { - return fmt.Errorf("failed to hash decrypted attachment file: %w", err) - } else if !hmac.Equal(hasher.Sum(nil), digest) { - return fmt.Errorf("%w (plaintext hash)", ErrInvalidDigestForAttachment) - } else if _, err = file.Seek(0, io.SeekStart); err != nil { - return fmt.Errorf("failed to seek attachment file after hashing plaintext: %w", err) - } - } - return nil -} - -type attachmentV4UploadAttributes struct { +type attachmentV3UploadAttributes struct { Cdn uint32 `json:"cdn"` Key string `json:"key"` Headers map[string]string `json:"headers"` SignedUploadLocation string `json:"signedUploadLocation"` } -func extend(data []byte, paddedLen int) []byte { - origLen := len(data) - if cap(data) >= paddedLen { - data = data[:paddedLen] - for i := origLen; i < paddedLen; i++ { - data[i] = 0 - } - return data - } else { - newData := make([]byte, paddedLen) - copy(newData, data) - return newData - } -} - -func macAndAESEncrypt(keys, plaintext []byte) ([]byte, error) { - encrypted, err := aesEncrypt(keys[:32], plaintext) - if err != nil { - return nil, err - } - return appendMAC(keys[32:], encrypted), nil -} - -func (cli *Client) UploadAttachment(ctx context.Context, body []byte) (*signalpb.AttachmentPointer, error) { +func UploadAttachment(ctx context.Context, device *Device, body []byte) (*signalpb.AttachmentPointer, error) { log := zerolog.Ctx(ctx).With().Str("func", "upload attachment").Logger() keys := random.Bytes(64) // combined AES and MAC keys plaintextLength := uint32(len(body)) @@ -261,42 +115,69 @@ func (cli *Client) UploadAttachment(ctx context.Context, body []byte) (*signalpb // Padded length uses exponential bracketing paddedLen := int(math.Max(541, math.Floor(math.Pow(1.05, math.Ceil(math.Log(float64(len(body)))/math.Log(1.05)))))) if paddedLen < len(body) { - log.Panic(). + log.Debug(). Int("padded_len", paddedLen). Int("len", len(body)). - Msg("Math error: padded length is less than body length") + Msg("Padded length is less than body length, continuing with a privacy risk") + } else { + body = append(body, bytes.Repeat([]byte{0}, int(paddedLen)-len(body))...) } - body = extend(body, paddedLen) - encryptedWithMAC, err := macAndAESEncrypt(keys, body) + encrypted, err := aesEncrypt(keys[:32], body) if err != nil { return nil, err } + encryptedWithMAC := appendMAC(keys[32:], encrypted) // Get upload attributes from Signal server - attributesPath := "/v4/attachments/form/upload" - resp, err := cli.AuthedWS.SendRequest(ctx, http.MethodGet, attributesPath, nil, nil) + attributesPath := "/v3/attachments/form/upload" + username, password := device.Data.BasicAuthCreds() + opts := &web.HTTPReqOpt{Username: &username, Password: &password} + resp, err := web.SendHTTPRequest(http.MethodGet, attributesPath, opts) if err != nil { - log.Err(err).Msg("Failed to request upload attributes") - return nil, fmt.Errorf("failed to request upload attributes: %w", err) - } - var uploadAttributes attachmentV4UploadAttributes - err = web.DecodeWSResponseBody(ctx, &uploadAttributes, resp) - if err != nil { - log.Err(err).Msg("Failed to decode upload attributes") - return nil, fmt.Errorf("failed to decode upload attributes: %w", err) - } - if uploadAttributes.Cdn == 3 { - log.Trace().Msg("Using TUS upload") - err = cli.uploadAttachmentTUS(ctx, uploadAttributes, encryptedWithMAC) - } else { - log.Trace().Msg("Using legacy upload") - err = cli.uploadAttachmentLegacy(ctx, uploadAttributes, encryptedWithMAC) - } - if err != nil { - log.Err(err).Msg("Failed to upload attachment") + log.Err(err).Msg("Error sending request fetching upload attributes") return nil, err } + var uploadAttributes attachmentV3UploadAttributes + err = web.DecodeHTTPResponseBody(ctx, &uploadAttributes, resp) + if err != nil { + log.Err(err).Msg("Error decoding response body fetching upload attributes") + return nil, err + } + + // Allocate attachment on CDN + resp, err = web.SendHTTPRequest(http.MethodPost, "", &web.HTTPReqOpt{ + OverrideURL: uploadAttributes.SignedUploadLocation, + ContentType: web.ContentTypeOctetStream, + Headers: uploadAttributes.Headers, + Username: &username, + Password: &password, + }) + if err != nil { + log.Err(err).Msg("Error sending request allocating attachment") + return nil, err + } + if resp.StatusCode < 200 || resp.StatusCode >= 300 { + log.Error().Int("status_code", resp.StatusCode).Msg("Error allocating attachment") + return nil, fmt.Errorf("error allocating attachment: %s", resp.Status) + } + + // Upload attachment to CDN + resp, err = web.SendHTTPRequest(http.MethodPut, "", &web.HTTPReqOpt{ + OverrideURL: resp.Header.Get("Location"), + Body: encryptedWithMAC, + ContentType: web.ContentTypeOctetStream, + Username: &username, + Password: &password, + }) + if err != nil { + log.Err(err).Msg("Error sending request uploading attachment") + return nil, err + } + if resp.StatusCode < 200 || resp.StatusCode >= 300 { + log.Error().Int("status_code", resp.StatusCode).Msg("Error uploading attachment") + return nil, fmt.Errorf("error uploading attachment: %s", resp.Status) + } digest := sha256.Sum256(encryptedWithMAC) @@ -313,155 +194,6 @@ func (cli *Client) UploadAttachment(ctx context.Context, body []byte) (*signalpb return attachmentPointer, nil } -func (cli *Client) uploadAttachmentLegacy( - ctx context.Context, - uploadAttributes attachmentV4UploadAttributes, - encryptedWithMAC []byte, -) error { - username, password := cli.Store.BasicAuthCreds() - // Allocate attachment on CDN - resp, err := web.SendHTTPRequest(ctx, "", http.MethodPost, "", &web.HTTPReqOpt{ - OverrideURL: uploadAttributes.SignedUploadLocation, - ContentType: web.ContentTypeOctetStream, - Headers: uploadAttributes.Headers, - Username: &username, - Password: &password, - }) - web.CloseBody(resp) - if err != nil { - return fmt.Errorf("failed to send allocate request: %w", err) - } else if resp.StatusCode < 200 || resp.StatusCode >= 300 { - return fmt.Errorf("allocate request returned HTTP %d", resp.StatusCode) - } - - // Upload attachment to CDN - resp, err = web.SendHTTPRequest(ctx, "", http.MethodPut, "", &web.HTTPReqOpt{ - OverrideURL: resp.Header.Get("Location"), - Body: encryptedWithMAC, - ContentType: web.ContentTypeOctetStream, - Username: &username, - Password: &password, - }) - web.CloseBody(resp) - if err != nil { - return fmt.Errorf("failed to send upload request: %w", err) - } else if resp.StatusCode < 200 || resp.StatusCode >= 300 { - return fmt.Errorf("upload request returned HTTP %d", resp.StatusCode) - } - return nil -} - -func (cli *Client) uploadAttachmentTUS( - ctx context.Context, - uploadAttributes attachmentV4UploadAttributes, - encryptedWithMAC []byte, -) error { - uploadAttributes.Headers["Tus-Resumable"] = "1.0.0" - uploadAttributes.Headers["Upload-Length"] = fmt.Sprintf("%d", len(encryptedWithMAC)) - uploadAttributes.Headers["Upload-Metadata"] = "filename " + base64.StdEncoding.EncodeToString([]byte(uploadAttributes.Key)) - - resp, err := web.SendHTTPRequest(ctx, "", http.MethodPost, "", &web.HTTPReqOpt{ - OverrideURL: uploadAttributes.SignedUploadLocation, - Body: encryptedWithMAC, - ContentType: web.ContentTypeOffsetOctetStream, - Headers: uploadAttributes.Headers, - }) - web.CloseBody(resp) - // TODO actually support resuming on error - if err != nil { - return fmt.Errorf("failed to send upload request: %w", err) - } else if resp.StatusCode < 200 || resp.StatusCode >= 300 { - zerolog.Ctx(ctx).Debug(). - Any("request_headers", uploadAttributes.Headers). - Any("response_headers", resp.Header). - Str("location", uploadAttributes.SignedUploadLocation). - Msg("TUS upload failed") - return fmt.Errorf("upload request returned HTTP %d", resp.StatusCode) - } - return nil -} - -func (cli *Client) UploadGroupAvatar(ctx context.Context, avatarBytes []byte, gid types.GroupIdentifier, groupMasterKey types.SerializedGroupMasterKey) (string, error) { - log := zerolog.Ctx(ctx) - if groupMasterKey == "" { - var err error - groupMasterKey, err = cli.Store.GroupStore.MasterKeyFromGroupIdentifier(ctx, gid) - if err != nil { - log.Err(err).Msg("Could not get master key from group id") - return "", err - } else if groupMasterKey == "" { - return "", fmt.Errorf("no master key found for group %s", gid) - } - } - groupAuth, err := cli.GetAuthorizationForToday(ctx, masterKeyToBytes(groupMasterKey)) - if err != nil { - log.Err(err).Msg("Failed to get Authorization for today") - return "", err - } - groupSecretParams, err := libsignalgo.DeriveGroupSecretParamsFromMasterKey(masterKeyToBytes(groupMasterKey)) - if err != nil { - log.Err(err).Msg("Could not get groupSecretParams from master key") - return "", err - } - attributeBlob := signalpb.GroupAttributeBlob{Content: &signalpb.GroupAttributeBlob_Avatar{Avatar: avatarBytes}} - encryptedAvatar, err := encryptBlobIntoGroupProperty(groupSecretParams, &attributeBlob) - if err != nil { - log.Err(err).Msg("Could not encrypt avatar into Group Property") - return "", err - } - - // Get upload form from Signal server - formPath := "/v2/groups/avatar/form" - opts := &web.HTTPReqOpt{Username: &groupAuth.Username, Password: &groupAuth.Password, ContentType: web.ContentTypeProtobuf} - resp, err := web.SendHTTPRequest(ctx, web.StorageHostname, http.MethodGet, formPath, opts) - if err != nil { - log.Err(err).Msg("Error sending request fetching avatar upload form") - return "", err - } - body, err := io.ReadAll(resp.Body) - web.CloseBody(resp) - if err != nil { - log.Err(err).Msg("Error decoding response body fetching upload attributes") - return "", err - } - uploadForm := signalpb.AvatarUploadAttributes{} - err = proto.Unmarshal(body, &uploadForm) - if err != nil { - log.Err(err).Msg("failed to unmarshal group avatar upload form") - return "", err - } - requestBody := &bytes.Buffer{} - w := multipart.NewWriter(requestBody) - w.WriteField("key", uploadForm.Key) - w.WriteField("x-amz-credential", uploadForm.Credential) - w.WriteField("acl", uploadForm.Acl) - w.WriteField("x-amz-algorithm", uploadForm.Algorithm) - w.WriteField("x-amz-date", uploadForm.Date) - w.WriteField("policy", uploadForm.Policy) - w.WriteField("x-amz-signature", uploadForm.Signature) - w.WriteField("Content-Type", "application/octet-stream") - filewriter, _ := w.CreateFormFile("file", "file") - filewriter.Write(*encryptedAvatar) - w.Close() - - // Upload avatar to CDN - resp, err = web.SendHTTPRequest(ctx, web.CDN1Hostname, http.MethodPost, "", &web.HTTPReqOpt{ - Body: requestBody.Bytes(), - ContentType: web.ContentType(w.FormDataContentType()), - }) - web.CloseBody(resp) - if err != nil { - log.Err(err).Msg("Error sending request uploading attachment") - return "", err - } - if resp.StatusCode < 200 || resp.StatusCode >= 300 { - log.Error().Int("status_code", resp.StatusCode).Msg("Error uploading attachment") - return "", fmt.Errorf("error uploading attachment: %s", resp.Status) - } - - return uploadForm.Key, nil -} - func verifyMAC(key, body, mac []byte) bool { m := hmac.New(sha256.New, key) m.Write(body) @@ -478,56 +210,14 @@ func aesDecrypt(key, ciphertext []byte) ([]byte, error) { return nil, fmt.Errorf("ciphertext not multiple of AES blocksize (%d extra bytes)", len(ciphertext)%aes.BlockSize) } - iv := ciphertext[:IVLength] - ciphertext = ciphertext[IVLength:] + iv := ciphertext[:aes.BlockSize] mode := cipher.NewCBCDecrypter(block, iv) mode.CryptBlocks(ciphertext, ciphertext) - return pkcs7.Unpad(ciphertext) -} - -func aesDecryptFile(key []byte, file *os.File, downloadedSize int64) (int64, error) { - block, err := aes.NewCipher(key) - if err != nil { - return 0, err - } - fileReader := io.LimitReader(file, downloadedSize) - - if downloadedSize%aes.BlockSize != 0 { - return 0, fmt.Errorf("ciphertext not multiple of AES blocksize (%d extra bytes)", downloadedSize%aes.BlockSize) - } - - iv := make([]byte, IVLength) - n, err := fileReader.Read(iv) - if err != nil { - return 0, fmt.Errorf("failed to read IV from attachment file: %w", err) - } else if n != IVLength { - return 0, fmt.Errorf("unexpected IV length read from attachment file: %d", n) - } - mode := cipher.NewCBCDecrypter(block, iv) - buf := make([]byte, 4096) - var offset int64 - var pad byte - for { - n, err = fileReader.Read(buf) - if err != nil && !errors.Is(err, io.EOF) { - return 0, fmt.Errorf("failed to read from attachment file: %w", err) - } - if n > 0 { - mode.CryptBlocks(buf[:n], buf[:n]) - if _, err = file.WriteAt(buf[:n], offset); err != nil { - return 0, fmt.Errorf("failed to write decrypted data to attachment file: %w", err) - } - offset += int64(n) - pad = buf[n-1] - } - if errors.Is(err, io.EOF) { - break - } - } + pad := ciphertext[len(ciphertext)-1] if pad > aes.BlockSize { - return 0, fmt.Errorf("pad value (%d) larger than AES blocksize (%d)", pad, aes.BlockSize) + return nil, fmt.Errorf("pad value (%d) larger than AES blocksize (%d)", pad, aes.BlockSize) } - return downloadedSize - int64(pad), nil + return ciphertext[aes.BlockSize : len(ciphertext)-int(pad)], nil } func appendMAC(key, body []byte) []byte { @@ -542,11 +232,14 @@ func aesEncrypt(key, plaintext []byte) ([]byte, error) { return nil, err } - plaintext = pkcs7.Pad(plaintext, aes.BlockSize) + pad := aes.BlockSize - len(plaintext)%aes.BlockSize + plaintext = append(plaintext, bytes.Repeat([]byte{byte(pad)}, pad)...) + + ciphertext := make([]byte, len(plaintext)) iv := random.Bytes(16) mode := cipher.NewCBCEncrypter(block, iv) - mode.CryptBlocks(plaintext, plaintext) + mode.CryptBlocks(ciphertext, plaintext) - return append(iv, plaintext...), nil + return append(iv, ciphertext...), nil } diff --git a/pkg/signalmeow/attachments_stream.go b/pkg/signalmeow/attachments_stream.go deleted file mode 100644 index 1dcd9f9..0000000 --- a/pkg/signalmeow/attachments_stream.go +++ /dev/null @@ -1,178 +0,0 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2025 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package signalmeow - -import ( - "bufio" - "crypto/aes" - "crypto/cipher" - "crypto/hmac" - "crypto/sha256" - "encoding/binary" - "errors" - "fmt" - "hash" - "io" - "os" - - "google.golang.org/protobuf/proto" -) - -func verifyMACStream(hmacKey [32]byte, input io.Reader, totalSize int64) (bool, error) { - if totalSize <= 0 { - file, ok := input.(*os.File) - if ok { - stat, err := file.Stat() - if err != nil { - return false, fmt.Errorf("failed to stat file: %w", err) - } - totalSize = stat.Size() - } else { - return false, fmt.Errorf("total size is unknown") - } - } - hasher := hmac.New(sha256.New, hmacKey[:]) - _, err := io.CopyN(hasher, input, totalSize-MACLength) - if err != nil { - return false, fmt.Errorf("failed to hash file: %w", err) - } - actualHash := hasher.Sum(nil) - expectedHash := make([]byte, MACLength) - _, err = io.ReadFull(input, expectedHash) - if err != nil { - return false, fmt.Errorf("failed to read hash: %w", err) - } - return hmac.Equal(expectedHash, actualHash), nil -} - -type decryptingReader struct { - input io.Reader - cipher cipher.BlockMode - hasher hash.Hash - aesKey *[32]byte - remainingSize int64 -} - -func (dr *decryptingReader) Read(p []byte) (int, error) { - if dr.remainingSize == 0 { - return 0, io.EOF - } else if len(p) < aes.BlockSize { - return 0, fmt.Errorf("buffer too small (must be at least %d bytes)", aes.BlockSize) - } - if dr.cipher == nil { - iv := make([]byte, IVLength) - _, err := io.ReadFull(dr.input, iv) - if err != nil { - return 0, fmt.Errorf("failed to read IV: %w", err) - } - block, err := aes.NewCipher(dr.aesKey[:]) - if err != nil { - return 0, fmt.Errorf("failed to create cipher: %w", err) - } - dr.cipher = cipher.NewCBCDecrypter(block, iv) - dr.hasher.Write(iv) - } - maxLen := int64(len(p) - len(p)%aes.BlockSize) - if maxLen > dr.remainingSize { - maxLen = dr.remainingSize - } - p = p[:maxLen] - _, err := io.ReadFull(dr.input, p) - if err != nil { - return 0, err - } - dr.remainingSize -= maxLen - dr.hasher.Write(p) - dr.cipher.CryptBlocks(p, p) - if dr.remainingSize == 0 { - p, err = UnpadPKCS7(p) - if err != nil { - return 0, fmt.Errorf("failed to unpad: %w", err) - } - expectedMAC := make([]byte, MACLength) - _, err = io.ReadFull(dr.input, expectedMAC) - if err != nil { - return 0, fmt.Errorf("failed to read MAC: %w", err) - } - actualMAC := dr.hasher.Sum(nil) - if !hmac.Equal(expectedMAC, actualMAC) { - return 0, fmt.Errorf("hmac mismatch") - } - } - return len(p), nil -} - -func (dr *decryptingReader) Close() error { - if dr.remainingSize != 0 { - return fmt.Errorf("unexpected remaining size %d", dr.remainingSize) - } - return nil -} - -func aesDecryptStream(aesKey, macKey [32]byte, input io.Reader, totalSize int64) io.ReadCloser { - return &decryptingReader{ - aesKey: &aesKey, - hasher: hmac.New(sha256.New, macKey[:]), - input: input, - remainingSize: totalSize - MACLength - IVLength, - } -} - -func splitChunksStream(input io.Reader, callback func([]byte) error) error { - byteReader, ok := input.(io.ByteReader) - if !ok { - bufInput := bufio.NewReader(input) - byteReader = bufInput - input = bufInput - } - var cachedBuf []byte - for { - msgLen, err := binary.ReadUvarint(byteReader) - if errors.Is(err, io.EOF) { - return nil - } else if err != nil { - return fmt.Errorf("failed to read chunk length: %w", err) - } - if msgLen == 0 { - continue - } - if msgLen > uint64(len(cachedBuf)) { - cachedBuf = make([]byte, max(msgLen, 8192)) - } - buf := cachedBuf[:msgLen] - _, err = io.ReadFull(input, buf) - if err != nil { - return fmt.Errorf("failed to read chunk: %w", err) - } - err = callback(buf) - if err != nil { - return err - } - } -} - -func splitProtoChunksStream[ChunkType proto.Message](input io.Reader, callback func(ChunkType) error) error { - protoReflect := (*new(ChunkType)).ProtoReflect() - return splitChunksStream(input, func(buf []byte) error { - msg := protoReflect.New().Interface().(ChunkType) - err := proto.Unmarshal(buf, msg) - if err != nil { - return fmt.Errorf("failed to unmarshal chunk: %w", err) - } - return callback(msg) - }) -} diff --git a/pkg/signalmeow/backup.go b/pkg/signalmeow/backup.go deleted file mode 100644 index f003e19..0000000 --- a/pkg/signalmeow/backup.go +++ /dev/null @@ -1,310 +0,0 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2025 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package signalmeow - -import ( - "bufio" - "compress/gzip" - "context" - "crypto/hmac" - "encoding/json" - "errors" - "fmt" - "io" - "net/http" - "os" - "strconv" - "time" - - "github.com/rs/zerolog" - "google.golang.org/protobuf/proto" - - "go.mau.fi/mautrix-signal/pkg/libsignalgo" - "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf/backuppb" - "go.mau.fi/mautrix-signal/pkg/signalmeow/web" -) - -const transferArchiveFetchTimeout = 1 * time.Hour - -var ( - ErrNoEphemeralBackupKey = errors.New("no ephemeral backup key") -) - -const ( - TransferErrorRelinkRequested = "RELINK_REQUESTED" - TransferErrorContinueWithoutUpload = "CONTINUE_WITHOUT_UPLOAD" -) - -type TransferArchiveMetadata struct { - CDN uint32 `json:"cdn"` - Key string `json:"key"` - Error string `json:"error"` // RELINK_REQUESTED or CONTINUE_WITHOUT_UPLOAD -} - -func (cli *Client) FetchAndProcessTransfer(ctx context.Context, meta *TransferArchiveMetadata) error { - if meta.Error != "" { - return fmt.Errorf("transfer archive error: %s", meta.Error) - } - aesKey, hmacKey, err := cli.deriveTransferKeys() - if err != nil { - return fmt.Errorf("failed to derive transfer keys: %w", err) - } - file, err := os.CreateTemp("", "signalmeow-transfer-archive-*") - if err != nil { - return fmt.Errorf("failed to create temporary file: %w", err) - } - defer func() { - _ = file.Close() - _ = os.Remove(file.Name()) - }() - err = downloadTransferArchive(ctx, meta, file) - if err != nil { - return err - } - _, err = file.Seek(0, io.SeekStart) - if err != nil { - return fmt.Errorf("failed to seek to start of file: %w", err) - } - stat, err := file.Stat() - if err != nil { - return fmt.Errorf("failed to stat file: %w", err) - } - ok, err := verifyMACStream(hmacKey, file, stat.Size()) - if err != nil { - return fmt.Errorf("failed to verify MAC: %w", err) - } else if !ok { - return fmt.Errorf("checksum mismatch") - } - _, err = file.Seek(0, io.SeekStart) - if err != nil { - return fmt.Errorf("failed to seek to start of file: %w", err) - } - err = cli.Store.DoContactTxn(ctx, func(ctx context.Context) error { - err = cli.Store.BackupStore.ClearBackup(ctx) - if err != nil { - return fmt.Errorf("failed to clear backup: %w", err) - } - err = cli.processTransferArchive(ctx, aesKey, hmacKey, file, stat.Size()) - if err != nil { - return err - } - err = cli.Store.BackupStore.RecalculateChatCounts(ctx) - if err != nil { - return fmt.Errorf("failed to calculate message counts: %w", err) - } - cli.Store.EphemeralBackupKey = nil - err = cli.Store.DeviceStore.PutDevice(ctx, &cli.Store.DeviceData) - if err != nil { - return fmt.Errorf("failed to save device data after clearing ephemeral backup key: %w", err) - } - return nil - }) - if err != nil { - return err - } - return nil -} - -func (cli *Client) processTransferArchive(ctx context.Context, aesKey, hmacKey [32]byte, file io.Reader, size int64) error { - decrypter := aesDecryptStream(aesKey, hmacKey, file, size) - bufDecrypted := bufio.NewReader(decrypter) - decompressor, err := gzip.NewReader(bufDecrypted) - if err != nil { - return fmt.Errorf("failed to create gzip reader: %w", err) - } - // There's an unknown amount of zero padding after the gzip stream, - // so tell gzip not to try to read another stream after the first one. - decompressor.Multistream(false) - err = splitChunksStream(decompressor, (&archiveChunkProcessor{cli: cli, ctx: ctx}).processChunk) - if err != nil { - return err - } - err = decompressor.Close() - if err != nil { - return fmt.Errorf("failed to close gzip reader: %w", err) - } - zeroBuf := make([]byte, 256) - var n int - // Validate that the zero padding is really all zeroes. This will also finish the hmac checking. - for { - n, err = bufDecrypted.Read(zeroBuf) - if errors.Is(err, io.EOF) && n == 0 { - break - } else if err != nil { - return fmt.Errorf("failed to read zero buffer: %w", err) - } - for i := 0; i < n; i++ { - if zeroBuf[i] != 0 { - return fmt.Errorf("unexpected data after decompression") - } - } - } - err = decrypter.Close() - if err != nil { - return fmt.Errorf("failed to close decryption reader: %w", err) - } - return nil -} - -type archiveChunkProcessor struct { - cli *Client - ctx context.Context - info *backuppb.BackupInfo -} - -const BackupVersion = 1 - -func (acp *archiveChunkProcessor) processChunk(buf []byte) error { - if acp.ctx.Err() != nil { - return acp.ctx.Err() - } - if acp.info == nil { - acp.info = &backuppb.BackupInfo{} - err := proto.Unmarshal(buf, acp.info) - if err != nil { - return fmt.Errorf("failed to unmarshal backup info: %w", err) - } else if acp.info.GetVersion() != BackupVersion { - return fmt.Errorf("unsupported backup version: %d", acp.info.GetVersion()) - } else if !hmac.Equal(acp.info.GetMediaRootBackupKey(), acp.cli.Store.MediaRootBackupKey[:]) { - return fmt.Errorf("media root backup key mismatch") - } - zerolog.Ctx(acp.ctx).Info().Any("backup_info", acp.info).Msg("Received backup info") - return nil - } - var frame backuppb.Frame - err := proto.Unmarshal(buf, &frame) - if err != nil { - return fmt.Errorf("failed to unmarshal frame: %w", err) - } - return acp.processFrame(&frame) -} - -func (acp *archiveChunkProcessor) processFrame(frame *backuppb.Frame) error { - acp.cli.Log.Trace().Any("backup_frame", frame).Msg("Processing backup frame") - switch item := frame.Item.(type) { - case *backuppb.Frame_Recipient: - if item.Recipient.Destination == nil { - zerolog.Ctx(acp.ctx).Debug().Msg("Ignoring recipient frame with no destination") - return nil - } - return acp.cli.Store.BackupStore.AddBackupRecipient(acp.ctx, item.Recipient) - case *backuppb.Frame_Chat: - return acp.cli.Store.BackupStore.AddBackupChat(acp.ctx, item.Chat) - case *backuppb.Frame_ChatItem: - switch item.ChatItem.Item.(type) { - case *backuppb.ChatItem_DirectStoryReplyMessage, *backuppb.ChatItem_UpdateMessage, nil: - zerolog.Ctx(acp.ctx).Debug(). - Uint64("chat_id", item.ChatItem.ChatId). - Uint64("message_id", item.ChatItem.DateSent). - Type("frame_type", item). - Msg("Not saving unsupported chat item type") - return nil - } - return acp.cli.Store.BackupStore.AddBackupChatItem(acp.ctx, item.ChatItem) - default: - zerolog.Ctx(acp.ctx).Debug().Type("frame_type", item).Msg("Ignoring backup frame") - return nil - } -} - -func (cli *Client) deriveTransferKeys() (aesKey, hmacKey [32]byte, err error) { - var backupID *libsignalgo.BackupID - var mbk *libsignalgo.MessageBackupKey - if cli.Store.EphemeralBackupKey == nil { - err = ErrNoEphemeralBackupKey - } else if backupID, err = cli.Store.EphemeralBackupKey.DeriveBackupID(cli.Store.ACIServiceID()); err != nil { - err = fmt.Errorf("failed to derive backup ID: %w", err) - } else if mbk, err = libsignalgo.MessageBackupKeyFromBackupKeyAndID(cli.Store.EphemeralBackupKey, backupID); err != nil { - err = fmt.Errorf("failed to derive message backup key: %w", err) - } else if aesKey, err = mbk.GetAESKey(); err != nil { - err = fmt.Errorf("failed to get AES key: %w", err) - } else if hmacKey, err = mbk.GetHMACKey(); err != nil { - err = fmt.Errorf("failed to get HMAC key: %w", err) - } - return -} - -func downloadTransferArchive(ctx context.Context, meta *TransferArchiveMetadata, writeTo io.Writer) error { - resp, err := web.GetAttachment(ctx, getAttachmentPath(0, meta.Key), meta.CDN) - if err != nil { - return fmt.Errorf("failed to download transfer archive: %w", err) - } - if writeToFile, ok := writeTo.(*os.File); ok { - fileInfo, err := writeToFile.Stat() - if err != nil { - return fmt.Errorf("failed to stat destination file: %w", err) - } - if size := fileInfo.Size(); size > 0 { - zerolog.Ctx(ctx).Debug().Int64("skip_count", size).Msg("Transfer archive already exists, skipping bytes") - _, err = io.CopyN(io.Discard, resp.Body, size) - if err != nil { - return fmt.Errorf("failed to skip existing bytes: %w", err) - } - } - } - _, err = io.Copy(writeTo, resp.Body) - if err != nil { - return fmt.Errorf("failed to write transfer archive to disk: %w", err) - } - return nil -} - -func (cli *Client) WaitForTransfer(ctx context.Context) (*TransferArchiveMetadata, error) { - if cli.Store.EphemeralBackupKey == nil { - return nil, ErrNoEphemeralBackupKey - } - timeout := time.Now().Add(transferArchiveFetchTimeout) - - for { - remainingTime := time.Until(timeout) - if remainingTime < 0 { - return nil, fmt.Errorf("timed out") - } - reqStart := time.Now() - reqTimeout := min(remainingTime, 5*time.Minute) - resp, err := cli.tryRequestTransferArchive(ctx, reqTimeout) - if resp != nil || err != nil { - return resp, err - } - reqDuration := time.Since(reqStart) - if reqDuration < reqTimeout-10*time.Second { - select { - case <-time.After(15 * time.Second): - case <-ctx.Done(): - return nil, ctx.Err() - } - } - } -} - -func (cli *Client) tryRequestTransferArchive(ctx context.Context, timeout time.Duration) (respBody *TransferArchiveMetadata, err error) { - reqCtx, cancel := context.WithTimeout(ctx, timeout+15*time.Second) - defer cancel() - path := "/v1/devices/transfer_archive?timeout=" + strconv.Itoa(int(timeout.Seconds())) - resp, err := cli.AuthedWS.SendRequest(reqCtx, http.MethodGet, path, nil, nil) - if err != nil { - return nil, err - } else if resp.GetStatus() == http.StatusNoContent { - return nil, nil - } else if resp.GetStatus() != http.StatusOK { - return nil, fmt.Errorf("unexpected status code %d", resp.GetStatus()) - } else if err = json.Unmarshal(resp.Body, &respBody); err != nil { - return nil, fmt.Errorf("failed to decode response: %w", err) - } else { - return respBody, nil - } -} diff --git a/pkg/signalmeow/client.go b/pkg/signalmeow/client.go deleted file mode 100644 index 57598cd..0000000 --- a/pkg/signalmeow/client.go +++ /dev/null @@ -1,147 +0,0 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2023 Scott Weber -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package signalmeow - -import ( - "context" - "encoding/json" - "errors" - "net/http" - "net/url" - "sync" - "time" - - "github.com/rs/zerolog" - "go.mau.fi/util/exsync" - - "go.mau.fi/mautrix-signal/pkg/libsignalgo" - "go.mau.fi/mautrix-signal/pkg/signalmeow/events" - signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" - "go.mau.fi/mautrix-signal/pkg/signalmeow/store" - "go.mau.fi/mautrix-signal/pkg/signalmeow/types" - "go.mau.fi/mautrix-signal/pkg/signalmeow/web" -) - -type Client struct { - Store *store.Device - Log zerolog.Logger - - senderCertificateWithE164 *libsignalgo.SenderCertificate - senderCertificateNoE164 *libsignalgo.SenderCertificate - senderCertificateCache sync.Mutex - - sendCache *exsync.RingBuffer[sendCacheKey, *signalpb.Content] - - GroupCache *GroupCache - ProfileCache *ProfileCache - LastContactRequestTime time.Time - SyncContactsOnConnect bool - - encryptionLock sync.Mutex - - AuthedWS *web.SignalWebsocket - UnauthedWS *web.SignalWebsocket - lastConnectionStatus SignalConnectionStatus - - loopCancel context.CancelFunc - loopWg sync.WaitGroup - - EventHandler func(events.SignalEvent) bool - - storageAuthLock sync.Mutex - storageAuth *basicExpiringCredentials - cdAuthLock sync.Mutex - cdAuth *basicExpiringCredentials - cdToken []byte - - writeCallbackCounter chan time.Time -} - -// InMemorySendCacheSize specifies how large the cache for sent messages is, which is used to respond to retry receipts. -// The cache is large because every group member will be listed separately. -// 2k entries should hold at least 2 messages in max size groups. -var InMemorySendCacheSize = 2048 - -func NewClient(device *store.Device, log zerolog.Logger, evtHandler func(events.SignalEvent) bool) *Client { - return &Client{ - Store: device, - Log: log, - EventHandler: evtHandler, - GroupCache: NewGroupCache(device.ACIServiceID()), - ProfileCache: &ProfileCache{ - profiles: make(map[string]*types.Profile), - errors: make(map[string]*error), - lastFetched: make(map[string]time.Time), - }, - sendCache: exsync.NewRingBuffer[sendCacheKey, *signalpb.Content](InMemorySendCacheSize), - } -} - -func (cli *Client) handleEvent(evt events.SignalEvent) bool { - return cli.EventHandler(evt) -} - -func (cli *Client) IsConnected() bool { - if cli == nil { - return false - } - return cli.AuthedWS.IsConnected() && cli.UnauthedWS.IsConnected() -} - -func (cli *Client) connectAuthedWS(ctx context.Context, requestHandler web.RequestHandlerFunc) (chan web.SignalWebsocketConnectionStatus, error) { - if cli.AuthedWS != nil { - return nil, errors.New("authed websocket already connected") - } - - username, password := cli.Store.BasicAuthCreds() - log := zerolog.Ctx(ctx).With(). - Str("websocket_type", "authed"). - Str("username", username). - Logger() - ctx = log.WithContext(ctx) - authedWS := web.NewSignalWebsocket(url.UserPassword(username, password)) - statusChan := authedWS.Connect(ctx, requestHandler) - cli.AuthedWS = authedWS - return statusChan, nil -} - -func (cli *Client) connectUnauthedWS(ctx context.Context) (chan web.SignalWebsocketConnectionStatus, error) { - if cli.UnauthedWS != nil { - return nil, errors.New("unauthed websocket already connected") - } - - log := zerolog.Ctx(ctx).With(). - Str("websocket_type", "unauthed"). - Logger() - ctx = log.WithContext(ctx) - unauthedWS := web.NewSignalWebsocket(nil) - statusChan := unauthedWS.Connect(ctx, nil) - cli.UnauthedWS = unauthedWS - return statusChan, nil -} - -func (cli *Client) IsLoggedIn() bool { - return cli.Store != nil && cli.Store.IsDeviceLoggedIn() -} - -func (cli *Client) GetRemoteConfig(ctx context.Context) (json.RawMessage, error) { - resp, err := cli.AuthedWS.SendRequest(ctx, http.MethodGet, "/v2/config", nil, nil) - if err != nil { - return nil, err - } - return resp.Body, web.DecodeWSResponseBody(ctx, nil, resp) -} diff --git a/pkg/signalmeow/contact.go b/pkg/signalmeow/contact.go index f30f54f..a2e8a7c 100644 --- a/pkg/signalmeow/contact.go +++ b/pkg/signalmeow/contact.go @@ -25,97 +25,222 @@ import ( "fmt" "net/http" "strings" - "time" "github.com/google/uuid" - "github.com/rs/zerolog" "google.golang.org/protobuf/proto" + "go.mau.fi/mautrix-signal/pkg/libsignalgo" signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" "go.mau.fi/mautrix-signal/pkg/signalmeow/types" ) -func (cli *Client) StoreContactDetailsAsContact(ctx context.Context, contactDetails *signalpb.ContactDetails, avatar *[]byte) (*types.Recipient, error) { - parsedUUID, err := ParseStringOrBinaryUUID(contactDetails.GetAci(), contactDetails.GetAciBinary()) +func StoreContactDetailsAsContact(d *Device, contactDetails *signalpb.ContactDetails, avatar *[]byte) (types.Contact, *types.ContactAvatar, error) { + ctx := context.TODO() + parsedUUID, err := uuid.Parse(contactDetails.GetAci()) if err != nil { - return nil, err + return types.Contact{}, nil, err } - ctx = zerolog.Ctx(ctx).With(). - Str("action", "store contact details as contact"). - Stringer("uuid", parsedUUID). - Logger().WithContext(ctx) - return cli.Store.RecipientStore.LoadAndUpdateRecipient(ctx, parsedUUID, uuid.Nil, func(recipient *types.Recipient) (bool, error) { - if contactDetails.GetNumber() != "" { - recipient.E164 = contactDetails.GetNumber() + existingContact, err := d.ContactStore.LoadContact(ctx, parsedUUID) + if err != nil { + zlog.Err(err).Msg("StoreContactDetailsAsContact error loading contact") + return types.Contact{}, nil, err + } + if existingContact == nil { + zlog.Debug().Msgf("StoreContactDetailsAsContact: creating new contact for uuid: %v", parsedUUID) + existingContact = &types.Contact{ + UUID: parsedUUID, } - recipient.ContactName = contactDetails.GetName() - //if profileKeyString := contactDetails.GetProfileKey(); profileKeyString != nil { - // profileKey := libsignalgo.ProfileKey(profileKeyString) - // recipient.Profile.Key = profileKey - //} - if avatar != nil && *avatar != nil && len(*avatar) > 0 { - rawHash := sha256.Sum256(*avatar) - avatarHash := hex.EncodeToString(rawHash[:]) + } else { + zlog.Debug().Msgf("StoreContactDetailsAsContact: updating existing contact for uuid: %v", parsedUUID) + } + + existingContact.E164 = contactDetails.GetNumber() + existingContact.ContactName = contactDetails.GetName() + if profileKeyString := contactDetails.GetProfileKey(); profileKeyString != nil { + existingContact.ProfileKey = profileKeyString + profileKey := libsignalgo.ProfileKey(profileKeyString) + err = d.ProfileKeyStore.StoreProfileKey(existingContact.UUID.String(), profileKey, ctx) + if err != nil { + zlog.Err(err).Msg("StoreContactDetailsAsContact error storing profile key") + //return *existingContact, nil, err + } + } + + // Check for avatar changes, and return ContactAvatar if it's changed + var contactAvatar *types.ContactAvatar + avatarHash := "" + if avatar != nil && *avatar != nil && len(*avatar) > 0 { + zlog.Debug().Msgf("StoreContactDetailsAsContact: found avatar for uuid: %v", contactDetails.GetAci()) + rawHash := sha256.Sum256(*avatar) + avatarHash = hex.EncodeToString(rawHash[:]) + if existingContact.ContactAvatarHash != avatarHash { + zlog.Debug().Msgf("StoreContactDetailsAsContact: avatar changed for uuid: %v", contactDetails.GetAci()) var contentType string if avatarDetails := contactDetails.GetAvatar(); avatarDetails != nil && !strings.HasSuffix(avatarDetails.GetContentType(), "/*") { contentType = *avatarDetails.ContentType + zlog.Debug().Msgf("StoreContactDetailsAsContact: using contentType from details: %v", contentType) } else { contentType = http.DetectContentType(*avatar) + zlog.Debug().Msgf("StoreContactDetailsAsContact: using autodetected contentType: %v", contentType) } - recipient.ContactAvatar = types.ContactAvatar{ + contactAvatar = &types.ContactAvatar{ Image: *avatar, ContentType: contentType, Hash: avatarHash, } + existingContact.ContactAvatarHash = avatarHash + } + } else { + // Avatar has been removed + zlog.Debug().Msgf("StoreContactDetailsAsContact: no avatar found for uuid: %v", contactDetails.GetAci()) + if existingContact.ContactAvatarHash != "" { + existingContact.ContactAvatarHash = "" } - return true, nil - }) -} - -func (cli *Client) fetchContactThenTryAndUpdateWithProfile(ctx context.Context, aci uuid.UUID, refreshAfter time.Duration) (*types.Recipient, error) { - log := zerolog.Ctx(ctx).With(). - Str("action", "fetch contact then try and update with profile"). - Stringer("profile_aci", aci). - Logger() - ctx = log.WithContext(ctx) - - profile, err := cli.RetrieveProfileByID(ctx, aci, refreshAfter) - if err != nil { - log.Debug().Err(err).Msg("Failed to fetch profile") - // Continue to return contact without profile } - return cli.Store.RecipientStore.LoadAndUpdateRecipient(ctx, aci, uuid.Nil, func(recipient *types.Recipient) (changed bool, err error) { - if profile != nil { - // Don't bother saving every fetched timestamp to the database, but save if anything else changed - if !recipient.Profile.Equals(profile) || recipient.Profile.FetchedAt.IsZero() { - changed = true - } - recipient.Profile = *profile - } - return - }) + + zlog.Debug().Msgf("StoreContactDetailsAsContact: storing contact for uuid: %v", contactDetails.GetAci()) + storeErr := d.ContactStore.StoreContact(ctx, *existingContact) + if storeErr != nil { + zlog.Err(storeErr).Msg("StoreContactDetailsAsContact: error storing contact") + return *existingContact, nil, storeErr + } + return *existingContact, contactAvatar, nil } -func (cli *Client) ContactByACI(ctx context.Context, aci uuid.UUID) (*types.Recipient, error) { - return cli.fetchContactThenTryAndUpdateWithProfile(ctx, aci, DefaultProfileRefreshAfter) -} +func fetchContactThenTryAndUpdateWithProfile(d *Device, profileUuid uuid.UUID, fetchProfileAvatar bool) (*types.Contact, *types.ContactAvatar, error) { + ctx := context.TODO() + contactChanged := false -func (cli *Client) ContactByACIWithRefreshAfter(ctx context.Context, aci uuid.UUID, refreshAfter time.Duration) (*types.Recipient, error) { - return cli.fetchContactThenTryAndUpdateWithProfile(ctx, aci, refreshAfter) -} - -func (cli *Client) ContactByE164(ctx context.Context, e164 string) (*types.Recipient, error) { - contact, err := cli.Store.RecipientStore.LoadRecipientByE164(ctx, e164) + existingContact, err := d.ContactStore.LoadContact(ctx, profileUuid) if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("ContactByE164 error loading contact") + zlog.Err(err).Msg("fetchContactThenTryAndUpdateWithProfile: error loading contact") + return nil, nil, err + } + if existingContact == nil { + zlog.Debug().Msgf("fetchContactThenTryAndUpdateWithProfile: creating new contact for uuid: %v", profileUuid) + existingContact = &types.Contact{ + UUID: profileUuid, + } + contactChanged = true + } else { + zlog.Debug().Msgf("fetchContactThenTryAndUpdateWithProfile: updating existing contact for uuid: %v", profileUuid) + } + var profile *Profile + var profileAvatarImage []byte + if fetchProfileAvatar && existingContact.ContactAvatarHash == "" { + // We only care about profile avatar if there is no contact avatar + profile, profileAvatarImage, err = RetrieveProfileAndAvatarByID(ctx, d, profileUuid) + } else { + profile, err = RetrieveProfileByID(ctx, d, profileUuid) + } + if err != nil { + zlog.Err(err).Msgf("fetchContactThenTryAndUpdateWithProfile: error retrieving profile for uuid: %v", profileUuid) + //return nil, nil, err + // Don't return here, we still want to return what we have + } + + if profile != nil { + if existingContact.ProfileName != profile.Name { + zlog.Debug().Msgf("fetchContactThenTryAndUpdateWithProfile: profile name changed for uuid: %v", profileUuid) + existingContact.ProfileName = profile.Name + contactChanged = true + } + if existingContact.ProfileAbout != profile.About { + zlog.Debug().Msgf("fetchContactThenTryAndUpdateWithProfile: profile about changed for uuid: %v", profileUuid) + existingContact.ProfileAbout = profile.About + contactChanged = true + } + if existingContact.ProfileAboutEmoji != profile.AboutEmoji { + zlog.Debug().Msgf("fetchContactThenTryAndUpdateWithProfile: profile about emoji changed for uuid: %v", profileUuid) + existingContact.ProfileAboutEmoji = profile.AboutEmoji + contactChanged = true + } + newProfileKey := profile.Key.Slice() + if !bytes.Equal(existingContact.ProfileKey, newProfileKey) { + zlog.Debug().Msgf("fetchContactThenTryAndUpdateWithProfile: profile key changed for uuid: %v", profileUuid) + existingContact.ProfileKey = newProfileKey + contactChanged = true + } + } + + var profileAvatar *types.ContactAvatar + if len(profileAvatarImage) > 0 { + // Avatar has changed according to profile cache + rawHash := sha256.Sum256(profileAvatarImage) + avatarHash := hex.EncodeToString(rawHash[:]) + if existingContact.ProfileAvatarHash != avatarHash { + profileAvatar = &types.ContactAvatar{ + Image: profileAvatarImage, + ContentType: http.DetectContentType(profileAvatarImage), + Hash: avatarHash, + } + existingContact.ProfileAvatarHash = avatarHash + contactChanged = true + } + } + + if contactChanged { + storeErr := d.ContactStore.StoreContact(ctx, *existingContact) + if storeErr != nil { + zlog.Err(storeErr).Msg("fetchContactThenTryAndUpdateWithProfile: error storing contact") + } + } + return existingContact, profileAvatar, nil +} + +func (d *Device) UpdateContactE164(uuid uuid.UUID, e164 string) error { + ctx := context.TODO() + existingContact, err := d.ContactStore.LoadContact(ctx, uuid) + if err != nil { + zlog.Err(err).Msg("UpdateContactE164: error loading contact") + return err + } + if existingContact == nil { + zlog.Debug().Msgf("UpdateContactE164: creating new contact for uuid: %v", uuid) + existingContact = &types.Contact{ + UUID: uuid, + } + } else { + zlog.Debug().Msgf("UpdateContactE164: found existing contact for uuid: %v", uuid) + } + if existingContact.E164 != e164 { + zlog.Debug().Msgf("UpdateContactE164: e164 changed for uuid: %v", uuid) + existingContact.E164 = e164 + storeErr := d.ContactStore.StoreContact(ctx, *existingContact) + if storeErr != nil { + zlog.Err(storeErr).Msg("UpdateContactE164: error storing contact") + return storeErr + } + } + return nil +} + +// ContactAvatar is only populated if there is no contact avatar, and the profile the avatar has changed +// If there is a contact avatar, it will have to have been updated when the contact is sent, we can't fetch on demand +func (d *Device) ContactByIDWithProfileAvatar(uuid uuid.UUID) (*types.Contact, *types.ContactAvatar, error) { + // Update the profile (we can call this liberally, there's a cache backing it) + // We can just return the result of this, ContactAvatar will be nil if there's no change or if there is a contact avatar + return fetchContactThenTryAndUpdateWithProfile(d, uuid, true) +} + +func (d *Device) ContactByID(uuid uuid.UUID) (*types.Contact, error) { + // Update the profile (we can call this liberally, there's a cache backing it) + contact, _, err := fetchContactThenTryAndUpdateWithProfile(d, uuid, false) + return contact, err +} + +func (d *Device) ContactByE164(e164 string) (*types.Contact, error) { + ctx := context.TODO() + contact, err := d.ContactStore.LoadContactByE164(ctx, e164) + if err != nil { + zlog.Err(err).Msg("ContactByE164 error loading contact") return nil, err } if contact == nil { return nil, nil } - if contact.ACI != uuid.Nil { - contact, err = cli.fetchContactThenTryAndUpdateWithProfile(ctx, contact.ACI, DefaultProfileRefreshAfter) - } + // Update profile information (we can call this liberally, there's a cache backing it) + contact, _, err = fetchContactThenTryAndUpdateWithProfile(d, contact.UUID, false) return contact, err } diff --git a/pkg/signalmeow/contact_store.go b/pkg/signalmeow/contact_store.go new file mode 100644 index 0000000..0d11978 --- /dev/null +++ b/pkg/signalmeow/contact_store.go @@ -0,0 +1,153 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2023 Scott Weber +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package signalmeow + +import ( + "context" + "database/sql" + "errors" + + "github.com/google/uuid" + + "go.mau.fi/mautrix-signal/pkg/signalmeow/types" +) + +var _ ContactStore = (*SQLStore)(nil) + +type ContactStore interface { + LoadContact(ctx context.Context, theirUUID uuid.UUID) (*types.Contact, error) + LoadContactByE164(ctx context.Context, e164 string) (*types.Contact, error) + StoreContact(ctx context.Context, contact types.Contact) error + AllContacts(ctx context.Context) ([]types.Contact, error) +} + +func scanContact(row scannable) (*types.Contact, error) { + var contact types.Contact + err := row.Scan( + &contact.UUID, + &contact.E164, + &contact.ContactName, + &contact.ContactAvatarHash, + &contact.ProfileKey, + &contact.ProfileName, + &contact.ProfileAbout, + &contact.ProfileAboutEmoji, + &contact.ProfileAvatarHash, + ) + if errors.Is(err, sql.ErrNoRows) { + return nil, nil + } else if err != nil { + return nil, err + } + return &contact, err +} + +var commonSelectQuery = ` + SELECT + aci_uuid, + e164_number, + contact_name, + contact_avatar_hash, + profile_key, + profile_name, + profile_about, + profile_about_emoji, + profile_avatar_hash + FROM signalmeow_contacts + ` + +func (s *SQLStore) LoadContact(ctx context.Context, theirUUID uuid.UUID) (*types.Contact, error) { + contactQuery := commonSelectQuery + + `WHERE our_aci_uuid = $1 AND aci_uuid = $2` + return scanContact(s.db.QueryRow(contactQuery, s.AciUuid, theirUUID)) +} + +func (s *SQLStore) LoadContactByE164(ctx context.Context, e164 string) (*types.Contact, error) { + contactQuery := commonSelectQuery + + `WHERE our_aci_uuid = $1 AND e164_number = $2` + return scanContact(s.db.QueryRow(contactQuery, s.AciUuid, e164)) +} + +func (s *SQLStore) AllContacts(ctx context.Context) ([]types.Contact, error) { + contactQuery := commonSelectQuery + + `WHERE our_aci_uuid = $1` + rows, err := s.db.Query(contactQuery, s.AciUuid) + if err != nil { + return nil, err + } + defer rows.Close() + var contacts []types.Contact + for rows.Next() { + contact, err := scanContact(rows) + if err != nil { + return nil, err + } + contacts = append(contacts, *contact) + } + return contacts, nil +} + +func (s *SQLStore) StoreContact(ctx context.Context, contact types.Contact) error { + storeContactQuery := ` + INSERT INTO signalmeow_contacts ( + our_aci_uuid, + aci_uuid, + e164_number, + contact_name, + contact_avatar_hash, + profile_key, + profile_name, + profile_about, + profile_about_emoji, + profile_avatar_hash + ) + VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) + ON CONFLICT (our_aci_uuid, aci_uuid) DO UPDATE SET + e164_number = excluded.e164_number, + contact_name = excluded.contact_name, + contact_avatar_hash = excluded.contact_avatar_hash, + profile_key = excluded.profile_key, + profile_name = excluded.profile_name, + profile_about = excluded.profile_about, + profile_about_emoji = excluded.profile_about_emoji, + profile_avatar_hash = excluded.profile_avatar_hash + ` + tx, err := s.db.BeginTx(ctx, nil) + if err != nil { + tx.Rollback() + return err + } + _, err = tx.Exec( + storeContactQuery, + s.AciUuid, + contact.UUID, + contact.E164, + contact.ContactName, + contact.ContactAvatarHash, + contact.ProfileKey, + contact.ProfileName, + contact.ProfileAbout, + contact.ProfileAboutEmoji, + contact.ProfileAvatarHash, + ) + if err != nil { + tx.Rollback() + return err + } + err = tx.Commit() + return err +} diff --git a/pkg/signalmeow/contactdiscovery.go b/pkg/signalmeow/contactdiscovery.go deleted file mode 100644 index 07d9b49..0000000 --- a/pkg/signalmeow/contactdiscovery.go +++ /dev/null @@ -1,260 +0,0 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2024 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package signalmeow - -import ( - "context" - "encoding/binary" - "encoding/hex" - "errors" - "fmt" - "net/url" - "path" - "sync" - "time" - - "github.com/coder/websocket" - "github.com/google/uuid" - "github.com/rs/zerolog" - "github.com/tidwall/gjson" - "go.mau.fi/util/exerrors" - "google.golang.org/protobuf/proto" - - "go.mau.fi/mautrix-signal/pkg/libsignalgo" - signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" - "go.mau.fi/mautrix-signal/pkg/signalmeow/web" -) - -const ProdContactDiscoveryServer = "cdsi.signal.org" -const ProdContactDiscoveryMrenclave = "ee9503070127120074612b6688e593b67e486b1541449f54d71e387484eb40a3" -const ContactDiscoveryAuthTTL = 23 * time.Hour - -const rateLimitCloseCode = websocket.StatusCode(4008) - -var prodContactDiscoveryMrenclaveBytes = exerrors.Must(hex.DecodeString(ProdContactDiscoveryMrenclave)) - -type ContactDiscoveryRateLimitError struct { - RetryAfter time.Duration -} - -func (cdrle ContactDiscoveryRateLimitError) Error() string { - return fmt.Sprintf("contact discovery rate limited for %s", cdrle.RetryAfter) -} - -type ContactDiscoveryClient struct { - CDS *libsignalgo.SGXClientState - WS *websocket.Conn - - Token []byte - Response ContactDiscoveryResponse - stateLock sync.Mutex -} - -type ContactDiscoveryResponse map[uint64]CDSResponseEntry - -type CDSResponseEntry struct { - ACI uuid.UUID - PNI uuid.UUID -} - -func (cli *Client) LookupPhone(ctx context.Context, e164s ...uint64) (ContactDiscoveryResponse, error) { - if len(e164s) == 0 { - return nil, nil - } - requestData := make([]byte, len(e164s)*8) - for i, e164 := range e164s { - binary.BigEndian.PutUint64(requestData[i*8:(i+1)*8], e164) - } - ctx, cancel := context.WithTimeout(ctx, 20*time.Second) - defer cancel() - resp, token, err := cli.doContactDiscovery(ctx, &signalpb.CDSClientRequest{ - // TODO figure out if tokens are useful - // (it's meant for old_e164s) - //Token: cli.cdToken, - NewE164S: requestData, - }) - if token != nil { - cli.cdToken = token - } - return resp, err -} - -func (cli *Client) doContactDiscovery(ctx context.Context, req *signalpb.CDSClientRequest) (ContactDiscoveryResponse, []byte, error) { - creds, err := cli.getContactDiscoveryCredentials(ctx) - if err != nil { - return nil, nil, fmt.Errorf("failed to fetch contact discovery auth: %w", err) - } - log := zerolog.Ctx(ctx).With(). - Str("websocket_type", "contact"). - Str("username", creds.Username). - Logger() - log.Trace().Any("creds", creds).Msg("Got contact discovery credentials") - ctx = log.WithContext(ctx) - addr := (&url.URL{ - Scheme: "wss", - Host: ProdContactDiscoveryServer, - User: url.UserPassword(creds.Username, creds.Password), - Path: path.Join("v1", ProdContactDiscoveryMrenclave, "discovery"), - }).String() - log.Trace().Msg("Connecting to contact discovery websocket") - ws, _, err := web.OpenWebsocket(ctx, addr) - if err != nil { - var closeErr websocket.CloseError - if errors.As(err, &closeErr) && closeErr.Code == rateLimitCloseCode { - retryAfter := gjson.Get(closeErr.Reason, "retry_after") - if retryAfter.Type == gjson.Number { - retryAfterDuration := time.Duration(retryAfter.Int()) * time.Second - return nil, nil, ContactDiscoveryRateLimitError{RetryAfter: retryAfterDuration} - } - } - return nil, nil, fmt.Errorf("failed to open contact discovery websocket: %w", err) - } - defer func() { - _ = ws.CloseNow() - }() - cdc := &ContactDiscoveryClient{ - WS: ws, - } - log.Trace().Msg("Doing contact discovery websocket handshake") - err = cdc.Handshake(ctx) - if err != nil { - return nil, nil, fmt.Errorf("failed to handshake with contact discovery server: %w", err) - } - log.Trace().Msg("Contact discovery websocket connected") - err = cdc.SendRequest(ctx, req) - if err != nil { - return nil, nil, fmt.Errorf("failed to send contact discovery request: %w", err) - } - log.Trace().Any("request", req).Msg("Contact discovery request sent") - err = cdc.ReadResponse(ctx) - if err != nil { - return nil, nil, err - } - log.Trace().Any("response", cdc.Response).Msg("Contact discovery response received") - err = cdc.WS.Close(3000, "Normal") - if err != nil { - log.Trace().Err(err).Msg("Error closing contact discovery websocket cleanly") - } - return cdc.Response, cdc.Token, nil -} - -func (cdc *ContactDiscoveryClient) Handshake(ctx context.Context) error { - msgType, attestationMsg, err := cdc.WS.Read(ctx) - if err != nil { - return fmt.Errorf("failed to read attestation message: %w", err) - } else if msgType != websocket.MessageBinary { - return fmt.Errorf("expected binary message, got %s", msgType.String()) - } - cdsClient, err := libsignalgo.NewCDS2ClientState(prodContactDiscoveryMrenclaveBytes, attestationMsg, time.Now()) - if err != nil { - return fmt.Errorf("failed to initialize CDS2 client state: %w", err) - } - initReq, err := cdsClient.InitialRequest() - if err != nil { - return fmt.Errorf("failed to generate initial request: %w", err) - } - err = cdc.WS.Write(ctx, websocket.MessageBinary, initReq) - if err != nil { - return fmt.Errorf("failed to write initial request: %w", err) - } - msgType, handshakeFinishMsg, err := cdc.WS.Read(ctx) - if err != nil { - return fmt.Errorf("failed to read handshake finish message: %w", err) - } else if msgType != websocket.MessageBinary { - return fmt.Errorf("expected binary message, got %s", msgType.String()) - } - err = cdsClient.CompleteHandshake(handshakeFinishMsg) - if err != nil { - return fmt.Errorf("failed to complete handshake: %w", err) - } - cdc.CDS = cdsClient - return nil -} - -func (cdc *ContactDiscoveryClient) SendRequest(ctx context.Context, req *signalpb.CDSClientRequest) error { - plaintext, err := proto.Marshal(req) - if err != nil { - return fmt.Errorf("failed to marshal request: %w", err) - } - ciphertext, err := cdc.CDS.EstablishedSend(plaintext) - if err != nil { - return fmt.Errorf("failed to encrypt request: %w", err) - } - err = cdc.WS.Write(ctx, websocket.MessageBinary, ciphertext) - if err != nil { - return fmt.Errorf("failed to write request: %w", err) - } - return nil -} - -func (cdc *ContactDiscoveryClient) ReadResponse(ctx context.Context) error { - for cdc.Response == nil { - msgType, msg, err := cdc.WS.Read(ctx) - if err != nil { - return fmt.Errorf("failed to read contact discovery message: %w", err) - } else if msgType != websocket.MessageBinary { - return fmt.Errorf("unexpected contact discovery message type: %w", err) - } - err = cdc.handleResponse(ctx, msg) - if err != nil { - return fmt.Errorf("failed to handle contact discovery message: %w", err) - } - } - return nil -} - -func (cdc *ContactDiscoveryClient) handleResponse(ctx context.Context, msg []byte) error { - decrypted, err := cdc.CDS.EstablishedReceive(msg) - if err != nil { - return fmt.Errorf("failed to decrypt message: %w", err) - } - var cdsClientResp signalpb.CDSClientResponse - err = proto.Unmarshal(decrypted, &cdsClientResp) - if err != nil { - return fmt.Errorf("failed to unmarshal message: %w", err) - } - if cdsClientResp.Token != nil { - cdc.Token = cdsClientResp.Token - err = cdc.SendRequest(ctx, &signalpb.CDSClientRequest{ - TokenAck: proto.Bool(true), - }) - if err != nil { - return fmt.Errorf("failed to send token ack request: %w", err) - } - } - if cdsClientResp.E164PniAciTriples != nil { - const tripleSize = 8 + 16 + 16 - triples := cdsClientResp.E164PniAciTriples - pairCount := len(triples) / tripleSize - if pairCount*tripleSize != len(triples) { - return fmt.Errorf("invalid response size %d (not divisible by 40)", len(triples)) - } - resp := make(ContactDiscoveryResponse, pairCount) - for i := 0; i < pairCount; i++ { - data := triples[i*tripleSize : (i+1)*tripleSize] - e164 := binary.BigEndian.Uint64(data[:8]) - pni := uuid.UUID(data[8:24]) - aci := uuid.UUID(data[24:40]) - // If some entries were not found, the server will return all zeros - if e164 != 0 { - resp[e164] = CDSResponseEntry{PNI: pni, ACI: aci} - } - } - cdc.Response = resp - } - return nil -} diff --git a/pkg/signalmeow/device.go b/pkg/signalmeow/device.go new file mode 100644 index 0000000..6dfa599 --- /dev/null +++ b/pkg/signalmeow/device.go @@ -0,0 +1,121 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2023 Scott Weber +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package signalmeow + +import ( + "context" + "errors" + "fmt" + "net/url" + "sync" + + "github.com/rs/zerolog" + "go.mau.fi/mautrix-signal/pkg/libsignalgo" + "go.mau.fi/mautrix-signal/pkg/signalmeow/events" + "go.mau.fi/mautrix-signal/pkg/signalmeow/web" +) + +// Note: right now, the parent `Device` struct is in store.go +type DeviceData struct { + AciIdentityKeyPair *libsignalgo.IdentityKeyPair + PniIdentityKeyPair *libsignalgo.IdentityKeyPair + RegistrationId int + PniRegistrationId int + AciUuid string + PniUuid string + DeviceId int + Number string + Password string +} + +func (d *DeviceData) BasicAuthCreds() (string, string) { + username := fmt.Sprintf("%s.%d", d.AciUuid, d.DeviceId) + password := d.Password + return username, password +} + +// DeviceConnection exists on a Device, and holds websockets, cached credentials, +// and other data that is used to communicate with the Signal servers and other clients. +type DeviceConnection struct { + // cached data (not persisted) + SenderCertificate *libsignalgo.SenderCertificate + GroupCredentials *GroupCredentials + GroupCache *GroupCache + ProfileCache *ProfileCache + GroupCallCache *map[string]bool + LastContactRequestTime *int64 + + // mutexes + EncryptionMutex sync.Mutex + + // Network interfaces + AuthedWS *web.SignalWebsocket + UnauthedWS *web.SignalWebsocket + WSCancel context.CancelFunc + + EventHandler func(events.SignalEvent) +} + +func (d *DeviceConnection) handleEvent(evt events.SignalEvent) { + if d.EventHandler != nil { + d.EventHandler(evt) + } +} + +func (d *DeviceConnection) IsConnected() bool { + if d == nil { + return false + } + return d.AuthedWS.IsConnected() && d.UnauthedWS.IsConnected() +} + +func (d *DeviceConnection) ConnectAuthedWS(ctx context.Context, data DeviceData, requestHandler web.RequestHandlerFunc) (chan web.SignalWebsocketConnectionStatus, error) { + if d.AuthedWS != nil { + return nil, errors.New("authed websocket already connected") + } + + username, password := data.BasicAuthCreds() + log := zerolog.Ctx(ctx).With(). + Str("websocket_type", "authed"). + Str("username", username). + Logger() + ctx = log.WithContext(ctx) + username = url.QueryEscape(username) + password = url.QueryEscape(password) + path := web.WebsocketPath + + "?login=" + username + + "&password=" + password + authedWS := web.NewSignalWebsocket(path, &username, &password) + statusChan := authedWS.Connect(ctx, &requestHandler) + d.AuthedWS = authedWS + return statusChan, nil +} + +func (d *DeviceConnection) ConnectUnauthedWS(ctx context.Context, data DeviceData) (chan web.SignalWebsocketConnectionStatus, error) { + if d.UnauthedWS != nil { + return nil, errors.New("unauthed websocket already connected") + } + + log := zerolog.Ctx(ctx).With(). + Str("websocket_type", "unauthed"). + Logger() + ctx = log.WithContext(ctx) + unauthedWS := web.NewSignalWebsocket(web.WebsocketPath, nil, nil) + statusChan := unauthedWS.Connect(ctx, nil) + d.UnauthedWS = unauthedWS + return statusChan, nil +} diff --git a/pkg/signalmeow/devicename.go b/pkg/signalmeow/devicename.go index ceca1e4..269a6c7 100644 --- a/pkg/signalmeow/devicename.go +++ b/pkg/signalmeow/devicename.go @@ -17,7 +17,6 @@ package signalmeow import ( - "context" "crypto/aes" "crypto/cipher" "crypto/hmac" @@ -30,6 +29,7 @@ import ( "go.mau.fi/mautrix-signal/pkg/libsignalgo" signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" + "go.mau.fi/mautrix-signal/pkg/signalmeow/web" ) func hmacSHA256(key, input []byte) []byte { @@ -43,31 +43,37 @@ func aes256CTR(key, iv, dst, source []byte) { cipher.NewCTR(block, iv).XORKeyStream(dst, source) } -func (cli *Client) UpdateDeviceName(ctx context.Context, name string) error { - encryptedName, err := EncryptDeviceName(name, cli.Store.ACIIdentityKeyPair.GetPublicKey()) +func (d *Device) UpdateDeviceName(name string) error { + encryptedName, err := EncryptDeviceName(name, d.Data.AciIdentityKeyPair.GetPublicKey()) if err != nil { return fmt.Errorf("failed to encrypt device name: %w", err) } - err = cli.updateDeviceName(ctx, encryptedName) + err = UpdateDeviceName(d, encryptedName) if err != nil { return fmt.Errorf("failed to update device name: %w", err) } return nil } -func (cli *Client) updateDeviceName(ctx context.Context, encryptedName []byte) error { +func UpdateDeviceName(device *Device, encryptedName []byte) error { reqData, err := json.Marshal(map[string]any{ "deviceName": encryptedName, }) if err != nil { return fmt.Errorf("failed to marshal device name update request: %w", err) } - resp, err := cli.AuthedWS.SendRequest(ctx, http.MethodPut, "/v1/accounts/name", reqData, nil) + username, password := device.Data.BasicAuthCreds() + resp, err := web.SendHTTPRequest(http.MethodPut, "/v1/accounts/name", &web.HTTPReqOpt{ + Body: reqData, + Username: &username, + Password: &password, + }) if err != nil { return fmt.Errorf("failed to send device name update request: %w", err) } - if resp.GetStatus() < 200 || resp.GetStatus() >= 300 { - return fmt.Errorf("device name update request returned status %d", resp.GetStatus()) + defer resp.Body.Close() + if resp.StatusCode < 200 || resp.StatusCode >= 300 { + return fmt.Errorf("device name update request returned status %d", resp.StatusCode) } return nil } diff --git a/pkg/signalmeow/events/message.go b/pkg/signalmeow/events/message.go index 7d3732a..a3146a1 100644 --- a/pkg/signalmeow/events/message.go +++ b/pkg/signalmeow/events/message.go @@ -19,7 +19,6 @@ package events import ( "github.com/google/uuid" - "go.mau.fi/mautrix-signal/pkg/libsignalgo" signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" "go.mau.fi/mautrix-signal/pkg/signalmeow/types" ) @@ -28,24 +27,18 @@ type SignalEvent interface { isSignalEvent() } -func (*ChatEvent) isSignalEvent() {} -func (*DecryptionError) isSignalEvent() {} -func (*Receipt) isSignalEvent() {} -func (*ReadSelf) isSignalEvent() {} -func (*Call) isSignalEvent() {} -func (*ContactList) isSignalEvent() {} -func (*ACIFound) isSignalEvent() {} -func (*DeleteForMe) isSignalEvent() {} -func (*MessageRequestResponse) isSignalEvent() {} -func (*QueueEmpty) isSignalEvent() {} -func (*LoggedOut) isSignalEvent() {} +func (*ChatEvent) isSignalEvent() {} +func (*Receipt) isSignalEvent() {} +func (*ReadSelf) isSignalEvent() {} +func (*Call) isSignalEvent() {} +func (*GroupChange) isSignalEvent() {} +func (*ContactChange) isSignalEvent() {} type MessageInfo struct { Sender uuid.UUID ChatID string - GroupRevision uint32 - ServerTimestamp uint64 + GroupRevision int } type ChatEvent struct { @@ -53,20 +46,13 @@ type ChatEvent struct { Event signalpb.ChatEventContent } -type DecryptionError struct { - Sender uuid.UUID - Err error - Timestamp uint64 -} - type Receipt struct { Sender uuid.UUID Content *signalpb.ReceiptMessage } type ReadSelf struct { - Timestamp uint64 - Messages []*signalpb.SyncMessage_Read + Messages []*signalpb.SyncMessage_Read } type Call struct { @@ -75,29 +61,14 @@ type Call struct { IsRinging bool } -type ContactList struct { - Contacts []*types.Recipient - IsFromDB bool -} - -type ACIFound struct { - PNI libsignalgo.ServiceID - ACI libsignalgo.ServiceID -} - -type DeleteForMe struct { +type GroupChange struct { + SenderID uuid.UUID Timestamp uint64 - *signalpb.SyncMessage_DeleteForMe + GroupID types.GroupIdentifier + Revision int } -type MessageRequestResponse struct { - Timestamp uint64 - ThreadACI uuid.UUID - GroupID *libsignalgo.GroupIdentifier - Type signalpb.SyncMessage_MessageRequestResponse_Type - Raw *signalpb.SyncMessage_MessageRequestResponse +type ContactChange struct { + types.Contact + Avatar *types.ContactAvatar } - -type QueueEmpty struct{} - -type LoggedOut struct{ Error error } diff --git a/pkg/signalmeow/group_store.go b/pkg/signalmeow/group_store.go new file mode 100644 index 0000000..b83f552 --- /dev/null +++ b/pkg/signalmeow/group_store.go @@ -0,0 +1,84 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2023 Scott Weber +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package signalmeow + +import ( + "context" + "database/sql" + "errors" + + "go.mau.fi/mautrix-signal/pkg/signalmeow/types" +) + +var _ GroupStore = (*SQLStore)(nil) + +type dbGroup struct { + OurAciUuid string + GroupIdentifier types.GroupIdentifier + GroupMasterKey SerializedGroupMasterKey +} + +type GroupStore interface { + MasterKeyFromGroupIdentifier(groupIdentifier types.GroupIdentifier, ctx context.Context) (SerializedGroupMasterKey, error) + StoreMasterKey(groupIdentifier types.GroupIdentifier, key SerializedGroupMasterKey, ctx context.Context) error +} + +func scanGroup(row scannable) (*dbGroup, error) { + var g dbGroup + err := row.Scan(&g.OurAciUuid, &g.GroupIdentifier, &g.GroupMasterKey) + if errors.Is(err, sql.ErrNoRows) { + return nil, nil + } else if err != nil { + return nil, err + } + return &g, nil +} + +func (s *SQLStore) MasterKeyFromGroupIdentifier(groupIdentifier types.GroupIdentifier, ctx context.Context) (SerializedGroupMasterKey, error) { + loadGroupQuery := `SELECT our_aci_uuid, group_identifier, master_key FROM signalmeow_groups WHERE our_aci_uuid=$1 AND group_identifier=$2` + g, err := scanGroup(s.db.QueryRow(loadGroupQuery, s.AciUuid, groupIdentifier)) + if err != nil { + return "", err + } + if g == nil { + return "", nil + } + return g.GroupMasterKey, nil +} + +func (s *SQLStore) StoreMasterKey(groupIdentifier types.GroupIdentifier, key SerializedGroupMasterKey, ctx context.Context) error { + // Insert, or update if already exists + storeMasterKeyQuery := ` + INSERT INTO signalmeow_groups (our_aci_uuid, group_identifier, master_key) + VALUES ($1, $2, $3) + ON CONFLICT (our_aci_uuid, group_identifier) DO UPDATE SET + master_key = excluded.master_key; + ` + + tx, err := s.db.BeginTx(ctx, nil) + if err != nil { + tx.Rollback() + return err + } + _, err = tx.Exec(storeMasterKeyQuery, s.AciUuid, groupIdentifier, key) + if err != nil { + tx.Rollback() + return err + } + err = tx.Commit() + return err +} diff --git a/pkg/signalmeow/groupcache.go b/pkg/signalmeow/groupcache.go deleted file mode 100644 index ee8259f..0000000 --- a/pkg/signalmeow/groupcache.go +++ /dev/null @@ -1,346 +0,0 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2025 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package signalmeow - -import ( - "context" - "fmt" - "slices" - "sync" - "time" - - "github.com/google/uuid" - - "go.mau.fi/mautrix-signal/pkg/libsignalgo" - "go.mau.fi/mautrix-signal/pkg/signalmeow/types" -) - -type SendEndorsementCache struct { - SendEndorsement libsignalgo.GroupSendEndorsement - MemberEndorsements map[libsignalgo.ServiceID]libsignalgo.GroupSendEndorsement - Expiration time.Time - SecretParams *libsignalgo.GroupSecretParams -} - -func (sec *SendEndorsementCache) GetToken() (libsignalgo.GroupSendFullToken, error) { - return sec.GetTokenWith(sec.SendEndorsement) -} - -func (sec *SendEndorsementCache) GetTokenWith(altToken libsignalgo.GroupSendEndorsement) (libsignalgo.GroupSendFullToken, error) { - return altToken.ToFullToken(sec.SecretParams, sec.Expiration) -} - -type cachedGroup struct { - *Group - *SendEndorsementCache - FetchedAt time.Time - UpdatedAt time.Time -} - -type GroupCache struct { - serviceID libsignalgo.ServiceID - - credentials *GroupCredentials - credentialsLock sync.RWMutex - - data map[types.GroupIdentifier]*cachedGroup - lock sync.RWMutex - - activeCalls map[types.GroupIdentifier]string - callsLock sync.RWMutex -} - -func NewGroupCache(serviceID libsignalgo.ServiceID) *GroupCache { - return &GroupCache{ - serviceID: serviceID, - data: make(map[types.GroupIdentifier]*cachedGroup), - activeCalls: make(map[types.GroupIdentifier]string), - } -} - -func (gc *GroupCache) GetCredentials( - ctx context.Context, - fetch func(context.Context, time.Time) (*GroupCredentials, error), -) (*GroupCredential, error) { - today := time.Now().Truncate(24 * time.Hour) - gc.credentialsLock.RLock() - cred := gc.getCachedCredentials(today.Unix()) - gc.credentialsLock.RUnlock() - if cred != nil { - return cred, nil - } - - gc.credentialsLock.Lock() - defer gc.credentialsLock.Unlock() - cred = gc.getCachedCredentials(today.Unix()) - if cred != nil { - return cred, nil - } - creds, err := fetch(ctx, today) - if err != nil { - return nil, err - } - gc.credentials = creds - cred = gc.getCachedCredentials(today.Unix()) - if cred == nil { - return nil, fmt.Errorf("no credentials for today after fetch") - } - return cred, nil -} - -func (gc *GroupCache) getCachedCredentials(today int64) *GroupCredential { - if gc.credentials == nil { - return nil - } - for _, cred := range gc.credentials.Credentials { - if cred.RedemptionTime == today { - return &cred - } - } - return nil -} - -func (gc *GroupCache) UpdateActiveCall(id types.GroupIdentifier, callID string) bool { - gc.callsLock.Lock() - defer gc.callsLock.Unlock() - currentCallID, ok := gc.activeCalls[id] - if ok { - // If we do, then this must be ending the call - if currentCallID == callID { - delete(gc.activeCalls, id) - return false - } - } - gc.activeCalls[id] = callID - return true -} - -func (gc *GroupCache) Get(id types.GroupIdentifier) (*Group, *SendEndorsementCache, bool) { - gc.lock.RLock() - defer gc.lock.RUnlock() - c, ok := gc.data[id] - if !ok || time.Until(c.Expiration) < 5*time.Minute { - return nil, nil, false - } - return c.Group, c.SendEndorsementCache, true -} - -func (gc *GroupCache) Delete(id types.GroupIdentifier) { - gc.lock.Lock() - defer gc.lock.Unlock() - delete(gc.data, id) -} - -func (gc *GroupCache) Put(data *Group, endorsementResponse libsignalgo.GroupSendEndorsementsResponse) error { - gsp, err := masterKeyToBytes(data.GroupMasterKey).SecretParams() - if err != nil { - return fmt.Errorf("failed to get secret params: %w", err) - } - expiration, err := endorsementResponse.GetExpiration() - if err != nil { - return fmt.Errorf("failed to get endorsement expiration: %w", err) - } - endorsement, memberEndorsements, err := endorsementResponse.ReceiveWithServiceIDs(data.getMemberServiceIDs(), gc.serviceID, &gsp, prodServerPublicParams) - if err != nil { - return fmt.Errorf("failed to receive endorsements: %w", err) - } - - gc.lock.Lock() - defer gc.lock.Unlock() - cached, exists := gc.data[data.GroupIdentifier] - if exists && cached.Revision > data.Revision { - return nil - } - gc.data[data.GroupIdentifier] = &cachedGroup{ - Group: data, - FetchedAt: time.Now(), - UpdatedAt: time.Now(), - - SendEndorsementCache: &SendEndorsementCache{ - Expiration: expiration, - SendEndorsement: endorsement, - MemberEndorsements: memberEndorsements, - SecretParams: &gsp, - }, - } - return nil -} - -func (gc *GroupCache) ApplyUpdate(change *GroupChange, endorsementResponse libsignalgo.GroupSendEndorsementsResponse) error { - mkBytes := masterKeyToBytes(change.GroupMasterKey) - rawGroupID, err := mkBytes.GroupIdentifier() - if err != nil { - return fmt.Errorf("failed to get group identifier: %w", err) - } - gsp, err := mkBytes.SecretParams() - if err != nil { - return fmt.Errorf("failed to get secret params: %w", err) - } - id := types.GroupIdentifier(rawGroupID.String()) - - gc.lock.Lock() - defer gc.lock.Unlock() - - cached, exists := gc.data[id] - if !exists || cached.Revision >= change.Revision { - return nil - } else if cached.Revision < change.Revision-1 { - // We missed an update, evict - delete(gc.data, id) - return nil - } - - // Pending member adds, promotes and removes - cached.PendingMembers = append(cached.PendingMembers, change.AddPendingMembers...) - for _, promo := range change.PromotePendingMembers { - cached.PendingMembers = slices.DeleteFunc(cached.PendingMembers, func(p *PendingMember) bool { - return p.ServiceID.Type == libsignalgo.ServiceIDTypeACI && p.ServiceID.UUID == promo.ACI - }) - cached.Members = append(cached.Members, &GroupMember{ - ACI: promo.ACI, - ProfileKey: promo.ProfileKey, - Role: GroupMember_DEFAULT, - JoinedAtRevision: change.Revision, - }) - } - for _, promo := range change.PromotePendingPniAciMembers { - cached.PendingMembers = slices.DeleteFunc(cached.PendingMembers, func(p *PendingMember) bool { - return (p.ServiceID.Type == libsignalgo.ServiceIDTypePNI && p.ServiceID.UUID == promo.PNI) || - (p.ServiceID.Type == libsignalgo.ServiceIDTypeACI && p.ServiceID.UUID == promo.ACI) - }) - cached.Members = append(cached.Members, &GroupMember{ - ACI: promo.ACI, - ProfileKey: promo.ProfileKey, - Role: GroupMember_DEFAULT, - JoinedAtRevision: change.Revision, - }) - } - cached.PendingMembers = slices.DeleteFunc(cached.PendingMembers, func(p *PendingMember) bool { - return slices.ContainsFunc(change.DeletePendingMembers, func(s *libsignalgo.ServiceID) bool { - return s != nil && p.ServiceID == *s - }) - }) - - // Requesting member adds, promotes and removes - cached.RequestingMembers = append(cached.RequestingMembers, change.AddRequestingMembers...) - for _, promo := range change.PromoteRequestingMembers { - var profileKey libsignalgo.ProfileKey - cached.RequestingMembers = slices.DeleteFunc(cached.RequestingMembers, func(r *RequestingMember) bool { - if r.ACI == promo.ACI { - profileKey = r.ProfileKey - return true - } - return false - }) - cached.Members = append(cached.Members, &GroupMember{ - ACI: promo.ACI, - ProfileKey: profileKey, - Role: promo.Role, - JoinedAtRevision: change.Revision, - }) - } - cached.RequestingMembers = slices.DeleteFunc(cached.RequestingMembers, func(r *RequestingMember) bool { - return slices.ContainsFunc(change.DeleteRequestingMembers, func(u *uuid.UUID) bool { - return u != nil && r.ACI == *u - }) - }) - - // Direct member adds, removes and modifications - for _, member := range change.AddMembers { - cached.Members = append(cached.Members, &GroupMember{ - ACI: member.ACI, - Role: member.Role, - ProfileKey: member.ProfileKey, - JoinedAtRevision: member.JoinedAtRevision, - }) - } - for _, rm := range change.ModifyMemberRoles { - cached.findMemberOrEmpty(rm.ACI).Role = rm.Role - } - for _, pk := range change.ModifyMemberProfileKeys { - cached.findMemberOrEmpty(pk.ACI).ProfileKey = pk.ProfileKey - } - cached.Members = slices.DeleteFunc(cached.Members, func(member *GroupMember) bool { - return slices.ContainsFunc(change.DeleteMembers, func(u *uuid.UUID) bool { - return u != nil && *u == member.ACI - }) - }) - - // Banned members - cached.BannedMembers = append(cached.BannedMembers, change.AddBannedMembers...) - cached.BannedMembers = slices.DeleteFunc(cached.BannedMembers, func(b *BannedMember) bool { - return slices.ContainsFunc(change.DeleteBannedMembers, func(s *libsignalgo.ServiceID) bool { - return s != nil && b.ServiceID == *s - }) - }) - - // Non-member modifications - if change.ModifyInviteLinkPassword != nil { - cached.InviteLinkPassword = change.ModifyInviteLinkPassword - } - if change.ModifyTitle != nil { - cached.Title = *change.ModifyTitle - } - if change.ModifyDescription != nil { - cached.Description = *change.ModifyDescription - } - if change.ModifyAvatar != nil { - cached.AvatarPath = *change.ModifyAvatar - } - if change.ModifyAnnouncementsOnly != nil { - cached.AnnouncementsOnly = *change.ModifyAnnouncementsOnly - } - if change.ModifyDisappearingMessagesDuration != nil { - cached.DisappearingMessagesDuration = *change.ModifyDisappearingMessagesDuration - } - if change.ModifyAttributesAccess != nil { - cached.AccessControl.Attributes = *change.ModifyAttributesAccess - } - if change.ModifyMemberAccess != nil { - cached.AccessControl.Members = *change.ModifyMemberAccess - } - if change.ModifyAddFromInviteLinkAccess != nil { - cached.AccessControl.AddFromInviteLink = *change.ModifyAddFromInviteLinkAccess - } - - cached.UpdatedAt = time.Now() - cached.Revision = change.Revision - endorsement, memberEndorsements, err := endorsementResponse.ReceiveWithServiceIDs( - cached.getMemberServiceIDs(), - gc.serviceID, - &gsp, - prodServerPublicParams, - ) - if err != nil { - delete(gc.data, id) - return fmt.Errorf("failed to receive endorsements: %w", err) - } - expiration, err := endorsementResponse.GetExpiration() - if err != nil { - delete(gc.data, id) - return fmt.Errorf("failed to get endorsement expiration: %w", err) - } - // TODO do these responses overwrite the entire thing? - cached.SendEndorsementCache = &SendEndorsementCache{ - SendEndorsement: endorsement, - MemberEndorsements: memberEndorsements, - Expiration: expiration, - SecretParams: &gsp, - } - - return nil -} diff --git a/pkg/signalmeow/groups.go b/pkg/signalmeow/groups.go index 147d63d..63f2192 100644 --- a/pkg/signalmeow/groups.go +++ b/pkg/signalmeow/groups.go @@ -1,5 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2023 Scott Weber, Malte Eggers +// Copyright (C) 2023 Scott Weber // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -30,10 +30,6 @@ import ( "unicode" "github.com/google/uuid" - "github.com/rs/zerolog" - "go.mau.fi/util/exslices" - "go.mau.fi/util/ptr" - "go.mau.fi/util/random" "google.golang.org/protobuf/proto" "go.mau.fi/mautrix-signal/pkg/libsignalgo" @@ -51,30 +47,16 @@ const ( GroupMember_ADMINISTRATOR GroupMemberRole = 2 ) -type AccessControl int32 - -const ( - AccessControl_UNKNOWN AccessControl = 0 - AccessControl_ANY AccessControl = 1 - AccessControl_MEMBER AccessControl = 2 - AccessControl_ADMINISTRATOR AccessControl = 3 - AccessControl_UNSATISFIABLE AccessControl = 4 -) - type GroupMember struct { - ACI uuid.UUID + UserID string Role GroupMemberRole ProfileKey libsignalgo.ProfileKey JoinedAtRevision uint32 + //Presentation []byte } - -func (gm *GroupMember) UserServiceID() libsignalgo.ServiceID { - return libsignalgo.NewACIServiceID(gm.ACI) -} - type Group struct { - GroupMasterKey types.SerializedGroupMasterKey // We should keep this relatively private - GroupIdentifier types.GroupIdentifier // This is what we should use to identify a group outside this file + groupMasterKey SerializedGroupMasterKey // We should keep this relatively private + GroupIdentifier types.GroupIdentifier // This is what we should use to identify a group outside this file Title string AvatarPath string @@ -83,239 +65,12 @@ type Group struct { AnnouncementsOnly bool Revision uint32 DisappearingMessagesDuration uint32 - AccessControl *GroupAccessControl - PendingMembers []*PendingMember - RequestingMembers []*RequestingMember - BannedMembers []*BannedMember - InviteLinkPassword *types.SerializedInviteLinkPassword //PublicKey *libsignalgo.PublicKey -} - -func (group *Group) getMemberServiceIDs() []libsignalgo.ServiceID { - return exslices.CastFunc(group.Members, func(from *GroupMember) libsignalgo.ServiceID { - return libsignalgo.NewACIServiceID(from.ACI) - }) -} - -func (group *Group) GetInviteLink() (string, error) { - if group.InviteLinkPassword == nil { - return "", fmt.Errorf("no invite link password set") - } - masterKeyBytes := masterKeyToBytes(group.GroupMasterKey) - inviteLinkPasswordBytes, err := inviteLinkPasswordToBytes(*group.InviteLinkPassword) - if err != nil { - return "", fmt.Errorf("couldn't decode invite link password") - } - inviteLinkContents := signalpb.GroupInviteLink_ContentsV1{ - ContentsV1: &signalpb.GroupInviteLink_GroupInviteLinkContentsV1{ - GroupMasterKey: masterKeyBytes[:], - InviteLinkPassword: inviteLinkPasswordBytes, - }, - } - inviteLink := signalpb.GroupInviteLink{Contents: &inviteLinkContents} - inviteLinkEncoded, err := proto.Marshal(&inviteLink) - if err != nil { - return "", fmt.Errorf("failed to marshal invite link") - } - inviteLinkPath := base64.URLEncoding.EncodeToString(inviteLinkEncoded) - return "https://signal.group/#" + inviteLinkPath, nil -} - -func (group *Group) findMemberOrEmpty(aci uuid.UUID) *GroupMember { - for _, member := range group.Members { - if member.ACI == aci { - return member - } - } - return &GroupMember{} -} - -type GroupAccessControl struct { - Members AccessControl - AddFromInviteLink AccessControl - Attributes AccessControl -} - -type AddMember struct { - GroupMember - JoinFromInviteLink bool -} - -type PendingMember struct { - ServiceID libsignalgo.ServiceID - Role GroupMemberRole - AddedByUserID uuid.UUID - Timestamp uint64 -} - -type ProfileKeyMember struct { - ACI uuid.UUID - ProfileKey libsignalgo.ProfileKey -} - -type RequestingMember struct { - ACI uuid.UUID - ProfileKey libsignalgo.ProfileKey - Timestamp uint64 -} - -type PromotePendingMember struct { - ACI uuid.UUID - ProfileKey libsignalgo.ProfileKey -} - -type PromotePendingPniAciMember struct { - ACI uuid.UUID - ProfileKey libsignalgo.ProfileKey - PNI uuid.UUID -} - -type RoleMember struct { - ACI uuid.UUID - Role GroupMemberRole -} - -type BannedMember struct { - ServiceID libsignalgo.ServiceID - Timestamp uint64 -} - -type GroupChange struct { - GroupMasterKey types.SerializedGroupMasterKey - SourceServiceID libsignalgo.ServiceID - Revision uint32 - AddMembers []*AddMember - DeleteMembers []*uuid.UUID - ModifyMemberRoles []*RoleMember - ModifyMemberProfileKeys []*ProfileKeyMember - AddPendingMembers []*PendingMember - DeletePendingMembers []*libsignalgo.ServiceID - PromotePendingMembers []*PromotePendingMember - ModifyTitle *string - ModifyAvatar *string - ModifyDisappearingMessagesDuration *uint32 - ModifyAttributesAccess *AccessControl - ModifyMemberAccess *AccessControl - ModifyAddFromInviteLinkAccess *AccessControl - AddRequestingMembers []*RequestingMember - DeleteRequestingMembers []*uuid.UUID - PromoteRequestingMembers []*RoleMember - ModifyDescription *string - ModifyAnnouncementsOnly *bool - AddBannedMembers []*BannedMember - DeleteBannedMembers []*libsignalgo.ServiceID - PromotePendingPniAciMembers []*PromotePendingPniAciMember - ModifyInviteLinkPassword *types.SerializedInviteLinkPassword -} - -func (groupChange *GroupChange) isEmpty() bool { - return len(groupChange.AddMembers) == 0 && - len(groupChange.DeleteMembers) == 0 && - len(groupChange.ModifyMemberRoles) == 0 && - len(groupChange.ModifyMemberProfileKeys) == 0 && - len(groupChange.AddPendingMembers) == 0 && - len(groupChange.PromotePendingMembers) == 0 && - groupChange.ModifyTitle == nil && - groupChange.ModifyAvatar == nil && - groupChange.ModifyDisappearingMessagesDuration == nil && - groupChange.ModifyAttributesAccess == nil && - groupChange.ModifyMemberAccess == nil && - groupChange.ModifyAddFromInviteLinkAccess == nil && - len(groupChange.AddRequestingMembers) == 0 && - len(groupChange.DeleteRequestingMembers) == 0 && - len(groupChange.PromoteRequestingMembers) == 0 && - groupChange.ModifyDescription == nil && - groupChange.ModifyAnnouncementsOnly == nil && - len(groupChange.AddBannedMembers) == 0 -} - -func (groupChange *GroupChange) resolveConflict(group *Group) { - if *groupChange.ModifyTitle == group.Title { - groupChange.ModifyTitle = nil - } - if *groupChange.ModifyDescription == group.Description { - groupChange.ModifyDescription = nil - } - if *groupChange.ModifyAvatar == group.AvatarPath { - groupChange.ModifyAvatar = nil - } - if *groupChange.ModifyDisappearingMessagesDuration == group.DisappearingMessagesDuration { - groupChange.ModifyDisappearingMessagesDuration = nil - } - if *groupChange.ModifyAttributesAccess == group.AccessControl.Attributes { - groupChange.ModifyAttributesAccess = nil - } - if *groupChange.ModifyMemberAccess == group.AccessControl.Members { - groupChange.ModifyAttributesAccess = nil - } - if *groupChange.ModifyAddFromInviteLinkAccess == group.AccessControl.AddFromInviteLink { - groupChange.ModifyAddFromInviteLinkAccess = nil - } - if *groupChange.ModifyAnnouncementsOnly == group.AnnouncementsOnly { - groupChange.ModifyAnnouncementsOnly = nil - } - members := make(map[uuid.UUID]GroupMemberRole) - for _, member := range group.Members { - members[member.ACI] = member.Role - } - pendingMembers := make(map[libsignalgo.ServiceID]bool) - for _, pendingMember := range group.PendingMembers { - pendingMembers[pendingMember.ServiceID] = true - } - requestingMembers := make(map[uuid.UUID]bool) - for _, requestingMember := range group.RequestingMembers { - requestingMembers[requestingMember.ACI] = true - } - for i, member := range groupChange.AddMembers { - if _, ok := members[member.GroupMember.ACI]; ok { - groupChange.AddMembers = append(groupChange.AddMembers[:i], groupChange.AddMembers[i+1:]...) - } - } - for i, promotePendingMember := range groupChange.PromotePendingMembers { - if _, ok := members[promotePendingMember.ACI]; ok { - groupChange.PromotePendingMembers = append(groupChange.PromotePendingMembers[:i], groupChange.PromotePendingMembers[i+1:]...) - } - } - for i, promoteRequestingMember := range groupChange.PromotePendingMembers { - if _, ok := members[promoteRequestingMember.ACI]; ok { - groupChange.PromoteRequestingMembers = append(groupChange.PromoteRequestingMembers[:i], groupChange.PromoteRequestingMembers[i+1:]...) - } - } - for i, pendingMember := range groupChange.AddPendingMembers { - if pendingMembers[pendingMember.ServiceID] { - groupChange.AddPendingMembers = append(groupChange.AddPendingMembers[:i], groupChange.AddPendingMembers[i+1:]...) - } - } - for i, requestingMember := range groupChange.AddRequestingMembers { - if requestingMembers[requestingMember.ACI] { - groupChange.AddRequestingMembers = append(groupChange.AddRequestingMembers[:i], groupChange.AddRequestingMembers[i+1:]...) - } - } - for i, deletePendingMember := range groupChange.DeletePendingMembers { - if !pendingMembers[*deletePendingMember] { - groupChange.DeletePendingMembers = append(groupChange.DeletePendingMembers[:i], groupChange.DeletePendingMembers[i+1:]...) - } - } - for i, deleteRequestingMember := range groupChange.DeleteRequestingMembers { - if !requestingMembers[*deleteRequestingMember] { - groupChange.DeleteRequestingMembers = append(groupChange.DeleteRequestingMembers[:i], groupChange.DeleteRequestingMembers[i+1:]...) - } - } - for i, deleteMember := range groupChange.DeleteMembers { - if _, ok := members[*deleteMember]; !ok { - groupChange.DeleteMembers = append(groupChange.DeleteMembers[:i], groupChange.DeleteMembers[i+1:]...) - } - } - for i, modifyMemberRole := range groupChange.ModifyMemberRoles { - if members[modifyMemberRole.ACI] == modifyMemberRole.Role { - groupChange.ModifyMemberRoles = append(groupChange.ModifyMemberRoles[:i], groupChange.ModifyMemberRoles[i+1:]...) - } - } -} - -type GroupChangeState struct { - GroupState *Group - GroupChange *GroupChange + //AccessControl *AccessControl + //PendingMembers []*PendingMember + //RequestingMembers []*RequestingMember + //InviteLinkPassword []byte + //BannedMembers []*BannedMember } type GroupAuth struct { @@ -323,82 +78,127 @@ type GroupAuth struct { Password string } -func (cli *Client) fetchNewGroupCreds(ctx context.Context, today time.Time) (*GroupCredentials, error) { - log := zerolog.Ctx(ctx).With(). - Str("action", "fetch new group creds"). - Logger() +// This is just base64 encoded group master key +type SerializedGroupMasterKey string + +func fetchNewGroupCreds(ctx context.Context, d *Device, today time.Time) (*GroupCredentials, error) { sevenDaysOut := today.Add(7 * 24 * time.Hour) - path := fmt.Sprintf("/v1/certificate/auth/group?redemptionStartSeconds=%d&redemptionEndSeconds=%d&pniAsServiceId=true", today.Unix(), sevenDaysOut.Unix()) - resp, err := cli.AuthedWS.SendRequest(ctx, http.MethodGet, path, nil, nil) + path := fmt.Sprintf("/v1/certificate/auth/group?redemptionStartSeconds=%d&redemptionEndSeconds=%d", today.Unix(), sevenDaysOut.Unix()) + authRequest := web.CreateWSRequest(http.MethodGet, path, nil, nil, nil) + resp, err := d.Connection.AuthedWS.SendRequest(ctx, authRequest) if err != nil { - return nil, fmt.Errorf("SendRequest error: %w", err) + zlog.Err(err).Msg("SendRequest error") + return nil, err } if *resp.Status != 200 { - return nil, fmt.Errorf("bad status code fetching group creds: %d", *resp.Status) + err := fmt.Errorf("bad status code: %d", *resp.Status) + zlog.Err(err).Msg("bad status code fetching group creds") + return nil, err } var creds GroupCredentials err = json.Unmarshal(resp.Body, &creds) if err != nil { - log.Err(err).Msg("json.Unmarshal error") + zlog.Err(err).Msg("json.Unmarshal error") return nil, err } - if creds.PNI != cli.Store.PNI { - return nil, fmt.Errorf("mismatching PNI in group credentials: %s != %s", creds.PNI, cli.Store.PNI) + // make sure pni matches device pni + if creds.Pni != d.Data.PniUuid { + err := fmt.Errorf("creds.Pni != d.PniUuid") + zlog.Err(err).Msg("creds.Pni != d.PniUuid") + return nil, err } return &creds, nil } -func (cli *Client) GetAuthorizationForToday(ctx context.Context, masterKey libsignalgo.GroupMasterKey) (*GroupAuth, error) { - log := zerolog.Ctx(ctx).With(). - Str("action", "get authorization for today"). - Logger() +func getCachedAuthorizationForToday(d *Device, today time.Time) *GroupCredential { + if d.Connection.GroupCredentials == nil { + // No cached credentials + return nil + } + allCreds := d.Connection.GroupCredentials + // Get the credential for today + for _, cred := range allCreds.Credentials { + if cred.RedemptionTime == today.Unix() { + return &cred + } + } + zlog.Info().Msg("No cached credential found for today") + return nil +} - todayCred, err := cli.GroupCache.GetCredentials(ctx, cli.fetchNewGroupCreds) - if err != nil { - return nil, fmt.Errorf("failed to get group credentials: %w", err) +func GetAuthorizationForToday(ctx context.Context, d *Device, masterKey libsignalgo.GroupMasterKey) (*GroupAuth, error) { + // Timestamps for the start of today, and 7 days later + today := time.Now().Truncate(24 * time.Hour) + + todayCred := getCachedAuthorizationForToday(d, today) + if todayCred == nil { + creds, err := fetchNewGroupCreds(ctx, d, today) + if err != nil { + zlog.Err(err).Msg("fetchNewGroupCreds error") + return nil, err + } + d.Connection.GroupCredentials = creds + todayCred = getCachedAuthorizationForToday(d, today) + } + if todayCred == nil { + err := errors.New("Couldn't get credential for today") + zlog.Err(err).Msg("GetAuthorizationForToday error") + return nil, err } + //TODO: cache cred after unmarshalling redemptionTime := uint64(todayCred.RedemptionTime) credential := todayCred.Credential authCredentialResponse, err := libsignalgo.NewAuthCredentialWithPniResponse(credential) if err != nil { - log.Err(err).Msg("NewAuthCredentialWithPniResponse error") + zlog.Err(err).Msg("NewAuthCredentialWithPniResponse error") return nil, err } // Receive the auth credential + aciUuidBytes, err := uuid.Parse(d.Data.AciUuid) + if err != nil { + zlog.Err(err).Msg("aci convertUUIDToBytes error") + return nil, err + } + pniUuidBytes, err := uuid.Parse(d.Data.PniUuid) + if err != nil { + zlog.Err(err).Msg("pni convertUUIDToBytes error") + return nil, err + } authCredential, err := libsignalgo.ReceiveAuthCredentialWithPni( - prodServerPublicParams, - cli.Store.ACI, - cli.Store.PNI, + serverPublicParams(), + aciUuidBytes, + pniUuidBytes, redemptionTime, *authCredentialResponse, ) if err != nil { - log.Err(err).Msg("ReceiveAuthCredentialWithPni error") + zlog.Err(err).Msg("ReceiveAuthCredentialWithPni error") return nil, err } // get auth presentation groupSecretParams, err := libsignalgo.DeriveGroupSecretParamsFromMasterKey(masterKey) if err != nil { - log.Err(err).Msg("DeriveGroupSecretParamsFromMasterKey error") + zlog.Err(err).Msg("DeriveGroupSecretParamsFromMasterKey error") return nil, err } + randomness, err := libsignalgo.GenerateRandomness() authCredentialPresentation, err := libsignalgo.CreateAuthCredentialWithPniPresentation( - prodServerPublicParams, - libsignalgo.GenerateRandomness(), + serverPublicParams(), + randomness, groupSecretParams, *authCredential, ) if err != nil { - log.Err(err).Msg("CreateAuthCredentialWithPniPresentation error") + zlog.Err(err).Msg("CreateAuthCredentialWithPniPresentation error") return nil, err } groupPublicParams, err := groupSecretParams.GetPublicParams() if err != nil { - log.Err(err).Msg("GetPublicParams error") + zlog.Err(err).Msg("GetPublicParams error") return nil, err } @@ -408,54 +208,56 @@ func (cli *Client) GetAuthorizationForToday(ctx context.Context, masterKey libsi }, nil } -func masterKeyToBytes(groupMasterKey types.SerializedGroupMasterKey) libsignalgo.GroupMasterKey { +func masterKeyToBytes(groupMasterKey SerializedGroupMasterKey) libsignalgo.GroupMasterKey { // We are very tricksy, groupMasterKey is just base64 encoded group master key :O masterKeyBytes, err := base64.StdEncoding.DecodeString(string(groupMasterKey)) if err != nil { - panic(fmt.Errorf("we should always be able to decode groupMasterKey into masterKeyBytes: %w", err)) + //zlog.Err(err).Msg("") + zlog.Fatal().Err(err).Msg("We should always be able to decode groupMasterKey into masterKeyBytes") } return libsignalgo.GroupMasterKey(masterKeyBytes) } -func masterKeyFromBytes(masterKey libsignalgo.GroupMasterKey) types.SerializedGroupMasterKey { - return types.SerializedGroupMasterKey(base64.StdEncoding.EncodeToString(masterKey[:])) +func masterKeyFromBytes(masterKey libsignalgo.GroupMasterKey) SerializedGroupMasterKey { + return SerializedGroupMasterKey(base64.StdEncoding.EncodeToString(masterKey[:])) } -func inviteLinkPasswordToBytes(inviteLinkPassword types.SerializedInviteLinkPassword) ([]byte, error) { - inviteLinkPasswordBytes, err := base64.StdEncoding.DecodeString((string(inviteLinkPassword))) - if err != nil { - return nil, err - } - return inviteLinkPasswordBytes, nil -} - -func InviteLinkPasswordFromBytes(inviteLinkPassword []byte) types.SerializedInviteLinkPassword { - return types.SerializedInviteLinkPassword(base64.StdEncoding.EncodeToString(inviteLinkPassword)) -} - -func groupIdentifierFromMasterKey(masterKey types.SerializedGroupMasterKey) (types.GroupIdentifier, error) { - groupIdentifier, err := masterKeyToBytes(masterKey).GroupIdentifier() +func groupIdentifierFromMasterKey(masterKey SerializedGroupMasterKey) (types.GroupIdentifier, error) { + groupSecretParams, err := libsignalgo.DeriveGroupSecretParamsFromMasterKey(masterKeyToBytes(masterKey)) if err != nil { + zlog.Err(err).Msg("DeriveGroupSecretParamsFromMasterKey error") return "", err } - return types.BytesToGroupIdentifier(groupIdentifier), nil + // Get the "group identifier" that isn't just the master key + groupPublicParams, err := groupSecretParams.GetPublicParams() + if err != nil { + zlog.Err(err).Msg("GetPublicParams error") + return "", err + } + groupIdentifier, err := libsignalgo.GetGroupIdentifier(*groupPublicParams) + if err != nil { + zlog.Err(err).Msg("GetGroupIdentifier error") + return "", err + } + base64GroupIdentifier := base64.StdEncoding.EncodeToString(groupIdentifier[:]) + gid := types.GroupIdentifier(base64GroupIdentifier) + return gid, nil } -func decryptGroup(ctx context.Context, encryptedGroup *signalpb.Group, groupMasterKey types.SerializedGroupMasterKey) (*Group, error) { - log := zerolog.Ctx(ctx).With().Str("action", "decrypt group").Logger() +func decryptGroup(encryptedGroup *signalpb.Group, groupMasterKey SerializedGroupMasterKey) (*Group, error) { decryptedGroup := &Group{ - GroupMasterKey: groupMasterKey, + groupMasterKey: groupMasterKey, } groupSecretParams, err := libsignalgo.DeriveGroupSecretParamsFromMasterKey(masterKeyToBytes(groupMasterKey)) if err != nil { - log.Err(err).Msg("DeriveGroupSecretParamsFromMasterKey error") + zlog.Err(err).Msg("DeriveGroupSecretParamsFromMasterKey error") return nil, err } gid, err := groupIdentifierFromMasterKey(groupMasterKey) if err != nil { - log.Err(err).Msg("groupIdentifierFromMasterKey error") + zlog.Err(err).Msg("groupIdentifierFromMasterKey error") return nil, err } decryptedGroup.GroupIdentifier = gid @@ -470,7 +272,7 @@ func decryptGroup(ctx context.Context, encryptedGroup *signalpb.Group, groupMast descriptionBlob, err := decryptGroupPropertyIntoBlob(groupSecretParams, encryptedGroup.Description) if err == nil { // treat a failure in obtaining the description as non-fatal - decryptedGroup.Description = cleanupStringProperty(descriptionBlob.GetDescriptionText()) + decryptedGroup.Description = cleanupStringProperty(descriptionBlob.GetDescription()) } if encryptedGroup.DisappearingMessagesTimer != nil && len(encryptedGroup.DisappearingMessagesTimer) > 0 { @@ -482,97 +284,51 @@ func decryptGroup(ctx context.Context, encryptedGroup *signalpb.Group, groupMast } // These aren't encrypted - decryptedGroup.AvatarPath = encryptedGroup.AvatarUrl - decryptedGroup.Revision = encryptedGroup.Version + decryptedGroup.AvatarPath = encryptedGroup.Avatar + decryptedGroup.Revision = encryptedGroup.Revision // Decrypt members + decryptedGroup.Members = make([]*GroupMember, 0) for _, member := range encryptedGroup.Members { if member == nil { continue } - decryptedMember, err := decryptMember(ctx, member, groupSecretParams) + encryptedUserID := libsignalgo.UUIDCiphertext(member.UserId) + userID, err := groupSecretParams.DecryptUUID(encryptedUserID) if err != nil { + zlog.Err(err).Msg("DecryptUUID UserId error") return nil, err } - decryptedGroup.Members = append(decryptedGroup.Members, decryptedMember) - } - - for _, pendingMember := range encryptedGroup.MembersPendingProfileKey { - if pendingMember == nil { - continue - } - decryptedPendingMember, err := decryptPendingMember(ctx, pendingMember, groupSecretParams) - if err != nil { - continue - // decryptPendingMember returns an error if the userID is a PNI, keep decrypting - } - decryptedGroup.PendingMembers = append(decryptedGroup.PendingMembers, decryptedPendingMember) - } - - for _, requestingMember := range encryptedGroup.MembersPendingAdminApproval { - if requestingMember == nil { - continue - } - decryptedRequestingMember, err := decryptRequestingMember(ctx, requestingMember, groupSecretParams) + encryptedProfileKey := libsignalgo.ProfileKeyCiphertext(member.ProfileKey) + profileKey, err := groupSecretParams.DecryptProfileKey(encryptedProfileKey, *userID) if err != nil { + zlog.Err(err).Msg("DecryptProfileKey ProfileKey error") return nil, err } - decryptedGroup.RequestingMembers = append(decryptedGroup.RequestingMembers, decryptedRequestingMember) - } - - for _, bannedMember := range encryptedGroup.MembersBanned { - if bannedMember == nil { - continue - } - encryptedUserID := libsignalgo.UUIDCiphertext(bannedMember.UserId) - serviceID, err := groupSecretParams.DecryptServiceID(encryptedUserID) - if err != nil { - log.Err(err).Msg("DecryptUUID UserId error") - return nil, err - } - decryptedGroup.BannedMembers = append(decryptedGroup.BannedMembers, &BannedMember{ - ServiceID: serviceID, - Timestamp: bannedMember.Timestamp, + decryptedGroup.Members = append(decryptedGroup.Members, &GroupMember{ + UserID: userID.String(), + ProfileKey: *profileKey, + Role: GroupMemberRole(member.Role), + JoinedAtRevision: member.JoinedAtRevision, }) } - if encryptedGroup.AccessControl != nil { - decryptedGroup.AccessControl = &GroupAccessControl{ - Members: (AccessControl)(encryptedGroup.AccessControl.Members), - Attributes: (AccessControl)(encryptedGroup.AccessControl.Attributes), - AddFromInviteLink: (AccessControl)(encryptedGroup.AccessControl.AddFromInviteLink), - } - } - if len(encryptedGroup.InviteLinkPassword) > 0 { - inviteLinkPassword := InviteLinkPasswordFromBytes(encryptedGroup.InviteLinkPassword) - decryptedGroup.InviteLinkPassword = &inviteLinkPassword - } return decryptedGroup, nil } func decryptGroupPropertyIntoBlob(groupSecretParams libsignalgo.GroupSecretParams, encryptedProperty []byte) (*signalpb.GroupAttributeBlob, error) { decryptedProperty, err := groupSecretParams.DecryptBlobWithPadding(encryptedProperty) if err != nil { - return nil, fmt.Errorf("error decrypting blob with padding: %w", err) + zlog.Err(err).Msg("DecryptBlobWithPadding error") + return nil, err } - var propertyBlob signalpb.GroupAttributeBlob - err = proto.Unmarshal(decryptedProperty, &propertyBlob) + propertyBlob := &signalpb.GroupAttributeBlob{} + err = proto.Unmarshal(decryptedProperty, propertyBlob) if err != nil { - return nil, fmt.Errorf("error unmarshalling blob: %w", err) + zlog.Err(err).Msg("Unmarshal error") + return nil, err } - return &propertyBlob, nil -} - -func encryptBlobIntoGroupProperty(groupSecretParams libsignalgo.GroupSecretParams, attributeBlob *signalpb.GroupAttributeBlob) (*[]byte, error) { - decryptedProperty, err := proto.Marshal(attributeBlob) - if err != nil { - return nil, fmt.Errorf("error marshalling groupProperty: %w", err) - } - encryptedProperty, err := groupSecretParams.EncryptBlobWithPaddingDeterministic(libsignalgo.GenerateRandomness(), decryptedProperty, 0) - if err != nil { - return nil, fmt.Errorf("error encrypting blob with padding: %w", err) - } - return &encryptedProperty, nil + return propertyBlob, nil } func cleanupStringProperty(property string) string { @@ -589,10 +345,11 @@ func cleanupStringMapping(r rune) rune { return -1 } -func decryptGroupAvatar(encryptedAvatar []byte, groupMasterKey types.SerializedGroupMasterKey) ([]byte, error) { +func decryptGroupAvatar(encryptedAvatar []byte, groupMasterKey SerializedGroupMasterKey) ([]byte, error) { groupSecretParams, err := libsignalgo.DeriveGroupSecretParamsFromMasterKey(masterKeyToBytes(groupMasterKey)) if err != nil { - return nil, fmt.Errorf("error deriving group secret params from master key: %w", err) + zlog.Err(err).Msg("DeriveGroupSecretParamsFromMasterKey error") + return nil, err } avatarBlob, err := decryptGroupPropertyIntoBlob(groupSecretParams, encryptedAvatar) if err != nil { @@ -605,7 +362,7 @@ func decryptGroupAvatar(encryptedAvatar []byte, groupMasterKey types.SerializedG } func groupMetadataForDataMessage(group Group) *signalpb.GroupContextV2 { - masterKey := masterKeyToBytes(group.GroupMasterKey) + masterKey := masterKeyToBytes(group.groupMasterKey) masterKeyBytes := masterKey[:] return &signalpb.GroupContextV2{ MasterKey: masterKeyBytes, @@ -613,20 +370,19 @@ func groupMetadataForDataMessage(group Group) *signalpb.GroupContextV2 { } } -func (cli *Client) fetchGroupByID(ctx context.Context, gid types.GroupIdentifier) (*Group, error) { - groupMasterKey, err := cli.Store.GroupStore.MasterKeyFromGroupIdentifier(ctx, gid) +func fetchGroupByID(ctx context.Context, d *Device, gid types.GroupIdentifier) (*Group, error) { + groupMasterKey, err := d.GroupStore.MasterKeyFromGroupIdentifier(gid, ctx) if err != nil { - return nil, fmt.Errorf("failed to get group master key: %w", err) + zlog.Err(err).Msg("Failed to get group master key") + return nil, err } if groupMasterKey == "" { - return nil, fmt.Errorf("%w for %s", ErrGroupMasterKeyNotFound, gid) + err := fmt.Errorf("No group master key found for group identifier") + zlog.Err(err).Str("gid", string(gid)).Msg("") + return nil, err } - return cli.fetchGroupWithMasterKey(ctx, groupMasterKey) -} - -func (cli *Client) fetchGroupWithMasterKey(ctx context.Context, groupMasterKey types.SerializedGroupMasterKey) (*Group, error) { masterKeyBytes := masterKeyToBytes(groupMasterKey) - groupAuth, err := cli.GetAuthorizationForToday(ctx, masterKeyBytes) + groupAuth, err := GetAuthorizationForToday(ctx, d, masterKeyBytes) if err != nil { return nil, err } @@ -634,1199 +390,179 @@ func (cli *Client) fetchGroupWithMasterKey(ctx context.Context, groupMasterKey t Username: &groupAuth.Username, Password: &groupAuth.Password, ContentType: web.ContentTypeProtobuf, + Host: web.StorageUrlHost, } - response, err := web.SendHTTPRequest(ctx, web.StorageHostname, http.MethodGet, "/v2/groups", opts) - defer web.CloseBody(response) + response, err := web.SendHTTPRequest(http.MethodGet, "/v1/groups", opts) if err != nil { + zlog.Err(err).Msg("RetrieveGroupById SendHTTPRequest error") return nil, err } if response.StatusCode != 200 { - return nil, fmt.Errorf("fetchGroupByID SendHTTPRequest bad status: %d", response.StatusCode) - } - return cli.parseGroupResponse(ctx, response, groupMasterKey) -} - -func (cli *Client) parseGroupResponse(ctx context.Context, response *http.Response, masterKey types.SerializedGroupMasterKey) (*Group, error) { - var groupResponse signalpb.GroupResponse - groupBytes, err := io.ReadAll(response.Body) - if err != nil { + err := fmt.Errorf("RetrieveGroupById SendHTTPRequest bad status: %v", response.StatusCode) + zlog.Err(err).Msg("") return nil, err } - err = proto.Unmarshal(groupBytes, &groupResponse) + encryptedGroup := &signalpb.Group{} + groupBytes, err := io.ReadAll(response.Body) if err != nil { - return nil, fmt.Errorf("failed to unmarshal group: %w", err) + zlog.Err(err).Msg("RetrieveGroupById ReadAll error") + return nil, err + } + err = proto.Unmarshal(groupBytes, encryptedGroup) + if err != nil { + zlog.Err(err).Msg("RetrieveGroupById Unmarshal error") + return nil, err } - group, err := decryptGroup(ctx, groupResponse.Group, masterKey) + group, err := decryptGroup(encryptedGroup, groupMasterKey) if err != nil { - return nil, fmt.Errorf("failed to decrypt group: %w", err) - } - err = cli.GroupCache.Put(group, groupResponse.GroupSendEndorsementsResponse) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to cache group response") + zlog.Err(err).Msg("RetrieveGroupById decryptGroup error") + return nil, err } // Store the profile keys in case they're new for _, member := range group.Members { - err = cli.Store.RecipientStore.StoreProfileKey(ctx, member.ACI, member.ProfileKey) + err = d.ProfileKeyStore.StoreProfileKey(member.UserID, member.ProfileKey, ctx) if err != nil { - return nil, fmt.Errorf("failed to store profile key: %w", err) - } - } - for _, requestingMember := range group.RequestingMembers { - err = cli.Store.RecipientStore.StoreProfileKey(ctx, requestingMember.ACI, requestingMember.ProfileKey) - if err != nil { - return nil, fmt.Errorf("failed to store profile key: %w", err) + zlog.Err(err).Msg("DecryptGroup StoreProfileKey error") + //return nil, err } } return group, nil } -func (cli *Client) DownloadGroupAvatar(ctx context.Context, avatarPath string, groupMasterKey types.SerializedGroupMasterKey) ([]byte, error) { - username, password := cli.Store.BasicAuthCreds() +func fetchAndDecryptGroupAvatarImage(d *Device, path string, masterKey SerializedGroupMasterKey) ([]byte, error) { + // Fetch avatar + username, password := d.Data.BasicAuthCreds() opts := &web.HTTPReqOpt{ + Host: web.CDNUrlHost, Username: &username, Password: &password, } - resp, err := web.SendHTTPRequest(ctx, web.CDN1Hostname, http.MethodGet, avatarPath, opts) - defer web.CloseBody(resp) + zlog.Info().Str("avatar_path", path).Msg("Fetching group avatar") + resp, err := web.SendHTTPRequest(http.MethodGet, path, opts) if err != nil { - return nil, fmt.Errorf("failed to send request: %w", err) + zlog.Err(err).Msg("error fetching group avatar") + return nil, err } if resp.StatusCode < 200 || resp.StatusCode >= 300 { - return nil, fmt.Errorf("unexpected response status %d", resp.StatusCode) + err := errors.New(fmt.Sprintf("%v (unsuccessful status code)", resp.Status)) + zlog.Err(err).Msg("bad status fetching group avatar") + return nil, err } encryptedAvatar, err := io.ReadAll(resp.Body) if err != nil { - return nil, fmt.Errorf("failed to read response: %w", err) + zlog.Err(err).Msg("error reading group avatar") + return nil, err } - decrypted, err := decryptGroupAvatar(encryptedAvatar, groupMasterKey) - if err != nil { - return nil, fmt.Errorf("failed to decrypt avatar: %w", err) - } - return decrypted, nil + encryptedBytes := encryptedAvatar + + // Decrypt avatar + decryptedBytes, err := decryptGroupAvatar(encryptedBytes, masterKey) + return decryptedBytes, nil } -func (cli *Client) RetrieveGroupByID(ctx context.Context, gid types.GroupIdentifier, revision uint32) (*Group, *SendEndorsementCache, error) { - cached, endorsement, ok := cli.GroupCache.Get(gid) - if ok && cached.Revision >= revision { - return cached, endorsement, nil +func RetrieveGroupByID(ctx context.Context, d *Device, gid types.GroupIdentifier) (*Group, error) { + d.initGroupCache() + + lastFetched, ok := d.Connection.GroupCache.lastFetched[gid] + if ok && time.Since(lastFetched) < 1*time.Hour { + group, ok := d.Connection.GroupCache.groups[gid] + if ok { + return group, nil + } } - group, err := cli.fetchGroupByID(ctx, gid) + group, err := fetchGroupByID(ctx, d, gid) + if err != nil { + return nil, err + } + d.Connection.GroupCache.groups[gid] = group + d.Connection.GroupCache.lastFetched[gid] = time.Now() + return group, nil +} + +func RetrieveGroupAndAvatarByID(ctx context.Context, d *Device, gid types.GroupIdentifier) (*Group, []byte, error) { + group, err := RetrieveGroupByID(ctx, d, gid) if err != nil { return nil, nil, err } - cached, endorsement, ok = cli.GroupCache.Get(gid) - if !ok { - zerolog.Ctx(ctx).Warn().Msg("Group not found in cache after fetching") - return group, nil, nil + gid = group.GroupIdentifier + + // If there is an avatarPath, and it's different from the cached one, fetch it + // (we only return the avatar if it's different from the cached one) + var avatarImage []byte + cachedAvatarPath, _ := d.Connection.GroupCache.avatarPaths[gid] + if group.AvatarPath != "" && cachedAvatarPath != group.AvatarPath { + avatarImage, err = fetchAndDecryptGroupAvatarImage(d, group.AvatarPath, group.groupMasterKey) + if err != nil { + zlog.Err(err).Msg("error fetching group avatarImage") + return nil, nil, err + } } - return cached, endorsement, nil + d.Connection.GroupCache.avatarPaths[gid] = group.AvatarPath + + return group, avatarImage, nil +} + +func InvalidateGroupCache(d *Device, gid types.GroupIdentifier) { + if d.Connection.GroupCache == nil { + return + } + delete(d.Connection.GroupCache.groups, gid) + delete(d.Connection.GroupCache.lastFetched, gid) + // Don't delete avatarPaths, they can stay cached } // We should store the group master key in the group store as soon as we see it, // then use the group identifier to refer to groups. As a convenience, we return // the group identifier, which is derived from the group master key. -func (cli *Client) StoreMasterKey(ctx context.Context, groupMasterKey types.SerializedGroupMasterKey) (types.GroupIdentifier, error) { +func StoreMasterKey(ctx context.Context, d *Device, groupMasterKey SerializedGroupMasterKey) (types.GroupIdentifier, error) { groupIdentifier, err := groupIdentifierFromMasterKey(groupMasterKey) if err != nil { - return "", fmt.Errorf("groupIdentifierFromMasterKey error: %w", err) + zlog.Err(err).Msg("groupIdentifierFromMasterKey error") + return "", err } - err = cli.Store.GroupStore.StoreMasterKey(ctx, groupIdentifier, groupMasterKey) + err = d.GroupStore.StoreMasterKey(groupIdentifier, groupMasterKey, ctx) if err != nil { - return groupIdentifier, fmt.Errorf("StoreMasterKey error: %w", err) + zlog.Err(err).Msg("StoreMasterKey error") + return "", err } return groupIdentifier, nil } -func (cli *Client) DecryptGroupChange(ctx context.Context, groupContext *signalpb.GroupContextV2) (*GroupChange, error) { - masterKeyBytes := libsignalgo.GroupMasterKey(groupContext.MasterKey) - groupMasterKey := masterKeyFromBytes(masterKeyBytes) - - groupChangeBytes := groupContext.GroupChange - encryptedGroupChange := &signalpb.GroupChange{} - err := proto.Unmarshal(groupChangeBytes, encryptedGroupChange) - if err != nil { - return nil, fmt.Errorf("Error unmarshalling group change: %w", err) +// We need to track active calls so we don't send too many IncomingSignalMessageCalls +// Of course for group calls Signal doesn't tell us *anything* so we're mostly just inferring +// So we just jam a new call ID in, and return true if we *think* this is a new incoming call +func (d *Device) UpdateActiveCalls(gid types.GroupIdentifier, callID string) (isActive bool) { + d.initGroupCache() + // Check to see if we currently have an active call for this group + currentCallID, ok := d.Connection.GroupCache.activeCalls[gid] + if ok { + // If we do, then this must be ending the call + if currentCallID == callID { + delete(d.Connection.GroupCache.activeCalls, gid) + return false + } } - return cli.decryptGroupChange(ctx, encryptedGroupChange, groupMasterKey, true) + d.Connection.GroupCache.activeCalls[gid] = callID + return true } -func (cli *Client) decryptGroupChange(ctx context.Context, encryptedGroupChange *signalpb.GroupChange, groupMasterKey types.SerializedGroupMasterKey, verifySignature bool) (*GroupChange, error) { - log := zerolog.Ctx(ctx).With().Str("action", "decrypt group change").Logger() - serverSignature := encryptedGroupChange.ServerSignature - encryptedActionsBytes := encryptedGroupChange.Actions - var success bool - defer func() { - if !success { - rawGroupID, _ := masterKeyToBytes(groupMasterKey).GroupIdentifier() - if rawGroupID != nil { - cli.GroupCache.Delete(types.GroupIdentifier(rawGroupID.String())) - } - } - }() - - var err error - if verifySignature { - err = libsignalgo.ServerPublicParamsVerifySignature(prodServerPublicParams, encryptedActionsBytes, libsignalgo.NotarySignature(serverSignature)) - if err != nil { - return nil, fmt.Errorf("Failed to verify Server Signature: %w", err) +func (d *Device) initGroupCache() { + if d.Connection.GroupCache == nil { + d.Connection.GroupCache = &GroupCache{ + groups: make(map[types.GroupIdentifier]*Group), + lastFetched: make(map[types.GroupIdentifier]time.Time), + avatarPaths: make(map[types.GroupIdentifier]string), + activeCalls: make(map[types.GroupIdentifier]string), } } - - encryptedActions := signalpb.GroupChange_Actions{} - - err = proto.Unmarshal(encryptedActionsBytes, &encryptedActions) - if err != nil { - return nil, fmt.Errorf("Error unmashalling group change actions: %w", err) - } - - groupSecretParams, err := libsignalgo.DeriveGroupSecretParamsFromMasterKey(masterKeyToBytes(groupMasterKey)) - if err != nil { - log.Err(err).Msg("DeriveGroupSecretParamsFromMasterKey error") - return nil, err - } - - sourceServiceID, err := groupSecretParams.DecryptServiceID(libsignalgo.UUIDCiphertext(encryptedActions.SourceUserId)) - if err != nil { - log.Err(err).Msg("Couldn't decrypt source serviceID") - return nil, err - } - decryptedGroupChange := &GroupChange{ - GroupMasterKey: groupMasterKey, - Revision: encryptedActions.Version, - SourceServiceID: sourceServiceID, - } - - if encryptedActions.ModifyTitle != nil { - titleBlob, err := decryptGroupPropertyIntoBlob(groupSecretParams, encryptedActions.ModifyTitle.Title) - if err != nil { - return nil, err - } - // The actual title is in the blob - newTitle := cleanupStringProperty(titleBlob.GetTitle()) - decryptedGroupChange.ModifyTitle = &newTitle - } - if encryptedActions.ModifyAvatar != nil { - decryptedGroupChange.ModifyAvatar = &encryptedActions.ModifyAvatar.Avatar - } - if encryptedActions.ModifyDescription != nil { - descriptionBlob, err := decryptGroupPropertyIntoBlob(groupSecretParams, encryptedActions.ModifyDescription.Description) - if err == nil { - // treat a failure in obtaining the description as non-fatal - newDescription := cleanupStringProperty(descriptionBlob.GetDescriptionText()) - decryptedGroupChange.ModifyDescription = &newDescription - } - } - - for _, addMember := range encryptedActions.AddMembers { - if addMember == nil { - continue - } - decryptedMember, err := decryptMember(ctx, addMember.Added, groupSecretParams) - if err != nil { - return nil, err - } - decryptedGroupChange.AddMembers = append(decryptedGroupChange.AddMembers, &AddMember{ - GroupMember: *decryptedMember, - JoinFromInviteLink: addMember.JoinFromInviteLink, - }) - err = cli.Store.RecipientStore.StoreProfileKey(ctx, decryptedMember.ACI, decryptedMember.ProfileKey) - if err != nil { - log.Err(err).Msg("failed to store profile key") - return nil, err - } - } - - for _, deleteMember := range encryptedActions.DeleteMembers { - if deleteMember == nil { - continue - } - encryptedUserID := libsignalgo.UUIDCiphertext(deleteMember.DeletedUserId) - serviceID, err := groupSecretParams.DecryptServiceID(encryptedUserID) - if err != nil { - log.Err(err).Msg("DecryptUUID UserId error for deleteMember") - return nil, err - } - if serviceID.Type != libsignalgo.ServiceIDTypeACI { - return nil, fmt.Errorf("wrong ServiceID kind for delete member: expected ACI, got PNI") - } - decryptedGroupChange.DeleteMembers = append(decryptedGroupChange.DeleteMembers, &serviceID.UUID) - } - - for _, modifyMemberRole := range encryptedActions.ModifyMemberRoles { - encryptedUserID := libsignalgo.UUIDCiphertext(modifyMemberRole.UserId) - serviceID, err := groupSecretParams.DecryptServiceID(encryptedUserID) - if err != nil { - log.Err(err).Msg("DecryptUUID UserId error for modifyMemberRole") - return nil, err - } - if serviceID.Type != libsignalgo.ServiceIDTypeACI { - return nil, fmt.Errorf("wrong ServiceID kind for modify member: expected ACI, got PNI") - } - decryptedGroupChange.ModifyMemberRoles = append(decryptedGroupChange.ModifyMemberRoles, &RoleMember{ - ACI: serviceID.UUID, - Role: GroupMemberRole(modifyMemberRole.Role), - }) - } - - for _, modifyProfileKey := range encryptedActions.ModifyMemberProfileKeys { - if modifyProfileKey == nil { - continue - } - aci, profileKey, err := decryptPKeyAndIDorPresentation(ctx, modifyProfileKey.UserId, modifyProfileKey.ProfileKey, modifyProfileKey.Presentation, groupSecretParams) - if err != nil { - return nil, err - } - decryptedGroupChange.ModifyMemberProfileKeys = append(decryptedGroupChange.ModifyMemberProfileKeys, &ProfileKeyMember{ - ACI: *aci, - ProfileKey: *profileKey, - }) - err = cli.Store.RecipientStore.StoreProfileKey(ctx, *aci, *profileKey) - if err != nil { - log.Err(err).Msg("failed to store profile key") - return nil, err - } - } - - for _, addPendingMember := range encryptedActions.AddMembersPendingProfileKey { - if addPendingMember == nil { - continue - } - pendingMember := addPendingMember.Added - decryptedPendingMember, err := decryptPendingMember(ctx, pendingMember, groupSecretParams) - if err != nil { - continue - // decryptPendingMember returns an error if the userID is a PNI, keep decrypting - } - decryptedGroupChange.AddPendingMembers = append(decryptedGroupChange.AddPendingMembers, decryptedPendingMember) - } - - for _, deletePendingMember := range encryptedActions.DeleteMembersPendingProfileKey { - if deletePendingMember == nil { - continue - } - encryptedUserID := libsignalgo.UUIDCiphertext(deletePendingMember.DeletedUserId) - userID, err := groupSecretParams.DecryptServiceID(encryptedUserID) - if err != nil { - log.Err(err).Msg("DecryptUUID UserId error for deletePendingMember") - return nil, err - } - decryptedGroupChange.DeletePendingMembers = append(decryptedGroupChange.DeletePendingMembers, &userID) - } - - for _, promotePendingMember := range encryptedActions.PromoteMembersPendingProfileKey { - if promotePendingMember == nil { - continue - } - aci, profileKey, err := decryptPKeyAndIDorPresentation(ctx, promotePendingMember.UserId, promotePendingMember.ProfileKey, promotePendingMember.Presentation, groupSecretParams) - if err != nil { - return nil, err - } - decryptedGroupChange.PromotePendingMembers = append(decryptedGroupChange.PromotePendingMembers, &PromotePendingMember{ - ACI: *aci, - ProfileKey: *profileKey, - }) - err = cli.Store.RecipientStore.StoreProfileKey(ctx, *aci, *profileKey) - if err != nil { - log.Err(err).Msg("failed to store profile key") - return nil, err - } - } - - for _, promotePendingPniAciMember := range encryptedActions.PromoteMembersPendingPniAciProfileKey { - // TODO: pretending this is a PendingMember should do for mautrix-signal, but we probably want to treat them separately at some point - if promotePendingPniAciMember == nil { - continue - } - aci, profileKey, err := decryptPKeyAndIDorPresentation(ctx, promotePendingPniAciMember.UserId, promotePendingPniAciMember.ProfileKey, promotePendingPniAciMember.Presentation, groupSecretParams) - if err != nil { - return nil, err - } - encryptedUserID := libsignalgo.UUIDCiphertext(promotePendingPniAciMember.Pni) - pniServiceID, err := groupSecretParams.DecryptServiceID(encryptedUserID) - if err != nil { - log.Err(err).Msg("DecryptUUID Pni error for promotePendingPniAciMember") - return nil, err - } - if pniServiceID.Type != libsignalgo.ServiceIDTypePNI { - return nil, fmt.Errorf("wrong ServiceID kind for promote pending pni->aci: expected PNI, got ACI") - } - decryptedGroupChange.PromotePendingPniAciMembers = append(decryptedGroupChange.PromotePendingPniAciMembers, &PromotePendingPniAciMember{ - ACI: *aci, - ProfileKey: *profileKey, - PNI: pniServiceID.UUID, - }) - err = cli.Store.RecipientStore.StoreProfileKey(ctx, *aci, *profileKey) - if err != nil { - log.Err(err).Msg("failed to store profile key") - return nil, err - } - } - - for _, addRequestingMember := range encryptedActions.AddMembersPendingAdminApproval { - if addRequestingMember == nil { - continue - } - decryptedRequestingMember, err := decryptRequestingMember(ctx, addRequestingMember.Added, groupSecretParams) - if err != nil { - return nil, err - } - decryptedGroupChange.AddRequestingMembers = append(decryptedGroupChange.AddRequestingMembers, decryptedRequestingMember) - err = cli.Store.RecipientStore.StoreProfileKey(ctx, decryptedRequestingMember.ACI, decryptedRequestingMember.ProfileKey) - if err != nil { - log.Err(err).Msg("failed to store profile key") - return nil, err - } - } - - for _, deleteRequestingMember := range encryptedActions.DeleteMembersPendingAdminApproval { - if deleteRequestingMember == nil { - continue - } - encryptedUserID := libsignalgo.UUIDCiphertext(deleteRequestingMember.DeletedUserId) - serviceID, err := groupSecretParams.DecryptServiceID(encryptedUserID) - if err != nil { - log.Err(err).Msg("DecryptUUID UserId error for deleteRequestingMember") - return nil, err - } - decryptedGroupChange.DeleteRequestingMembers = append(decryptedGroupChange.DeleteRequestingMembers, &serviceID.UUID) - } - - for _, promoteRequestingMember := range encryptedActions.PromoteMembersPendingAdminApproval { - if promoteRequestingMember == nil { - continue - } - encryptedUserID := libsignalgo.UUIDCiphertext(promoteRequestingMember.UserId) - serviceID, err := groupSecretParams.DecryptServiceID(encryptedUserID) - if err != nil { - log.Err(err).Msg("DecryptUUID UserId error for promoteRequestingMember") - return nil, err - } - decryptedGroupChange.PromoteRequestingMembers = append(decryptedGroupChange.PromoteRequestingMembers, &RoleMember{ - ACI: serviceID.UUID, - Role: GroupMemberRole(promoteRequestingMember.Role), - }) - } - - for _, addBannedMember := range encryptedActions.AddMembersBanned { - if addBannedMember == nil { - continue - } - bannedMember := addBannedMember.Added - encryptedUserID := libsignalgo.UUIDCiphertext(bannedMember.UserId) - serviceID, err := groupSecretParams.DecryptServiceID(encryptedUserID) - if err != nil { - log.Err(err).Msg("DecryptUUID UserId error for addBannedMember") - return nil, err - } - decryptedGroupChange.AddBannedMembers = append(decryptedGroupChange.AddBannedMembers, &BannedMember{ - ServiceID: serviceID, - Timestamp: bannedMember.Timestamp, - }) - } - - for _, deleteBannedMember := range encryptedActions.DeleteMembersBanned { - if deleteBannedMember == nil { - continue - } - encryptedUserID := libsignalgo.UUIDCiphertext(deleteBannedMember.DeletedUserId) - userID, err := groupSecretParams.DecryptServiceID(encryptedUserID) - if err != nil { - log.Err(err).Msg("DecryptUUID UserId error for deleteBannedMember") - return nil, err - } - decryptedGroupChange.DeleteBannedMembers = append(decryptedGroupChange.DeleteBannedMembers, &userID) - } - - if encryptedActions.ModifyAttributesAccess != nil { - decryptedGroupChange.ModifyAttributesAccess = (*AccessControl)(&encryptedActions.ModifyAttributesAccess.AttributesAccess) - } - - if encryptedActions.ModifyMemberAccess != nil { - decryptedGroupChange.ModifyMemberAccess = (*AccessControl)(&encryptedActions.ModifyMemberAccess.MembersAccess) - } - - if encryptedActions.ModifyAddFromInviteLinkAccess != nil { - decryptedGroupChange.ModifyAddFromInviteLinkAccess = (*AccessControl)(&encryptedActions.ModifyAddFromInviteLinkAccess.AddFromInviteLinkAccess) - } - - if encryptedActions.ModifyAnnouncementsOnly != nil { - decryptedGroupChange.ModifyAnnouncementsOnly = &encryptedActions.ModifyAnnouncementsOnly.AnnouncementsOnly - } - if encryptedActions.ModifyDisappearingMessageTimer != nil && len(encryptedActions.ModifyDisappearingMessageTimer.Timer) > 0 { - timerBlob, err := decryptGroupPropertyIntoBlob(groupSecretParams, encryptedActions.ModifyDisappearingMessageTimer.Timer) - if err != nil { - return nil, err - } - newDisappaeringMessagesDuration := timerBlob.GetDisappearingMessagesDuration() - decryptedGroupChange.ModifyDisappearingMessagesDuration = &newDisappaeringMessagesDuration - } - if encryptedActions.ModifyInviteLinkPassword != nil { - inviteLinkPassword := InviteLinkPasswordFromBytes(encryptedActions.ModifyInviteLinkPassword.InviteLinkPassword) - decryptedGroupChange.ModifyInviteLinkPassword = &inviteLinkPassword - } - - success = true - err = cli.GroupCache.ApplyUpdate(decryptedGroupChange, nil) - if err != nil { - log.Err(err).Msg("Failed to apply group change to cache") - } - - return decryptedGroupChange, nil } -func decryptPKeyAndIDorPresentation(ctx context.Context, userID []byte, profileKeyBytes []byte, presentationBytes []byte, groupSecretParams libsignalgo.GroupSecretParams) (*uuid.UUID, *libsignalgo.ProfileKey, error) { - log := zerolog.Ctx(ctx) - var encryptedUserID libsignalgo.UUIDCiphertext - var encryptedProfileKey libsignalgo.ProfileKeyCiphertext - if len(userID) == 0 || len(profileKeyBytes) == 0 { - presentation := libsignalgo.ProfileKeyCredentialPresentation(presentationBytes) - err := presentation.CheckValidContents() - if err != nil { - log.Err(err).Msg("Invalid presentation contents") - return nil, nil, err - } - encryptedUserID, err = presentation.UUIDCiphertext() - if err != nil { - log.Err(err).Msg("unable to get UUID from presentation") - return nil, nil, err - } - encryptedProfileKey, err = presentation.ProfileKeyCiphertext() - if err != nil { - log.Err(err).Msg("unable to get ProfileKey from presentation") - return nil, nil, err - } - } else { - encryptedUserID = libsignalgo.UUIDCiphertext(userID) - encryptedProfileKey = libsignalgo.ProfileKeyCiphertext(profileKeyBytes) - } - serviceID, err := groupSecretParams.DecryptServiceID(encryptedUserID) - if err != nil { - log.Err(err).Msg("Failed to decrypt ServiceID") - return nil, nil, err - } - profileKey, err := groupSecretParams.DecryptProfileKey(encryptedProfileKey, serviceID.UUID) - if err != nil { - return nil, nil, err - } - if serviceID.Type == libsignalgo.ServiceIDTypePNI { - return nil, nil, fmt.Errorf("wrong serviceid kind for profile key: expected ACI, got PNI") - } - return &serviceID.UUID, profileKey, nil - -} - -func decryptMember(ctx context.Context, member *signalpb.Member, groupSecretParams libsignalgo.GroupSecretParams) (*GroupMember, error) { - aci, profileKey, err := decryptPKeyAndIDorPresentation(ctx, member.UserId, member.ProfileKey, member.Presentation, groupSecretParams) - if err != nil { - return nil, err - } - return &GroupMember{ - ACI: *aci, - ProfileKey: *profileKey, - Role: GroupMemberRole(member.Role), - JoinedAtRevision: member.JoinedAtVersion, - }, nil -} - -func decryptPendingMember(ctx context.Context, pendingMember *signalpb.MemberPendingProfileKey, groupSecretParams libsignalgo.GroupSecretParams) (*PendingMember, error) { - log := zerolog.Ctx(ctx) - encryptedUserID := libsignalgo.UUIDCiphertext(pendingMember.Member.UserId) - userID, err := groupSecretParams.DecryptServiceID(encryptedUserID) - if err != nil { - log.Err(err).Msg("DecryptUUID UserId error for pendingMember") - return nil, err - } - // pendingMembers don't have profile keys - encryptedAddedByUserID := pendingMember.AddedByUserId - addedByServiceId, err := groupSecretParams.DecryptServiceID(libsignalgo.UUIDCiphertext(encryptedAddedByUserID)) - if err != nil { - log.Err(err).Msg("DecryptUUID addedByUserId error for pendingMember") - return nil, err - } - return &PendingMember{ - ServiceID: userID, - Role: GroupMemberRole(pendingMember.Member.Role), - AddedByUserID: addedByServiceId.UUID, - Timestamp: pendingMember.Timestamp, - }, nil -} - -func decryptRequestingMember(ctx context.Context, requestingMember *signalpb.MemberPendingAdminApproval, groupSecretParams libsignalgo.GroupSecretParams) (*RequestingMember, error) { - aci, profileKey, err := decryptPKeyAndIDorPresentation(ctx, requestingMember.UserId, requestingMember.ProfileKey, requestingMember.Presentation, groupSecretParams) - if err != nil { - return nil, err - } - return &RequestingMember{ - ACI: *aci, - ProfileKey: *profileKey, - Timestamp: requestingMember.Timestamp, - }, nil -} - -func (cli *Client) EncryptAndSignGroupChange(ctx context.Context, decryptedGroupChange *GroupChange) (*signalpb.GroupChangeResponse, error) { - log := zerolog.Ctx(ctx).With().Str("action", "EncryptGroupChange").Logger() - groupMasterKey := decryptedGroupChange.GroupMasterKey - masterKeyBytes := masterKeyToBytes(groupMasterKey) - groupSecretParams, err := libsignalgo.DeriveGroupSecretParamsFromMasterKey(masterKeyBytes) - if err != nil { - log.Err(err).Msg("Could not get groupSecretParams from master key") - return nil, err - } - groupChangeActions := &signalpb.GroupChange_Actions{Version: decryptedGroupChange.Revision} - if decryptedGroupChange.ModifyTitle != nil { - attributeBlob := signalpb.GroupAttributeBlob{Content: &signalpb.GroupAttributeBlob_Title{Title: *decryptedGroupChange.ModifyTitle}} - encryptedTitle, err := encryptBlobIntoGroupProperty(groupSecretParams, &attributeBlob) - if err != nil { - log.Err(err).Msg("Could not get encrypt Title") - return nil, err - } - groupChangeActions.ModifyTitle = &signalpb.GroupChange_Actions_ModifyTitleAction{Title: *encryptedTitle} - } - if decryptedGroupChange.ModifyDescription != nil { - attributeBlob := signalpb.GroupAttributeBlob{Content: &signalpb.GroupAttributeBlob_DescriptionText{DescriptionText: *decryptedGroupChange.ModifyDescription}} - encryptedDescription, err := encryptBlobIntoGroupProperty(groupSecretParams, &attributeBlob) - if err != nil { - log.Err(err).Msg("Could not get encrypt description") - return nil, err - } - groupChangeActions.ModifyDescription = &signalpb.GroupChange_Actions_ModifyDescriptionAction{Description: *encryptedDescription} - } - if decryptedGroupChange.ModifyAvatar != nil { - groupChangeActions.ModifyAvatar = &signalpb.GroupChange_Actions_ModifyAvatarAction{Avatar: *decryptedGroupChange.ModifyAvatar} - } - for _, addMember := range decryptedGroupChange.AddMembers { - encryptedMember, encryptedPendingMember, err := cli.encryptMember(ctx, &addMember.GroupMember, &groupSecretParams) - if err != nil { - log.Err(err).Msg("Failed to encrypt GroupMember") - } - if encryptedMember != nil { - groupChangeActions.AddMembers = append(groupChangeActions.AddMembers, &signalpb.GroupChange_Actions_AddMemberAction{ - Added: encryptedMember, - JoinFromInviteLink: addMember.JoinFromInviteLink, - }) - } else { - groupChangeActions.AddMembersPendingProfileKey = append(groupChangeActions.AddMembersPendingProfileKey, &signalpb.GroupChange_Actions_AddMemberPendingProfileKeyAction{ - Added: encryptedPendingMember, - }) - } - } - for _, deleteMember := range decryptedGroupChange.DeleteMembers { - encryptedUserID, err := groupSecretParams.EncryptServiceID(libsignalgo.NewACIServiceID(*deleteMember)) - if err != nil { - log.Err(err).Msg("Encrypt UserId error for deleteMember") - return nil, err - } - groupChangeActions.DeleteMembers = append(groupChangeActions.DeleteMembers, &signalpb.GroupChange_Actions_DeleteMemberAction{ - DeletedUserId: encryptedUserID[:], - }) - } - for _, modifyMemberRoles := range decryptedGroupChange.ModifyMemberRoles { - encryptedUserID, err := groupSecretParams.EncryptServiceID(libsignalgo.NewACIServiceID(modifyMemberRoles.ACI)) - if err != nil { - log.Err(err).Msg("Encrypt UserId error for modifyMemberRoles") - return nil, err - } - groupChangeActions.ModifyMemberRoles = append(groupChangeActions.ModifyMemberRoles, &signalpb.GroupChange_Actions_ModifyMemberRoleAction{ - UserId: encryptedUserID[:], - Role: signalpb.Member_Role(modifyMemberRoles.Role), - }) - } - for _, addPendingMember := range decryptedGroupChange.AddPendingMembers { - encryptedPendingMember, err := cli.encryptPendingMember(ctx, addPendingMember, &groupSecretParams) - if err != nil { - log.Err(err).Msg("Failed to encrypt pendingMember") - return nil, err - } - groupChangeActions.AddMembersPendingProfileKey = append(groupChangeActions.AddMembersPendingProfileKey, &signalpb.GroupChange_Actions_AddMemberPendingProfileKeyAction{ - Added: encryptedPendingMember, - }) - } - for _, deletePendingMember := range decryptedGroupChange.DeletePendingMembers { - encryptedUserID, err := groupSecretParams.EncryptServiceID(*deletePendingMember) - if err != nil { - log.Err(err).Msg("Encrypt UserId error for deletePendingMember") - return nil, err - } - groupChangeActions.DeleteMembersPendingProfileKey = append(groupChangeActions.DeleteMembersPendingProfileKey, &signalpb.GroupChange_Actions_DeleteMemberPendingProfileKeyAction{ - DeletedUserId: encryptedUserID[:], - }) - } - for _, promotePendingMember := range decryptedGroupChange.PromotePendingMembers { - expiringProfileKeyCredential, err := cli.FetchExpiringProfileKeyCredentialById(ctx, promotePendingMember.ACI) - if err != nil { - log.Err(err).Msg("failed getting expiring profile key credential for addMember") - return nil, err - } - presentation, err := groupSecretParams.CreateExpiringProfileKeyCredentialPresentation( - prodServerPublicParams, - *expiringProfileKeyCredential, - ) - if err != nil { - log.Err(err).Msg("failed creating expiring profile key credential presentation for addMember") - return nil, err - } - groupChangeActions.PromoteMembersPendingProfileKey = append(groupChangeActions.PromoteMembersPendingProfileKey, &signalpb.GroupChange_Actions_PromoteMemberPendingProfileKeyAction{ - Presentation: *presentation, - }) - } - for _, addRequestingMember := range decryptedGroupChange.AddRequestingMembers { - expiringProfileKeyCredential, err := cli.FetchExpiringProfileKeyCredentialById(ctx, addRequestingMember.ACI) - if err != nil { - log.Err(err).Msg("failed getting expiring profile key credential for addMember") - return nil, err - } - presentation, err := groupSecretParams.CreateExpiringProfileKeyCredentialPresentation( - prodServerPublicParams, - *expiringProfileKeyCredential, - ) - if err != nil { - log.Err(err).Msg("failed creating expiring profile key credential presentation for addMember") - return nil, err - } - groupChangeActions.AddMembersPendingAdminApproval = append(groupChangeActions.AddMembersPendingAdminApproval, &signalpb.GroupChange_Actions_AddMemberPendingAdminApprovalAction{ - Added: &signalpb.MemberPendingAdminApproval{ - Presentation: *presentation, - }, - }) - } - for _, deleteRequestingMember := range decryptedGroupChange.DeleteRequestingMembers { - encryptedUserID, err := groupSecretParams.EncryptServiceID(libsignalgo.NewACIServiceID(*deleteRequestingMember)) - if err != nil { - log.Err(err).Msg("Encrypt UserId error for deleteRequestingMember") - return nil, err - } - groupChangeActions.DeleteMembersPendingAdminApproval = append(groupChangeActions.DeleteMembersPendingAdminApproval, &signalpb.GroupChange_Actions_DeleteMemberPendingAdminApprovalAction{ - DeletedUserId: encryptedUserID[:], - }) - } - for _, promoteRequestingMember := range decryptedGroupChange.PromoteRequestingMembers { - encryptedUserID, err := groupSecretParams.EncryptServiceID(libsignalgo.NewACIServiceID(promoteRequestingMember.ACI)) - if err != nil { - log.Err(err).Msg("Encrypt UserId error for promoteRequestingMember") - return nil, err - } - - groupChangeActions.PromoteMembersPendingAdminApproval = append(groupChangeActions.PromoteMembersPendingAdminApproval, &signalpb.GroupChange_Actions_PromoteMemberPendingAdminApprovalAction{ - UserId: encryptedUserID[:], - Role: signalpb.Member_Role(promoteRequestingMember.Role), - }) - } - for _, addBannedMember := range decryptedGroupChange.AddBannedMembers { - encryptedUserID, err := groupSecretParams.EncryptServiceID(addBannedMember.ServiceID) - if err != nil { - log.Err(err).Msg("Encrypt UserId error for promoteRequestingMember") - return nil, err - } - groupChangeActions.AddMembersBanned = append(groupChangeActions.AddMembersBanned, &signalpb.GroupChange_Actions_AddMemberBannedAction{ - Added: &signalpb.MemberBanned{ - UserId: encryptedUserID[:], - Timestamp: addBannedMember.Timestamp, - }, - }) - } - for _, deleteBannedMember := range decryptedGroupChange.DeleteBannedMembers { - encryptedUserID, err := groupSecretParams.EncryptServiceID(*deleteBannedMember) - if err != nil { - log.Err(err).Msg("Encrypt UserId error for promoteRequestingMember") - return nil, err - } - groupChangeActions.DeleteMembersBanned = append(groupChangeActions.DeleteMembersBanned, &signalpb.GroupChange_Actions_DeleteMemberBannedAction{ - DeletedUserId: encryptedUserID[:], - }) - } - if decryptedGroupChange.ModifyAnnouncementsOnly != nil { - groupChangeActions.ModifyAnnouncementsOnly = &signalpb.GroupChange_Actions_ModifyAnnouncementsOnlyAction{ - AnnouncementsOnly: *decryptedGroupChange.ModifyAnnouncementsOnly, - } - } - if decryptedGroupChange.ModifyAttributesAccess != nil { - groupChangeActions.ModifyAttributesAccess = &signalpb.GroupChange_Actions_ModifyAttributesAccessControlAction{ - AttributesAccess: signalpb.AccessControl_AccessRequired(*decryptedGroupChange.ModifyAttributesAccess), - } - } - if decryptedGroupChange.ModifyMemberAccess != nil { - groupChangeActions.ModifyMemberAccess = &signalpb.GroupChange_Actions_ModifyMembersAccessControlAction{ - MembersAccess: signalpb.AccessControl_AccessRequired(*decryptedGroupChange.ModifyMemberAccess), - } - } - if decryptedGroupChange.ModifyAddFromInviteLinkAccess != nil { - groupChangeActions.ModifyAddFromInviteLinkAccess = &signalpb.GroupChange_Actions_ModifyAddFromInviteLinkAccessControlAction{ - AddFromInviteLinkAccess: signalpb.AccessControl_AccessRequired(*decryptedGroupChange.ModifyAddFromInviteLinkAccess), - } - } - if decryptedGroupChange.ModifyDisappearingMessagesDuration != nil { - attributeBlob := signalpb.GroupAttributeBlob{Content: &signalpb.GroupAttributeBlob_DisappearingMessagesDuration{DisappearingMessagesDuration: *decryptedGroupChange.ModifyDisappearingMessagesDuration}} - encryptedTimer, err := encryptBlobIntoGroupProperty(groupSecretParams, &attributeBlob) - if err != nil { - log.Err(err).Msg("Could not get encrypt Title") - return nil, err - } - groupChangeActions.ModifyDisappearingMessageTimer = &signalpb.GroupChange_Actions_ModifyDisappearingMessageTimerAction{Timer: *encryptedTimer} - } - if decryptedGroupChange.ModifyInviteLinkPassword != nil { - inviteLinkPasswordBytes, err := inviteLinkPasswordToBytes(*decryptedGroupChange.ModifyInviteLinkPassword) - if err != nil { - log.Err(err).Msg("Failed to decode invite link password") - } - groupChangeActions.ModifyInviteLinkPassword = &signalpb.GroupChange_Actions_ModifyInviteLinkPasswordAction{ - InviteLinkPassword: inviteLinkPasswordBytes, - } - } - - return cli.patchGroup(ctx, groupChangeActions, groupMasterKey, nil) -} - -func (cli *Client) encryptMember(ctx context.Context, member *GroupMember, groupSecretParams *libsignalgo.GroupSecretParams) (*signalpb.Member, *signalpb.MemberPendingProfileKey, error) { - log := zerolog.Ctx(ctx) - expiringProfileKeyCredential, err := cli.FetchExpiringProfileKeyCredentialById(ctx, member.ACI) - if err != nil { - log.Err(err).Msg("failed getting expiring profile key credential for member, trying to encrypt as PendingMember") - pendingMember := PendingMember{ - ServiceID: member.UserServiceID(), - Role: member.Role, - AddedByUserID: cli.Store.ACI, - } - encryptedPendingMember, err := cli.encryptPendingMember(ctx, &pendingMember, groupSecretParams) - return nil, encryptedPendingMember, err - } - presentation, err := groupSecretParams.CreateExpiringProfileKeyCredentialPresentation( - prodServerPublicParams, - *expiringProfileKeyCredential, - ) - if err != nil { - log.Err(err).Msg("failed creating expiring profile key credential presentation for addMember") - return nil, nil, err - } - encryptedMember := signalpb.Member{ - Presentation: *presentation, - Role: signalpb.Member_Role(member.Role), - } - return &encryptedMember, nil, nil -} - -func (cli *Client) encryptPendingMember(ctx context.Context, pendingMember *PendingMember, groupSecretParams *libsignalgo.GroupSecretParams) (*signalpb.MemberPendingProfileKey, error) { - log := zerolog.Ctx(ctx) - encryptedUserID, err := groupSecretParams.EncryptServiceID(pendingMember.ServiceID) - if err != nil { - log.Err(err).Msg("Encrypt UserId error for addPendingMember") - return nil, err - } - encryptedAddedByUserID, err := groupSecretParams.EncryptServiceID(libsignalgo.NewACIServiceID(pendingMember.AddedByUserID)) - if err != nil { - log.Err(err).Msg("Encrypt AddedByUserId error for addPendingMember") - return nil, err - } - encryptedPendingMember := signalpb.MemberPendingProfileKey{ - AddedByUserId: encryptedAddedByUserID[:], - Member: &signalpb.Member{ - UserId: encryptedUserID[:], - Role: signalpb.Member_Role(pendingMember.Role), - }, - } - return &encryptedPendingMember, nil -} - -var ( - NoContentError = RespError{Err: "NoContentError"} - GroupPatchNotAcceptedError = RespError{Err: "GroupPatchNotAcceptedError"} - ConflictError = RespError{Err: "ConflictError"} - AuthorizationFailedError = RespError{Err: "AuthorizationFailedError"} - NotFoundError = RespError{Err: "NotFoundError"} - ContactManifestMismatchError = RespError{Err: "ContactManifestMismatchError"} - RateLimitError = RespError{Err: "RateLimitError"} - DeprecatedVersionError = RespError{Err: "DeprecatedVersionError"} - GroupExistsError = RespError{Err: "GroupExistsError"} -) - -type RespError struct { - Err string -} - -func (e RespError) Error() string { - return e.Err -} - -func (cli *Client) patchGroup(ctx context.Context, groupChange *signalpb.GroupChange_Actions, groupMasterKey types.SerializedGroupMasterKey, groupLinkPassword []byte) (*signalpb.GroupChangeResponse, error) { - log := zerolog.Ctx(ctx).With().Str("action", "patchGroup").Logger() - groupAuth, err := cli.GetAuthorizationForToday(ctx, masterKeyToBytes(groupMasterKey)) - if err != nil { - log.Err(err).Msg("Failed to get Authorization for today") - return nil, err - } - var path string - if groupLinkPassword == nil { - path = "/v2/groups/" - } else { - path = fmt.Sprintf("/v2/groups/?inviteLinkPassword=%s", base64.StdEncoding.EncodeToString(groupLinkPassword)) - } - requestBody, err := proto.Marshal(groupChange) - if err != nil { - log.Err(err).Msg("Failed to marshal request") - return nil, err - } - opts := &web.HTTPReqOpt{ - Username: &groupAuth.Username, - Password: &groupAuth.Password, - ContentType: web.ContentTypeProtobuf, - Body: requestBody, - } - resp, err := web.SendHTTPRequest(ctx, web.StorageHostname, http.MethodPatch, path, opts) - defer web.CloseBody(resp) - if err != nil { - return nil, fmt.Errorf("SendRequest error: %w", err) - } - switch resp.StatusCode { - case http.StatusNoContent: - return nil, NoContentError - case http.StatusBadRequest: - return nil, GroupPatchNotAcceptedError - case http.StatusForbidden: - return nil, AuthorizationFailedError - case http.StatusNotFound: - return nil, NotFoundError - case http.StatusConflict: - if resp.Body != nil { - return nil, ContactManifestMismatchError - } else { - return nil, ConflictError - } - case http.StatusTooManyRequests: - return nil, RateLimitError - case 499: - return nil, DeprecatedVersionError - } - if resp.Body == nil { - return nil, errors.New("no response body") - } - body, err := io.ReadAll(resp.Body) - if err != nil { - return nil, fmt.Errorf("failed to read storage manifest response: %w", err) - } - var changeResp signalpb.GroupChangeResponse - err = proto.Unmarshal(body, &changeResp) - if err != nil { - return nil, fmt.Errorf("failed to unmarshal signed groupChange: %w", err) - } - return &changeResp, nil -} - -var ErrGroupMasterKeyNotFound = errors.New("group master key not found in store") - -func (cli *Client) UpdateGroup(ctx context.Context, groupChange *GroupChange, gid types.GroupIdentifier) (uint32, error) { - log := zerolog.Ctx(ctx).With().Str("action", "UpdateGroup").Logger() - groupMasterKey, err := cli.Store.GroupStore.MasterKeyFromGroupIdentifier(ctx, gid) - if err != nil { - return 0, fmt.Errorf("failed to get master key for group: %w", err) - } else if groupMasterKey == "" { - return 0, ErrGroupMasterKeyNotFound - } - groupChange.GroupMasterKey = groupMasterKey - masterKeyBytes := masterKeyToBytes(groupMasterKey) - var refetchedAddMemberCredentials bool - var signedGroupChange *signalpb.GroupChangeResponse - group, _, err := cli.RetrieveGroupByID(ctx, gid, 0) - if err != nil { - return 0, fmt.Errorf("failed to fetch group info to update: %w", err) - } - if group.InviteLinkPassword == nil && groupChange.ModifyAddFromInviteLinkAccess != nil && groupChange.ModifyInviteLinkPassword != nil { - groupChange.ModifyInviteLinkPassword = ptr.Ptr(GenerateInviteLinkPassword()) - } - groupChange.Revision = group.Revision + 1 - for attempt := 0; ; attempt++ { - signedGroupChange, err = cli.EncryptAndSignGroupChange(ctx, groupChange) - if err == nil { - break - } else if attempt >= 5 { - return 0, fmt.Errorf("failed to encrypt and sign group change after multiple retries: %w", err) - } else if errors.Is(err, GroupPatchNotAcceptedError) { - log.Err(err).Msg("Failed to apply group change, retrying...") - if len(groupChange.AddMembers) > 0 && !refetchedAddMemberCredentials { - refetchedAddMemberCredentials = true - // change = refetchAddMemberCredentials(change); TODO - } else { - return 0, fmt.Errorf("failed to update group: %w", err) - } - } else if errors.Is(err, ConflictError) { - cli.GroupCache.Delete(gid) - group, _, err = cli.RetrieveGroupByID(ctx, gid, 0) - if err != nil { - return 0, fmt.Errorf("failed to fetch group after conflict: %w", err) - } - groupChange.resolveConflict(group) - if groupChange.isEmpty() { - log.Debug().Msg("Change is empty after conflict resolution") - } - groupChange.Revision = group.Revision + 1 - } else { - return 0, fmt.Errorf("unknown error encrypting and signing group change: %w", err) - } - } - if signedGroupChange == nil { - return 0, fmt.Errorf("no signed group change returned: %w", err) - } - err = cli.GroupCache.ApplyUpdate(groupChange, signedGroupChange.GroupSendEndorsementsResponse) - if err != nil { - log.Err(err).Msg("Failed to apply group change to cache") - } - groupChangeBytes, err := proto.Marshal(signedGroupChange.GroupChange) - if err != nil { - return 0, fmt.Errorf("failed to marshal signed group change: %w", err) - } - groupContext := &signalpb.GroupContextV2{ - Revision: &groupChange.Revision, - GroupChange: groupChangeBytes, - MasterKey: masterKeyBytes[:], - } - _, err = cli.SendGroupUpdate(ctx, group, groupContext, groupChange) - if err != nil { - log.Err(err).Msg("Error sending GroupChange to group members") - } - return groupChange.Revision, nil -} - -func (cli *Client) EncryptGroup(ctx context.Context, decryptedGroup *Group, groupSecretParams libsignalgo.GroupSecretParams) (*signalpb.Group, error) { - log := zerolog.Ctx(ctx) - attributeBlob := signalpb.GroupAttributeBlob{Content: &signalpb.GroupAttributeBlob_Title{Title: decryptedGroup.Title}} - encryptedTitle, err := encryptBlobIntoGroupProperty(groupSecretParams, &attributeBlob) - if err != nil { - log.Err(err).Msg("Could not get encrypt Title") - return nil, err - } - groupPublicParams, err := groupSecretParams.GetPublicParams() - if err != nil { - log.Err(err).Msg("Couldn't get public params from GroupSecretParams") - return nil, err - } - encryptedGroup := &signalpb.Group{ - PublicKey: groupPublicParams[:], - Title: *encryptedTitle, - AvatarUrl: decryptedGroup.AvatarPath, - AnnouncementsOnly: decryptedGroup.AnnouncementsOnly, - Version: 0, - } - if decryptedGroup.Description != "" { - attributeBlob := signalpb.GroupAttributeBlob{Content: &signalpb.GroupAttributeBlob_DescriptionText{DescriptionText: decryptedGroup.Description}} - encryptedDescription, err := encryptBlobIntoGroupProperty(groupSecretParams, &attributeBlob) - if err != nil { - log.Err(err).Msg("Could not get encrypt Description") - return nil, err - } - encryptedGroup.Description = *encryptedDescription - } - if decryptedGroup.AccessControl != nil { - encryptedGroup.AccessControl = &signalpb.AccessControl{ - Members: signalpb.AccessControl_AccessRequired(decryptedGroup.AccessControl.Members), - Attributes: signalpb.AccessControl_AccessRequired(decryptedGroup.AccessControl.Attributes), - AddFromInviteLink: signalpb.AccessControl_AccessRequired(decryptedGroup.AccessControl.AddFromInviteLink), - } - if decryptedGroup.AccessControl.AddFromInviteLink != AccessControl_UNSATISFIABLE { - encryptedGroup.InviteLinkPassword = random.Bytes(16) - } - } - for _, member := range decryptedGroup.Members { - encryptedMember, encryptedPendingMember, err := cli.encryptMember(ctx, member, &groupSecretParams) - if err != nil { - log.Err(err).Msg("Failed to encrypt GroupMember") - } - if encryptedMember != nil { - encryptedGroup.Members = append(encryptedGroup.Members, encryptedMember) - } else { - encryptedGroup.MembersPendingProfileKey = append(encryptedGroup.MembersPendingProfileKey, encryptedPendingMember) - } - } - for _, pendingMember := range decryptedGroup.PendingMembers { - encryptedPendingMember, err := cli.encryptPendingMember(ctx, pendingMember, &groupSecretParams) - if err != nil { - log.Err(err).Msg("Failed to encrypt pendingMember") - return nil, err - } - encryptedGroup.MembersPendingProfileKey = append(encryptedGroup.MembersPendingProfileKey, encryptedPendingMember) - } - return encryptedGroup, nil -} - -func PrepareGroupCreation(decryptedGroup *Group) (libsignalgo.GroupMasterKey, error) { - var masterKeyBytes libsignalgo.GroupMasterKey - if decryptedGroup.GroupMasterKey == "" { - masterKeyBytes = libsignalgo.GroupMasterKey(random.Bytes(32)) - decryptedGroup.GroupMasterKey = masterKeyFromBytes(masterKeyBytes) - } else { - masterKeyBytes = masterKeyToBytes(decryptedGroup.GroupMasterKey) - } - if decryptedGroup.GroupIdentifier == "" { - var err error - decryptedGroup.GroupIdentifier, err = groupIdentifierFromMasterKey(decryptedGroup.GroupMasterKey) - if err != nil { - return masterKeyBytes, err - } - } - return masterKeyBytes, nil -} - -func (cli *Client) createGroupOnServer(ctx context.Context, decryptedGroup *Group) (*Group, error) { - log := zerolog.Ctx(ctx).With().Str("action", "CreateGroupOnServer").Logger() - masterKeyBytes, err := PrepareGroupCreation(decryptedGroup) - if err != nil { - return nil, err - } - err = cli.Store.GroupStore.StoreMasterKey(ctx, decryptedGroup.GroupIdentifier, decryptedGroup.GroupMasterKey) - if err != nil { - return nil, fmt.Errorf("StoreMasterKey error: %w", err) - } - groupSecretParams, err := libsignalgo.DeriveGroupSecretParamsFromMasterKey(masterKeyBytes) - if err != nil { - log.Err(err).Msg("DeriveGroupSecretParamsFromMasterKey error") - return nil, err - } - encryptedGroup, err := cli.EncryptGroup(ctx, decryptedGroup, groupSecretParams) - if err != nil { - log.Err(err).Msg("Failed to encrypt group") - return nil, err - } - groupAuth, err := cli.GetAuthorizationForToday(ctx, masterKeyBytes) - if err != nil { - log.Err(err).Msg("Failed to get Authorization for today") - return nil, err - } - path := "/v2/groups/" - requestBody, err := proto.Marshal(encryptedGroup) - if err != nil { - log.Err(err).Msg("Failed to marshal request") - return nil, err - } - opts := &web.HTTPReqOpt{ - Username: &groupAuth.Username, - Password: &groupAuth.Password, - ContentType: web.ContentTypeProtobuf, - Body: requestBody, - } - resp, err := web.SendHTTPRequest(ctx, web.StorageHostname, http.MethodPut, path, opts) - defer web.CloseBody(resp) - if err != nil { - return nil, fmt.Errorf("SendRequest error: %w", err) - } - switch resp.StatusCode { - case http.StatusNoContent: - return nil, NoContentError - case http.StatusForbidden: - return nil, AuthorizationFailedError - case http.StatusNotFound: - return nil, NotFoundError - case http.StatusConflict: - return nil, GroupExistsError - case http.StatusTooManyRequests: - return nil, RateLimitError - case 499: - return nil, DeprecatedVersionError - case http.StatusBadRequest: - return nil, fmt.Errorf("failed to put new group: bad request") - } - return cli.parseGroupResponse(ctx, resp, decryptedGroup.GroupMasterKey) -} - -func GenerateInviteLinkPassword() types.SerializedInviteLinkPassword { - return InviteLinkPasswordFromBytes(random.Bytes(16)) -} - -func (cli *Client) CreateGroup(ctx context.Context, decryptedGroup *Group) (*Group, error) { - log := zerolog.Ctx(ctx).With().Str("action", "CreateGroup").Logger() - group, err := cli.createGroupOnServer(ctx, decryptedGroup) - if err != nil { - log.Err(err).Msg("Error creating group on server") - return nil, err - } - masterKeyBytes := masterKeyToBytes(group.GroupMasterKey) - groupContext := &signalpb.GroupContextV2{Revision: &group.Revision, MasterKey: masterKeyBytes[:]} - _, err = cli.SendGroupUpdate(ctx, group, groupContext, nil) - if err != nil { - log.Err(err).Msg("Error sending GroupUpdate to group members") - return nil, err - } - return group, nil -} - -func (cli *Client) GetGroupHistoryPage(ctx context.Context, gid types.GroupIdentifier, fromRevision uint32, includeFirstState bool) ([]*GroupChangeState, error) { - log := zerolog.Ctx(ctx).With().Str("action", "GetGroupHistoryPage").Logger() - groupMasterKey, err := cli.Store.GroupStore.MasterKeyFromGroupIdentifier(ctx, gid) - if err != nil { - log.Err(err).Msg("Failed to get group master key") - return nil, err - } - if groupMasterKey == "" { - return nil, ErrGroupMasterKeyNotFound - } - masterKeyBytes := masterKeyToBytes(groupMasterKey) - groupAuth, err := cli.GetAuthorizationForToday(ctx, masterKeyBytes) - if err != nil { - return nil, err - } - opts := &web.HTTPReqOpt{ - Username: &groupAuth.Username, - Password: &groupAuth.Password, - ContentType: web.ContentTypeProtobuf, - Headers: map[string]string{ - // TODO actually cache the data and provide real expiry timestamp - "Cached-Send-Endorsements": "0", - }, - } - // highest known epoch seems to always be 5, but that may change in the future. includeLastState is always false - path := fmt.Sprintf("/v2/groups/logs/%d?maxSupportedChangeEpoch=%d&includeFirstState=%t&includeLastState=false", fromRevision, 5, includeFirstState) - response, err := web.SendHTTPRequest(ctx, web.StorageHostname, http.MethodGet, path, opts) - defer web.CloseBody(response) - if err != nil { - return nil, err - } - if response.StatusCode != 200 { - return nil, fmt.Errorf("fetchGroupByID SendHTTPRequest bad status: %d", response.StatusCode) - } - var encryptedGroupChanges signalpb.GroupChanges - groupChangesBytes, err := io.ReadAll(response.Body) - if err != nil { - return nil, err - } - err = proto.Unmarshal(groupChangesBytes, &encryptedGroupChanges) - if err != nil { - return nil, fmt.Errorf("failed to unmarshal group: %w", err) - } - - groupChanges, err := cli.decryptGroupChanges(ctx, &encryptedGroupChanges, groupMasterKey) - if err != nil { - return nil, fmt.Errorf("failed to decrypt group: %w", err) - } - return groupChanges, nil -} - -func (cli *Client) decryptGroupChanges(ctx context.Context, encryptedGroupChanges *signalpb.GroupChanges, groupMasterKey types.SerializedGroupMasterKey) ([]*GroupChangeState, error) { - log := zerolog.Ctx(ctx).With().Str("action", "decryptGroupChanges").Logger() - var groupChanges []*GroupChangeState - for _, groupChangeState := range encryptedGroupChanges.GroupChanges { - var group *Group - var err error - // GroupState == nil is normal, except for first and last, depending on the parameters it was fetched with - if groupChangeState.GroupState != nil { - group, err = decryptGroup(ctx, groupChangeState.GroupState, groupMasterKey) - if err != nil { - log.Err(err).Msg("Failed to decrypt Group") - return nil, err - } - } - var groupChange *GroupChange - // GroupChange shouldn't be nil - if it is, something will probably go wrong - if groupChangeState.GroupChange == nil { - return nil, fmt.Errorf("received group change state without group change") - } - groupChange, err = cli.decryptGroupChange(ctx, groupChangeState.GroupChange, groupMasterKey, false) - if err != nil { - log.Err(err).Msg("Failed to decrypt GroupChange") - return nil, err - } - groupChanges = append(groupChanges, &GroupChangeState{ - GroupState: group, - GroupChange: groupChange, - }) - } - return groupChanges, nil +type GroupCache struct { + groups map[types.GroupIdentifier]*Group + lastFetched map[types.GroupIdentifier]time.Time + avatarPaths map[types.GroupIdentifier]string + activeCalls map[types.GroupIdentifier]string } diff --git a/pkg/signalmeow/identity_store.go b/pkg/signalmeow/identity_store.go new file mode 100644 index 0000000..0687bf1 --- /dev/null +++ b/pkg/signalmeow/identity_store.go @@ -0,0 +1,175 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2023 Scott Weber +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package signalmeow + +import ( + "context" + "database/sql" + "errors" + "fmt" + + "go.mau.fi/mautrix-signal/pkg/libsignalgo" +) + +var _ libsignalgo.IdentityKeyStore = (*SQLStore)(nil) + +const ( + getIdentityKeyPairQuery = `SELECT aci_identity_key_pair FROM signalmeow_device WHERE aci_uuid=$1` + getRegistrationLocalIDQuery = `SELECT registration_id FROM signalmeow_device WHERE aci_uuid=$1` + insertIdentityKeyQuery = `INSERT INTO signalmeow_identity_keys (our_aci_uuid, their_aci_uuid, their_device_id, key, trust_level) VALUES ($1, $2, $3, $4, $5) ON CONFLICT (our_aci_uuid, their_aci_uuid, their_device_id) DO UPDATE SET key=excluded.key, trust_level=excluded.trust_level` + getIdentityKeyTrustLevelQuery = `SELECT trust_level FROM signalmeow_identity_keys WHERE our_aci_uuid=$1 AND their_aci_uuid=$2 AND their_device_id=$3` + getIdentityKeyQuery = `SELECT key FROM signalmeow_identity_keys WHERE our_aci_uuid=$1 AND their_aci_uuid=$2 AND their_device_id=$3` +) + +func scanIdentityKeyPair(row scannable) (*libsignalgo.IdentityKeyPair, error) { + var keyPair []byte + err := row.Scan(&keyPair) + if errors.Is(err, sql.ErrNoRows) { + zlog.Info().Msg("no identity key pair found") + return nil, nil + } else if err != nil { + return nil, err + } + return libsignalgo.DeserializeIdentityKeyPair(keyPair) +} + +func scanIdentityKey(row scannable) (*libsignalgo.IdentityKey, error) { + var key []byte + err := row.Scan(&key) + if errors.Is(err, sql.ErrNoRows) { + zlog.Info().Msg("no identity key found") + return nil, nil + } else if err != nil { + return nil, err + } + return libsignalgo.DeserializeIdentityKey(key) +} + +func (s *SQLStore) GetIdentityKeyPair(ctx context.Context) (*libsignalgo.IdentityKeyPair, error) { + keyPair, err := scanIdentityKeyPair(s.db.QueryRow(getIdentityKeyPairQuery, s.AciUuid)) + if err != nil { + err = fmt.Errorf("failed to get identity key pair: %w", err) + zlog.Error().Err(err).Msg("") + return nil, err + } else if keyPair == nil { + return nil, nil + } + return keyPair, nil +} + +func (s *SQLStore) GetLocalRegistrationID(ctx context.Context) (uint32, error) { + var regID sql.NullInt64 + err := s.db.QueryRow(getRegistrationLocalIDQuery, s.AciUuid).Scan(®ID) + if err != nil { + err = fmt.Errorf("failed to get local registration ID: %w", err) + zlog.Error().Err(err).Msg("") + return 0, err + } + return uint32(regID.Int64), nil +} + +func (s *SQLStore) SaveIdentityKey(address *libsignalgo.Address, identityKey *libsignalgo.IdentityKey, ctx context.Context) (bool, error) { + trustLevel := "TRUSTED_UNVERIFIED" // TODO: this should be hard coded here + serialized, err := identityKey.Serialize() + if err != nil { + zlog.Err(err).Msg("error serializing identityKey") + return false, err + } + theirUuid, err := address.Name() + if err != nil { + zlog.Err(err).Msg("error getting theirUuid") + return false, err + } + deviceId, err := address.DeviceID() + if err != nil { + zlog.Err(err).Msg("error getting deviceId") + return false, err + } + oldKey, err := scanIdentityKey(s.db.QueryRow(getIdentityKeyQuery, s.AciUuid, theirUuid, deviceId)) + if err != nil { + zlog.Err(err).Msg("error getting old identity key") + } + replacing := false + if oldKey != nil { + equal, err := oldKey.Equal(identityKey) + if err != nil { + zlog.Err(err).Msg("error comparing old and new identity keys") + } + // We are replacing the old key iff the old key exists and it is not equal to the new key + replacing = !equal + } + _, err = s.db.Exec(insertIdentityKeyQuery, s.AciUuid, theirUuid, deviceId, serialized, trustLevel) + if err != nil { + zlog.Err(err).Msg("error inserting identity") + } + return replacing, err +} +func (s *SQLStore) IsTrustedIdentity( + address *libsignalgo.Address, + identityKey *libsignalgo.IdentityKey, + direction libsignalgo.SignalDirection, + ctx context.Context, +) (bool, error) { + // TODO: this should check direction, and probably some other stuff (though whisperfish is pretty basic) + theirUuid, err := address.Name() + if err != nil { + zlog.Err(err).Msg("error getting theirUuid") + zlog.Info().Msg("RETURNING NOT TRUSTED") + return false, err + } + deviceId, err := address.DeviceID() + if err != nil { + zlog.Err(err).Msg("error getting deviceId") + zlog.Info().Msg("RETURNING NOT TRUSTED") + return false, err + } + var trustLevel string + err = s.db.QueryRow(getIdentityKeyTrustLevelQuery, s.AciUuid, theirUuid, deviceId).Scan(&trustLevel) + // If no rows, they are a new identity, so trust by default + if errors.Is(err, sql.ErrNoRows) { + zlog.Info().Msg("no rows, TRUSTING BY DEFAULT") + return true, nil + } else if err != nil { + zlog.Err(err).Msg("error getting trust level") + zlog.Info().Msg("RETURNING NOT TRUSTED") + return false, err + } + trusted := trustLevel == "TRUSTED_UNVERIFIED" || trustLevel == "TRUSTED_VERIFIED" + if !trusted { + zlog.Info().Msg("RETURNING NOT TRUSTED") + } + return trusted, nil +} + +func (s *SQLStore) GetIdentityKey(address *libsignalgo.Address, ctx context.Context) (*libsignalgo.IdentityKey, error) { + theirUuid, err := address.Name() + if err != nil { + zlog.Err(err).Msg("error getting theirUuid") + return nil, err + } + deviceId, err := address.DeviceID() + if err != nil { + zlog.Err(err).Msg("error getting deviceId") + return nil, err + } + key, err := scanIdentityKey(s.db.QueryRow(getIdentityKeyQuery, s.AciUuid, theirUuid, deviceId)) + if err != nil { + zlog.Err(err).Msg("error getting identity key") + return nil, err + } + return key, err +} diff --git a/pkg/signalmeow/keys.go b/pkg/signalmeow/keys.go index 5439755..856cb69 100644 --- a/pkg/signalmeow/keys.go +++ b/pkg/signalmeow/keys.go @@ -20,208 +20,130 @@ import ( "context" "encoding/base64" "encoding/json" - "errors" "fmt" - "math/rand/v2" "net/http" "strings" "time" - "github.com/rs/zerolog" - "go.mau.fi/mautrix-signal/pkg/libsignalgo" - "go.mau.fi/mautrix-signal/pkg/signalmeow/events" - "go.mau.fi/mautrix-signal/pkg/signalmeow/store" "go.mau.fi/mautrix-signal/pkg/signalmeow/web" ) -const PREKEY_BATCH_SIZE = 100 - type GeneratedPreKeys struct { PreKeys []*libsignalgo.PreKeyRecord KyberPreKeys []*libsignalgo.KyberPreKeyRecord IdentityKey []uint8 } -func (cli *Client) RegisterAllPreKeys(ctx context.Context, pks store.PreKeyStore) error { +func GenerateAndRegisterPreKeys(device *Device, uuidKind UUIDKind) error { var identityKeyPair *libsignalgo.IdentityKeyPair - var pni bool - if pks.GetServiceID().Type == libsignalgo.ServiceIDTypePNI { - pni = true - identityKeyPair = cli.Store.PNIIdentityKeyPair + if uuidKind == UUID_KIND_PNI { + identityKeyPair = device.Data.PniIdentityKeyPair } else { - identityKeyPair = cli.Store.ACIIdentityKeyPair + identityKeyPair = device.Data.AciIdentityKeyPair } - // Get all prekeys and kyber prekeys from the database - preKeys, err := pks.AllPreKeys(ctx) + // Generate prekeys + nextPreKeyId, err := device.PreKeyStoreExtras.GetNextPreKeyID(uuidKind) if err != nil { - return fmt.Errorf("failed to get all prekeys: %w", err) + zlog.Err(err).Msg("Error getting next prekey id") + return err } - kyberPreKeys, err := pks.AllNormalKyberPreKeys(ctx) + nextKyberPreKeyId, err := device.PreKeyStoreExtras.GetNextKyberPreKeyID(uuidKind) if err != nil { - return fmt.Errorf("failed to get all kyber prekeys: %w", err) - } - - // We need to have some keys to upload - if len(preKeys) == 0 && len(kyberPreKeys) == 0 { - return fmt.Errorf("no prekeys to upload") + zlog.Err(err).Msg("Error getting next kyber prekey id") + return err + } + preKeys := GeneratePreKeys(nextPreKeyId, 100, uuidKind) + kyberPreKeys := GenerateKyberPreKeys(nextKyberPreKeyId, 100, uuidKind, identityKeyPair) + + // Persist prekeys + for _, preKey := range preKeys { + device.PreKeyStoreExtras.SavePreKey(uuidKind, preKey, false) + } + for _, kyberPreKey := range kyberPreKeys { + device.PreKeyStoreExtras.SaveKyberPreKey(uuidKind, kyberPreKey, false) } + // Register prekeys identityKey, err := identityKeyPair.GetPublicKey().Serialize() if err != nil { - return fmt.Errorf("failed to serialize identity key: %w", err) + zlog.Err(err).Msg("Error serializing identity key") + return err } - generatedPreKeys := GeneratedPreKeys{ PreKeys: preKeys, KyberPreKeys: kyberPreKeys, IdentityKey: identityKey, } - zerolog.Ctx(ctx).Debug(). - Int("num_prekeys", len(preKeys)). - Int("num_kyber_prekeys", len(kyberPreKeys)). - Msg("Registering all prekeys") - err = cli.RegisterPreKeys(ctx, &generatedPreKeys, pni) + preKeyUsername := device.Data.Number + if device.Data.AciUuid != "" { + preKeyUsername = device.Data.AciUuid + } + preKeyUsername = preKeyUsername + "." + fmt.Sprint(device.Data.DeviceId) + err = RegisterPreKeys(&generatedPreKeys, uuidKind, preKeyUsername, device.Data.Password) if err != nil { - return fmt.Errorf("failed to register prekeys: %w", err) + zlog.Err(err).Msg("RegisterPreKeys error") + return err + } + + // Mark prekeys as registered + // (kyber prekeys don't have "mark as uploaded" we just assume they always are) + lastPreKeyId, err := preKeys[len(preKeys)-1].GetID() + err = device.PreKeyStoreExtras.MarkPreKeysAsUploaded(uuidKind, lastPreKeyId) + + if err != nil { + zlog.Err(err).Msg("Error marking prekeys as uploaded") } return err } -func (cli *Client) GenerateAndSaveNextPreKeyBatch(ctx context.Context, pks store.PreKeyStore, serverCount int) (bool, error) { - storeCount, nextPreKeyID, err := pks.GetNextPreKeyID(ctx) - if err != nil { - return false, fmt.Errorf("failed to get next prekey ID: %w", err) - } - if serverCount < PREKEY_BATCH_SIZE/2 { - if storeCount >= PREKEY_BATCH_SIZE { - zerolog.Ctx(ctx).Warn(). - Int("server_count", serverCount). - Uint32("store_count", storeCount). - Msg("Store is full, but server is not, reuploading EC prekeys without generating more") - } else { - zerolog.Ctx(ctx).Info(). - Int("server_count", serverCount). - Uint32("store_count", storeCount). - Msg("Generating and uploading EC prekeys") - } - } else if uint32(serverCount) > storeCount { - zerolog.Ctx(ctx).Warn(). - Int("server_count", serverCount). - Uint32("store_count", storeCount). - Msg("Server has more EC prekeys than store, reuploading") - } else { - zerolog.Ctx(ctx).Debug(). - Int("server_count", serverCount). - Uint32("store_count", storeCount). - Msg("EC prekey count is good") - return false, nil - } - if storeCount < PREKEY_BATCH_SIZE { - preKeys := GeneratePreKeys(nextPreKeyID, PREKEY_BATCH_SIZE-storeCount) - for _, preKey := range preKeys { - err = pks.StorePreKey(ctx, 0, preKey) - if err != nil { - return false, fmt.Errorf("failed to save prekey: %w", err) - } - } - } - return true, nil -} - -func (cli *Client) GenerateAndSaveNextKyberPreKeyBatch(ctx context.Context, pks store.PreKeyStore, serverCount int) (bool, error) { - var identityKeyPair *libsignalgo.IdentityKeyPair - if pks.GetServiceID().Type == libsignalgo.ServiceIDTypePNI { - identityKeyPair = cli.Store.PNIIdentityKeyPair - } else { - identityKeyPair = cli.Store.ACIIdentityKeyPair - } - storeCount, nextKyberPreKeyID, err := pks.GetNextKyberPreKeyID(ctx) - if err != nil { - return false, fmt.Errorf("failed to get next kyber prekey ID: %w", err) - } - if serverCount < PREKEY_BATCH_SIZE/2 { - if storeCount >= PREKEY_BATCH_SIZE { - zerolog.Ctx(ctx).Warn(). - Int("server_count", serverCount). - Uint32("store_count", storeCount). - Msg("Store is full, but server is not, reuploading kyber prekeys without generating more") - } else { - zerolog.Ctx(ctx).Info(). - Int("server_count", serverCount). - Uint32("store_count", storeCount). - Msg("Generating and uploading kyber prekeys") - } - } else if uint32(serverCount) > storeCount { - zerolog.Ctx(ctx).Warn(). - Int("server_count", serverCount). - Uint32("store_count", storeCount). - Msg("Server has more kyber prekeys than store, reuploading") - } else { - zerolog.Ctx(ctx).Debug(). - Int("server_count", serverCount). - Uint32("store_count", storeCount). - Msg("Kyber prekey count is good") - return false, nil - } - if storeCount < PREKEY_BATCH_SIZE { - kyberPreKeys := GenerateKyberPreKeys(nextKyberPreKeyID, PREKEY_BATCH_SIZE-storeCount, identityKeyPair) - for _, kyberPreKey := range kyberPreKeys { - err = pks.StoreKyberPreKey(ctx, 0, kyberPreKey) - if err != nil { - return false, fmt.Errorf("failed to save kyber prekey: %w", err) - } - } - } - return true, nil -} - -func GeneratePreKeys(startKeyID uint32, count uint32) []*libsignalgo.PreKeyRecord { - if count > PREKEY_BATCH_SIZE { - panic("count must be less than or equal to PREKEY_BATCH_SIZE") - } - generatedPreKeys := make([]*libsignalgo.PreKeyRecord, 0, count) - for keyID := startKeyID; keyID < startKeyID+count; keyID++ { +func GeneratePreKeys(startKeyId uint, count uint, uuidKind UUIDKind) []*libsignalgo.PreKeyRecord { + generatedPreKeys := []*libsignalgo.PreKeyRecord{} + for i := startKeyId; i < startKeyId+count; i++ { privateKey, err := libsignalgo.GeneratePrivateKey() if err != nil { - panic(fmt.Errorf("error generating private key: %w", err)) + zlog.Err(err).Msg("Error generating private key") + panic(err) } - preKey, err := libsignalgo.NewPreKeyRecordFromPrivateKey(keyID, privateKey) + preKey, err := libsignalgo.NewPreKeyRecordFromPrivateKey(uint32(i), privateKey) if err != nil { - panic(fmt.Errorf("error creating prekey record: %w", err)) + zlog.Err(err).Msg("Error creating preKey record") + panic(err) } generatedPreKeys = append(generatedPreKeys, preKey) } return generatedPreKeys } -func GenerateKyberPreKeys(startKeyID uint32, count uint32, identityKeyPair *libsignalgo.IdentityKeyPair) []*libsignalgo.KyberPreKeyRecord { - if count > PREKEY_BATCH_SIZE { - panic("count must be less than or equal to PREKEY_BATCH_SIZE") - } - generatedKyberPreKeys := make([]*libsignalgo.KyberPreKeyRecord, 0, count) - for keyID := startKeyID; keyID < startKeyID+count; keyID++ { +func GenerateKyberPreKeys(startKeyId uint, count uint, uuidKind UUIDKind, identityKeyPair *libsignalgo.IdentityKeyPair) []*libsignalgo.KyberPreKeyRecord { + generatedKyberPreKeys := []*libsignalgo.KyberPreKeyRecord{} + for i := startKeyId; i < startKeyId+count; i++ { kyberPreKeyPair, err := libsignalgo.KyberKeyPairGenerate() if err != nil { - panic(fmt.Errorf("error generating kyber key pair: %w", err)) + zlog.Err(err).Msg("Error generating kyber key pair") + panic(err) } publicKey, err := kyberPreKeyPair.GetPublicKey() if err != nil { - panic(fmt.Errorf("error getting kyber public key: %w", err)) + zlog.Err(err).Msg("Error getting kyber public key") + panic(err) } serializedPublicKey, err := publicKey.Serialize() if err != nil { - panic(fmt.Errorf("error serializing kyber public key: %w", err)) + zlog.Err(err).Msg("Error serializing kyber public key") + panic(err) } signature, err := identityKeyPair.GetPrivateKey().Sign(serializedPublicKey) if err != nil { - panic(fmt.Errorf("error signing kyber public key: %w", err)) + zlog.Err(err).Msg("Error signing kyber public key") + panic(err) } - preKey, err := libsignalgo.NewKyberPreKeyRecord(keyID, time.Now(), kyberPreKeyPair, signature) + preKey, err := libsignalgo.NewKyberPreKeyRecord(uint32(i), time.Now(), kyberPreKeyPair, signature) if err != nil { - panic(fmt.Errorf("error creating kyber prekey record: %w", err)) + zlog.Err(err).Msg("Error creating kyber preKey record") + panic(err) } generatedKyberPreKeys = append(generatedKyberPreKeys, preKey) @@ -229,147 +151,127 @@ func GenerateKyberPreKeys(startKeyID uint32, count uint32, identityKeyPair *libs return generatedKyberPreKeys } -func GenerateSignedPreKey(startSignedKeyId uint32, identityKeyPair *libsignalgo.IdentityKeyPair) *libsignalgo.SignedPreKeyRecord { +func GenerateSignedPreKey(startSignedKeyId uint32, uuidKind UUIDKind, identityKeyPair *libsignalgo.IdentityKeyPair) *libsignalgo.SignedPreKeyRecord { // Generate a signed prekey privateKey, err := libsignalgo.GeneratePrivateKey() if err != nil { - panic(fmt.Errorf("error generating private key: %w", err)) + zlog.Err(err).Msg("Error generating private key") + panic(err) } timestamp := time.Now() publicKey, err := privateKey.GetPublicKey() if err != nil { - panic(fmt.Errorf("error getting public key: %w", err)) + zlog.Err(err).Msg("Error getting public key") + panic(err) } serializedPublicKey, err := publicKey.Serialize() if err != nil { - panic(fmt.Errorf("error serializing public key: %w", err)) + zlog.Err(err).Msg("Error serializing public key") + panic(err) } signature, err := identityKeyPair.GetPrivateKey().Sign(serializedPublicKey) if err != nil { - panic(fmt.Errorf("error signing public key: %w", err)) + zlog.Err(err).Msg("Error signing public key") + panic(err) } signedPreKey, err := libsignalgo.NewSignedPreKeyRecordFromPrivateKey(startSignedKeyId, timestamp, privateKey, signature) if err != nil { - panic(fmt.Errorf("error creating signed prekey record: %w", err)) + zlog.Err(err).Msg("Error creating signed preKey record") + panic(err) } return signedPreKey } -func PreKeyToJSON(preKey *libsignalgo.PreKeyRecord) (map[string]interface{}, error) { - id, err := preKey.GetID() - if err != nil { - return nil, fmt.Errorf("failed to get ID: %w", err) - } - publicKey, err := preKey.GetPublicKey() - if err != nil { - return nil, fmt.Errorf("failed to get public key: %w", err) - } - serializedKey, err := publicKey.Serialize() - if err != nil { - return nil, fmt.Errorf("failed to serialize public key: %w", err) - } +func StoreSignedPreKey(device *Device, signedPreKey *libsignalgo.SignedPreKeyRecord, uuidKind UUIDKind) { + // Note: marking as uploaded right now because we're about to upload as part of + // provisioning, and if provisioning fails, we'll just generate a new one + // Also we don't really use the uploaded for anything + device.PreKeyStoreExtras.SaveSignedPreKey(uuidKind, signedPreKey, true) +} + +func StoreKyberLastResortPreKey(device *Device, kyberPreKey *libsignalgo.KyberPreKeyRecord, uuidKind UUIDKind) { + device.PreKeyStoreExtras.SaveKyberPreKey(uuidKind, kyberPreKey, true) +} + +func PreKeyToJSON(preKey *libsignalgo.PreKeyRecord) map[string]interface{} { + id, _ := preKey.GetID() + publicKey, _ := preKey.GetPublicKey() + serializedKey, _ := publicKey.Serialize() preKeyJson := map[string]interface{}{ "keyId": id, "publicKey": base64.StdEncoding.EncodeToString(serializedKey), } - return preKeyJson, nil + return preKeyJson } -func SignedPreKeyToJSON(signedPreKey *libsignalgo.SignedPreKeyRecord) (map[string]interface{}, error) { - id, err := signedPreKey.GetID() - if err != nil { - return nil, fmt.Errorf("failed to get ID: %w", err) - } - publicKey, err := signedPreKey.GetPublicKey() - if err != nil { - return nil, fmt.Errorf("failed to get public key: %w", err) - } - serializedKey, err := publicKey.Serialize() - if err != nil { - return nil, fmt.Errorf("failed to serialize public key: %w", err) - } - signature, err := signedPreKey.GetSignature() - if err != nil { - return nil, fmt.Errorf("failed to get signature: %w", err) - } +func SignedPreKeyToJSON(signedPreKey *libsignalgo.SignedPreKeyRecord) map[string]interface{} { + id, _ := signedPreKey.GetID() + publicKey, _ := signedPreKey.GetPublicKey() + serializedKey, _ := publicKey.Serialize() + signature, _ := signedPreKey.GetSignature() signedPreKeyJson := map[string]interface{}{ "keyId": id, "publicKey": base64.StdEncoding.EncodeToString(serializedKey), "signature": base64.StdEncoding.EncodeToString(signature), } - return signedPreKeyJson, nil + return signedPreKeyJson } -func KyberPreKeyToJSON(kyberPreKey *libsignalgo.KyberPreKeyRecord) (map[string]interface{}, error) { - id, err := kyberPreKey.GetID() - if err != nil { - return nil, fmt.Errorf("failed to get ID: %w", err) - } - publicKey, err := kyberPreKey.GetPublicKey() - if err != nil { - return nil, fmt.Errorf("failed to get public key: %w", err) - } - serializedKey, err := publicKey.Serialize() - if err != nil { - return nil, fmt.Errorf("failed to serialize public key: %w", err) - } - signature, err := kyberPreKey.GetSignature() - if err != nil { - return nil, fmt.Errorf("failed to get signature: %w", err) - } +func KyberPreKeyToJSON(kyberPreKey *libsignalgo.KyberPreKeyRecord) map[string]interface{} { + id, _ := kyberPreKey.GetID() + publicKey, _ := kyberPreKey.GetPublicKey() + serializedKey, _ := publicKey.Serialize() + signature, _ := kyberPreKey.GetSignature() kyberPreKeyJson := map[string]interface{}{ "keyId": id, "publicKey": base64.StdEncoding.EncodeToString(serializedKey), "signature": base64.StdEncoding.EncodeToString(signature), } - return kyberPreKeyJson, nil + return kyberPreKeyJson } -var errPrekeyUpload422 = errors.New("http 422 while registering prekeys") - -func (cli *Client) RegisterPreKeys(ctx context.Context, generatedPreKeys *GeneratedPreKeys, pni bool) error { - log := zerolog.Ctx(ctx).With().Str("action", "register prekeys").Logger() +func RegisterPreKeys(generatedPreKeys *GeneratedPreKeys, uuidKind UUIDKind, username string, password string) error { // Convert generated prekeys to JSON - preKeysJson := []map[string]any{} - kyberPreKeysJson := []map[string]any{} + preKeysJson := []map[string]interface{}{} + kyberPreKeysJson := []map[string]interface{}{} for _, preKey := range generatedPreKeys.PreKeys { - preKeyJson, err := PreKeyToJSON(preKey) - if err != nil { - return fmt.Errorf("failed to convert prekey to JSON: %w", err) - } + preKeyJson := PreKeyToJSON(preKey) preKeysJson = append(preKeysJson, preKeyJson) } for _, kyberPreKey := range generatedPreKeys.KyberPreKeys { - kyberPreKeyJson, err := KyberPreKeyToJSON(kyberPreKey) - if err != nil { - return fmt.Errorf("failed to convert kyber prekey to JSON: %w", err) - } + kyberPreKeyJson := KyberPreKeyToJSON(kyberPreKey) kyberPreKeysJson = append(kyberPreKeysJson, kyberPreKeyJson) } identityKey := generatedPreKeys.IdentityKey - registerJSON := map[string]any{ + register_json := map[string]interface{}{ "preKeys": preKeysJson, "pqPreKeys": kyberPreKeysJson, "identityKey": base64.StdEncoding.EncodeToString(identityKey), } // Send request - jsonBytes, err := json.Marshal(registerJSON) + keysPath := "/v2/keys?identity=" + string(uuidKind) + jsonBytes, err := json.Marshal(register_json) if err != nil { - log.Err(err).Msg("Error marshalling register JSON") + zlog.Err(err).Msg("Error marshalling register JSON") return err } - resp, err := cli.AuthedWS.SendRequest(ctx, http.MethodPut, keysPath(pni), jsonBytes, nil) + opts := &web.HTTPReqOpt{Body: jsonBytes, Username: &username, Password: &password} + resp, err := web.SendHTTPRequest(http.MethodPut, keysPath, opts) if err != nil { - log.Err(err).Msg("Error sending request") + zlog.Err(err).Msg("Error sending request") return err } - if resp.GetStatus() == 422 { - return errPrekeyUpload422 + // status code not 2xx + if resp.StatusCode < 200 || resp.StatusCode >= 300 { + err := fmt.Errorf("Error registering prekeys: %v", resp.Status) + zlog.Err(err).Msg("Error registering prekeys") + return err } - return web.DecodeWSResponseBody(ctx, nil, resp) + defer resp.Body.Close() + return err } type prekeyResponse struct { @@ -377,11 +279,6 @@ type prekeyResponse struct { Devices []prekeyDevice `json:"devices"` } -type preKeyCountResponse struct { - Count int `json:"count"` - PQCount int `json:"pqCount"` -} - type prekeyDevice struct { DeviceID int `json:"deviceId"` RegistrationID int `json:"registrationId"` @@ -404,243 +301,126 @@ func addBase64PaddingAndDecode(data string) ([]byte, error) { return base64.StdEncoding.DecodeString(data) } -var ( - ErrUnregisteredUser = errors.New("user is unregistered") - ErrDevicesChanged = errors.New("device list changed while sending skdm") -) - -func (cli *Client) FetchAndProcessPreKey(ctx context.Context, theirServiceID libsignalgo.ServiceID, specificDeviceID int) error { - if cli.Store.RecipientStore.IsUnregistered(ctx, theirServiceID) { - return fmt.Errorf("%w (cached)", ErrUnregisteredUser) - } - localAddress, err := cli.Store.ACIServiceID().Address(uint(cli.Store.DeviceID)) - if err != nil { - return fmt.Errorf("failed to get own address: %w", err) - } +func FetchAndProcessPreKey(ctx context.Context, device *Device, theirUuid string, specificDeviceID int) error { // Fetch prekey deviceIDPath := "/*" if specificDeviceID >= 0 { deviceIDPath = "/" + fmt.Sprint(specificDeviceID) } - // TODO this should be done via the unauthed websocket if possible - path := "/v2/keys/" + theirServiceID.String() + deviceIDPath + "?pq=true" - resp, err := cli.AuthedWS.SendRequest(ctx, http.MethodGet, path, nil, nil) + path := "/v2/keys/" + theirUuid + deviceIDPath + "?pq=true" + username, password := device.Data.BasicAuthCreds() + resp, err := web.SendHTTPRequest(http.MethodGet, path, &web.HTTPReqOpt{Username: &username, Password: &password}) if err != nil { - return fmt.Errorf("error sending request: %w", err) - } else if resp.GetStatus() == 404 { - cli.Store.RecipientStore.MarkUnregistered(ctx, theirServiceID, true) - return fmt.Errorf("%w (404 while querying keys)", ErrUnregisteredUser) + zlog.Err(err).Msg("Error sending request") + return err } - var respData prekeyResponse - err = web.DecodeWSResponseBody(ctx, &respData, resp) + var prekeyResponse prekeyResponse + err = web.DecodeHTTPResponseBody(ctx, &prekeyResponse, resp) if err != nil { - return fmt.Errorf("error decoding response body: %w", err) + zlog.Err(err).Msg("Fetching prekeys, error with response body") + return err } - rawIdentityKey, err := addBase64PaddingAndDecode(respData.IdentityKey) - if err != nil { - return fmt.Errorf("error decoding identity key: %w", err) - } + rawIdentityKey, err := addBase64PaddingAndDecode(prekeyResponse.IdentityKey) identityKey, err := libsignalgo.DeserializeIdentityKey([]byte(rawIdentityKey)) if err != nil { - return fmt.Errorf("error deserializing identity key: %w", err) + zlog.Err(err).Msg("Error deserializing identity key") + return err } if identityKey == nil { - return fmt.Errorf("deserializing identity key returned nil with no error") + err := fmt.Errorf("Deserializing identity key returned nil with no error") + zlog.Err(err).Msg("") + return err } // Process each prekey in response (should only be one at the moment) - for _, d := range respData.Devices { + for _, d := range prekeyResponse.Devices { var publicKey *libsignalgo.PublicKey - var preKeyID uint32 + var preKeyId uint32 if d.PreKey != nil { - preKeyID = uint32(d.PreKey.KeyID) + preKeyId = uint32(d.PreKey.KeyID) rawPublicKey, err := addBase64PaddingAndDecode(d.PreKey.PublicKey) if err != nil { - return fmt.Errorf("error decoding public key: %w", err) + zlog.Err(err).Msg("Error decoding public key") + return err } publicKey, err = libsignalgo.DeserializePublicKey(rawPublicKey) if err != nil { - return fmt.Errorf("error deserializing public key: %w", err) + zlog.Err(err).Msg("Error deserializing public key") + return err } } rawSignedPublicKey, err := addBase64PaddingAndDecode(d.SignedPreKey.PublicKey) if err != nil { - return fmt.Errorf("error decoding signed public key: %w", err) + zlog.Err(err).Msg("Error decoding signed public key") + return err } signedPublicKey, err := libsignalgo.DeserializePublicKey(rawSignedPublicKey) if err != nil { - return fmt.Errorf("error deserializing signed public key: %w", err) + zlog.Err(err).Msg("Error deserializing signed public key") + return err } var kyberPublicKey *libsignalgo.KyberPublicKey - var kyberPreKeyID uint32 + var kyberPreKeyId uint32 var kyberPreKeySignature []byte if d.PQPreKey != nil { - kyberPreKeyID = uint32(d.PQPreKey.KeyID) + kyberPreKeyId = uint32(d.PQPreKey.KeyID) rawKyberPublicKey, err := addBase64PaddingAndDecode(d.PQPreKey.PublicKey) if err != nil { - return fmt.Errorf("error decoding kyber public key: %w", err) + zlog.Err(err).Msg("Error decoding kyber public key") + return err } kyberPublicKey, err = libsignalgo.DeserializeKyberPublicKey(rawKyberPublicKey) if err != nil { - return fmt.Errorf("error deserializing kyber public key: %w", err) + zlog.Err(err).Msg("Error deserializing kyber public key") + return err } kyberPreKeySignature, err = addBase64PaddingAndDecode(d.PQPreKey.Signature) - if err != nil { - return fmt.Errorf("error decoding kyber prekey signature: %w", err) - } } rawSignature, err := addBase64PaddingAndDecode(d.SignedPreKey.Signature) if err != nil { - return fmt.Errorf("error decoding signature: %w", err) + zlog.Err(err).Msg("Error decoding signature") + return err } preKeyBundle, err := libsignalgo.NewPreKeyBundle( uint32(d.RegistrationID), uint32(d.DeviceID), - preKeyID, + preKeyId, publicKey, uint32(d.SignedPreKey.KeyID), signedPublicKey, rawSignature, - kyberPreKeyID, + kyberPreKeyId, kyberPublicKey, kyberPreKeySignature, identityKey, ) if err != nil { - return fmt.Errorf("error creating prekey bundle: %w", err) + zlog.Err(err).Msg("Error creating prekey bundle") + return err } - address, err := theirServiceID.Address(uint(d.DeviceID)) + address, err := libsignalgo.NewAddress(theirUuid, uint(d.DeviceID)) if err != nil { - return fmt.Errorf("error creating address: %w", err) + zlog.Err(err).Msg("Error creating address") + return err } err = libsignalgo.ProcessPreKeyBundle( - ctx, preKeyBundle, address, - localAddress, - cli.Store.ACISessionStore, - cli.Store.ACIIdentityStore, + device.SessionStore, + device.IdentityStore, + libsignalgo.NewCallbackContext(ctx), ) + if err != nil { - return fmt.Errorf("error processing prekey bundle: %w", err) + zlog.Err(err).Msg("Error processing prekey bundle") + return err } } return err } - -const ( - aciKeysPath = "/v2/keys?identity=aci" - pniKeysPath = "/v2/keys?identity=pni" -) - -func keysPath(pni bool) string { - if pni { - return pniKeysPath - } - return aciKeysPath -} - -func (cli *Client) GetMyKeyCounts(ctx context.Context, pni bool) (int, int, error) { - log := zerolog.Ctx(ctx).With().Str("action", "get my key counts").Logger() - resp, err := cli.AuthedWS.SendRequest(ctx, http.MethodGet, keysPath(pni), nil, nil) - if err != nil { - log.Err(err).Msg("Error sending request") - return 0, 0, err - } - var respData preKeyCountResponse - err = web.DecodeWSResponseBody(ctx, &respData, resp) - if err != nil { - log.Err(err).Msg("Fetching prekey counts, error with response body") - return 0, 0, err - } - return respData.Count, respData.PQCount, err -} - -func (cli *Client) CheckAndUploadNewPreKeys(ctx context.Context, pks store.PreKeyStore) error { - log := zerolog.Ctx(ctx).With().Str("action", "check and upload new prekeys").Logger() - // Check if we need to upload prekeys - preKeyCount, kyberPreKeyCount, err := cli.GetMyKeyCounts(ctx, pks.GetServiceID().Type == libsignalgo.ServiceIDTypePNI) - if err != nil { - log.Err(err).Msg("Error getting prekey counts") - return err - } - doECUpload, err := cli.GenerateAndSaveNextPreKeyBatch(ctx, pks, preKeyCount) - if err != nil { - log.Err(err).Msg("Error generating and saving next prekey batch") - return err - } - doKyberUpload, err := cli.GenerateAndSaveNextKyberPreKeyBatch(ctx, pks, kyberPreKeyCount) - if err != nil { - log.Err(err).Msg("Error generating and saving next kyber prekey batch") - return err - } - if !doECUpload && !doKyberUpload { - log.Debug().Msg("No new prekeys to upload") - return nil - } - err = cli.RegisterAllPreKeys(ctx, pks) - if err != nil { - log.Err(err).Msg("Error registering prekey batches") - return err - } - return nil -} - -func (cli *Client) keyCheckLoop(ctx context.Context) { - log := zerolog.Ctx(ctx).With().Str("action", "start key check loop").Logger() - - // Do the initial check in 5-10 minutes after starting the loop - windowStart := 0 - windowSize := 1 - firstRun := true - for { - randomMinutesInWindow := rand.IntN(windowSize) + windowStart - checkTime := time.Duration(randomMinutesInWindow) * time.Minute - if firstRun { - checkTime = 0 - firstRun = false - } else { - log.Debug().Dur("check_time", checkTime).Msg("Waiting to check for new prekeys") - } - - select { - case <-ctx.Done(): - return - case <-time.After(checkTime): - err := cli.CheckAndUploadNewPreKeys(ctx, cli.Store.ACIPreKeyStore) - if err != nil { - log.Err(err).Msg("Error checking and uploading new prekeys for ACI identity") - // Retry within half an hour - windowStart = 5 - windowSize = 25 - continue - } - err = cli.CheckAndUploadNewPreKeys(ctx, cli.Store.PNIPreKeyStore) - if err != nil { - if errors.Is(err, errPrekeyUpload422) { - log.Err(err).Msg("Got 422 error while uploading PNI prekeys, deleting session") - disconnectErr := cli.ClearKeysAndDisconnect(ctx) - if disconnectErr != nil { - log.Err(disconnectErr).Msg("ClearKeysAndDisconnect error") - } - cli.handleEvent(&events.LoggedOut{Error: err}) - return - } - log.Err(err).Msg("Error checking and uploading new prekeys for PNI identity") - // Retry within half an hour - windowStart = 5 - windowSize = 25 - continue - } - // After a successful check, check again in 36 to 60 hours - windowStart = 36 * 60 - windowSize = 24 * 60 - } - } -} diff --git a/pkg/signalmeow/misc.go b/pkg/signalmeow/misc.go index 70d3ba5..7977bb5 100644 --- a/pkg/signalmeow/misc.go +++ b/pkg/signalmeow/misc.go @@ -17,51 +17,49 @@ package signalmeow import ( - _ "embed" - "errors" - "fmt" + "encoding/base64" - "github.com/google/uuid" "github.com/rs/zerolog" - "go.mau.fi/util/exerrors" "go.mau.fi/mautrix-signal/pkg/libsignalgo" + "go.mau.fi/mautrix-signal/pkg/signalmeow/web" ) -var loggingSetup = false +// signalmeow Logging + +var zlog zerolog.Logger = zerolog.New(zerolog.ConsoleWriter{}).With().Timestamp().Logger() func SetLogger(l zerolog.Logger) { - if loggingSetup { - return - } - libsignalgo.InitLogger(libsignalgo.LogLevelInfo, FFILogger{ - logger: l, - }) - loggingSetup = true + zlog = l + setupFFILogging() + web.SetLogger(l.With().Str("component", "signalmeow/web").Logger()) } -type FFILogger struct { - logger zerolog.Logger -} +// libsignalgo Logging -func (l FFILogger) Log(level libsignalgo.LogLevel, file string, line uint, message string) { +type FFILogger struct{} + +func (FFILogger) Enabled(target string, level libsignalgo.LogLevel) bool { return true } + +func (FFILogger) Log(target string, level libsignalgo.LogLevel, file string, line uint, message string) { var evt *zerolog.Event switch level { case libsignalgo.LogLevelError: - evt = l.logger.Error() + evt = zlog.Error() case libsignalgo.LogLevelWarn: - evt = l.logger.Warn() + evt = zlog.Warn() case libsignalgo.LogLevelInfo: - evt = l.logger.Info() + evt = zlog.Info() case libsignalgo.LogLevelDebug: - evt = l.logger.Debug() + evt = zlog.Debug() case libsignalgo.LogLevelTrace: - evt = l.logger.Trace() + evt = zlog.Trace() default: panic("invalid log level from libsignal") } evt.Str("component", "libsignal"). + Str("target", target). Str("file", file). Uint("line", line). Msg(message) @@ -69,40 +67,27 @@ func (l FFILogger) Log(level libsignalgo.LogLevel, file string, line uint, messa func (FFILogger) Flush() {} -func (FFILogger) Destroy() {} - // Ensure FFILogger implements the Logger interface var _ libsignalgo.Logger = FFILogger{} -//go:embed prod-server-public-params.dat -var prodServerPublicParamsSlice []byte -var prodServerPublicParams *libsignalgo.ServerPublicParams +var loggingSetup = false -func init() { - prodServerPublicParams = exerrors.Must(libsignalgo.DeserializeServerPublicParams(prodServerPublicParamsSlice)) +func setupFFILogging() { + if !loggingSetup { + libsignalgo.InitLogger(libsignalgo.LogLevelInfo, FFILogger{}) + loggingSetup = true + } } -var ErrEmptyUUIDInput = errors.New("both input variables are empty") +// Other misc things -func ParseStringOrBinaryServiceID(str string, bytes []byte) (libsignalgo.ServiceID, error) { - if str != "" { - return libsignalgo.ServiceIDFromString(str) +func serverPublicParams() libsignalgo.ServerPublicParams { + serverPublicParamsBase64 := "AMhf5ywVwITZMsff/eCyudZx9JDmkkkbV6PInzG4p8x3VqVJSFiMvnvlEKWuRob/1eaIetR31IYeAbm0NdOuHH8Qi+Rexi1wLlpzIo1gstHWBfZzy1+qHRV5A4TqPp15YzBPm0WSggW6PbSn+F4lf57VCnHF7p8SvzAA2ZZJPYJURt8X7bbg+H3i+PEjH9DXItNEqs2sNcug37xZQDLm7X36nOoGPs54XsEGzPdEV+itQNGUFEjY6X9Uv+Acuks7NpyGvCoKxGwgKgE5XyJ+nNKlyHHOLb6N1NuHyBrZrgtY/JYJHRooo5CEqYKBqdFnmbTVGEkCvJKxLnjwKWf+fEPoWeQFj5ObDjcKMZf2Jm2Ae69x+ikU5gBXsRmoF94GXTLfN0/vLt98KDPnxwAQL9j5V1jGOY8jQl6MLxEs56cwXN0dqCnImzVH3TZT1cJ8SW1BRX6qIVxEzjsSGx3yxF3suAilPMqGRp4ffyopjMD1JXiKR2RwLKzizUe5e8XyGOy9fplzhw3jVzTRyUZTRSZKkMLWcQ/gv0E4aONNqs4P" + serverPublicParamsBytes, err := base64.StdEncoding.DecodeString(serverPublicParamsBase64) + if err != nil { + panic(err) } - if bytes != nil { - return libsignalgo.ServiceIDFromBytes(bytes) - } - return libsignalgo.EmptyServiceID, ErrEmptyUUIDInput -} - -func ParseStringOrBinaryUUID(str string, bytes []byte) (uuid.UUID, error) { - if str != "" { - return uuid.Parse(str) - } - if bytes != nil { - if len(bytes) != 16 { - return uuid.Nil, fmt.Errorf("invalid UUID length %d (expected 16)", len(bytes)) - } - return uuid.UUID(bytes), nil - } - return uuid.Nil, ErrEmptyUUIDInput + var serverPublicParams libsignalgo.ServerPublicParams + copy(serverPublicParams[:], serverPublicParamsBytes) + return serverPublicParams } diff --git a/pkg/signalmeow/prekey_store.go b/pkg/signalmeow/prekey_store.go new file mode 100644 index 0000000..df36e01 --- /dev/null +++ b/pkg/signalmeow/prekey_store.go @@ -0,0 +1,266 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2023 Scott Weber +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package signalmeow + +import ( + "context" + "database/sql" + "errors" + "fmt" + + "go.mau.fi/mautrix-signal/pkg/libsignalgo" +) + +var _ libsignalgo.PreKeyStore = (*SQLStore)(nil) +var _ libsignalgo.SignedPreKeyStore = (*SQLStore)(nil) +var _ libsignalgo.KyberPreKeyStore = (*SQLStore)(nil) +var _ PreKeyStoreExtras = (*SQLStore)(nil) + +// TODO: figure out how best to handle ACI vs PNI UUIDs + +type PreKeyStoreExtras interface { + PreKey(uuidKind UUIDKind, preKeyId int) (*libsignalgo.PreKeyRecord, error) + SignedPreKey(uuidKind UUIDKind, preKeyId int) (*libsignalgo.SignedPreKeyRecord, error) + KyberPreKey(uuidKind UUIDKind, preKeyId int) (*libsignalgo.KyberPreKeyRecord, error) + SavePreKey(uuidKind UUIDKind, preKey *libsignalgo.PreKeyRecord, markUploaded bool) error + SaveSignedPreKey(uuidKind UUIDKind, preKey *libsignalgo.SignedPreKeyRecord, markUploaded bool) error + SaveKyberPreKey(uuidKind UUIDKind, preKey *libsignalgo.KyberPreKeyRecord, lastResort bool) error + DeletePreKey(uuidKind UUIDKind, preKeyId int) error + DeleteSignedPreKey(uuidKind UUIDKind, preKeyId int) error + DeleteKyberPreKey(uuidKind UUIDKind, preKeyId int) error + GetNextPreKeyID(uuidKind UUIDKind) (uint, error) + GetSignedNextPreKeyID(uuidKind UUIDKind) (uint, error) + GetNextKyberPreKeyID(uuidKind UUIDKind) (uint, error) + MarkPreKeysAsUploaded(uuidKind UUIDKind, upToID uint) error + MarkSignedPreKeysAsUploaded(uuidKind UUIDKind, upToID uint) error + IsKyberPreKeyLastResort(uuidKind UUIDKind, preKeyId int) (bool, error) + DeleteAllPreKeys() error +} + +// libsignalgo.PreKeyStore implementation +func (s *SQLStore) LoadPreKey(id uint32, ctx context.Context) (*libsignalgo.PreKeyRecord, error) { + return s.PreKey(UUID_KIND_ACI, int(id)) +} +func (s *SQLStore) StorePreKey(id uint32, preKeyRecord *libsignalgo.PreKeyRecord, ctx context.Context) error { + return s.SavePreKey(UUID_KIND_ACI, preKeyRecord, false) +} +func (s *SQLStore) RemovePreKey(id uint32, ctx context.Context) error { + return s.DeletePreKey(UUID_KIND_ACI, int(id)) +} + +// libsignalgo.SignedPreKeyStore implementation +func (s *SQLStore) LoadSignedPreKey(id uint32, ctx context.Context) (*libsignalgo.SignedPreKeyRecord, error) { + return s.SignedPreKey(UUID_KIND_ACI, int(id)) +} +func (s *SQLStore) StoreSignedPreKey(id uint32, signedPreKeyRecord *libsignalgo.SignedPreKeyRecord, ctx context.Context) error { + return s.SaveSignedPreKey(UUID_KIND_ACI, signedPreKeyRecord, false) +} +func (s *SQLStore) RemoveSignedPreKey(id uint32, ctx context.Context) error { + return s.DeleteSignedPreKey(UUID_KIND_ACI, int(id)) +} + +// libsignalgo.KyberPreKeyStore implementation +func (s *SQLStore) LoadKyberPreKey(id uint32, ctx context.Context) (*libsignalgo.KyberPreKeyRecord, error) { + return s.KyberPreKey(UUID_KIND_ACI, int(id)) +} +func (s *SQLStore) StoreKyberPreKey(id uint32, preKeyRecord *libsignalgo.KyberPreKeyRecord, ctx context.Context) error { + return s.SaveKyberPreKey(UUID_KIND_ACI, preKeyRecord, false) +} +func (s *SQLStore) MarkKyberPreKeyUsed(id uint32, ctx context.Context) error { + isLastResort, err := s.IsKyberPreKeyLastResort(UUID_KIND_ACI, int(id)) + if err != nil { + return err + } + if !isLastResort { + return s.DeleteKyberPreKey(UUID_KIND_ACI, int(id)) + } + return nil +} + +func (s *SQLStore) KyberPreKey(uuidKind UUIDKind, preKeyId int) (*libsignalgo.KyberPreKeyRecord, error) { + getKyberPreKeyQuery := `SELECT key_pair, is_last_resort FROM signalmeow_kyber_pre_keys WHERE aci_uuid=$1 AND key_id=$2 AND uuid_kind=$3` + var record []byte + var isLastResort bool + err := s.db.QueryRow(getKyberPreKeyQuery, s.AciUuid, preKeyId, uuidKind).Scan(&record, &isLastResort) + if errors.Is(err, sql.ErrNoRows) { + zlog.Info().Msg("scanKyberPreKey: no rows") + return nil, nil + } + if err != nil { + return nil, err + } + return libsignalgo.DeserializeKyberPreKeyRecord(record) +} + +func (s *SQLStore) SaveKyberPreKey(uuidKind UUIDKind, kyberPreKeyRecord *libsignalgo.KyberPreKeyRecord, lastResort bool) error { + insertKyberPreKeyQuery := `INSERT INTO signalmeow_kyber_pre_keys (aci_uuid, key_id, uuid_kind, key_pair, is_last_resort) VALUES ($1, $2, $3, $4, $5)` + id, err := kyberPreKeyRecord.GetID() + if err != nil { + return err + } + serialized, err := kyberPreKeyRecord.Serialize() + if err != nil { + return err + } + _, err = s.db.Exec(insertKyberPreKeyQuery, s.AciUuid, id, uuidKind, serialized, lastResort) + if err != nil { + zlog.Err(err).Msg("error inserting kyberPreKeyRecord") + } + return err +} + +func (s *SQLStore) DeleteKyberPreKey(uuidKind UUIDKind, preKeyId int) error { + deleteKyberPreKeyQuery := `DELETE FROM signalmeow_kyber_pre_keys WHERE aci_uuid=$1 AND key_id=$2 AND uuid_kind=$3` + _, err := s.db.Exec(deleteKyberPreKeyQuery, s.AciUuid, preKeyId, uuidKind) + return err +} + +func (s *SQLStore) GetNextKyberPreKeyID(uuidKind UUIDKind) (uint, error) { + getLastKyberPreKeyIDQuery := `SELECT MAX(key_id) FROM signalmeow_kyber_pre_keys WHERE aci_uuid=$1 AND uuid_kind=$2` + var lastKeyID sql.NullInt64 + err := s.db.QueryRow(getLastKyberPreKeyIDQuery, s.AciUuid, uuidKind).Scan(&lastKeyID) + if err != nil { + return 0, fmt.Errorf("failed to query next kyber prekey ID: %w", err) + } + return uint(lastKeyID.Int64) + 1, nil +} + +func (s *SQLStore) IsKyberPreKeyLastResort(uuidKind UUIDKind, preKeyId int) (bool, error) { + isLastResortQuery := `SELECT is_last_resort FROM signalmeow_kyber_pre_keys WHERE aci_uuid=$1 AND key_id=$2 AND uuid_kind=$3` + var isLastResort bool + err := s.db.QueryRow(isLastResortQuery, s.AciUuid, preKeyId, uuidKind).Scan(&isLastResort) + if err != nil { + return false, err + } + return isLastResort, nil +} + +const ( + getPreKeyQuery = `SELECT key_id, key_pair FROM signalmeow_pre_keys WHERE aci_uuid=$1 AND key_id=$2 AND uuid_kind=$3 and is_signed=$4` + insertPreKeyQuery = `INSERT INTO signalmeow_pre_keys (aci_uuid, key_id, uuid_kind, is_signed, key_pair, uploaded) VALUES ($1, $2, $3, $4, $5, $6)` + deletePreKeyQuery = `DELETE FROM signalmeow_pre_keys WHERE aci_uuid=$1 AND key_id=$2 AND uuid_kind=$3 AND is_signed=$4` + getLastPreKeyIDQuery = `SELECT MAX(key_id) FROM signalmeow_pre_keys WHERE aci_uuid=$1 AND uuid_kind=$2 AND is_signed=$3` + markPreKeysAsUploadedQuery = `UPDATE signalmeow_pre_keys SET uploaded=true WHERE aci_uuid=$1 AND uuid_kind=$2 AND is_signed=$3 AND key_id<=$4` + getUnuploadedPreKeysQuery = `SELECT key_id, key_pair FROM signalmeow_pre_keys WHERE aci_uuid=$1 AND uuid_kind=$2 AND is_signed=$3 AND uploaded=false ORDER BY key_id` + getUploadedPreKeyCountQuery = `SELECT COUNT(*) FROM signalmeow_pre_keys WHERE aci_uuid=$1 AND uuid_kind=$2 AND is_signed=$3 AND uploaded=true` +) + +func scanPreKey(row scannable) (*libsignalgo.PreKeyRecord, error) { + var id uint + var record []byte + err := row.Scan(&id, &record) + if errors.Is(err, sql.ErrNoRows) { + zlog.Info().Msg("scanPreKey: no rows") + return nil, nil + } else if err != nil { + return nil, err + } + return libsignalgo.DeserializePreKeyRecord(record) +} + +func scanSignedPreKey(row scannable) (*libsignalgo.SignedPreKeyRecord, error) { + var id uint + var record []byte + err := row.Scan(&id, &record) + if errors.Is(err, sql.ErrNoRows) { + zlog.Info().Msg("scanSignedPreKey: no rows") + return nil, nil + } else if err != nil { + return nil, err + } + return libsignalgo.DeserializeSignedPreKeyRecord(record) +} + +func (s *SQLStore) PreKey(uuidKind UUIDKind, preKeyId int) (*libsignalgo.PreKeyRecord, error) { + return scanPreKey(s.db.QueryRow(getPreKeyQuery, s.AciUuid, preKeyId, uuidKind, false)) +} + +func (s *SQLStore) SignedPreKey(uuidKind UUIDKind, preKeyId int) (*libsignalgo.SignedPreKeyRecord, error) { + return scanSignedPreKey(s.db.QueryRow(getPreKeyQuery, s.AciUuid, preKeyId, uuidKind, true)) +} + +func (s *SQLStore) SavePreKey(uuidKind UUIDKind, preKey *libsignalgo.PreKeyRecord, markUploaded bool) error { + id, err := preKey.GetID() + serialized, err := preKey.Serialize() + if err != nil { + zlog.Err(err).Msg("error serializing prekey") + return err + } + _, err = s.db.Exec(insertPreKeyQuery, s.AciUuid, id, uuidKind, false, serialized, markUploaded) + if err != nil { + zlog.Err(err).Msg("error inserting prekey") + } + return err +} + +func (s *SQLStore) SaveSignedPreKey(uuidKind UUIDKind, preKey *libsignalgo.SignedPreKeyRecord, markUploaded bool) error { + id, err := preKey.GetID() + serialized, err := preKey.Serialize() + if err != nil { + zlog.Err(err).Msg("error serializing signed prekey") + return err + } + _, err = s.db.Exec(insertPreKeyQuery, s.AciUuid, id, uuidKind, true, serialized, markUploaded) + if err != nil { + zlog.Err(err).Msg("error inserting signed prekey") + } + return err +} + +func (s *SQLStore) DeletePreKey(uuidKind UUIDKind, preKeyId int) error { + _, err := s.db.Exec(deletePreKeyQuery, s.AciUuid, preKeyId, uuidKind, false) + return err +} + +func (s *SQLStore) DeleteSignedPreKey(uuidKind UUIDKind, preKeyId int) error { + _, err := s.db.Exec(deletePreKeyQuery, s.AciUuid, preKeyId, uuidKind, true) + return err +} + +func (s *SQLStore) GetNextPreKeyID(uuidKind UUIDKind) (uint, error) { + var lastKeyID sql.NullInt64 + err := s.db.QueryRow(getLastPreKeyIDQuery, s.AciUuid, uuidKind, false).Scan(&lastKeyID) + if err != nil { + return 0, fmt.Errorf("failed to query next prekey ID: %w", err) + } + return uint(lastKeyID.Int64) + 1, nil +} + +func (s *SQLStore) GetSignedNextPreKeyID(uuidKind UUIDKind) (uint, error) { + var lastKeyID sql.NullInt64 + err := s.db.QueryRow(getLastPreKeyIDQuery, s.AciUuid, uuidKind, true).Scan(&lastKeyID) + if err != nil { + return 0, fmt.Errorf("failed to query next signed prekey ID: %w", err) + } + return uint(lastKeyID.Int64) + 1, nil +} + +func (s *SQLStore) MarkPreKeysAsUploaded(uuidKind UUIDKind, upToID uint) error { + _, err := s.db.Exec(markPreKeysAsUploadedQuery, s.AciUuid, uuidKind, false, upToID) + return err +} + +func (s *SQLStore) MarkSignedPreKeysAsUploaded(uuidKind UUIDKind, upToID uint) error { + _, err := s.db.Exec(markPreKeysAsUploadedQuery, s.AciUuid, uuidKind, true, upToID) + return err +} + +func (s *SQLStore) DeleteAllPreKeys() error { + _, err := s.db.Exec("DELETE FROM signalmeow_pre_keys WHERE aci_uuid=$1", s.AciUuid) + _, err = s.db.Exec("DELETE FROM signalmeow_kyber_pre_keys WHERE aci_uuid=$1", s.AciUuid) + return err +} diff --git a/pkg/signalmeow/prod-server-public-params.dat b/pkg/signalmeow/prod-server-public-params.dat deleted file mode 100644 index 9391895..0000000 Binary files a/pkg/signalmeow/prod-server-public-params.dat and /dev/null differ diff --git a/pkg/signalmeow/profile.go b/pkg/signalmeow/profile.go index a515f5a..bc48f26 100644 --- a/pkg/signalmeow/profile.go +++ b/pkg/signalmeow/profile.go @@ -17,10 +17,10 @@ package signalmeow import ( - "bytes" "context" "crypto/aes" "crypto/cipher" + "crypto/rand" "encoding/base64" "encoding/hex" "encoding/json" @@ -29,76 +29,64 @@ import ( "io" "net/http" "strings" - "sync" "time" "github.com/google/uuid" - "github.com/rs/zerolog" - "go.mau.fi/util/random" "go.mau.fi/mautrix-signal/pkg/libsignalgo" - "go.mau.fi/mautrix-signal/pkg/signalmeow/types" "go.mau.fi/mautrix-signal/pkg/signalmeow/web" ) -const DefaultProfileRefreshAfter = 1 * time.Hour - -type Capabilities struct { - SenderKey bool `json:"senderKey"` - AnnouncementGroup bool `json:"announcementGroup"` - ChangeNumber bool `json:"changeNumber"` - Stories bool `json:"stories"` - GiftBadges bool `json:"giftBadges"` - PaymentActivation bool `json:"paymentActivation"` - PNI bool `json:"pni"` - Gv1Migration bool `json:"gv1-migration"` +type ProfileName struct { + GivenName string + FamilyName *string } type ProfileResponse struct { - UUID uuid.UUID `json:"uuid"` + Name string + About string + AboutEmoji string + Avatar string +} - Name []byte `json:"name"` - About []byte `json:"about"` - AboutEmoji []byte `json:"aboutEmoji"` - Avatar string `json:"avatar"` - - Capabilities Capabilities `json:"capabilities"` - - Credential []byte `json:"credential"` - IdentityKey []byte `json:"identityKey"` - UnidentifiedAccess []byte `json:"unidentifiedAccess"` - - UnrestrictedUnidentifiedAccess bool `json:"UnrestrictedUnidentifiedAccess"` - - //Badges []any `json:"badges"` - //PhoneNumberSharing []byte `json:"phoneNumberSharing"` - //PaymentAddress []byte `json:"paymentAddress"` +type Profile struct { + Name string + About string + AboutEmoji string + AvatarPath string + Key libsignalgo.ProfileKey } type ProfileCache struct { - profiles map[string]*types.Profile + profiles map[string]*Profile errors map[string]*error lastFetched map[string]time.Time - lock sync.RWMutex + avatarPaths map[string]string } -func (cli *Client) ProfileKeyCredentialRequest(ctx context.Context, signalACI uuid.UUID) ([]byte, error) { - profileKey, err := cli.ProfileKeyForSignalID(ctx, signalACI) +func ProfileKeyCredentialRequest(ctx context.Context, d *Device, signalId string) ([]byte, error) { + profileKey, err := ProfileKeyForSignalID(ctx, d, signalId) if err != nil { - return nil, fmt.Errorf("error getting profile key for ACI: %w", err) + zlog.Err(err).Msg("ProfileKey error") + return nil, err } + parsedUUID, err := uuid.Parse(signalId) + serverPublicParams := serverPublicParams() + requestContext, err := libsignalgo.CreateProfileKeyCredentialRequestContext( - prodServerPublicParams, - signalACI, + serverPublicParams, + parsedUUID, *profileKey, ) if err != nil { - return nil, fmt.Errorf("error creating profile key credential request context: %w", err) + zlog.Err(err).Msg("CreateProfileKeyCredentialRequestContext error") + return nil, err } request, err := requestContext.ProfileKeyCredentialRequestContextGetRequest() if err != nil { - return nil, fmt.Errorf("error getting profile key credential request: %w", err) + zlog.Err(err).Msg("CreateProfileKeyCredentialRequest error") + return nil, err } // convert request bytes to hexidecimal representation @@ -106,101 +94,118 @@ func (cli *Client) ProfileKeyCredentialRequest(ctx context.Context, signalACI uu return []byte(hexRequest), nil } -func (cli *Client) ProfileKeyForSignalID(ctx context.Context, signalACI uuid.UUID) (*libsignalgo.ProfileKey, error) { - profileKey, err := cli.Store.RecipientStore.LoadProfileKey(ctx, signalACI) +func ProfileKeyForSignalID(ctx context.Context, d *Device, signalId string) (*libsignalgo.ProfileKey, error) { + profileKey, err := d.ProfileKeyStore.LoadProfileKey(signalId, ctx) if err != nil { - return nil, fmt.Errorf("error getting profile key: %w", err) + zlog.Err(err).Msg("GetProfileKey error") + return nil, err } return profileKey, nil } var errProfileKeyNotFound = errors.New("profile key not found") -func (cli *Client) getCachedProfileByID(signalID uuid.UUID, refreshAfter time.Duration) (*types.Profile, error) { - cli.ProfileCache.lock.RLock() - defer cli.ProfileCache.lock.RUnlock() - lastFetched, ok := cli.ProfileCache.lastFetched[signalID.String()] - if ok && time.Since(lastFetched) < refreshAfter { - profile, ok := cli.ProfileCache.profiles[signalID.String()] +func RetrieveProfileByID(ctx context.Context, d *Device, signalID uuid.UUID) (*Profile, error) { + if d.Connection.ProfileCache == nil { + d.Connection.ProfileCache = &ProfileCache{ + profiles: make(map[string]*Profile), + errors: make(map[string]*error), + lastFetched: make(map[string]time.Time), + avatarPaths: make(map[string]string), + } + } + + // Check if we have a cached profile that is less than an hour old + // or if we have a cached error that is less than an hour old + lastFetched, ok := d.Connection.ProfileCache.lastFetched[signalID.String()] + if ok && time.Since(lastFetched) < 1*time.Hour { + profile, ok := d.Connection.ProfileCache.profiles[signalID.String()] if ok { return profile, nil } - err, ok := cli.ProfileCache.errors[signalID.String()] + err, ok := d.Connection.ProfileCache.errors[signalID.String()] if ok { - return nil, fmt.Errorf("%w: %w", ErrCachedError, *err) + return nil, *err } } - return nil, nil -} - -func (cli *Client) RetrieveProfileByID(ctx context.Context, signalID uuid.UUID, refreshAfter time.Duration) (*types.Profile, error) { - // Check if we have a cached profile that is less than an hour old - // or if we have a cached error that is less than an hour old - profile, err := cli.getCachedProfileByID(signalID, refreshAfter) - if err != nil || profile != nil { - return profile, err - } // If we get here, we don't have a cached profile, so fetch it - profile, err = cli.fetchProfileByID(ctx, signalID) + profile, err := fetchProfileByID(ctx, d, signalID) if err != nil { // If we get a 401 or 5xx error, we should not retry until the cache expires - if errors.Is(err, ErrProfileUnauthorized) || errors.Is(err, ErrProfileInternalError) { - cli.ProfileCache.lock.Lock() - defer cli.ProfileCache.lock.Unlock() - cli.ProfileCache.errors[signalID.String()] = &err - cli.ProfileCache.lastFetched[signalID.String()] = time.Now() + if strings.HasPrefix(err.Error(), "401") || strings.HasPrefix(err.Error(), "5") { + d.Connection.ProfileCache.errors[signalID.String()] = &err + d.Connection.ProfileCache.lastFetched[signalID.String()] = time.Now() } return nil, err } + if profile == nil { + return nil, errProfileKeyNotFound + } // If we get here, we have a valid profile, so cache it - cli.ProfileCache.lock.Lock() - defer cli.ProfileCache.lock.Unlock() - cli.ProfileCache.profiles[signalID.String()] = profile - cli.ProfileCache.lastFetched[signalID.String()] = time.Now() + d.Connection.ProfileCache.profiles[signalID.String()] = profile + d.Connection.ProfileCache.lastFetched[signalID.String()] = time.Now() return profile, nil } -func (cli *Client) fetchProfileByID(ctx context.Context, signalID uuid.UUID) (*types.Profile, error) { - profileKey, err := cli.ProfileKeyForSignalID(ctx, signalID) +func RetrieveProfileAndAvatarByID(ctx context.Context, d *Device, signalID uuid.UUID) (*Profile, []byte, error) { + profile, err := RetrieveProfileByID(ctx, d, signalID) if err != nil { - return nil, fmt.Errorf("error getting profile key: %w", err) - } else if profileKey == nil { - return nil, errProfileKeyNotFound + return nil, nil, err } - credentialRequest, err := cli.ProfileKeyCredentialRequest(ctx, signalID) - if err != nil { - return nil, fmt.Errorf("error getting profile key credential request: %w", err) + // If there is an avatarPath, and it's different from the cached one, fetch it + // (we only return the avatar if it's different from the cached one) + var avatarImage []byte + cachedAvatarPath, _ := d.Connection.ProfileCache.avatarPaths[signalID.String()] + if profile.AvatarPath != "" && cachedAvatarPath != profile.AvatarPath { + avatarImage, err = fetchAndDecryptAvatarImage(d, profile.AvatarPath, &profile.Key) + if err != nil { + zlog.Err(err).Msg("error fetching profile avatarImage") + return nil, nil, err + } } - return cli.fetchProfileWithRequestAndKey(ctx, signalID, credentialRequest, profileKey) + d.Connection.ProfileCache.avatarPaths[signalID.String()] = profile.AvatarPath + + return profile, avatarImage, nil } -var ( - ErrCachedError = errors.New("cached error") - ErrProfileUnauthorized = errors.New("profile get returned 401") - ErrProfileNotFound = errors.New("profile get returned 404") - ErrProfileInternalError = errors.New("profile get returned") -) +func fetchProfileByID(ctx context.Context, d *Device, signalID uuid.UUID) (*Profile, error) { + profileKey, err := ProfileKeyForSignalID(ctx, d, signalID.String()) + if err != nil { + zlog.Err(err).Msg("ProfileKey error") + return nil, err + } + if profileKey == nil { + zlog.Err(err).Msg("profileKey is nil") + return nil, nil + } -func (cli *Client) fetchProfileWithRequestAndKey(ctx context.Context, signalID uuid.UUID, credentialRequest []byte, profileKey *libsignalgo.ProfileKey) (*types.Profile, error) { - log := zerolog.Ctx(ctx) profileKeyVersion, err := profileKey.GetProfileKeyVersion(signalID) if err != nil { - return nil, fmt.Errorf("error getting profile key version: %w", err) + zlog.Err(err).Msg("profileKey error") + return nil, err } accessKey, err := profileKey.DeriveAccessKey() if err != nil { - return nil, fmt.Errorf("error deriving access key: %w", err) + zlog.Err(err).Msg("DeriveAccessKey error") + return nil, err } base64AccessKey := base64.StdEncoding.EncodeToString(accessKey[:]) + + credentialRequest, err := ProfileKeyCredentialRequest(ctx, d, signalID.String()) + if err != nil { + zlog.Err(err).Msg("ProfileKeyCredentialRequest error") + return nil, err + } + path := "/v1/profile/" + signalID.String() useUnidentified := profileKeyVersion != nil && accessKey != nil if useUnidentified { - log.Trace(). + zlog.Trace(). Hex("profile_key_version", profileKeyVersion[:]). Msg("Using unidentified profile request") // Assuming we can just make the version bytes into a string @@ -210,117 +215,137 @@ func (cli *Client) fetchProfileWithRequestAndKey(ctx context.Context, signalID u path += "/" + string(credentialRequest) path += "?credentialType=expiringProfileKey" } - headers := http.Header{} + profileRequest := web.CreateWSRequest(http.MethodGet, path, nil, nil, nil) if useUnidentified { - headers.Set("Unidentified-Access-Key", base64AccessKey) - headers.Set("Accept-Language", "en-US") + profileRequest.Headers = append(profileRequest.Headers, "unidentified-access-key:"+base64AccessKey) + profileRequest.Headers = append(profileRequest.Headers, "accept-language:en-CA") } - resp, err := cli.UnauthedWS.SendRequest(ctx, http.MethodGet, path, nil, headers) + resp, err := d.Connection.UnauthedWS.SendRequest(ctx, profileRequest) if err != nil { - return nil, fmt.Errorf("error sending request: %w", err) + zlog.Err(err).Msg("SendRequest error") + return nil, err } - var profile types.Profile - profile.FetchedAt = time.Now() - logEvt := log.Trace().Uint32("status_code", resp.GetStatus()).Str("resp_message", resp.GetMessage()) - if logEvt.Enabled() { - if json.Valid(resp.Body) { - logEvt.RawJSON("response_data", resp.Body) - } else { - logEvt.Str("invalid_response_data", base64.StdEncoding.EncodeToString(resp.Body)) - } - } - logEvt.Msg("Got profile response") + zlog.Trace().Msg("Got profile response") if *resp.Status < 200 || *resp.Status >= 300 { - if *resp.Status == 401 { - return nil, ErrProfileUnauthorized - } else if *resp.Status == 404 { - return nil, ErrProfileNotFound - } else if *resp.Status >= 500 { - return nil, fmt.Errorf("%w %d", ErrProfileInternalError, *resp.Status) - } - return nil, fmt.Errorf("unexpected status code %d", *resp.Status) + err := errors.New(fmt.Sprintf("%v (unsuccessful status code)", *resp.Status)) + zlog.Err(err).Msg("profile response error") + return nil, err } var profileResponse ProfileResponse + var profile Profile err = json.Unmarshal(resp.Body, &profileResponse) if err != nil { - return nil, fmt.Errorf("error unmarshalling profile response: %w", err) + zlog.Err(err).Msg("json.Unmarshal error") + return nil, err } - if len(profileResponse.Name) > 0 { - profile.Name, err = decryptString(profileKey, profileResponse.Name) + if profileResponse.Name != "" { + base64Name, err := base64.StdEncoding.DecodeString(profileResponse.Name) + decryptedName, err := decryptString(*profileKey, base64Name) if err != nil { - return nil, fmt.Errorf("error decrypting profile name: %w", err) + zlog.Err(err).Msg("error decrypting profile name") } - // TODO store first and last name separately instead of removing the separator - profile.Name = strings.ReplaceAll(profile.Name, "\x00", " ") + profile.Name = *decryptedName + // I've seen profile names come in with a null byte instead of a space + // between first and last names, so replace any null bytes with spaces + profile.Name = strings.Replace(profile.Name, "\x00", " ", -1) } - if len(profileResponse.About) > 0 { - profile.About, err = decryptString(profileKey, profileResponse.About) + if profileResponse.About != "" { + base64About, err := base64.StdEncoding.DecodeString(profileResponse.About) + decryptedAbout, err := decryptString(*profileKey, base64About) if err != nil { - return nil, fmt.Errorf("error decrypting profile about: %w", err) + zlog.Err(err).Msg("error decrypting profile about") } + profile.About = *decryptedAbout } - if len(profileResponse.AboutEmoji) > 0 { - profile.AboutEmoji, err = decryptString(profileKey, profileResponse.AboutEmoji) + if profileResponse.AboutEmoji != "" { + base64AboutEmoji, err := base64.StdEncoding.DecodeString(profileResponse.AboutEmoji) + decryptedAboutEmoji, err := decryptString(*profileKey, base64AboutEmoji) if err != nil { - return nil, fmt.Errorf("error decrypting profile aboutEmoji: %w", err) + zlog.Err(err).Msg("error decrypting profile aboutEmoji") } + profile.AboutEmoji = *decryptedAboutEmoji } - // TODO store other metadata fields? - if profileResponse.Avatar == "" { - profile.AvatarPath = "clear" - } else { - profile.AvatarPath = profileResponse.Avatar - } - profile.Credential = profileResponse.Credential + profile.AvatarPath = profileResponse.Avatar profile.Key = *profileKey return &profile, nil } -func (cli *Client) DownloadUserAvatar(ctx context.Context, avatarPath string, profileKey libsignalgo.ProfileKey) ([]byte, error) { - username, password := cli.Store.BasicAuthCreds() +func fetchAndDecryptAvatarImage(d *Device, avatarPath string, profileKey *libsignalgo.ProfileKey) ([]byte, error) { + username, password := d.Data.BasicAuthCreds() opts := &web.HTTPReqOpt{ + Host: web.CDNUrlHost, // I guess don't use CDN2 for profiles? Username: &username, Password: &password, } - resp, err := web.SendHTTPRequest(ctx, web.CDN1Hostname, http.MethodGet, avatarPath, opts) + zlog.Info().Str("avatar_path", avatarPath).Msg("Fetching profile avatar") + resp, err := web.SendHTTPRequest(http.MethodGet, avatarPath, opts) if err != nil { - return nil, fmt.Errorf("failed to send request: %w", err) + zlog.Err(err).Msg("error fetching profile avatar") + return nil, err } - defer web.CloseBody(resp) if resp.StatusCode < 200 || resp.StatusCode >= 300 { - return nil, fmt.Errorf("unexpected response status %d", resp.StatusCode) + err := errors.New(fmt.Sprintf("%v (unsuccessful status code)", resp.Status)) + zlog.Err(err).Msg("bad status fetching profile avatar") + return nil, err } encryptedAvatar, err := io.ReadAll(resp.Body) if err != nil { - return nil, fmt.Errorf("failed to read response body: %w", err) + zlog.Err(err).Msg("error reading profile avatar") + return nil, err } - avatar, err := decryptBytes(profileKey[:], encryptedAvatar) + avatar, err := decryptBytes(*profileKey, encryptedAvatar) if err != nil { - return nil, fmt.Errorf("failed to decrypt response: %w", err) + zlog.Err(err).Msg("error decrypting profile avatar") + return nil, err } return avatar, nil } -func decryptBytes(key []byte, encryptedText []byte) ([]byte, error) { - if len(encryptedText) < NONCE_LENGTH+16+1 { +func decryptBytes(key libsignalgo.ProfileKey, encryptedBytes []byte) ([]byte, error) { + if len(encryptedBytes) < NONCE_LENGTH+16+1 { return nil, errors.New("invalid encryptedBytes length") } - nonce := encryptedText[:NONCE_LENGTH] - ciphertext := encryptedText[NONCE_LENGTH:] - decrypted, err := AesgcmDecrypt(key, nonce, ciphertext, []byte{}) + nonce := encryptedBytes[:NONCE_LENGTH] + ciphertext := encryptedBytes[NONCE_LENGTH:] + keyBytes := key[:] + padded, err := AesgcmDecrypt(keyBytes, nonce, ciphertext, []byte{}) if err != nil { return nil, err } - return decrypted, nil + paddedLength := len(padded) + plaintextLength := 0 + for i := paddedLength - 1; i >= 0; i-- { + if padded[i] != byte(0) { + plaintextLength = i + 1 + break + } + } + returnString := padded[:plaintextLength] + return returnString, nil } -func decryptString(key *libsignalgo.ProfileKey, encryptedText []byte) (string, error) { - data, err := decryptBytes(key[:], encryptedText) - if err != nil { - return "", err +func decryptString(key libsignalgo.ProfileKey, encryptedText []byte) (*string, error) { + if len(encryptedText) < NONCE_LENGTH+16+1 { + return nil, errors.New("invalid encryptedText length") } - return string(bytes.TrimRight(data, "\x00")), nil + nonce := encryptedText[:NONCE_LENGTH] + ciphertext := encryptedText[NONCE_LENGTH:] + keyBytes := key[:] + padded, err := AesgcmDecrypt(keyBytes, nonce, ciphertext, []byte{}) + if err != nil { + return nil, err + } + paddedLength := len(padded) + plaintextLength := 0 + for i := paddedLength - 1; i >= 0; i-- { + if padded[i] != byte(0) { + plaintextLength = i + 1 + break + } + } + returnString := string(padded[:plaintextLength]) + return &returnString, nil } func encryptString(key libsignalgo.ProfileKey, plaintext string, paddedLength int) ([]byte, error) { @@ -329,7 +354,8 @@ func encryptString(key libsignalgo.ProfileKey, plaintext string, paddedLength in return nil, errors.New("plaintext longer than paddedLength") } padded := append([]byte(plaintext), make([]byte, paddedLength-inputLength)...) - nonce := random.Bytes(NONCE_LENGTH) + nonce := make([]byte, NONCE_LENGTH) + rand.Read(nonce) keyBytes := key[:] ciphertext, err := AesgcmEncrypt(keyBytes, nonce, padded) if err != nil { @@ -367,43 +393,3 @@ func AesgcmEncrypt(key, nonce, plaintext []byte) ([]byte, error) { } return aesgcm.Seal(nil, nonce, plaintext, nil), nil } - -func (cli *Client) FetchExpiringProfileKeyCredentialById(ctx context.Context, signalACI uuid.UUID) (*libsignalgo.ExpiringProfileKeyCredential, error) { - profileKey, err := cli.ProfileKeyForSignalID(ctx, signalACI) - if err != nil { - return nil, fmt.Errorf("error getting profile key for ACI: %w", err) - } else if profileKey == nil { - return nil, errProfileKeyNotFound - } - requestContext, err := libsignalgo.CreateProfileKeyCredentialRequestContext( - prodServerPublicParams, - signalACI, - *profileKey, - ) - if err != nil { - return nil, fmt.Errorf("error creating profile key credential request context: %w", err) - } - - request, err := requestContext.ProfileKeyCredentialRequestContextGetRequest() - if err != nil { - return nil, fmt.Errorf("error getting profile key credential request: %w", err) - } - - // convert request bytes to hexidecimal representation - hexRequest := hex.EncodeToString(request[:]) - credentialRequest := []byte(hexRequest) - - profile, err := cli.fetchProfileWithRequestAndKey(ctx, signalACI, credentialRequest, profileKey) - if err != nil { - return nil, fmt.Errorf("failed to fetch profile: %w", err) - } - response, err := libsignalgo.NewExpiringProfileKeyCredentialResponse(profile.Credential) - if err != nil { - return nil, fmt.Errorf("failed to get expiring profile key credential response: %w", err) - } - epkc, err := libsignalgo.ReceiveExpiringProfileKeyCredential(prodServerPublicParams, requestContext, response, uint64(time.Now().Unix())) - if err != nil { - return nil, fmt.Errorf("failed to receive expiring profile key credential: %w", err) - } - return epkc, nil -} diff --git a/pkg/signalmeow/profile_key_store.go b/pkg/signalmeow/profile_key_store.go new file mode 100644 index 0000000..4bc77a3 --- /dev/null +++ b/pkg/signalmeow/profile_key_store.go @@ -0,0 +1,75 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2023 Scott Weber +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package signalmeow + +import ( + "context" + "database/sql" + "errors" + + "go.mau.fi/mautrix-signal/pkg/libsignalgo" +) + +var _ ProfileKeyStore = (*SQLStore)(nil) + +type ProfileKeyStore interface { + // LoadProfileKey loads the profile key for the given address. + // If the address is not found, nil is returned. + LoadProfileKey(theirUuid string, ctx context.Context) (*libsignalgo.ProfileKey, error) + StoreProfileKey(theirUuid string, key libsignalgo.ProfileKey, ctx context.Context) error + MyProfileKey(ctx context.Context) (*libsignalgo.ProfileKey, error) +} + +const ( + loadProfileKeyQuery = `SELECT key FROM signalmeow_profile_keys WHERE our_aci_uuid=$1 AND their_aci_uuid=$2` + storeProfileKeyQuery = `INSERT INTO signalmeow_profile_keys (our_aci_uuid, their_aci_uuid, key) VALUES ($1, $2, $3) ON CONFLICT (our_aci_uuid, their_aci_uuid) DO UPDATE SET key=excluded.key` +) + +func scanProfileKey(row scannable) (*libsignalgo.ProfileKey, error) { + var record []byte + err := row.Scan(&record) + if errors.Is(err, sql.ErrNoRows) { + return nil, nil + } else if err != nil { + return nil, err + } + profileKey := libsignalgo.ProfileKey(record) + return &profileKey, err +} + +func (s *SQLStore) LoadProfileKey(theirUuid string, ctx context.Context) (*libsignalgo.ProfileKey, error) { + return scanProfileKey(s.db.QueryRow(loadProfileKeyQuery, s.AciUuid, theirUuid)) +} + +func (s *SQLStore) MyProfileKey(ctx context.Context) (*libsignalgo.ProfileKey, error) { + return scanProfileKey(s.db.QueryRow(loadProfileKeyQuery, s.AciUuid, s.AciUuid)) +} + +func (s *SQLStore) StoreProfileKey(theirUuid string, key libsignalgo.ProfileKey, ctx context.Context) error { + tx, err := s.db.BeginTx(ctx, nil) + if err != nil { + tx.Rollback() + return err + } + _, err = tx.Exec(storeProfileKeyQuery, s.AciUuid, theirUuid, key.Slice()) + if err != nil { + tx.Rollback() + return err + } + err = tx.Commit() + return err +} diff --git a/pkg/signalmeow/protobuf/ContactDiscovery.pb.go b/pkg/signalmeow/protobuf/ContactDiscovery.pb.go deleted file mode 100644 index 5cb232c..0000000 --- a/pkg/signalmeow/protobuf/ContactDiscovery.pb.go +++ /dev/null @@ -1,272 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.11 -// protoc v7.34.1 -// source: ContactDiscovery.proto - -// Copyright 2021 Signal Messenger, LLC -// SPDX-License-Identifier: AGPL-3.0-only - -package signalpb - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type CDSClientRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Each ACI/UAK pair is a 32-byte buffer, containing the 16-byte ACI followed - // by its 16-byte UAK. - AciUakPairs []byte `protobuf:"bytes,1,opt,name=aci_uak_pairs,json=aciUakPairs" json:"aci_uak_pairs,omitempty"` - // Each E164 is an 8-byte big-endian number, as 8 bytes. - PrevE164S []byte `protobuf:"bytes,2,opt,name=prev_e164s,json=prevE164s" json:"prev_e164s,omitempty"` - NewE164S []byte `protobuf:"bytes,3,opt,name=new_e164s,json=newE164s" json:"new_e164s,omitempty"` - DiscardE164S []byte `protobuf:"bytes,4,opt,name=discard_e164s,json=discardE164s" json:"discard_e164s,omitempty"` - // If true, the client has more pairs or e164s to send. If false or unset, - // this is the client's last request, and processing should commence. - HasMore *bool `protobuf:"varint,5,opt,name=has_more,json=hasMore" json:"has_more,omitempty"` - // If set, a token which allows rate limiting to discount the e164s in - // the request's prev_e164s, only counting new_e164s. If not set, then - // rate limiting considers both prev_e164s' and new_e164s' size. - Token []byte `protobuf:"bytes,6,opt,name=token" json:"token,omitempty"` - // After receiving a new token from the server, send back a message just - // containing a token_ack. - TokenAck *bool `protobuf:"varint,7,opt,name=token_ack,json=tokenAck" json:"token_ack,omitempty"` - // Request that, if the server allows, both ACI and PNI be returned even - // if the aci_uak_pairs don't match. - ReturnAcisWithoutUaks *bool `protobuf:"varint,8,opt,name=return_acis_without_uaks,json=returnAcisWithoutUaks" json:"return_acis_without_uaks,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CDSClientRequest) Reset() { - *x = CDSClientRequest{} - mi := &file_ContactDiscovery_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CDSClientRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CDSClientRequest) ProtoMessage() {} - -func (x *CDSClientRequest) ProtoReflect() protoreflect.Message { - mi := &file_ContactDiscovery_proto_msgTypes[0] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CDSClientRequest.ProtoReflect.Descriptor instead. -func (*CDSClientRequest) Descriptor() ([]byte, []int) { - return file_ContactDiscovery_proto_rawDescGZIP(), []int{0} -} - -func (x *CDSClientRequest) GetAciUakPairs() []byte { - if x != nil { - return x.AciUakPairs - } - return nil -} - -func (x *CDSClientRequest) GetPrevE164S() []byte { - if x != nil { - return x.PrevE164S - } - return nil -} - -func (x *CDSClientRequest) GetNewE164S() []byte { - if x != nil { - return x.NewE164S - } - return nil -} - -func (x *CDSClientRequest) GetDiscardE164S() []byte { - if x != nil { - return x.DiscardE164S - } - return nil -} - -func (x *CDSClientRequest) GetHasMore() bool { - if x != nil && x.HasMore != nil { - return *x.HasMore - } - return false -} - -func (x *CDSClientRequest) GetToken() []byte { - if x != nil { - return x.Token - } - return nil -} - -func (x *CDSClientRequest) GetTokenAck() bool { - if x != nil && x.TokenAck != nil { - return *x.TokenAck - } - return false -} - -func (x *CDSClientRequest) GetReturnAcisWithoutUaks() bool { - if x != nil && x.ReturnAcisWithoutUaks != nil { - return *x.ReturnAcisWithoutUaks - } - return false -} - -type CDSClientResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Each triple is an 8-byte e164, a 16-byte PNI, and a 16-byte ACI. - // If the e164 was not found, PNI and ACI are all zeros. If the PNI - // was found but the ACI was not, the PNI will be non-zero and the ACI - // will be all zeros. ACI will be returned if one of the returned - // PNIs has an ACI/UAK pair that matches. - // - // Should the request be successful (IE: a successful status returned), - // |e164_pni_aci_triple| will always equal |e164| of the request, - // so the entire marshalled size of the response will be (2+32)*|e164|, - // where the additional 2 bytes are the id/type/length additions of the - // protobuf marshaling added to each byte array. This avoids any data - // leakage based on the size of the encrypted output. - E164PniAciTriples []byte `protobuf:"bytes,1,opt,name=e164_pni_aci_triples,json=e164PniAciTriples" json:"e164_pni_aci_triples,omitempty"` - // A token which allows subsequent calls' rate limiting to discount the - // e164s sent up in this request, only counting those in the next - // request's new_e164s. - Token []byte `protobuf:"bytes,3,opt,name=token" json:"token,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CDSClientResponse) Reset() { - *x = CDSClientResponse{} - mi := &file_ContactDiscovery_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CDSClientResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CDSClientResponse) ProtoMessage() {} - -func (x *CDSClientResponse) ProtoReflect() protoreflect.Message { - mi := &file_ContactDiscovery_proto_msgTypes[1] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CDSClientResponse.ProtoReflect.Descriptor instead. -func (*CDSClientResponse) Descriptor() ([]byte, []int) { - return file_ContactDiscovery_proto_rawDescGZIP(), []int{1} -} - -func (x *CDSClientResponse) GetE164PniAciTriples() []byte { - if x != nil { - return x.E164PniAciTriples - } - return nil -} - -func (x *CDSClientResponse) GetToken() []byte { - if x != nil { - return x.Token - } - return nil -} - -var File_ContactDiscovery_proto protoreflect.FileDescriptor - -const file_ContactDiscovery_proto_rawDesc = "" + - "\n" + - "\x16ContactDiscovery.proto\x12\rsignalservice\"\x9e\x02\n" + - "\x10CDSClientRequest\x12\"\n" + - "\raci_uak_pairs\x18\x01 \x01(\fR\vaciUakPairs\x12\x1d\n" + - "\n" + - "prev_e164s\x18\x02 \x01(\fR\tprevE164s\x12\x1b\n" + - "\tnew_e164s\x18\x03 \x01(\fR\bnewE164s\x12#\n" + - "\rdiscard_e164s\x18\x04 \x01(\fR\fdiscardE164s\x12\x19\n" + - "\bhas_more\x18\x05 \x01(\bR\ahasMore\x12\x14\n" + - "\x05token\x18\x06 \x01(\fR\x05token\x12\x1b\n" + - "\ttoken_ack\x18\a \x01(\bR\btokenAck\x127\n" + - "\x18return_acis_without_uaks\x18\b \x01(\bR\x15returnAcisWithoutUaks\"Z\n" + - "\x11CDSClientResponse\x12/\n" + - "\x14e164_pni_aci_triples\x18\x01 \x01(\fR\x11e164PniAciTriples\x12\x14\n" + - "\x05token\x18\x03 \x01(\fR\x05token" - -var ( - file_ContactDiscovery_proto_rawDescOnce sync.Once - file_ContactDiscovery_proto_rawDescData []byte -) - -func file_ContactDiscovery_proto_rawDescGZIP() []byte { - file_ContactDiscovery_proto_rawDescOnce.Do(func() { - file_ContactDiscovery_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_ContactDiscovery_proto_rawDesc), len(file_ContactDiscovery_proto_rawDesc))) - }) - return file_ContactDiscovery_proto_rawDescData -} - -var file_ContactDiscovery_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_ContactDiscovery_proto_goTypes = []any{ - (*CDSClientRequest)(nil), // 0: signalservice.CDSClientRequest - (*CDSClientResponse)(nil), // 1: signalservice.CDSClientResponse -} -var file_ContactDiscovery_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_ContactDiscovery_proto_init() } -func file_ContactDiscovery_proto_init() { - if File_ContactDiscovery_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_ContactDiscovery_proto_rawDesc), len(file_ContactDiscovery_proto_rawDesc)), - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_ContactDiscovery_proto_goTypes, - DependencyIndexes: file_ContactDiscovery_proto_depIdxs, - MessageInfos: file_ContactDiscovery_proto_msgTypes, - }.Build() - File_ContactDiscovery_proto = out.File - file_ContactDiscovery_proto_goTypes = nil - file_ContactDiscovery_proto_depIdxs = nil -} diff --git a/pkg/signalmeow/protobuf/ContactDiscovery.proto b/pkg/signalmeow/protobuf/ContactDiscovery.proto deleted file mode 100644 index d1f5e04..0000000 --- a/pkg/signalmeow/protobuf/ContactDiscovery.proto +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2021 Signal Messenger, LLC -// SPDX-License-Identifier: AGPL-3.0-only - -package signalservice; - -message CDSClientRequest { - // Each ACI/UAK pair is a 32-byte buffer, containing the 16-byte ACI followed - // by its 16-byte UAK. - optional bytes aci_uak_pairs = 1; - - // Each E164 is an 8-byte big-endian number, as 8 bytes. - optional bytes prev_e164s = 2; - optional bytes new_e164s = 3; - optional bytes discard_e164s = 4; - - // If true, the client has more pairs or e164s to send. If false or unset, - // this is the client's last request, and processing should commence. - optional bool has_more = 5; - - // If set, a token which allows rate limiting to discount the e164s in - // the request's prev_e164s, only counting new_e164s. If not set, then - // rate limiting considers both prev_e164s' and new_e164s' size. - optional bytes token = 6; - - // After receiving a new token from the server, send back a message just - // containing a token_ack. - optional bool token_ack = 7; - - // Request that, if the server allows, both ACI and PNI be returned even - // if the aci_uak_pairs don't match. - optional bool return_acis_without_uaks = 8; -} - -message CDSClientResponse { - // Each triple is an 8-byte e164, a 16-byte PNI, and a 16-byte ACI. - // If the e164 was not found, PNI and ACI are all zeros. If the PNI - // was found but the ACI was not, the PNI will be non-zero and the ACI - // will be all zeros. ACI will be returned if one of the returned - // PNIs has an ACI/UAK pair that matches. - // - // Should the request be successful (IE: a successful status returned), - // |e164_pni_aci_triple| will always equal |e164| of the request, - // so the entire marshalled size of the response will be (2+32)*|e164|, - // where the additional 2 bytes are the id/type/length additions of the - // protobuf marshaling added to each byte array. This avoids any data - // leakage based on the size of the encrypted output. - optional bytes e164_pni_aci_triples = 1; - - // A token which allows subsequent calls' rate limiting to discount the - // e164s sent up in this request, only counting those in the next - // request's new_e164s. - optional bytes token = 3; -} diff --git a/pkg/signalmeow/protobuf/DeviceName.pb.go b/pkg/signalmeow/protobuf/DeviceName.pb.go index 31b5704..657dcf5 100644 --- a/pkg/signalmeow/protobuf/DeviceName.pb.go +++ b/pkg/signalmeow/protobuf/DeviceName.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.11 -// protoc v7.34.1 +// protoc-gen-go v1.31.0 +// protoc v3.21.12 // source: DeviceName.proto // Copyright 2018 Signal Messenger, LLC @@ -14,7 +14,6 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" - unsafe "unsafe" ) const ( @@ -25,19 +24,22 @@ const ( ) type DeviceName struct { - state protoimpl.MessageState `protogen:"open.v1"` - EphemeralPublic []byte `protobuf:"bytes,1,opt,name=ephemeralPublic" json:"ephemeralPublic,omitempty"` - SyntheticIv []byte `protobuf:"bytes,2,opt,name=syntheticIv" json:"syntheticIv,omitempty"` - Ciphertext []byte `protobuf:"bytes,3,opt,name=ciphertext" json:"ciphertext,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + EphemeralPublic []byte `protobuf:"bytes,1,opt,name=ephemeralPublic" json:"ephemeralPublic,omitempty"` + SyntheticIv []byte `protobuf:"bytes,2,opt,name=syntheticIv" json:"syntheticIv,omitempty"` + Ciphertext []byte `protobuf:"bytes,3,opt,name=ciphertext" json:"ciphertext,omitempty"` } func (x *DeviceName) Reset() { *x = DeviceName{} - mi := &file_DeviceName_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_DeviceName_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *DeviceName) String() string { @@ -48,7 +50,7 @@ func (*DeviceName) ProtoMessage() {} func (x *DeviceName) ProtoReflect() protoreflect.Message { mi := &file_DeviceName_proto_msgTypes[0] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -86,31 +88,33 @@ func (x *DeviceName) GetCiphertext() []byte { var File_DeviceName_proto protoreflect.FileDescriptor -const file_DeviceName_proto_rawDesc = "" + - "\n" + - "\x10DeviceName.proto\x12\rsignalservice\"x\n" + - "\n" + - "DeviceName\x12(\n" + - "\x0fephemeralPublic\x18\x01 \x01(\fR\x0fephemeralPublic\x12 \n" + - "\vsyntheticIv\x18\x02 \x01(\fR\vsyntheticIv\x12\x1e\n" + - "\n" + - "ciphertext\x18\x03 \x01(\fR\n" + - "ciphertext" +var file_DeviceName_proto_rawDesc = []byte{ + 0x0a, 0x10, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x0d, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x22, 0x78, 0x0a, 0x0a, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, + 0x28, 0x0a, 0x0f, 0x65, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x50, 0x75, 0x62, 0x6c, + 0x69, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0f, 0x65, 0x70, 0x68, 0x65, 0x6d, 0x65, + 0x72, 0x61, 0x6c, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x79, 0x6e, + 0x74, 0x68, 0x65, 0x74, 0x69, 0x63, 0x49, 0x76, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, + 0x73, 0x79, 0x6e, 0x74, 0x68, 0x65, 0x74, 0x69, 0x63, 0x49, 0x76, 0x12, 0x1e, 0x0a, 0x0a, 0x63, + 0x69, 0x70, 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x0a, 0x63, 0x69, 0x70, 0x68, 0x65, 0x72, 0x74, 0x65, 0x78, 0x74, +} var ( file_DeviceName_proto_rawDescOnce sync.Once - file_DeviceName_proto_rawDescData []byte + file_DeviceName_proto_rawDescData = file_DeviceName_proto_rawDesc ) func file_DeviceName_proto_rawDescGZIP() []byte { file_DeviceName_proto_rawDescOnce.Do(func() { - file_DeviceName_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_DeviceName_proto_rawDesc), len(file_DeviceName_proto_rawDesc))) + file_DeviceName_proto_rawDescData = protoimpl.X.CompressGZIP(file_DeviceName_proto_rawDescData) }) return file_DeviceName_proto_rawDescData } var file_DeviceName_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_DeviceName_proto_goTypes = []any{ +var file_DeviceName_proto_goTypes = []interface{}{ (*DeviceName)(nil), // 0: signalservice.DeviceName } var file_DeviceName_proto_depIdxs = []int32{ @@ -126,11 +130,25 @@ func file_DeviceName_proto_init() { if File_DeviceName_proto != nil { return } + if !protoimpl.UnsafeEnabled { + file_DeviceName_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeviceName); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_DeviceName_proto_rawDesc), len(file_DeviceName_proto_rawDesc)), + RawDescriptor: file_DeviceName_proto_rawDesc, NumEnums: 0, NumMessages: 1, NumExtensions: 0, @@ -141,6 +159,7 @@ func file_DeviceName_proto_init() { MessageInfos: file_DeviceName_proto_msgTypes, }.Build() File_DeviceName_proto = out.File + file_DeviceName_proto_rawDesc = nil file_DeviceName_proto_goTypes = nil file_DeviceName_proto_depIdxs = nil } diff --git a/pkg/signalmeow/protobuf/Groups.pb.go b/pkg/signalmeow/protobuf/Groups.pb.go index 8d4e2e3..a49ea9f 100644 --- a/pkg/signalmeow/protobuf/Groups.pb.go +++ b/pkg/signalmeow/protobuf/Groups.pb.go @@ -1,11 +1,12 @@ +//* +// Copyright (C) 2019 Open Whisper Systems // -// Copyright 2020 Signal Messenger, LLC -// SPDX-License-Identifier: AGPL-3.0-only +// Licensed according to the LICENSE file in this repository. // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.11 -// protoc v7.34.1 +// protoc-gen-go v1.31.0 +// protoc v3.21.12 // source: Groups.proto package signalpb @@ -15,7 +16,6 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" - unsafe "unsafe" ) const ( @@ -130,23 +130,26 @@ func (AccessControl_AccessRequired) EnumDescriptor() ([]byte, []int) { } type AvatarUploadAttributes struct { - state protoimpl.MessageState `protogen:"open.v1"` - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Credential string `protobuf:"bytes,2,opt,name=credential,proto3" json:"credential,omitempty"` - Acl string `protobuf:"bytes,3,opt,name=acl,proto3" json:"acl,omitempty"` - Algorithm string `protobuf:"bytes,4,opt,name=algorithm,proto3" json:"algorithm,omitempty"` - Date string `protobuf:"bytes,5,opt,name=date,proto3" json:"date,omitempty"` - Policy string `protobuf:"bytes,6,opt,name=policy,proto3" json:"policy,omitempty"` - Signature string `protobuf:"bytes,7,opt,name=signature,proto3" json:"signature,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Credential string `protobuf:"bytes,2,opt,name=credential,proto3" json:"credential,omitempty"` + Acl string `protobuf:"bytes,3,opt,name=acl,proto3" json:"acl,omitempty"` + Algorithm string `protobuf:"bytes,4,opt,name=algorithm,proto3" json:"algorithm,omitempty"` + Date string `protobuf:"bytes,5,opt,name=date,proto3" json:"date,omitempty"` + Policy string `protobuf:"bytes,6,opt,name=policy,proto3" json:"policy,omitempty"` + Signature string `protobuf:"bytes,7,opt,name=signature,proto3" json:"signature,omitempty"` } func (x *AvatarUploadAttributes) Reset() { *x = AvatarUploadAttributes{} - mi := &file_Groups_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *AvatarUploadAttributes) String() string { @@ -157,7 +160,7 @@ func (*AvatarUploadAttributes) ProtoMessage() {} func (x *AvatarUploadAttributes) ProtoReflect() protoreflect.Message { mi := &file_Groups_proto_msgTypes[0] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -222,23 +225,24 @@ func (x *AvatarUploadAttributes) GetSignature() string { } type Member struct { - state protoimpl.MessageState `protogen:"open.v1"` - UserId []byte `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId,omitempty"` - Role Member_Role `protobuf:"varint,2,opt,name=role,proto3,enum=signal.Member_Role" json:"role,omitempty"` - ProfileKey []byte `protobuf:"bytes,3,opt,name=profileKey,proto3" json:"profileKey,omitempty"` - Presentation []byte `protobuf:"bytes,4,opt,name=presentation,proto3" json:"presentation,omitempty"` - JoinedAtVersion uint32 `protobuf:"varint,5,opt,name=joinedAtVersion,proto3" json:"joinedAtVersion,omitempty"` - LabelEmoji []byte `protobuf:"bytes,6,opt,name=labelEmoji,proto3" json:"labelEmoji,omitempty"` // decrypts to a UTF-8 string - LabelString []byte `protobuf:"bytes,7,opt,name=labelString,proto3" json:"labelString,omitempty"` // decrypts to a UTF-8 string - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserId []byte `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId,omitempty"` + Role Member_Role `protobuf:"varint,2,opt,name=role,proto3,enum=Member_Role" json:"role,omitempty"` + ProfileKey []byte `protobuf:"bytes,3,opt,name=profileKey,proto3" json:"profileKey,omitempty"` + Presentation []byte `protobuf:"bytes,4,opt,name=presentation,proto3" json:"presentation,omitempty"` // Only set when sending to server + JoinedAtRevision uint32 `protobuf:"varint,5,opt,name=joinedAtRevision,proto3" json:"joinedAtRevision,omitempty"` } func (x *Member) Reset() { *x = Member{} - mi := &file_Groups_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *Member) String() string { @@ -249,7 +253,7 @@ func (*Member) ProtoMessage() {} func (x *Member) ProtoReflect() protoreflect.Message { mi := &file_Groups_proto_msgTypes[1] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -292,52 +296,41 @@ func (x *Member) GetPresentation() []byte { return nil } -func (x *Member) GetJoinedAtVersion() uint32 { +func (x *Member) GetJoinedAtRevision() uint32 { if x != nil { - return x.JoinedAtVersion + return x.JoinedAtRevision } return 0 } -func (x *Member) GetLabelEmoji() []byte { - if x != nil { - return x.LabelEmoji - } - return nil -} - -func (x *Member) GetLabelString() []byte { - if x != nil { - return x.LabelString - } - return nil -} - -type MemberPendingProfileKey struct { - state protoimpl.MessageState `protogen:"open.v1"` - Member *Member `protobuf:"bytes,1,opt,name=member,proto3" json:"member,omitempty"` - AddedByUserId []byte `protobuf:"bytes,2,opt,name=addedByUserId,proto3" json:"addedByUserId,omitempty"` - Timestamp uint64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // ms since epoch - unknownFields protoimpl.UnknownFields +type PendingMember struct { + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Member *Member `protobuf:"bytes,1,opt,name=member,proto3" json:"member,omitempty"` + AddedByUserId []byte `protobuf:"bytes,2,opt,name=addedByUserId,proto3" json:"addedByUserId,omitempty"` + Timestamp uint64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` } -func (x *MemberPendingProfileKey) Reset() { - *x = MemberPendingProfileKey{} - mi := &file_Groups_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) +func (x *PendingMember) Reset() { + *x = PendingMember{} + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (x *MemberPendingProfileKey) String() string { +func (x *PendingMember) String() string { return protoimpl.X.MessageStringOf(x) } -func (*MemberPendingProfileKey) ProtoMessage() {} +func (*PendingMember) ProtoMessage() {} -func (x *MemberPendingProfileKey) ProtoReflect() protoreflect.Message { +func (x *PendingMember) ProtoReflect() protoreflect.Message { mi := &file_Groups_proto_msgTypes[2] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -347,58 +340,61 @@ func (x *MemberPendingProfileKey) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use MemberPendingProfileKey.ProtoReflect.Descriptor instead. -func (*MemberPendingProfileKey) Descriptor() ([]byte, []int) { +// Deprecated: Use PendingMember.ProtoReflect.Descriptor instead. +func (*PendingMember) Descriptor() ([]byte, []int) { return file_Groups_proto_rawDescGZIP(), []int{2} } -func (x *MemberPendingProfileKey) GetMember() *Member { +func (x *PendingMember) GetMember() *Member { if x != nil { return x.Member } return nil } -func (x *MemberPendingProfileKey) GetAddedByUserId() []byte { +func (x *PendingMember) GetAddedByUserId() []byte { if x != nil { return x.AddedByUserId } return nil } -func (x *MemberPendingProfileKey) GetTimestamp() uint64 { +func (x *PendingMember) GetTimestamp() uint64 { if x != nil { return x.Timestamp } return 0 } -type MemberPendingAdminApproval struct { - state protoimpl.MessageState `protogen:"open.v1"` - UserId []byte `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId,omitempty"` - ProfileKey []byte `protobuf:"bytes,2,opt,name=profileKey,proto3" json:"profileKey,omitempty"` - Presentation []byte `protobuf:"bytes,3,opt,name=presentation,proto3" json:"presentation,omitempty"` - Timestamp uint64 `protobuf:"varint,4,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // ms since epoch - unknownFields protoimpl.UnknownFields +type RequestingMember struct { + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserId []byte `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId,omitempty"` + ProfileKey []byte `protobuf:"bytes,2,opt,name=profileKey,proto3" json:"profileKey,omitempty"` + Presentation []byte `protobuf:"bytes,3,opt,name=presentation,proto3" json:"presentation,omitempty"` // Only set when sending to server + Timestamp uint64 `protobuf:"varint,4,opt,name=timestamp,proto3" json:"timestamp,omitempty"` } -func (x *MemberPendingAdminApproval) Reset() { - *x = MemberPendingAdminApproval{} - mi := &file_Groups_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) +func (x *RequestingMember) Reset() { + *x = RequestingMember{} + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (x *MemberPendingAdminApproval) String() string { +func (x *RequestingMember) String() string { return protoimpl.X.MessageStringOf(x) } -func (*MemberPendingAdminApproval) ProtoMessage() {} +func (*RequestingMember) ProtoMessage() {} -func (x *MemberPendingAdminApproval) ProtoReflect() protoreflect.Message { +func (x *RequestingMember) ProtoReflect() protoreflect.Message { mi := &file_Groups_proto_msgTypes[3] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -408,63 +404,66 @@ func (x *MemberPendingAdminApproval) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use MemberPendingAdminApproval.ProtoReflect.Descriptor instead. -func (*MemberPendingAdminApproval) Descriptor() ([]byte, []int) { +// Deprecated: Use RequestingMember.ProtoReflect.Descriptor instead. +func (*RequestingMember) Descriptor() ([]byte, []int) { return file_Groups_proto_rawDescGZIP(), []int{3} } -func (x *MemberPendingAdminApproval) GetUserId() []byte { +func (x *RequestingMember) GetUserId() []byte { if x != nil { return x.UserId } return nil } -func (x *MemberPendingAdminApproval) GetProfileKey() []byte { +func (x *RequestingMember) GetProfileKey() []byte { if x != nil { return x.ProfileKey } return nil } -func (x *MemberPendingAdminApproval) GetPresentation() []byte { +func (x *RequestingMember) GetPresentation() []byte { if x != nil { return x.Presentation } return nil } -func (x *MemberPendingAdminApproval) GetTimestamp() uint64 { +func (x *RequestingMember) GetTimestamp() uint64 { if x != nil { return x.Timestamp } return 0 } -type MemberBanned struct { - state protoimpl.MessageState `protogen:"open.v1"` - UserId []byte `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId,omitempty"` - Timestamp uint64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // ms since epoch - unknownFields protoimpl.UnknownFields +type BannedMember struct { + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserId []byte `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId,omitempty"` + Timestamp uint64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` } -func (x *MemberBanned) Reset() { - *x = MemberBanned{} - mi := &file_Groups_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) +func (x *BannedMember) Reset() { + *x = BannedMember{} + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (x *MemberBanned) String() string { +func (x *BannedMember) String() string { return protoimpl.X.MessageStringOf(x) } -func (*MemberBanned) ProtoMessage() {} +func (*BannedMember) ProtoMessage() {} -func (x *MemberBanned) ProtoReflect() protoreflect.Message { +func (x *BannedMember) ProtoReflect() protoreflect.Message { mi := &file_Groups_proto_msgTypes[4] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -474,19 +473,19 @@ func (x *MemberBanned) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use MemberBanned.ProtoReflect.Descriptor instead. -func (*MemberBanned) Descriptor() ([]byte, []int) { +// Deprecated: Use BannedMember.ProtoReflect.Descriptor instead. +func (*BannedMember) Descriptor() ([]byte, []int) { return file_Groups_proto_rawDescGZIP(), []int{4} } -func (x *MemberBanned) GetUserId() []byte { +func (x *BannedMember) GetUserId() []byte { if x != nil { return x.UserId } return nil } -func (x *MemberBanned) GetTimestamp() uint64 { +func (x *BannedMember) GetTimestamp() uint64 { if x != nil { return x.Timestamp } @@ -494,20 +493,22 @@ func (x *MemberBanned) GetTimestamp() uint64 { } type AccessControl struct { - state protoimpl.MessageState `protogen:"open.v1"` - Attributes AccessControl_AccessRequired `protobuf:"varint,1,opt,name=attributes,proto3,enum=signal.AccessControl_AccessRequired" json:"attributes,omitempty"` - Members AccessControl_AccessRequired `protobuf:"varint,2,opt,name=members,proto3,enum=signal.AccessControl_AccessRequired" json:"members,omitempty"` - AddFromInviteLink AccessControl_AccessRequired `protobuf:"varint,3,opt,name=addFromInviteLink,proto3,enum=signal.AccessControl_AccessRequired" json:"addFromInviteLink,omitempty"` - MemberLabel AccessControl_AccessRequired `protobuf:"varint,4,opt,name=memberLabel,proto3,enum=signal.AccessControl_AccessRequired" json:"memberLabel,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Attributes AccessControl_AccessRequired `protobuf:"varint,1,opt,name=attributes,proto3,enum=AccessControl_AccessRequired" json:"attributes,omitempty"` + Members AccessControl_AccessRequired `protobuf:"varint,2,opt,name=members,proto3,enum=AccessControl_AccessRequired" json:"members,omitempty"` + AddFromInviteLink AccessControl_AccessRequired `protobuf:"varint,3,opt,name=addFromInviteLink,proto3,enum=AccessControl_AccessRequired" json:"addFromInviteLink,omitempty"` } func (x *AccessControl) Reset() { *x = AccessControl{} - mi := &file_Groups_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *AccessControl) String() string { @@ -518,7 +519,7 @@ func (*AccessControl) ProtoMessage() {} func (x *AccessControl) ProtoReflect() protoreflect.Message { mi := &file_Groups_proto_msgTypes[5] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -554,40 +555,33 @@ func (x *AccessControl) GetAddFromInviteLink() AccessControl_AccessRequired { return AccessControl_UNKNOWN } -func (x *AccessControl) GetMemberLabel() AccessControl_AccessRequired { - if x != nil { - return x.MemberLabel - } - return AccessControl_UNKNOWN -} - type Group struct { - state protoimpl.MessageState `protogen:"open.v1"` - PublicKey []byte `protobuf:"bytes,1,opt,name=publicKey,proto3" json:"publicKey,omitempty"` - Title []byte `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"` - Description []byte `protobuf:"bytes,11,opt,name=description,proto3" json:"description,omitempty"` - // The URL for this group's avatar. The content at this URL can be - // decrypted/deserialized into a `GroupAttributeBlob`. - AvatarUrl string `protobuf:"bytes,3,opt,name=avatarUrl,proto3" json:"avatarUrl,omitempty"` - DisappearingMessagesTimer []byte `protobuf:"bytes,4,opt,name=disappearingMessagesTimer,proto3" json:"disappearingMessagesTimer,omitempty"` - AccessControl *AccessControl `protobuf:"bytes,5,opt,name=accessControl,proto3" json:"accessControl,omitempty"` - Version uint32 `protobuf:"varint,6,opt,name=version,proto3" json:"version,omitempty"` - Members []*Member `protobuf:"bytes,7,rep,name=members,proto3" json:"members,omitempty"` - MembersPendingProfileKey []*MemberPendingProfileKey `protobuf:"bytes,8,rep,name=membersPendingProfileKey,proto3" json:"membersPendingProfileKey,omitempty"` - MembersPendingAdminApproval []*MemberPendingAdminApproval `protobuf:"bytes,9,rep,name=membersPendingAdminApproval,proto3" json:"membersPendingAdminApproval,omitempty"` - InviteLinkPassword []byte `protobuf:"bytes,10,opt,name=inviteLinkPassword,proto3" json:"inviteLinkPassword,omitempty"` - AnnouncementsOnly bool `protobuf:"varint,12,opt,name=announcements_only,json=announcementsOnly,proto3" json:"announcements_only,omitempty"` - MembersBanned []*MemberBanned `protobuf:"bytes,13,rep,name=members_banned,json=membersBanned,proto3" json:"members_banned,omitempty"` - Terminated bool `protobuf:"varint,14,opt,name=terminated,proto3" json:"terminated,omitempty"` // next: 15 - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + PublicKey []byte `protobuf:"bytes,1,opt,name=publicKey,proto3" json:"publicKey,omitempty"` + Title []byte `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"` + Avatar string `protobuf:"bytes,3,opt,name=avatar,proto3" json:"avatar,omitempty"` + DisappearingMessagesTimer []byte `protobuf:"bytes,4,opt,name=disappearingMessagesTimer,proto3" json:"disappearingMessagesTimer,omitempty"` + AccessControl *AccessControl `protobuf:"bytes,5,opt,name=accessControl,proto3" json:"accessControl,omitempty"` + Revision uint32 `protobuf:"varint,6,opt,name=revision,proto3" json:"revision,omitempty"` + Members []*Member `protobuf:"bytes,7,rep,name=members,proto3" json:"members,omitempty"` + PendingMembers []*PendingMember `protobuf:"bytes,8,rep,name=pendingMembers,proto3" json:"pendingMembers,omitempty"` + RequestingMembers []*RequestingMember `protobuf:"bytes,9,rep,name=requestingMembers,proto3" json:"requestingMembers,omitempty"` + InviteLinkPassword []byte `protobuf:"bytes,10,opt,name=inviteLinkPassword,proto3" json:"inviteLinkPassword,omitempty"` + Description []byte `protobuf:"bytes,11,opt,name=description,proto3" json:"description,omitempty"` + AnnouncementsOnly bool `protobuf:"varint,12,opt,name=announcementsOnly,proto3" json:"announcementsOnly,omitempty"` + BannedMembers []*BannedMember `protobuf:"bytes,13,rep,name=bannedMembers,proto3" json:"bannedMembers,omitempty"` } func (x *Group) Reset() { *x = Group{} - mi := &file_Groups_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *Group) String() string { @@ -598,7 +592,7 @@ func (*Group) ProtoMessage() {} func (x *Group) ProtoReflect() protoreflect.Message { mi := &file_Groups_proto_msgTypes[6] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -627,16 +621,9 @@ func (x *Group) GetTitle() []byte { return nil } -func (x *Group) GetDescription() []byte { +func (x *Group) GetAvatar() string { if x != nil { - return x.Description - } - return nil -} - -func (x *Group) GetAvatarUrl() string { - if x != nil { - return x.AvatarUrl + return x.Avatar } return "" } @@ -655,9 +642,9 @@ func (x *Group) GetAccessControl() *AccessControl { return nil } -func (x *Group) GetVersion() uint32 { +func (x *Group) GetRevision() uint32 { if x != nil { - return x.Version + return x.Revision } return 0 } @@ -669,16 +656,16 @@ func (x *Group) GetMembers() []*Member { return nil } -func (x *Group) GetMembersPendingProfileKey() []*MemberPendingProfileKey { +func (x *Group) GetPendingMembers() []*PendingMember { if x != nil { - return x.MembersPendingProfileKey + return x.PendingMembers } return nil } -func (x *Group) GetMembersPendingAdminApproval() []*MemberPendingAdminApproval { +func (x *Group) GetRequestingMembers() []*RequestingMember { if x != nil { - return x.MembersPendingAdminApproval + return x.RequestingMembers } return nil } @@ -690,6 +677,13 @@ func (x *Group) GetInviteLinkPassword() []byte { return nil } +func (x *Group) GetDescription() []byte { + if x != nil { + return x.Description + } + return nil +} + func (x *Group) GetAnnouncementsOnly() bool { if x != nil { return x.AnnouncementsOnly @@ -697,38 +691,144 @@ func (x *Group) GetAnnouncementsOnly() bool { return false } -func (x *Group) GetMembersBanned() []*MemberBanned { +func (x *Group) GetBannedMembers() []*BannedMember { if x != nil { - return x.MembersBanned + return x.BannedMembers } return nil } -func (x *Group) GetTerminated() bool { - if x != nil { - return x.Terminated +type GroupChange struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Actions []byte `protobuf:"bytes,1,opt,name=actions,proto3" json:"actions,omitempty"` + ServerSignature []byte `protobuf:"bytes,2,opt,name=serverSignature,proto3" json:"serverSignature,omitempty"` + ChangeEpoch uint32 `protobuf:"varint,3,opt,name=changeEpoch,proto3" json:"changeEpoch,omitempty"` +} + +func (x *GroupChange) Reset() { + *x = GroupChange{} + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - return false +} + +func (x *GroupChange) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GroupChange) ProtoMessage() {} + +func (x *GroupChange) ProtoReflect() protoreflect.Message { + mi := &file_Groups_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GroupChange.ProtoReflect.Descriptor instead. +func (*GroupChange) Descriptor() ([]byte, []int) { + return file_Groups_proto_rawDescGZIP(), []int{7} +} + +func (x *GroupChange) GetActions() []byte { + if x != nil { + return x.Actions + } + return nil +} + +func (x *GroupChange) GetServerSignature() []byte { + if x != nil { + return x.ServerSignature + } + return nil +} + +func (x *GroupChange) GetChangeEpoch() uint32 { + if x != nil { + return x.ChangeEpoch + } + return 0 +} + +type GroupChanges struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + GroupChanges []*GroupChanges_GroupChangeState `protobuf:"bytes,1,rep,name=groupChanges,proto3" json:"groupChanges,omitempty"` +} + +func (x *GroupChanges) Reset() { + *x = GroupChanges{} + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GroupChanges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GroupChanges) ProtoMessage() {} + +func (x *GroupChanges) ProtoReflect() protoreflect.Message { + mi := &file_Groups_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GroupChanges.ProtoReflect.Descriptor instead. +func (*GroupChanges) Descriptor() ([]byte, []int) { + return file_Groups_proto_rawDescGZIP(), []int{8} +} + +func (x *GroupChanges) GetGroupChanges() []*GroupChanges_GroupChangeState { + if x != nil { + return x.GroupChanges + } + return nil } type GroupAttributeBlob struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Types that are valid to be assigned to Content: + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Content: // // *GroupAttributeBlob_Title // *GroupAttributeBlob_Avatar // *GroupAttributeBlob_DisappearingMessagesDuration - // *GroupAttributeBlob_DescriptionText - Content isGroupAttributeBlob_Content `protobuf_oneof:"content"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + // *GroupAttributeBlob_Description + Content isGroupAttributeBlob_Content `protobuf_oneof:"content"` } func (x *GroupAttributeBlob) Reset() { *x = GroupAttributeBlob{} - mi := &file_Groups_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *GroupAttributeBlob) String() string { @@ -738,8 +838,8 @@ func (x *GroupAttributeBlob) String() string { func (*GroupAttributeBlob) ProtoMessage() {} func (x *GroupAttributeBlob) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[7] - if x != nil { + mi := &file_Groups_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -751,48 +851,40 @@ func (x *GroupAttributeBlob) ProtoReflect() protoreflect.Message { // Deprecated: Use GroupAttributeBlob.ProtoReflect.Descriptor instead. func (*GroupAttributeBlob) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{7} + return file_Groups_proto_rawDescGZIP(), []int{9} } -func (x *GroupAttributeBlob) GetContent() isGroupAttributeBlob_Content { - if x != nil { - return x.Content +func (m *GroupAttributeBlob) GetContent() isGroupAttributeBlob_Content { + if m != nil { + return m.Content } return nil } func (x *GroupAttributeBlob) GetTitle() string { - if x != nil { - if x, ok := x.Content.(*GroupAttributeBlob_Title); ok { - return x.Title - } + if x, ok := x.GetContent().(*GroupAttributeBlob_Title); ok { + return x.Title } return "" } func (x *GroupAttributeBlob) GetAvatar() []byte { - if x != nil { - if x, ok := x.Content.(*GroupAttributeBlob_Avatar); ok { - return x.Avatar - } + if x, ok := x.GetContent().(*GroupAttributeBlob_Avatar); ok { + return x.Avatar } return nil } func (x *GroupAttributeBlob) GetDisappearingMessagesDuration() uint32 { - if x != nil { - if x, ok := x.Content.(*GroupAttributeBlob_DisappearingMessagesDuration); ok { - return x.DisappearingMessagesDuration - } + if x, ok := x.GetContent().(*GroupAttributeBlob_DisappearingMessagesDuration); ok { + return x.DisappearingMessagesDuration } return 0 } -func (x *GroupAttributeBlob) GetDescriptionText() string { - if x != nil { - if x, ok := x.Content.(*GroupAttributeBlob_DescriptionText); ok { - return x.DescriptionText - } +func (x *GroupAttributeBlob) GetDescription() string { + if x, ok := x.GetContent().(*GroupAttributeBlob_Description); ok { + return x.Description } return "" } @@ -813,8 +905,8 @@ type GroupAttributeBlob_DisappearingMessagesDuration struct { DisappearingMessagesDuration uint32 `protobuf:"varint,3,opt,name=disappearingMessagesDuration,proto3,oneof"` } -type GroupAttributeBlob_DescriptionText struct { - DescriptionText string `protobuf:"bytes,4,opt,name=descriptionText,proto3,oneof"` +type GroupAttributeBlob_Description struct { + Description string `protobuf:"bytes,4,opt,name=description,proto3,oneof"` } func (*GroupAttributeBlob_Title) isGroupAttributeBlob_Content() {} @@ -823,23 +915,26 @@ func (*GroupAttributeBlob_Avatar) isGroupAttributeBlob_Content() {} func (*GroupAttributeBlob_DisappearingMessagesDuration) isGroupAttributeBlob_Content() {} -func (*GroupAttributeBlob_DescriptionText) isGroupAttributeBlob_Content() {} +func (*GroupAttributeBlob_Description) isGroupAttributeBlob_Content() {} type GroupInviteLink struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Types that are valid to be assigned to Contents: - // - // *GroupInviteLink_ContentsV1 - Contents isGroupInviteLink_Contents `protobuf_oneof:"contents"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Contents: + // + // *GroupInviteLink_V1Contents + Contents isGroupInviteLink_Contents `protobuf_oneof:"contents"` } func (x *GroupInviteLink) Reset() { *x = GroupInviteLink{} - mi := &file_Groups_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *GroupInviteLink) String() string { @@ -849,8 +944,8 @@ func (x *GroupInviteLink) String() string { func (*GroupInviteLink) ProtoMessage() {} func (x *GroupInviteLink) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[8] - if x != nil { + mi := &file_Groups_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -862,21 +957,19 @@ func (x *GroupInviteLink) ProtoReflect() protoreflect.Message { // Deprecated: Use GroupInviteLink.ProtoReflect.Descriptor instead. func (*GroupInviteLink) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{8} + return file_Groups_proto_rawDescGZIP(), []int{10} } -func (x *GroupInviteLink) GetContents() isGroupInviteLink_Contents { - if x != nil { - return x.Contents +func (m *GroupInviteLink) GetContents() isGroupInviteLink_Contents { + if m != nil { + return m.Contents } return nil } -func (x *GroupInviteLink) GetContentsV1() *GroupInviteLink_GroupInviteLinkContentsV1 { - if x != nil { - if x, ok := x.Contents.(*GroupInviteLink_ContentsV1); ok { - return x.ContentsV1 - } +func (x *GroupInviteLink) GetV1Contents() *GroupInviteLink_GroupInviteLinkContentsV1 { + if x, ok := x.GetContents().(*GroupInviteLink_V1Contents); ok { + return x.V1Contents } return nil } @@ -885,31 +978,34 @@ type isGroupInviteLink_Contents interface { isGroupInviteLink_Contents() } -type GroupInviteLink_ContentsV1 struct { - ContentsV1 *GroupInviteLink_GroupInviteLinkContentsV1 `protobuf:"bytes,1,opt,name=contentsV1,proto3,oneof"` +type GroupInviteLink_V1Contents struct { + V1Contents *GroupInviteLink_GroupInviteLinkContentsV1 `protobuf:"bytes,1,opt,name=v1Contents,proto3,oneof"` } -func (*GroupInviteLink_ContentsV1) isGroupInviteLink_Contents() {} +func (*GroupInviteLink_V1Contents) isGroupInviteLink_Contents() {} type GroupJoinInfo struct { - state protoimpl.MessageState `protogen:"open.v1"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + PublicKey []byte `protobuf:"bytes,1,opt,name=publicKey,proto3" json:"publicKey,omitempty"` Title []byte `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"` - Description []byte `protobuf:"bytes,8,opt,name=description,proto3" json:"description,omitempty"` Avatar string `protobuf:"bytes,3,opt,name=avatar,proto3" json:"avatar,omitempty"` MemberCount uint32 `protobuf:"varint,4,opt,name=memberCount,proto3" json:"memberCount,omitempty"` - AddFromInviteLink AccessControl_AccessRequired `protobuf:"varint,5,opt,name=addFromInviteLink,proto3,enum=signal.AccessControl_AccessRequired" json:"addFromInviteLink,omitempty"` - Version uint32 `protobuf:"varint,6,opt,name=version,proto3" json:"version,omitempty"` + AddFromInviteLink AccessControl_AccessRequired `protobuf:"varint,5,opt,name=addFromInviteLink,proto3,enum=AccessControl_AccessRequired" json:"addFromInviteLink,omitempty"` + Revision uint32 `protobuf:"varint,6,opt,name=revision,proto3" json:"revision,omitempty"` PendingAdminApproval bool `protobuf:"varint,7,opt,name=pendingAdminApproval,proto3" json:"pendingAdminApproval,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + Description []byte `protobuf:"bytes,8,opt,name=description,proto3" json:"description,omitempty"` } func (x *GroupJoinInfo) Reset() { *x = GroupJoinInfo{} - mi := &file_Groups_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *GroupJoinInfo) String() string { @@ -919,8 +1015,8 @@ func (x *GroupJoinInfo) String() string { func (*GroupJoinInfo) ProtoMessage() {} func (x *GroupJoinInfo) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[9] - if x != nil { + mi := &file_Groups_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -932,7 +1028,7 @@ func (x *GroupJoinInfo) ProtoReflect() protoreflect.Message { // Deprecated: Use GroupJoinInfo.ProtoReflect.Descriptor instead. func (*GroupJoinInfo) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{9} + return file_Groups_proto_rawDescGZIP(), []int{11} } func (x *GroupJoinInfo) GetPublicKey() []byte { @@ -949,13 +1045,6 @@ func (x *GroupJoinInfo) GetTitle() []byte { return nil } -func (x *GroupJoinInfo) GetDescription() []byte { - if x != nil { - return x.Description - } - return nil -} - func (x *GroupJoinInfo) GetAvatar() string { if x != nil { return x.Avatar @@ -977,9 +1066,9 @@ func (x *GroupJoinInfo) GetAddFromInviteLink() AccessControl_AccessRequired { return AccessControl_UNKNOWN } -func (x *GroupJoinInfo) GetVersion() uint32 { +func (x *GroupJoinInfo) GetRevision() uint32 { if x != nil { - return x.Version + return x.Revision } return 0 } @@ -991,89 +1080,39 @@ func (x *GroupJoinInfo) GetPendingAdminApproval() bool { return false } -type GroupChange struct { - state protoimpl.MessageState `protogen:"open.v1"` - Actions []byte `protobuf:"bytes,1,opt,name=actions,proto3" json:"actions,omitempty"` - ServerSignature []byte `protobuf:"bytes,2,opt,name=serverSignature,proto3" json:"serverSignature,omitempty"` - ChangeEpoch uint32 `protobuf:"varint,3,opt,name=changeEpoch,proto3" json:"changeEpoch,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupChange) Reset() { - *x = GroupChange{} - mi := &file_Groups_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupChange) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupChange) ProtoMessage() {} - -func (x *GroupChange) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[10] +func (x *GroupJoinInfo) GetDescription() []byte { if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupChange.ProtoReflect.Descriptor instead. -func (*GroupChange) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{10} -} - -func (x *GroupChange) GetActions() []byte { - if x != nil { - return x.Actions + return x.Description } return nil } -func (x *GroupChange) GetServerSignature() []byte { - if x != nil { - return x.ServerSignature - } - return nil -} - -func (x *GroupChange) GetChangeEpoch() uint32 { - if x != nil { - return x.ChangeEpoch - } - return 0 -} - -type ExternalGroupCredential struct { - state protoimpl.MessageState `protogen:"open.v1"` - Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` - unknownFields protoimpl.UnknownFields +type GroupExternalCredential struct { + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` } -func (x *ExternalGroupCredential) Reset() { - *x = ExternalGroupCredential{} - mi := &file_Groups_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) +func (x *GroupExternalCredential) Reset() { + *x = GroupExternalCredential{} + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (x *ExternalGroupCredential) String() string { +func (x *GroupExternalCredential) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ExternalGroupCredential) ProtoMessage() {} +func (*GroupExternalCredential) ProtoMessage() {} -func (x *ExternalGroupCredential) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[11] - if x != nil { +func (x *GroupExternalCredential) ProtoReflect() protoreflect.Message { + mi := &file_Groups_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1083,267 +1122,56 @@ func (x *ExternalGroupCredential) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ExternalGroupCredential.ProtoReflect.Descriptor instead. -func (*ExternalGroupCredential) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{11} +// Deprecated: Use GroupExternalCredential.ProtoReflect.Descriptor instead. +func (*GroupExternalCredential) Descriptor() ([]byte, []int) { + return file_Groups_proto_rawDescGZIP(), []int{12} } -func (x *ExternalGroupCredential) GetToken() string { +func (x *GroupExternalCredential) GetToken() string { if x != nil { return x.Token } return "" } -type GroupResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Group *Group `protobuf:"bytes,1,opt,name=group,proto3" json:"group,omitempty"` - GroupSendEndorsementsResponse []byte `protobuf:"bytes,2,opt,name=group_send_endorsements_response,json=groupSendEndorsementsResponse,proto3" json:"group_send_endorsements_response,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupResponse) Reset() { - *x = GroupResponse{} - mi := &file_Groups_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupResponse) ProtoMessage() {} - -func (x *GroupResponse) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[12] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupResponse.ProtoReflect.Descriptor instead. -func (*GroupResponse) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{12} -} - -func (x *GroupResponse) GetGroup() *Group { - if x != nil { - return x.Group - } - return nil -} - -func (x *GroupResponse) GetGroupSendEndorsementsResponse() []byte { - if x != nil { - return x.GroupSendEndorsementsResponse - } - return nil -} - -type GroupChanges struct { - state protoimpl.MessageState `protogen:"open.v1"` - GroupChanges []*GroupChanges_GroupChangeState `protobuf:"bytes,1,rep,name=groupChanges,proto3" json:"groupChanges,omitempty"` - GroupSendEndorsementsResponse []byte `protobuf:"bytes,2,opt,name=group_send_endorsements_response,json=groupSendEndorsementsResponse,proto3" json:"group_send_endorsements_response,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupChanges) Reset() { - *x = GroupChanges{} - mi := &file_Groups_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupChanges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupChanges) ProtoMessage() {} - -func (x *GroupChanges) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[13] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupChanges.ProtoReflect.Descriptor instead. -func (*GroupChanges) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{13} -} - -func (x *GroupChanges) GetGroupChanges() []*GroupChanges_GroupChangeState { - if x != nil { - return x.GroupChanges - } - return nil -} - -func (x *GroupChanges) GetGroupSendEndorsementsResponse() []byte { - if x != nil { - return x.GroupSendEndorsementsResponse - } - return nil -} - -type GroupChangeResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - GroupChange *GroupChange `protobuf:"bytes,1,opt,name=group_change,json=groupChange,proto3" json:"group_change,omitempty"` - GroupSendEndorsementsResponse []byte `protobuf:"bytes,2,opt,name=group_send_endorsements_response,json=groupSendEndorsementsResponse,proto3" json:"group_send_endorsements_response,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupChangeResponse) Reset() { - *x = GroupChangeResponse{} - mi := &file_Groups_proto_msgTypes[14] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupChangeResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupChangeResponse) ProtoMessage() {} - -func (x *GroupChangeResponse) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[14] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupChangeResponse.ProtoReflect.Descriptor instead. -func (*GroupChangeResponse) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{14} -} - -func (x *GroupChangeResponse) GetGroupChange() *GroupChange { - if x != nil { - return x.GroupChange - } - return nil -} - -func (x *GroupChangeResponse) GetGroupSendEndorsementsResponse() []byte { - if x != nil { - return x.GroupSendEndorsementsResponse - } - return nil -} - -type GroupInviteLink_GroupInviteLinkContentsV1 struct { - state protoimpl.MessageState `protogen:"open.v1"` - GroupMasterKey []byte `protobuf:"bytes,1,opt,name=groupMasterKey,proto3" json:"groupMasterKey,omitempty"` - InviteLinkPassword []byte `protobuf:"bytes,2,opt,name=inviteLinkPassword,proto3" json:"inviteLinkPassword,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupInviteLink_GroupInviteLinkContentsV1) Reset() { - *x = GroupInviteLink_GroupInviteLinkContentsV1{} - mi := &file_Groups_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupInviteLink_GroupInviteLinkContentsV1) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupInviteLink_GroupInviteLinkContentsV1) ProtoMessage() {} - -func (x *GroupInviteLink_GroupInviteLinkContentsV1) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[15] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupInviteLink_GroupInviteLinkContentsV1.ProtoReflect.Descriptor instead. -func (*GroupInviteLink_GroupInviteLinkContentsV1) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{8, 0} -} - -func (x *GroupInviteLink_GroupInviteLinkContentsV1) GetGroupMasterKey() []byte { - if x != nil { - return x.GroupMasterKey - } - return nil -} - -func (x *GroupInviteLink_GroupInviteLinkContentsV1) GetInviteLinkPassword() []byte { - if x != nil { - return x.InviteLinkPassword - } - return nil -} - type GroupChange_Actions struct { - state protoimpl.MessageState `protogen:"open.v1"` - SourceUserId []byte `protobuf:"bytes,1,opt,name=sourceUserId,proto3" json:"sourceUserId,omitempty"` - // clients should not provide this value; the server will provide it in the response buffer to ensure the signature is binding to a particular group - // if clients set it during a request the server will respond with 400. - GroupId []byte `protobuf:"bytes,25,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` - Version uint32 `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"` - AddMembers []*GroupChange_Actions_AddMemberAction `protobuf:"bytes,3,rep,name=addMembers,proto3" json:"addMembers,omitempty"` - DeleteMembers []*GroupChange_Actions_DeleteMemberAction `protobuf:"bytes,4,rep,name=deleteMembers,proto3" json:"deleteMembers,omitempty"` - ModifyMemberRoles []*GroupChange_Actions_ModifyMemberRoleAction `protobuf:"bytes,5,rep,name=modifyMemberRoles,proto3" json:"modifyMemberRoles,omitempty"` - ModifyMemberProfileKeys []*GroupChange_Actions_ModifyMemberProfileKeyAction `protobuf:"bytes,6,rep,name=modifyMemberProfileKeys,proto3" json:"modifyMemberProfileKeys,omitempty"` - AddMembersPendingProfileKey []*GroupChange_Actions_AddMemberPendingProfileKeyAction `protobuf:"bytes,7,rep,name=addMembersPendingProfileKey,proto3" json:"addMembersPendingProfileKey,omitempty"` - DeleteMembersPendingProfileKey []*GroupChange_Actions_DeleteMemberPendingProfileKeyAction `protobuf:"bytes,8,rep,name=deleteMembersPendingProfileKey,proto3" json:"deleteMembersPendingProfileKey,omitempty"` - PromoteMembersPendingProfileKey []*GroupChange_Actions_PromoteMemberPendingProfileKeyAction `protobuf:"bytes,9,rep,name=promoteMembersPendingProfileKey,proto3" json:"promoteMembersPendingProfileKey,omitempty"` - ModifyTitle *GroupChange_Actions_ModifyTitleAction `protobuf:"bytes,10,opt,name=modifyTitle,proto3" json:"modifyTitle,omitempty"` - ModifyAvatar *GroupChange_Actions_ModifyAvatarAction `protobuf:"bytes,11,opt,name=modifyAvatar,proto3" json:"modifyAvatar,omitempty"` - ModifyDisappearingMessageTimer *GroupChange_Actions_ModifyDisappearingMessageTimerAction `protobuf:"bytes,12,opt,name=modifyDisappearingMessageTimer,proto3" json:"modifyDisappearingMessageTimer,omitempty"` - ModifyAttributesAccess *GroupChange_Actions_ModifyAttributesAccessControlAction `protobuf:"bytes,13,opt,name=modifyAttributesAccess,proto3" json:"modifyAttributesAccess,omitempty"` - ModifyMemberAccess *GroupChange_Actions_ModifyMembersAccessControlAction `protobuf:"bytes,14,opt,name=modifyMemberAccess,proto3" json:"modifyMemberAccess,omitempty"` - ModifyAddFromInviteLinkAccess *GroupChange_Actions_ModifyAddFromInviteLinkAccessControlAction `protobuf:"bytes,15,opt,name=modifyAddFromInviteLinkAccess,proto3" json:"modifyAddFromInviteLinkAccess,omitempty"` // change epoch = 1 - AddMembersPendingAdminApproval []*GroupChange_Actions_AddMemberPendingAdminApprovalAction `protobuf:"bytes,16,rep,name=addMembersPendingAdminApproval,proto3" json:"addMembersPendingAdminApproval,omitempty"` // change epoch = 1 - DeleteMembersPendingAdminApproval []*GroupChange_Actions_DeleteMemberPendingAdminApprovalAction `protobuf:"bytes,17,rep,name=deleteMembersPendingAdminApproval,proto3" json:"deleteMembersPendingAdminApproval,omitempty"` // change epoch = 1 - PromoteMembersPendingAdminApproval []*GroupChange_Actions_PromoteMemberPendingAdminApprovalAction `protobuf:"bytes,18,rep,name=promoteMembersPendingAdminApproval,proto3" json:"promoteMembersPendingAdminApproval,omitempty"` // change epoch = 1 - ModifyInviteLinkPassword *GroupChange_Actions_ModifyInviteLinkPasswordAction `protobuf:"bytes,19,opt,name=modifyInviteLinkPassword,proto3" json:"modifyInviteLinkPassword,omitempty"` // change epoch = 1 - ModifyDescription *GroupChange_Actions_ModifyDescriptionAction `protobuf:"bytes,20,opt,name=modifyDescription,proto3" json:"modifyDescription,omitempty"` // change epoch = 2 - ModifyAnnouncementsOnly *GroupChange_Actions_ModifyAnnouncementsOnlyAction `protobuf:"bytes,21,opt,name=modify_announcements_only,json=modifyAnnouncementsOnly,proto3" json:"modify_announcements_only,omitempty"` // change epoch = 3 - AddMembersBanned []*GroupChange_Actions_AddMemberBannedAction `protobuf:"bytes,22,rep,name=add_members_banned,json=addMembersBanned,proto3" json:"add_members_banned,omitempty"` // change epoch = 4 - DeleteMembersBanned []*GroupChange_Actions_DeleteMemberBannedAction `protobuf:"bytes,23,rep,name=delete_members_banned,json=deleteMembersBanned,proto3" json:"delete_members_banned,omitempty"` // change epoch = 4 - PromoteMembersPendingPniAciProfileKey []*GroupChange_Actions_PromoteMemberPendingPniAciProfileKeyAction `protobuf:"bytes,24,rep,name=promote_members_pending_pni_aci_profile_key,json=promoteMembersPendingPniAciProfileKey,proto3" json:"promote_members_pending_pni_aci_profile_key,omitempty"` // change epoch = 5 - ModifyMemberLabels []*GroupChange_Actions_ModifyMemberLabelAction `protobuf:"bytes,26,rep,name=modifyMemberLabels,proto3" json:"modifyMemberLabels,omitempty"` // change epoch = 6; - ModifyMemberLabelAccess *GroupChange_Actions_ModifyMemberLabelAccessControlAction `protobuf:"bytes,27,opt,name=modifyMemberLabelAccess,proto3" json:"modifyMemberLabelAccess,omitempty"` // change epoch = 6 - TerminateGroup *GroupChange_Actions_TerminateGroupAction `protobuf:"bytes,28,opt,name=terminate_group,json=terminateGroup,proto3" json:"terminate_group,omitempty"` // change epoch = 7 - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SourceServiceId []byte `protobuf:"bytes,1,opt,name=sourceServiceId,proto3" json:"sourceServiceId,omitempty"` + Revision uint32 `protobuf:"varint,2,opt,name=revision,proto3" json:"revision,omitempty"` + AddMembers []*GroupChange_Actions_AddMemberAction `protobuf:"bytes,3,rep,name=addMembers,proto3" json:"addMembers,omitempty"` + DeleteMembers []*GroupChange_Actions_DeleteMemberAction `protobuf:"bytes,4,rep,name=deleteMembers,proto3" json:"deleteMembers,omitempty"` + ModifyMemberRoles []*GroupChange_Actions_ModifyMemberRoleAction `protobuf:"bytes,5,rep,name=modifyMemberRoles,proto3" json:"modifyMemberRoles,omitempty"` + ModifyMemberProfileKeys []*GroupChange_Actions_ModifyMemberProfileKeyAction `protobuf:"bytes,6,rep,name=modifyMemberProfileKeys,proto3" json:"modifyMemberProfileKeys,omitempty"` + AddPendingMembers []*GroupChange_Actions_AddPendingMemberAction `protobuf:"bytes,7,rep,name=addPendingMembers,proto3" json:"addPendingMembers,omitempty"` + DeletePendingMembers []*GroupChange_Actions_DeletePendingMemberAction `protobuf:"bytes,8,rep,name=deletePendingMembers,proto3" json:"deletePendingMembers,omitempty"` + PromotePendingMembers []*GroupChange_Actions_PromotePendingMemberAction `protobuf:"bytes,9,rep,name=promotePendingMembers,proto3" json:"promotePendingMembers,omitempty"` + ModifyTitle *GroupChange_Actions_ModifyTitleAction `protobuf:"bytes,10,opt,name=modifyTitle,proto3" json:"modifyTitle,omitempty"` + ModifyAvatar *GroupChange_Actions_ModifyAvatarAction `protobuf:"bytes,11,opt,name=modifyAvatar,proto3" json:"modifyAvatar,omitempty"` + ModifyDisappearingMessagesTimer *GroupChange_Actions_ModifyDisappearingMessagesTimerAction `protobuf:"bytes,12,opt,name=modifyDisappearingMessagesTimer,proto3" json:"modifyDisappearingMessagesTimer,omitempty"` + ModifyAttributesAccess *GroupChange_Actions_ModifyAttributesAccessControlAction `protobuf:"bytes,13,opt,name=modifyAttributesAccess,proto3" json:"modifyAttributesAccess,omitempty"` + ModifyMemberAccess *GroupChange_Actions_ModifyMembersAccessControlAction `protobuf:"bytes,14,opt,name=modifyMemberAccess,proto3" json:"modifyMemberAccess,omitempty"` + ModifyAddFromInviteLinkAccess *GroupChange_Actions_ModifyAddFromInviteLinkAccessControlAction `protobuf:"bytes,15,opt,name=modifyAddFromInviteLinkAccess,proto3" json:"modifyAddFromInviteLinkAccess,omitempty"` + AddRequestingMembers []*GroupChange_Actions_AddRequestingMemberAction `protobuf:"bytes,16,rep,name=addRequestingMembers,proto3" json:"addRequestingMembers,omitempty"` + DeleteRequestingMembers []*GroupChange_Actions_DeleteRequestingMemberAction `protobuf:"bytes,17,rep,name=deleteRequestingMembers,proto3" json:"deleteRequestingMembers,omitempty"` + PromoteRequestingMembers []*GroupChange_Actions_PromoteRequestingMemberAction `protobuf:"bytes,18,rep,name=promoteRequestingMembers,proto3" json:"promoteRequestingMembers,omitempty"` + ModifyInviteLinkPassword *GroupChange_Actions_ModifyInviteLinkPasswordAction `protobuf:"bytes,19,opt,name=modifyInviteLinkPassword,proto3" json:"modifyInviteLinkPassword,omitempty"` + ModifyDescription *GroupChange_Actions_ModifyDescriptionAction `protobuf:"bytes,20,opt,name=modifyDescription,proto3" json:"modifyDescription,omitempty"` + ModifyAnnouncementsOnly *GroupChange_Actions_ModifyAnnouncementsOnlyAction `protobuf:"bytes,21,opt,name=modifyAnnouncementsOnly,proto3" json:"modifyAnnouncementsOnly,omitempty"` + AddBannedMembers []*GroupChange_Actions_AddBannedMemberAction `protobuf:"bytes,22,rep,name=addBannedMembers,proto3" json:"addBannedMembers,omitempty"` + DeleteBannedMembers []*GroupChange_Actions_DeleteBannedMemberAction `protobuf:"bytes,23,rep,name=deleteBannedMembers,proto3" json:"deleteBannedMembers,omitempty"` + PromotePendingPniAciMembers []*GroupChange_Actions_PromotePendingPniAciMemberProfileKeyAction `protobuf:"bytes,24,rep,name=promotePendingPniAciMembers,proto3" json:"promotePendingPniAciMembers,omitempty"` } func (x *GroupChange_Actions) Reset() { *x = GroupChange_Actions{} - mi := &file_Groups_proto_msgTypes[16] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *GroupChange_Actions) String() string { @@ -1353,8 +1181,8 @@ func (x *GroupChange_Actions) String() string { func (*GroupChange_Actions) ProtoMessage() {} func (x *GroupChange_Actions) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[16] - if x != nil { + mi := &file_Groups_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1366,26 +1194,19 @@ func (x *GroupChange_Actions) ProtoReflect() protoreflect.Message { // Deprecated: Use GroupChange_Actions.ProtoReflect.Descriptor instead. func (*GroupChange_Actions) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{10, 0} + return file_Groups_proto_rawDescGZIP(), []int{7, 0} } -func (x *GroupChange_Actions) GetSourceUserId() []byte { +func (x *GroupChange_Actions) GetSourceServiceId() []byte { if x != nil { - return x.SourceUserId + return x.SourceServiceId } return nil } -func (x *GroupChange_Actions) GetGroupId() []byte { +func (x *GroupChange_Actions) GetRevision() uint32 { if x != nil { - return x.GroupId - } - return nil -} - -func (x *GroupChange_Actions) GetVersion() uint32 { - if x != nil { - return x.Version + return x.Revision } return 0 } @@ -1418,23 +1239,23 @@ func (x *GroupChange_Actions) GetModifyMemberProfileKeys() []*GroupChange_Action return nil } -func (x *GroupChange_Actions) GetAddMembersPendingProfileKey() []*GroupChange_Actions_AddMemberPendingProfileKeyAction { +func (x *GroupChange_Actions) GetAddPendingMembers() []*GroupChange_Actions_AddPendingMemberAction { if x != nil { - return x.AddMembersPendingProfileKey + return x.AddPendingMembers } return nil } -func (x *GroupChange_Actions) GetDeleteMembersPendingProfileKey() []*GroupChange_Actions_DeleteMemberPendingProfileKeyAction { +func (x *GroupChange_Actions) GetDeletePendingMembers() []*GroupChange_Actions_DeletePendingMemberAction { if x != nil { - return x.DeleteMembersPendingProfileKey + return x.DeletePendingMembers } return nil } -func (x *GroupChange_Actions) GetPromoteMembersPendingProfileKey() []*GroupChange_Actions_PromoteMemberPendingProfileKeyAction { +func (x *GroupChange_Actions) GetPromotePendingMembers() []*GroupChange_Actions_PromotePendingMemberAction { if x != nil { - return x.PromoteMembersPendingProfileKey + return x.PromotePendingMembers } return nil } @@ -1453,9 +1274,9 @@ func (x *GroupChange_Actions) GetModifyAvatar() *GroupChange_Actions_ModifyAvata return nil } -func (x *GroupChange_Actions) GetModifyDisappearingMessageTimer() *GroupChange_Actions_ModifyDisappearingMessageTimerAction { +func (x *GroupChange_Actions) GetModifyDisappearingMessagesTimer() *GroupChange_Actions_ModifyDisappearingMessagesTimerAction { if x != nil { - return x.ModifyDisappearingMessageTimer + return x.ModifyDisappearingMessagesTimer } return nil } @@ -1481,23 +1302,23 @@ func (x *GroupChange_Actions) GetModifyAddFromInviteLinkAccess() *GroupChange_Ac return nil } -func (x *GroupChange_Actions) GetAddMembersPendingAdminApproval() []*GroupChange_Actions_AddMemberPendingAdminApprovalAction { +func (x *GroupChange_Actions) GetAddRequestingMembers() []*GroupChange_Actions_AddRequestingMemberAction { if x != nil { - return x.AddMembersPendingAdminApproval + return x.AddRequestingMembers } return nil } -func (x *GroupChange_Actions) GetDeleteMembersPendingAdminApproval() []*GroupChange_Actions_DeleteMemberPendingAdminApprovalAction { +func (x *GroupChange_Actions) GetDeleteRequestingMembers() []*GroupChange_Actions_DeleteRequestingMemberAction { if x != nil { - return x.DeleteMembersPendingAdminApproval + return x.DeleteRequestingMembers } return nil } -func (x *GroupChange_Actions) GetPromoteMembersPendingAdminApproval() []*GroupChange_Actions_PromoteMemberPendingAdminApprovalAction { +func (x *GroupChange_Actions) GetPromoteRequestingMembers() []*GroupChange_Actions_PromoteRequestingMemberAction { if x != nil { - return x.PromoteMembersPendingAdminApproval + return x.PromoteRequestingMembers } return nil } @@ -1523,61 +1344,43 @@ func (x *GroupChange_Actions) GetModifyAnnouncementsOnly() *GroupChange_Actions_ return nil } -func (x *GroupChange_Actions) GetAddMembersBanned() []*GroupChange_Actions_AddMemberBannedAction { +func (x *GroupChange_Actions) GetAddBannedMembers() []*GroupChange_Actions_AddBannedMemberAction { if x != nil { - return x.AddMembersBanned + return x.AddBannedMembers } return nil } -func (x *GroupChange_Actions) GetDeleteMembersBanned() []*GroupChange_Actions_DeleteMemberBannedAction { +func (x *GroupChange_Actions) GetDeleteBannedMembers() []*GroupChange_Actions_DeleteBannedMemberAction { if x != nil { - return x.DeleteMembersBanned + return x.DeleteBannedMembers } return nil } -func (x *GroupChange_Actions) GetPromoteMembersPendingPniAciProfileKey() []*GroupChange_Actions_PromoteMemberPendingPniAciProfileKeyAction { +func (x *GroupChange_Actions) GetPromotePendingPniAciMembers() []*GroupChange_Actions_PromotePendingPniAciMemberProfileKeyAction { if x != nil { - return x.PromoteMembersPendingPniAciProfileKey - } - return nil -} - -func (x *GroupChange_Actions) GetModifyMemberLabels() []*GroupChange_Actions_ModifyMemberLabelAction { - if x != nil { - return x.ModifyMemberLabels - } - return nil -} - -func (x *GroupChange_Actions) GetModifyMemberLabelAccess() *GroupChange_Actions_ModifyMemberLabelAccessControlAction { - if x != nil { - return x.ModifyMemberLabelAccess - } - return nil -} - -func (x *GroupChange_Actions) GetTerminateGroup() *GroupChange_Actions_TerminateGroupAction { - if x != nil { - return x.TerminateGroup + return x.PromotePendingPniAciMembers } return nil } type GroupChange_Actions_AddMemberAction struct { - state protoimpl.MessageState `protogen:"open.v1"` - Added *Member `protobuf:"bytes,1,opt,name=added,proto3" json:"added,omitempty"` - JoinFromInviteLink bool `protobuf:"varint,2,opt,name=joinFromInviteLink,proto3" json:"joinFromInviteLink,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Added *Member `protobuf:"bytes,1,opt,name=added,proto3" json:"added,omitempty"` + JoinFromInviteLink bool `protobuf:"varint,2,opt,name=joinFromInviteLink,proto3" json:"joinFromInviteLink,omitempty"` } func (x *GroupChange_Actions_AddMemberAction) Reset() { *x = GroupChange_Actions_AddMemberAction{} - mi := &file_Groups_proto_msgTypes[17] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *GroupChange_Actions_AddMemberAction) String() string { @@ -1587,8 +1390,8 @@ func (x *GroupChange_Actions_AddMemberAction) String() string { func (*GroupChange_Actions_AddMemberAction) ProtoMessage() {} func (x *GroupChange_Actions_AddMemberAction) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[17] - if x != nil { + mi := &file_Groups_proto_msgTypes[14] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1600,7 +1403,7 @@ func (x *GroupChange_Actions_AddMemberAction) ProtoReflect() protoreflect.Messag // Deprecated: Use GroupChange_Actions_AddMemberAction.ProtoReflect.Descriptor instead. func (*GroupChange_Actions_AddMemberAction) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{10, 0, 0} + return file_Groups_proto_rawDescGZIP(), []int{7, 0, 0} } func (x *GroupChange_Actions_AddMemberAction) GetAdded() *Member { @@ -1618,17 +1421,20 @@ func (x *GroupChange_Actions_AddMemberAction) GetJoinFromInviteLink() bool { } type GroupChange_Actions_DeleteMemberAction struct { - state protoimpl.MessageState `protogen:"open.v1"` - DeletedUserId []byte `protobuf:"bytes,1,opt,name=deletedUserId,proto3" json:"deletedUserId,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + DeletedUserId []byte `protobuf:"bytes,1,opt,name=deletedUserId,proto3" json:"deletedUserId,omitempty"` } func (x *GroupChange_Actions_DeleteMemberAction) Reset() { *x = GroupChange_Actions_DeleteMemberAction{} - mi := &file_Groups_proto_msgTypes[18] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *GroupChange_Actions_DeleteMemberAction) String() string { @@ -1638,8 +1444,8 @@ func (x *GroupChange_Actions_DeleteMemberAction) String() string { func (*GroupChange_Actions_DeleteMemberAction) ProtoMessage() {} func (x *GroupChange_Actions_DeleteMemberAction) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[18] - if x != nil { + mi := &file_Groups_proto_msgTypes[15] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1651,7 +1457,7 @@ func (x *GroupChange_Actions_DeleteMemberAction) ProtoReflect() protoreflect.Mes // Deprecated: Use GroupChange_Actions_DeleteMemberAction.ProtoReflect.Descriptor instead. func (*GroupChange_Actions_DeleteMemberAction) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{10, 0, 1} + return file_Groups_proto_rawDescGZIP(), []int{7, 0, 1} } func (x *GroupChange_Actions_DeleteMemberAction) GetDeletedUserId() []byte { @@ -1662,18 +1468,21 @@ func (x *GroupChange_Actions_DeleteMemberAction) GetDeletedUserId() []byte { } type GroupChange_Actions_ModifyMemberRoleAction struct { - state protoimpl.MessageState `protogen:"open.v1"` - UserId []byte `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId,omitempty"` - Role Member_Role `protobuf:"varint,2,opt,name=role,proto3,enum=signal.Member_Role" json:"role,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserId []byte `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId,omitempty"` + Role Member_Role `protobuf:"varint,2,opt,name=role,proto3,enum=Member_Role" json:"role,omitempty"` } func (x *GroupChange_Actions_ModifyMemberRoleAction) Reset() { *x = GroupChange_Actions_ModifyMemberRoleAction{} - mi := &file_Groups_proto_msgTypes[19] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *GroupChange_Actions_ModifyMemberRoleAction) String() string { @@ -1683,8 +1492,8 @@ func (x *GroupChange_Actions_ModifyMemberRoleAction) String() string { func (*GroupChange_Actions_ModifyMemberRoleAction) ProtoMessage() {} func (x *GroupChange_Actions_ModifyMemberRoleAction) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[19] - if x != nil { + mi := &file_Groups_proto_msgTypes[16] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1696,7 +1505,7 @@ func (x *GroupChange_Actions_ModifyMemberRoleAction) ProtoReflect() protoreflect // Deprecated: Use GroupChange_Actions_ModifyMemberRoleAction.ProtoReflect.Descriptor instead. func (*GroupChange_Actions_ModifyMemberRoleAction) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{10, 0, 2} + return file_Groups_proto_rawDescGZIP(), []int{7, 0, 2} } func (x *GroupChange_Actions_ModifyMemberRoleAction) GetUserId() []byte { @@ -1713,80 +1522,23 @@ func (x *GroupChange_Actions_ModifyMemberRoleAction) GetRole() Member_Role { return Member_UNKNOWN } -type GroupChange_Actions_ModifyMemberLabelAction struct { - state protoimpl.MessageState `protogen:"open.v1"` - UserId []byte `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId,omitempty"` - LabelEmoji []byte `protobuf:"bytes,2,opt,name=labelEmoji,proto3" json:"labelEmoji,omitempty"` // decrypts to a UTF-8 string - LabelString []byte `protobuf:"bytes,3,opt,name=labelString,proto3" json:"labelString,omitempty"` // decrypts to a UTF-8 string - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupChange_Actions_ModifyMemberLabelAction) Reset() { - *x = GroupChange_Actions_ModifyMemberLabelAction{} - mi := &file_Groups_proto_msgTypes[20] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupChange_Actions_ModifyMemberLabelAction) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupChange_Actions_ModifyMemberLabelAction) ProtoMessage() {} - -func (x *GroupChange_Actions_ModifyMemberLabelAction) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[20] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupChange_Actions_ModifyMemberLabelAction.ProtoReflect.Descriptor instead. -func (*GroupChange_Actions_ModifyMemberLabelAction) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{10, 0, 3} -} - -func (x *GroupChange_Actions_ModifyMemberLabelAction) GetUserId() []byte { - if x != nil { - return x.UserId - } - return nil -} - -func (x *GroupChange_Actions_ModifyMemberLabelAction) GetLabelEmoji() []byte { - if x != nil { - return x.LabelEmoji - } - return nil -} - -func (x *GroupChange_Actions_ModifyMemberLabelAction) GetLabelString() []byte { - if x != nil { - return x.LabelString - } - return nil -} - type GroupChange_Actions_ModifyMemberProfileKeyAction struct { - state protoimpl.MessageState `protogen:"open.v1"` - Presentation []byte `protobuf:"bytes,1,opt,name=presentation,proto3" json:"presentation,omitempty"` - UserId []byte `protobuf:"bytes,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` - ProfileKey []byte `protobuf:"bytes,3,opt,name=profile_key,json=profileKey,proto3" json:"profile_key,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Presentation []byte `protobuf:"bytes,1,opt,name=presentation,proto3" json:"presentation,omitempty"` // Only set when sending to server + UserId []byte `protobuf:"bytes,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // Only set when receiving from server + ProfileKey []byte `protobuf:"bytes,3,opt,name=profile_key,json=profileKey,proto3" json:"profile_key,omitempty"` // Only set when receiving from server } func (x *GroupChange_Actions_ModifyMemberProfileKeyAction) Reset() { *x = GroupChange_Actions_ModifyMemberProfileKeyAction{} - mi := &file_Groups_proto_msgTypes[21] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *GroupChange_Actions_ModifyMemberProfileKeyAction) String() string { @@ -1796,8 +1548,8 @@ func (x *GroupChange_Actions_ModifyMemberProfileKeyAction) String() string { func (*GroupChange_Actions_ModifyMemberProfileKeyAction) ProtoMessage() {} func (x *GroupChange_Actions_ModifyMemberProfileKeyAction) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[21] - if x != nil { + mi := &file_Groups_proto_msgTypes[17] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1809,7 +1561,7 @@ func (x *GroupChange_Actions_ModifyMemberProfileKeyAction) ProtoReflect() protor // Deprecated: Use GroupChange_Actions_ModifyMemberProfileKeyAction.ProtoReflect.Descriptor instead. func (*GroupChange_Actions_ModifyMemberProfileKeyAction) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{10, 0, 4} + return file_Groups_proto_rawDescGZIP(), []int{7, 0, 3} } func (x *GroupChange_Actions_ModifyMemberProfileKeyAction) GetPresentation() []byte { @@ -1833,29 +1585,32 @@ func (x *GroupChange_Actions_ModifyMemberProfileKeyAction) GetProfileKey() []byt return nil } -type GroupChange_Actions_AddMemberPendingProfileKeyAction struct { - state protoimpl.MessageState `protogen:"open.v1"` - Added *MemberPendingProfileKey `protobuf:"bytes,1,opt,name=added,proto3" json:"added,omitempty"` - unknownFields protoimpl.UnknownFields +type GroupChange_Actions_AddPendingMemberAction struct { + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Added *PendingMember `protobuf:"bytes,1,opt,name=added,proto3" json:"added,omitempty"` } -func (x *GroupChange_Actions_AddMemberPendingProfileKeyAction) Reset() { - *x = GroupChange_Actions_AddMemberPendingProfileKeyAction{} - mi := &file_Groups_proto_msgTypes[22] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) +func (x *GroupChange_Actions_AddPendingMemberAction) Reset() { + *x = GroupChange_Actions_AddPendingMemberAction{} + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (x *GroupChange_Actions_AddMemberPendingProfileKeyAction) String() string { +func (x *GroupChange_Actions_AddPendingMemberAction) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GroupChange_Actions_AddMemberPendingProfileKeyAction) ProtoMessage() {} +func (*GroupChange_Actions_AddPendingMemberAction) ProtoMessage() {} -func (x *GroupChange_Actions_AddMemberPendingProfileKeyAction) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[22] - if x != nil { +func (x *GroupChange_Actions_AddPendingMemberAction) ProtoReflect() protoreflect.Message { + mi := &file_Groups_proto_msgTypes[18] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1865,41 +1620,44 @@ func (x *GroupChange_Actions_AddMemberPendingProfileKeyAction) ProtoReflect() pr return mi.MessageOf(x) } -// Deprecated: Use GroupChange_Actions_AddMemberPendingProfileKeyAction.ProtoReflect.Descriptor instead. -func (*GroupChange_Actions_AddMemberPendingProfileKeyAction) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{10, 0, 5} +// Deprecated: Use GroupChange_Actions_AddPendingMemberAction.ProtoReflect.Descriptor instead. +func (*GroupChange_Actions_AddPendingMemberAction) Descriptor() ([]byte, []int) { + return file_Groups_proto_rawDescGZIP(), []int{7, 0, 4} } -func (x *GroupChange_Actions_AddMemberPendingProfileKeyAction) GetAdded() *MemberPendingProfileKey { +func (x *GroupChange_Actions_AddPendingMemberAction) GetAdded() *PendingMember { if x != nil { return x.Added } return nil } -type GroupChange_Actions_DeleteMemberPendingProfileKeyAction struct { - state protoimpl.MessageState `protogen:"open.v1"` - DeletedUserId []byte `protobuf:"bytes,1,opt,name=deletedUserId,proto3" json:"deletedUserId,omitempty"` - unknownFields protoimpl.UnknownFields +type GroupChange_Actions_DeletePendingMemberAction struct { + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + DeletedUserId []byte `protobuf:"bytes,1,opt,name=deletedUserId,proto3" json:"deletedUserId,omitempty"` } -func (x *GroupChange_Actions_DeleteMemberPendingProfileKeyAction) Reset() { - *x = GroupChange_Actions_DeleteMemberPendingProfileKeyAction{} - mi := &file_Groups_proto_msgTypes[23] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) +func (x *GroupChange_Actions_DeletePendingMemberAction) Reset() { + *x = GroupChange_Actions_DeletePendingMemberAction{} + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (x *GroupChange_Actions_DeleteMemberPendingProfileKeyAction) String() string { +func (x *GroupChange_Actions_DeletePendingMemberAction) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GroupChange_Actions_DeleteMemberPendingProfileKeyAction) ProtoMessage() {} +func (*GroupChange_Actions_DeletePendingMemberAction) ProtoMessage() {} -func (x *GroupChange_Actions_DeleteMemberPendingProfileKeyAction) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[23] - if x != nil { +func (x *GroupChange_Actions_DeletePendingMemberAction) ProtoReflect() protoreflect.Message { + mi := &file_Groups_proto_msgTypes[19] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1909,43 +1667,46 @@ func (x *GroupChange_Actions_DeleteMemberPendingProfileKeyAction) ProtoReflect() return mi.MessageOf(x) } -// Deprecated: Use GroupChange_Actions_DeleteMemberPendingProfileKeyAction.ProtoReflect.Descriptor instead. -func (*GroupChange_Actions_DeleteMemberPendingProfileKeyAction) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{10, 0, 6} +// Deprecated: Use GroupChange_Actions_DeletePendingMemberAction.ProtoReflect.Descriptor instead. +func (*GroupChange_Actions_DeletePendingMemberAction) Descriptor() ([]byte, []int) { + return file_Groups_proto_rawDescGZIP(), []int{7, 0, 5} } -func (x *GroupChange_Actions_DeleteMemberPendingProfileKeyAction) GetDeletedUserId() []byte { +func (x *GroupChange_Actions_DeletePendingMemberAction) GetDeletedUserId() []byte { if x != nil { return x.DeletedUserId } return nil } -type GroupChange_Actions_PromoteMemberPendingProfileKeyAction struct { - state protoimpl.MessageState `protogen:"open.v1"` - Presentation []byte `protobuf:"bytes,1,opt,name=presentation,proto3" json:"presentation,omitempty"` - UserId []byte `protobuf:"bytes,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` - ProfileKey []byte `protobuf:"bytes,3,opt,name=profile_key,json=profileKey,proto3" json:"profile_key,omitempty"` - unknownFields protoimpl.UnknownFields +type GroupChange_Actions_PromotePendingMemberAction struct { + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Presentation []byte `protobuf:"bytes,1,opt,name=presentation,proto3" json:"presentation,omitempty"` // Only set when sending to server + UserId []byte `protobuf:"bytes,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // Only set when receiving from server + ProfileKey []byte `protobuf:"bytes,3,opt,name=profile_key,json=profileKey,proto3" json:"profile_key,omitempty"` // Only set when receiving from server } -func (x *GroupChange_Actions_PromoteMemberPendingProfileKeyAction) Reset() { - *x = GroupChange_Actions_PromoteMemberPendingProfileKeyAction{} - mi := &file_Groups_proto_msgTypes[24] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) +func (x *GroupChange_Actions_PromotePendingMemberAction) Reset() { + *x = GroupChange_Actions_PromotePendingMemberAction{} + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (x *GroupChange_Actions_PromoteMemberPendingProfileKeyAction) String() string { +func (x *GroupChange_Actions_PromotePendingMemberAction) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GroupChange_Actions_PromoteMemberPendingProfileKeyAction) ProtoMessage() {} +func (*GroupChange_Actions_PromotePendingMemberAction) ProtoMessage() {} -func (x *GroupChange_Actions_PromoteMemberPendingProfileKeyAction) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[24] - if x != nil { +func (x *GroupChange_Actions_PromotePendingMemberAction) ProtoReflect() protoreflect.Message { + mi := &file_Groups_proto_msgTypes[20] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1955,58 +1716,61 @@ func (x *GroupChange_Actions_PromoteMemberPendingProfileKeyAction) ProtoReflect( return mi.MessageOf(x) } -// Deprecated: Use GroupChange_Actions_PromoteMemberPendingProfileKeyAction.ProtoReflect.Descriptor instead. -func (*GroupChange_Actions_PromoteMemberPendingProfileKeyAction) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{10, 0, 7} +// Deprecated: Use GroupChange_Actions_PromotePendingMemberAction.ProtoReflect.Descriptor instead. +func (*GroupChange_Actions_PromotePendingMemberAction) Descriptor() ([]byte, []int) { + return file_Groups_proto_rawDescGZIP(), []int{7, 0, 6} } -func (x *GroupChange_Actions_PromoteMemberPendingProfileKeyAction) GetPresentation() []byte { +func (x *GroupChange_Actions_PromotePendingMemberAction) GetPresentation() []byte { if x != nil { return x.Presentation } return nil } -func (x *GroupChange_Actions_PromoteMemberPendingProfileKeyAction) GetUserId() []byte { +func (x *GroupChange_Actions_PromotePendingMemberAction) GetUserId() []byte { if x != nil { return x.UserId } return nil } -func (x *GroupChange_Actions_PromoteMemberPendingProfileKeyAction) GetProfileKey() []byte { +func (x *GroupChange_Actions_PromotePendingMemberAction) GetProfileKey() []byte { if x != nil { return x.ProfileKey } return nil } -type GroupChange_Actions_PromoteMemberPendingPniAciProfileKeyAction struct { - state protoimpl.MessageState `protogen:"open.v1"` - Presentation []byte `protobuf:"bytes,1,opt,name=presentation,proto3" json:"presentation,omitempty"` - UserId []byte `protobuf:"bytes,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` - Pni []byte `protobuf:"bytes,3,opt,name=pni,proto3" json:"pni,omitempty"` - ProfileKey []byte `protobuf:"bytes,4,opt,name=profile_key,json=profileKey,proto3" json:"profile_key,omitempty"` - unknownFields protoimpl.UnknownFields +type GroupChange_Actions_PromotePendingPniAciMemberProfileKeyAction struct { + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Presentation []byte `protobuf:"bytes,1,opt,name=presentation,proto3" json:"presentation,omitempty"` // Only set when sending to server + UserId []byte `protobuf:"bytes,2,opt,name=userId,proto3" json:"userId,omitempty"` // Only set when receiving from server + Pni []byte `protobuf:"bytes,3,opt,name=pni,proto3" json:"pni,omitempty"` // Only set when receiving from server + ProfileKey []byte `protobuf:"bytes,4,opt,name=profileKey,proto3" json:"profileKey,omitempty"` // Only set when receiving from server } -func (x *GroupChange_Actions_PromoteMemberPendingPniAciProfileKeyAction) Reset() { - *x = GroupChange_Actions_PromoteMemberPendingPniAciProfileKeyAction{} - mi := &file_Groups_proto_msgTypes[25] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) +func (x *GroupChange_Actions_PromotePendingPniAciMemberProfileKeyAction) Reset() { + *x = GroupChange_Actions_PromotePendingPniAciMemberProfileKeyAction{} + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[21] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (x *GroupChange_Actions_PromoteMemberPendingPniAciProfileKeyAction) String() string { +func (x *GroupChange_Actions_PromotePendingPniAciMemberProfileKeyAction) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GroupChange_Actions_PromoteMemberPendingPniAciProfileKeyAction) ProtoMessage() {} +func (*GroupChange_Actions_PromotePendingPniAciMemberProfileKeyAction) ProtoMessage() {} -func (x *GroupChange_Actions_PromoteMemberPendingPniAciProfileKeyAction) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[25] - if x != nil { +func (x *GroupChange_Actions_PromotePendingPniAciMemberProfileKeyAction) ProtoReflect() protoreflect.Message { + mi := &file_Groups_proto_msgTypes[21] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2016,62 +1780,65 @@ func (x *GroupChange_Actions_PromoteMemberPendingPniAciProfileKeyAction) ProtoRe return mi.MessageOf(x) } -// Deprecated: Use GroupChange_Actions_PromoteMemberPendingPniAciProfileKeyAction.ProtoReflect.Descriptor instead. -func (*GroupChange_Actions_PromoteMemberPendingPniAciProfileKeyAction) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{10, 0, 8} +// Deprecated: Use GroupChange_Actions_PromotePendingPniAciMemberProfileKeyAction.ProtoReflect.Descriptor instead. +func (*GroupChange_Actions_PromotePendingPniAciMemberProfileKeyAction) Descriptor() ([]byte, []int) { + return file_Groups_proto_rawDescGZIP(), []int{7, 0, 7} } -func (x *GroupChange_Actions_PromoteMemberPendingPniAciProfileKeyAction) GetPresentation() []byte { +func (x *GroupChange_Actions_PromotePendingPniAciMemberProfileKeyAction) GetPresentation() []byte { if x != nil { return x.Presentation } return nil } -func (x *GroupChange_Actions_PromoteMemberPendingPniAciProfileKeyAction) GetUserId() []byte { +func (x *GroupChange_Actions_PromotePendingPniAciMemberProfileKeyAction) GetUserId() []byte { if x != nil { return x.UserId } return nil } -func (x *GroupChange_Actions_PromoteMemberPendingPniAciProfileKeyAction) GetPni() []byte { +func (x *GroupChange_Actions_PromotePendingPniAciMemberProfileKeyAction) GetPni() []byte { if x != nil { return x.Pni } return nil } -func (x *GroupChange_Actions_PromoteMemberPendingPniAciProfileKeyAction) GetProfileKey() []byte { +func (x *GroupChange_Actions_PromotePendingPniAciMemberProfileKeyAction) GetProfileKey() []byte { if x != nil { return x.ProfileKey } return nil } -type GroupChange_Actions_AddMemberPendingAdminApprovalAction struct { - state protoimpl.MessageState `protogen:"open.v1"` - Added *MemberPendingAdminApproval `protobuf:"bytes,1,opt,name=added,proto3" json:"added,omitempty"` - unknownFields protoimpl.UnknownFields +type GroupChange_Actions_AddRequestingMemberAction struct { + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Added *RequestingMember `protobuf:"bytes,1,opt,name=added,proto3" json:"added,omitempty"` } -func (x *GroupChange_Actions_AddMemberPendingAdminApprovalAction) Reset() { - *x = GroupChange_Actions_AddMemberPendingAdminApprovalAction{} - mi := &file_Groups_proto_msgTypes[26] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) +func (x *GroupChange_Actions_AddRequestingMemberAction) Reset() { + *x = GroupChange_Actions_AddRequestingMemberAction{} + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[22] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (x *GroupChange_Actions_AddMemberPendingAdminApprovalAction) String() string { +func (x *GroupChange_Actions_AddRequestingMemberAction) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GroupChange_Actions_AddMemberPendingAdminApprovalAction) ProtoMessage() {} +func (*GroupChange_Actions_AddRequestingMemberAction) ProtoMessage() {} -func (x *GroupChange_Actions_AddMemberPendingAdminApprovalAction) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[26] - if x != nil { +func (x *GroupChange_Actions_AddRequestingMemberAction) ProtoReflect() protoreflect.Message { + mi := &file_Groups_proto_msgTypes[22] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2081,41 +1848,44 @@ func (x *GroupChange_Actions_AddMemberPendingAdminApprovalAction) ProtoReflect() return mi.MessageOf(x) } -// Deprecated: Use GroupChange_Actions_AddMemberPendingAdminApprovalAction.ProtoReflect.Descriptor instead. -func (*GroupChange_Actions_AddMemberPendingAdminApprovalAction) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{10, 0, 9} +// Deprecated: Use GroupChange_Actions_AddRequestingMemberAction.ProtoReflect.Descriptor instead. +func (*GroupChange_Actions_AddRequestingMemberAction) Descriptor() ([]byte, []int) { + return file_Groups_proto_rawDescGZIP(), []int{7, 0, 8} } -func (x *GroupChange_Actions_AddMemberPendingAdminApprovalAction) GetAdded() *MemberPendingAdminApproval { +func (x *GroupChange_Actions_AddRequestingMemberAction) GetAdded() *RequestingMember { if x != nil { return x.Added } return nil } -type GroupChange_Actions_DeleteMemberPendingAdminApprovalAction struct { - state protoimpl.MessageState `protogen:"open.v1"` - DeletedUserId []byte `protobuf:"bytes,1,opt,name=deletedUserId,proto3" json:"deletedUserId,omitempty"` - unknownFields protoimpl.UnknownFields +type GroupChange_Actions_DeleteRequestingMemberAction struct { + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + DeletedUserId []byte `protobuf:"bytes,1,opt,name=deletedUserId,proto3" json:"deletedUserId,omitempty"` } -func (x *GroupChange_Actions_DeleteMemberPendingAdminApprovalAction) Reset() { - *x = GroupChange_Actions_DeleteMemberPendingAdminApprovalAction{} - mi := &file_Groups_proto_msgTypes[27] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) +func (x *GroupChange_Actions_DeleteRequestingMemberAction) Reset() { + *x = GroupChange_Actions_DeleteRequestingMemberAction{} + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[23] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (x *GroupChange_Actions_DeleteMemberPendingAdminApprovalAction) String() string { +func (x *GroupChange_Actions_DeleteRequestingMemberAction) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GroupChange_Actions_DeleteMemberPendingAdminApprovalAction) ProtoMessage() {} +func (*GroupChange_Actions_DeleteRequestingMemberAction) ProtoMessage() {} -func (x *GroupChange_Actions_DeleteMemberPendingAdminApprovalAction) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[27] - if x != nil { +func (x *GroupChange_Actions_DeleteRequestingMemberAction) ProtoReflect() protoreflect.Message { + mi := &file_Groups_proto_msgTypes[23] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2125,42 +1895,45 @@ func (x *GroupChange_Actions_DeleteMemberPendingAdminApprovalAction) ProtoReflec return mi.MessageOf(x) } -// Deprecated: Use GroupChange_Actions_DeleteMemberPendingAdminApprovalAction.ProtoReflect.Descriptor instead. -func (*GroupChange_Actions_DeleteMemberPendingAdminApprovalAction) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{10, 0, 10} +// Deprecated: Use GroupChange_Actions_DeleteRequestingMemberAction.ProtoReflect.Descriptor instead. +func (*GroupChange_Actions_DeleteRequestingMemberAction) Descriptor() ([]byte, []int) { + return file_Groups_proto_rawDescGZIP(), []int{7, 0, 9} } -func (x *GroupChange_Actions_DeleteMemberPendingAdminApprovalAction) GetDeletedUserId() []byte { +func (x *GroupChange_Actions_DeleteRequestingMemberAction) GetDeletedUserId() []byte { if x != nil { return x.DeletedUserId } return nil } -type GroupChange_Actions_PromoteMemberPendingAdminApprovalAction struct { - state protoimpl.MessageState `protogen:"open.v1"` - UserId []byte `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId,omitempty"` - Role Member_Role `protobuf:"varint,2,opt,name=role,proto3,enum=signal.Member_Role" json:"role,omitempty"` - unknownFields protoimpl.UnknownFields +type GroupChange_Actions_PromoteRequestingMemberAction struct { + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserId []byte `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId,omitempty"` + Role Member_Role `protobuf:"varint,2,opt,name=role,proto3,enum=Member_Role" json:"role,omitempty"` } -func (x *GroupChange_Actions_PromoteMemberPendingAdminApprovalAction) Reset() { - *x = GroupChange_Actions_PromoteMemberPendingAdminApprovalAction{} - mi := &file_Groups_proto_msgTypes[28] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) +func (x *GroupChange_Actions_PromoteRequestingMemberAction) Reset() { + *x = GroupChange_Actions_PromoteRequestingMemberAction{} + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[24] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (x *GroupChange_Actions_PromoteMemberPendingAdminApprovalAction) String() string { +func (x *GroupChange_Actions_PromoteRequestingMemberAction) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GroupChange_Actions_PromoteMemberPendingAdminApprovalAction) ProtoMessage() {} +func (*GroupChange_Actions_PromoteRequestingMemberAction) ProtoMessage() {} -func (x *GroupChange_Actions_PromoteMemberPendingAdminApprovalAction) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[28] - if x != nil { +func (x *GroupChange_Actions_PromoteRequestingMemberAction) ProtoReflect() protoreflect.Message { + mi := &file_Groups_proto_msgTypes[24] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2170,48 +1943,51 @@ func (x *GroupChange_Actions_PromoteMemberPendingAdminApprovalAction) ProtoRefle return mi.MessageOf(x) } -// Deprecated: Use GroupChange_Actions_PromoteMemberPendingAdminApprovalAction.ProtoReflect.Descriptor instead. -func (*GroupChange_Actions_PromoteMemberPendingAdminApprovalAction) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{10, 0, 11} +// Deprecated: Use GroupChange_Actions_PromoteRequestingMemberAction.ProtoReflect.Descriptor instead. +func (*GroupChange_Actions_PromoteRequestingMemberAction) Descriptor() ([]byte, []int) { + return file_Groups_proto_rawDescGZIP(), []int{7, 0, 10} } -func (x *GroupChange_Actions_PromoteMemberPendingAdminApprovalAction) GetUserId() []byte { +func (x *GroupChange_Actions_PromoteRequestingMemberAction) GetUserId() []byte { if x != nil { return x.UserId } return nil } -func (x *GroupChange_Actions_PromoteMemberPendingAdminApprovalAction) GetRole() Member_Role { +func (x *GroupChange_Actions_PromoteRequestingMemberAction) GetRole() Member_Role { if x != nil { return x.Role } return Member_UNKNOWN } -type GroupChange_Actions_AddMemberBannedAction struct { - state protoimpl.MessageState `protogen:"open.v1"` - Added *MemberBanned `protobuf:"bytes,1,opt,name=added,proto3" json:"added,omitempty"` - unknownFields protoimpl.UnknownFields +type GroupChange_Actions_AddBannedMemberAction struct { + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Added *BannedMember `protobuf:"bytes,1,opt,name=added,proto3" json:"added,omitempty"` } -func (x *GroupChange_Actions_AddMemberBannedAction) Reset() { - *x = GroupChange_Actions_AddMemberBannedAction{} - mi := &file_Groups_proto_msgTypes[29] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) +func (x *GroupChange_Actions_AddBannedMemberAction) Reset() { + *x = GroupChange_Actions_AddBannedMemberAction{} + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[25] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (x *GroupChange_Actions_AddMemberBannedAction) String() string { +func (x *GroupChange_Actions_AddBannedMemberAction) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GroupChange_Actions_AddMemberBannedAction) ProtoMessage() {} +func (*GroupChange_Actions_AddBannedMemberAction) ProtoMessage() {} -func (x *GroupChange_Actions_AddMemberBannedAction) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[29] - if x != nil { +func (x *GroupChange_Actions_AddBannedMemberAction) ProtoReflect() protoreflect.Message { + mi := &file_Groups_proto_msgTypes[25] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2221,41 +1997,44 @@ func (x *GroupChange_Actions_AddMemberBannedAction) ProtoReflect() protoreflect. return mi.MessageOf(x) } -// Deprecated: Use GroupChange_Actions_AddMemberBannedAction.ProtoReflect.Descriptor instead. -func (*GroupChange_Actions_AddMemberBannedAction) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{10, 0, 12} +// Deprecated: Use GroupChange_Actions_AddBannedMemberAction.ProtoReflect.Descriptor instead. +func (*GroupChange_Actions_AddBannedMemberAction) Descriptor() ([]byte, []int) { + return file_Groups_proto_rawDescGZIP(), []int{7, 0, 11} } -func (x *GroupChange_Actions_AddMemberBannedAction) GetAdded() *MemberBanned { +func (x *GroupChange_Actions_AddBannedMemberAction) GetAdded() *BannedMember { if x != nil { return x.Added } return nil } -type GroupChange_Actions_DeleteMemberBannedAction struct { - state protoimpl.MessageState `protogen:"open.v1"` - DeletedUserId []byte `protobuf:"bytes,1,opt,name=deletedUserId,proto3" json:"deletedUserId,omitempty"` - unknownFields protoimpl.UnknownFields +type GroupChange_Actions_DeleteBannedMemberAction struct { + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + DeletedUserId []byte `protobuf:"bytes,1,opt,name=deletedUserId,proto3" json:"deletedUserId,omitempty"` } -func (x *GroupChange_Actions_DeleteMemberBannedAction) Reset() { - *x = GroupChange_Actions_DeleteMemberBannedAction{} - mi := &file_Groups_proto_msgTypes[30] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) +func (x *GroupChange_Actions_DeleteBannedMemberAction) Reset() { + *x = GroupChange_Actions_DeleteBannedMemberAction{} + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[26] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (x *GroupChange_Actions_DeleteMemberBannedAction) String() string { +func (x *GroupChange_Actions_DeleteBannedMemberAction) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GroupChange_Actions_DeleteMemberBannedAction) ProtoMessage() {} +func (*GroupChange_Actions_DeleteBannedMemberAction) ProtoMessage() {} -func (x *GroupChange_Actions_DeleteMemberBannedAction) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[30] - if x != nil { +func (x *GroupChange_Actions_DeleteBannedMemberAction) ProtoReflect() protoreflect.Message { + mi := &file_Groups_proto_msgTypes[26] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2265,12 +2044,12 @@ func (x *GroupChange_Actions_DeleteMemberBannedAction) ProtoReflect() protorefle return mi.MessageOf(x) } -// Deprecated: Use GroupChange_Actions_DeleteMemberBannedAction.ProtoReflect.Descriptor instead. -func (*GroupChange_Actions_DeleteMemberBannedAction) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{10, 0, 13} +// Deprecated: Use GroupChange_Actions_DeleteBannedMemberAction.ProtoReflect.Descriptor instead. +func (*GroupChange_Actions_DeleteBannedMemberAction) Descriptor() ([]byte, []int) { + return file_Groups_proto_rawDescGZIP(), []int{7, 0, 12} } -func (x *GroupChange_Actions_DeleteMemberBannedAction) GetDeletedUserId() []byte { +func (x *GroupChange_Actions_DeleteBannedMemberAction) GetDeletedUserId() []byte { if x != nil { return x.DeletedUserId } @@ -2278,17 +2057,20 @@ func (x *GroupChange_Actions_DeleteMemberBannedAction) GetDeletedUserId() []byte } type GroupChange_Actions_ModifyTitleAction struct { - state protoimpl.MessageState `protogen:"open.v1"` - Title []byte `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Title []byte `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` } func (x *GroupChange_Actions_ModifyTitleAction) Reset() { *x = GroupChange_Actions_ModifyTitleAction{} - mi := &file_Groups_proto_msgTypes[31] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[27] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *GroupChange_Actions_ModifyTitleAction) String() string { @@ -2298,8 +2080,8 @@ func (x *GroupChange_Actions_ModifyTitleAction) String() string { func (*GroupChange_Actions_ModifyTitleAction) ProtoMessage() {} func (x *GroupChange_Actions_ModifyTitleAction) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[31] - if x != nil { + mi := &file_Groups_proto_msgTypes[27] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2311,7 +2093,7 @@ func (x *GroupChange_Actions_ModifyTitleAction) ProtoReflect() protoreflect.Mess // Deprecated: Use GroupChange_Actions_ModifyTitleAction.ProtoReflect.Descriptor instead. func (*GroupChange_Actions_ModifyTitleAction) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{10, 0, 14} + return file_Groups_proto_rawDescGZIP(), []int{7, 0, 13} } func (x *GroupChange_Actions_ModifyTitleAction) GetTitle() []byte { @@ -2322,17 +2104,20 @@ func (x *GroupChange_Actions_ModifyTitleAction) GetTitle() []byte { } type GroupChange_Actions_ModifyDescriptionAction struct { - state protoimpl.MessageState `protogen:"open.v1"` - Description []byte `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Description []byte `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"` } func (x *GroupChange_Actions_ModifyDescriptionAction) Reset() { *x = GroupChange_Actions_ModifyDescriptionAction{} - mi := &file_Groups_proto_msgTypes[32] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[28] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *GroupChange_Actions_ModifyDescriptionAction) String() string { @@ -2342,8 +2127,8 @@ func (x *GroupChange_Actions_ModifyDescriptionAction) String() string { func (*GroupChange_Actions_ModifyDescriptionAction) ProtoMessage() {} func (x *GroupChange_Actions_ModifyDescriptionAction) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[32] - if x != nil { + mi := &file_Groups_proto_msgTypes[28] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2355,7 +2140,7 @@ func (x *GroupChange_Actions_ModifyDescriptionAction) ProtoReflect() protoreflec // Deprecated: Use GroupChange_Actions_ModifyDescriptionAction.ProtoReflect.Descriptor instead. func (*GroupChange_Actions_ModifyDescriptionAction) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{10, 0, 15} + return file_Groups_proto_rawDescGZIP(), []int{7, 0, 14} } func (x *GroupChange_Actions_ModifyDescriptionAction) GetDescription() []byte { @@ -2366,17 +2151,20 @@ func (x *GroupChange_Actions_ModifyDescriptionAction) GetDescription() []byte { } type GroupChange_Actions_ModifyAvatarAction struct { - state protoimpl.MessageState `protogen:"open.v1"` - Avatar string `protobuf:"bytes,1,opt,name=avatar,proto3" json:"avatar,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Avatar string `protobuf:"bytes,1,opt,name=avatar,proto3" json:"avatar,omitempty"` } func (x *GroupChange_Actions_ModifyAvatarAction) Reset() { *x = GroupChange_Actions_ModifyAvatarAction{} - mi := &file_Groups_proto_msgTypes[33] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[29] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *GroupChange_Actions_ModifyAvatarAction) String() string { @@ -2386,8 +2174,8 @@ func (x *GroupChange_Actions_ModifyAvatarAction) String() string { func (*GroupChange_Actions_ModifyAvatarAction) ProtoMessage() {} func (x *GroupChange_Actions_ModifyAvatarAction) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[33] - if x != nil { + mi := &file_Groups_proto_msgTypes[29] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2399,7 +2187,7 @@ func (x *GroupChange_Actions_ModifyAvatarAction) ProtoReflect() protoreflect.Mes // Deprecated: Use GroupChange_Actions_ModifyAvatarAction.ProtoReflect.Descriptor instead. func (*GroupChange_Actions_ModifyAvatarAction) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{10, 0, 16} + return file_Groups_proto_rawDescGZIP(), []int{7, 0, 15} } func (x *GroupChange_Actions_ModifyAvatarAction) GetAvatar() string { @@ -2409,29 +2197,32 @@ func (x *GroupChange_Actions_ModifyAvatarAction) GetAvatar() string { return "" } -type GroupChange_Actions_ModifyDisappearingMessageTimerAction struct { - state protoimpl.MessageState `protogen:"open.v1"` - Timer []byte `protobuf:"bytes,1,opt,name=timer,proto3" json:"timer,omitempty"` - unknownFields protoimpl.UnknownFields +type GroupChange_Actions_ModifyDisappearingMessagesTimerAction struct { + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Timer []byte `protobuf:"bytes,1,opt,name=timer,proto3" json:"timer,omitempty"` } -func (x *GroupChange_Actions_ModifyDisappearingMessageTimerAction) Reset() { - *x = GroupChange_Actions_ModifyDisappearingMessageTimerAction{} - mi := &file_Groups_proto_msgTypes[34] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) +func (x *GroupChange_Actions_ModifyDisappearingMessagesTimerAction) Reset() { + *x = GroupChange_Actions_ModifyDisappearingMessagesTimerAction{} + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[30] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (x *GroupChange_Actions_ModifyDisappearingMessageTimerAction) String() string { +func (x *GroupChange_Actions_ModifyDisappearingMessagesTimerAction) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GroupChange_Actions_ModifyDisappearingMessageTimerAction) ProtoMessage() {} +func (*GroupChange_Actions_ModifyDisappearingMessagesTimerAction) ProtoMessage() {} -func (x *GroupChange_Actions_ModifyDisappearingMessageTimerAction) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[34] - if x != nil { +func (x *GroupChange_Actions_ModifyDisappearingMessagesTimerAction) ProtoReflect() protoreflect.Message { + mi := &file_Groups_proto_msgTypes[30] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2441,12 +2232,12 @@ func (x *GroupChange_Actions_ModifyDisappearingMessageTimerAction) ProtoReflect( return mi.MessageOf(x) } -// Deprecated: Use GroupChange_Actions_ModifyDisappearingMessageTimerAction.ProtoReflect.Descriptor instead. -func (*GroupChange_Actions_ModifyDisappearingMessageTimerAction) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{10, 0, 17} +// Deprecated: Use GroupChange_Actions_ModifyDisappearingMessagesTimerAction.ProtoReflect.Descriptor instead. +func (*GroupChange_Actions_ModifyDisappearingMessagesTimerAction) Descriptor() ([]byte, []int) { + return file_Groups_proto_rawDescGZIP(), []int{7, 0, 16} } -func (x *GroupChange_Actions_ModifyDisappearingMessageTimerAction) GetTimer() []byte { +func (x *GroupChange_Actions_ModifyDisappearingMessagesTimerAction) GetTimer() []byte { if x != nil { return x.Timer } @@ -2454,17 +2245,20 @@ func (x *GroupChange_Actions_ModifyDisappearingMessageTimerAction) GetTimer() [] } type GroupChange_Actions_ModifyAttributesAccessControlAction struct { - state protoimpl.MessageState `protogen:"open.v1"` - AttributesAccess AccessControl_AccessRequired `protobuf:"varint,1,opt,name=attributesAccess,proto3,enum=signal.AccessControl_AccessRequired" json:"attributesAccess,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AttributesAccess AccessControl_AccessRequired `protobuf:"varint,1,opt,name=attributesAccess,proto3,enum=AccessControl_AccessRequired" json:"attributesAccess,omitempty"` } func (x *GroupChange_Actions_ModifyAttributesAccessControlAction) Reset() { *x = GroupChange_Actions_ModifyAttributesAccessControlAction{} - mi := &file_Groups_proto_msgTypes[35] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[31] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *GroupChange_Actions_ModifyAttributesAccessControlAction) String() string { @@ -2474,8 +2268,8 @@ func (x *GroupChange_Actions_ModifyAttributesAccessControlAction) String() strin func (*GroupChange_Actions_ModifyAttributesAccessControlAction) ProtoMessage() {} func (x *GroupChange_Actions_ModifyAttributesAccessControlAction) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[35] - if x != nil { + mi := &file_Groups_proto_msgTypes[31] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2487,7 +2281,7 @@ func (x *GroupChange_Actions_ModifyAttributesAccessControlAction) ProtoReflect() // Deprecated: Use GroupChange_Actions_ModifyAttributesAccessControlAction.ProtoReflect.Descriptor instead. func (*GroupChange_Actions_ModifyAttributesAccessControlAction) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{10, 0, 18} + return file_Groups_proto_rawDescGZIP(), []int{7, 0, 17} } func (x *GroupChange_Actions_ModifyAttributesAccessControlAction) GetAttributesAccess() AccessControl_AccessRequired { @@ -2498,17 +2292,20 @@ func (x *GroupChange_Actions_ModifyAttributesAccessControlAction) GetAttributesA } type GroupChange_Actions_ModifyMembersAccessControlAction struct { - state protoimpl.MessageState `protogen:"open.v1"` - MembersAccess AccessControl_AccessRequired `protobuf:"varint,1,opt,name=membersAccess,proto3,enum=signal.AccessControl_AccessRequired" json:"membersAccess,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + MembersAccess AccessControl_AccessRequired `protobuf:"varint,1,opt,name=membersAccess,proto3,enum=AccessControl_AccessRequired" json:"membersAccess,omitempty"` } func (x *GroupChange_Actions_ModifyMembersAccessControlAction) Reset() { *x = GroupChange_Actions_ModifyMembersAccessControlAction{} - mi := &file_Groups_proto_msgTypes[36] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[32] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *GroupChange_Actions_ModifyMembersAccessControlAction) String() string { @@ -2518,8 +2315,8 @@ func (x *GroupChange_Actions_ModifyMembersAccessControlAction) String() string { func (*GroupChange_Actions_ModifyMembersAccessControlAction) ProtoMessage() {} func (x *GroupChange_Actions_ModifyMembersAccessControlAction) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[36] - if x != nil { + mi := &file_Groups_proto_msgTypes[32] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2531,7 +2328,7 @@ func (x *GroupChange_Actions_ModifyMembersAccessControlAction) ProtoReflect() pr // Deprecated: Use GroupChange_Actions_ModifyMembersAccessControlAction.ProtoReflect.Descriptor instead. func (*GroupChange_Actions_ModifyMembersAccessControlAction) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{10, 0, 19} + return file_Groups_proto_rawDescGZIP(), []int{7, 0, 18} } func (x *GroupChange_Actions_ModifyMembersAccessControlAction) GetMembersAccess() AccessControl_AccessRequired { @@ -2542,17 +2339,20 @@ func (x *GroupChange_Actions_ModifyMembersAccessControlAction) GetMembersAccess( } type GroupChange_Actions_ModifyAddFromInviteLinkAccessControlAction struct { - state protoimpl.MessageState `protogen:"open.v1"` - AddFromInviteLinkAccess AccessControl_AccessRequired `protobuf:"varint,1,opt,name=addFromInviteLinkAccess,proto3,enum=signal.AccessControl_AccessRequired" json:"addFromInviteLinkAccess,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AddFromInviteLinkAccess AccessControl_AccessRequired `protobuf:"varint,1,opt,name=addFromInviteLinkAccess,proto3,enum=AccessControl_AccessRequired" json:"addFromInviteLinkAccess,omitempty"` } func (x *GroupChange_Actions_ModifyAddFromInviteLinkAccessControlAction) Reset() { *x = GroupChange_Actions_ModifyAddFromInviteLinkAccessControlAction{} - mi := &file_Groups_proto_msgTypes[37] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[33] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *GroupChange_Actions_ModifyAddFromInviteLinkAccessControlAction) String() string { @@ -2562,8 +2362,8 @@ func (x *GroupChange_Actions_ModifyAddFromInviteLinkAccessControlAction) String( func (*GroupChange_Actions_ModifyAddFromInviteLinkAccessControlAction) ProtoMessage() {} func (x *GroupChange_Actions_ModifyAddFromInviteLinkAccessControlAction) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[37] - if x != nil { + mi := &file_Groups_proto_msgTypes[33] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2575,7 +2375,7 @@ func (x *GroupChange_Actions_ModifyAddFromInviteLinkAccessControlAction) ProtoRe // Deprecated: Use GroupChange_Actions_ModifyAddFromInviteLinkAccessControlAction.ProtoReflect.Descriptor instead. func (*GroupChange_Actions_ModifyAddFromInviteLinkAccessControlAction) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{10, 0, 20} + return file_Groups_proto_rawDescGZIP(), []int{7, 0, 19} } func (x *GroupChange_Actions_ModifyAddFromInviteLinkAccessControlAction) GetAddFromInviteLinkAccess() AccessControl_AccessRequired { @@ -2585,62 +2385,21 @@ func (x *GroupChange_Actions_ModifyAddFromInviteLinkAccessControlAction) GetAddF return AccessControl_UNKNOWN } -type GroupChange_Actions_ModifyMemberLabelAccessControlAction struct { - state protoimpl.MessageState `protogen:"open.v1"` - MemberLabelAccess AccessControl_AccessRequired `protobuf:"varint,1,opt,name=memberLabelAccess,proto3,enum=signal.AccessControl_AccessRequired" json:"memberLabelAccess,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupChange_Actions_ModifyMemberLabelAccessControlAction) Reset() { - *x = GroupChange_Actions_ModifyMemberLabelAccessControlAction{} - mi := &file_Groups_proto_msgTypes[38] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupChange_Actions_ModifyMemberLabelAccessControlAction) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupChange_Actions_ModifyMemberLabelAccessControlAction) ProtoMessage() {} - -func (x *GroupChange_Actions_ModifyMemberLabelAccessControlAction) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[38] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupChange_Actions_ModifyMemberLabelAccessControlAction.ProtoReflect.Descriptor instead. -func (*GroupChange_Actions_ModifyMemberLabelAccessControlAction) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{10, 0, 21} -} - -func (x *GroupChange_Actions_ModifyMemberLabelAccessControlAction) GetMemberLabelAccess() AccessControl_AccessRequired { - if x != nil { - return x.MemberLabelAccess - } - return AccessControl_UNKNOWN -} - type GroupChange_Actions_ModifyInviteLinkPasswordAction struct { - state protoimpl.MessageState `protogen:"open.v1"` - InviteLinkPassword []byte `protobuf:"bytes,1,opt,name=inviteLinkPassword,proto3" json:"inviteLinkPassword,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + InviteLinkPassword []byte `protobuf:"bytes,1,opt,name=inviteLinkPassword,proto3" json:"inviteLinkPassword,omitempty"` } func (x *GroupChange_Actions_ModifyInviteLinkPasswordAction) Reset() { *x = GroupChange_Actions_ModifyInviteLinkPasswordAction{} - mi := &file_Groups_proto_msgTypes[39] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[34] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *GroupChange_Actions_ModifyInviteLinkPasswordAction) String() string { @@ -2650,8 +2409,8 @@ func (x *GroupChange_Actions_ModifyInviteLinkPasswordAction) String() string { func (*GroupChange_Actions_ModifyInviteLinkPasswordAction) ProtoMessage() {} func (x *GroupChange_Actions_ModifyInviteLinkPasswordAction) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[39] - if x != nil { + mi := &file_Groups_proto_msgTypes[34] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2663,7 +2422,7 @@ func (x *GroupChange_Actions_ModifyInviteLinkPasswordAction) ProtoReflect() prot // Deprecated: Use GroupChange_Actions_ModifyInviteLinkPasswordAction.ProtoReflect.Descriptor instead. func (*GroupChange_Actions_ModifyInviteLinkPasswordAction) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{10, 0, 22} + return file_Groups_proto_rawDescGZIP(), []int{7, 0, 20} } func (x *GroupChange_Actions_ModifyInviteLinkPasswordAction) GetInviteLinkPassword() []byte { @@ -2674,17 +2433,20 @@ func (x *GroupChange_Actions_ModifyInviteLinkPasswordAction) GetInviteLinkPasswo } type GroupChange_Actions_ModifyAnnouncementsOnlyAction struct { - state protoimpl.MessageState `protogen:"open.v1"` - AnnouncementsOnly bool `protobuf:"varint,1,opt,name=announcements_only,json=announcementsOnly,proto3" json:"announcements_only,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AnnouncementsOnly bool `protobuf:"varint,1,opt,name=announcementsOnly,proto3" json:"announcementsOnly,omitempty"` } func (x *GroupChange_Actions_ModifyAnnouncementsOnlyAction) Reset() { *x = GroupChange_Actions_ModifyAnnouncementsOnlyAction{} - mi := &file_Groups_proto_msgTypes[40] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[35] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *GroupChange_Actions_ModifyAnnouncementsOnlyAction) String() string { @@ -2694,8 +2456,8 @@ func (x *GroupChange_Actions_ModifyAnnouncementsOnlyAction) String() string { func (*GroupChange_Actions_ModifyAnnouncementsOnlyAction) ProtoMessage() {} func (x *GroupChange_Actions_ModifyAnnouncementsOnlyAction) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[40] - if x != nil { + mi := &file_Groups_proto_msgTypes[35] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2707,7 +2469,7 @@ func (x *GroupChange_Actions_ModifyAnnouncementsOnlyAction) ProtoReflect() proto // Deprecated: Use GroupChange_Actions_ModifyAnnouncementsOnlyAction.ProtoReflect.Descriptor instead. func (*GroupChange_Actions_ModifyAnnouncementsOnlyAction) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{10, 0, 23} + return file_Groups_proto_rawDescGZIP(), []int{7, 0, 21} } func (x *GroupChange_Actions_ModifyAnnouncementsOnlyAction) GetAnnouncementsOnly() bool { @@ -2717,55 +2479,22 @@ func (x *GroupChange_Actions_ModifyAnnouncementsOnlyAction) GetAnnouncementsOnly return false } -type GroupChange_Actions_TerminateGroupAction struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupChange_Actions_TerminateGroupAction) Reset() { - *x = GroupChange_Actions_TerminateGroupAction{} - mi := &file_Groups_proto_msgTypes[41] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupChange_Actions_TerminateGroupAction) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupChange_Actions_TerminateGroupAction) ProtoMessage() {} - -func (x *GroupChange_Actions_TerminateGroupAction) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[41] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupChange_Actions_TerminateGroupAction.ProtoReflect.Descriptor instead. -func (*GroupChange_Actions_TerminateGroupAction) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{10, 0, 24} -} - type GroupChanges_GroupChangeState struct { - state protoimpl.MessageState `protogen:"open.v1"` - GroupChange *GroupChange `protobuf:"bytes,1,opt,name=groupChange,proto3" json:"groupChange,omitempty"` - GroupState *Group `protobuf:"bytes,2,opt,name=groupState,proto3" json:"groupState,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + GroupChange *GroupChange `protobuf:"bytes,1,opt,name=groupChange,proto3" json:"groupChange,omitempty"` + GroupState *Group `protobuf:"bytes,2,opt,name=groupState,proto3" json:"groupState,omitempty"` } func (x *GroupChanges_GroupChangeState) Reset() { *x = GroupChanges_GroupChangeState{} - mi := &file_Groups_proto_msgTypes[42] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[36] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *GroupChanges_GroupChangeState) String() string { @@ -2775,8 +2504,8 @@ func (x *GroupChanges_GroupChangeState) String() string { func (*GroupChanges_GroupChangeState) ProtoMessage() {} func (x *GroupChanges_GroupChangeState) ProtoReflect() protoreflect.Message { - mi := &file_Groups_proto_msgTypes[42] - if x != nil { + mi := &file_Groups_proto_msgTypes[36] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2788,7 +2517,7 @@ func (x *GroupChanges_GroupChangeState) ProtoReflect() protoreflect.Message { // Deprecated: Use GroupChanges_GroupChangeState.ProtoReflect.Descriptor instead. func (*GroupChanges_GroupChangeState) Descriptor() ([]byte, []int) { - return file_Groups_proto_rawDescGZIP(), []int{13, 0} + return file_Groups_proto_rawDescGZIP(), []int{8, 0} } func (x *GroupChanges_GroupChangeState) GetGroupChange() *GroupChange { @@ -2805,347 +2534,611 @@ func (x *GroupChanges_GroupChangeState) GetGroupState() *Group { return nil } +type GroupInviteLink_GroupInviteLinkContentsV1 struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + GroupMasterKey []byte `protobuf:"bytes,1,opt,name=groupMasterKey,proto3" json:"groupMasterKey,omitempty"` + InviteLinkPassword []byte `protobuf:"bytes,2,opt,name=inviteLinkPassword,proto3" json:"inviteLinkPassword,omitempty"` +} + +func (x *GroupInviteLink_GroupInviteLinkContentsV1) Reset() { + *x = GroupInviteLink_GroupInviteLinkContentsV1{} + if protoimpl.UnsafeEnabled { + mi := &file_Groups_proto_msgTypes[37] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GroupInviteLink_GroupInviteLinkContentsV1) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GroupInviteLink_GroupInviteLinkContentsV1) ProtoMessage() {} + +func (x *GroupInviteLink_GroupInviteLinkContentsV1) ProtoReflect() protoreflect.Message { + mi := &file_Groups_proto_msgTypes[37] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GroupInviteLink_GroupInviteLinkContentsV1.ProtoReflect.Descriptor instead. +func (*GroupInviteLink_GroupInviteLinkContentsV1) Descriptor() ([]byte, []int) { + return file_Groups_proto_rawDescGZIP(), []int{10, 0} +} + +func (x *GroupInviteLink_GroupInviteLinkContentsV1) GetGroupMasterKey() []byte { + if x != nil { + return x.GroupMasterKey + } + return nil +} + +func (x *GroupInviteLink_GroupInviteLinkContentsV1) GetInviteLinkPassword() []byte { + if x != nil { + return x.InviteLinkPassword + } + return nil +} + var File_Groups_proto protoreflect.FileDescriptor -const file_Groups_proto_rawDesc = "" + - "\n" + - "\fGroups.proto\x12\x06signal\"\xc4\x01\n" + - "\x16AvatarUploadAttributes\x12\x10\n" + - "\x03key\x18\x01 \x01(\tR\x03key\x12\x1e\n" + - "\n" + - "credential\x18\x02 \x01(\tR\n" + - "credential\x12\x10\n" + - "\x03acl\x18\x03 \x01(\tR\x03acl\x12\x1c\n" + - "\talgorithm\x18\x04 \x01(\tR\talgorithm\x12\x12\n" + - "\x04date\x18\x05 \x01(\tR\x04date\x12\x16\n" + - "\x06policy\x18\x06 \x01(\tR\x06policy\x12\x1c\n" + - "\tsignature\x18\a \x01(\tR\tsignature\"\xae\x02\n" + - "\x06Member\x12\x16\n" + - "\x06userId\x18\x01 \x01(\fR\x06userId\x12'\n" + - "\x04role\x18\x02 \x01(\x0e2\x13.signal.Member.RoleR\x04role\x12\x1e\n" + - "\n" + - "profileKey\x18\x03 \x01(\fR\n" + - "profileKey\x12\"\n" + - "\fpresentation\x18\x04 \x01(\fR\fpresentation\x12(\n" + - "\x0fjoinedAtVersion\x18\x05 \x01(\rR\x0fjoinedAtVersion\x12\x1e\n" + - "\n" + - "labelEmoji\x18\x06 \x01(\fR\n" + - "labelEmoji\x12 \n" + - "\vlabelString\x18\a \x01(\fR\vlabelString\"3\n" + - "\x04Role\x12\v\n" + - "\aUNKNOWN\x10\x00\x12\v\n" + - "\aDEFAULT\x10\x01\x12\x11\n" + - "\rADMINISTRATOR\x10\x02\"\x85\x01\n" + - "\x17MemberPendingProfileKey\x12&\n" + - "\x06member\x18\x01 \x01(\v2\x0e.signal.MemberR\x06member\x12$\n" + - "\raddedByUserId\x18\x02 \x01(\fR\raddedByUserId\x12\x1c\n" + - "\ttimestamp\x18\x03 \x01(\x04R\ttimestamp\"\x96\x01\n" + - "\x1aMemberPendingAdminApproval\x12\x16\n" + - "\x06userId\x18\x01 \x01(\fR\x06userId\x12\x1e\n" + - "\n" + - "profileKey\x18\x02 \x01(\fR\n" + - "profileKey\x12\"\n" + - "\fpresentation\x18\x03 \x01(\fR\fpresentation\x12\x1c\n" + - "\ttimestamp\x18\x04 \x01(\x04R\ttimestamp\"D\n" + - "\fMemberBanned\x12\x16\n" + - "\x06userId\x18\x01 \x01(\fR\x06userId\x12\x1c\n" + - "\ttimestamp\x18\x02 \x01(\x04R\ttimestamp\"\x8b\x03\n" + - "\rAccessControl\x12D\n" + - "\n" + - "attributes\x18\x01 \x01(\x0e2$.signal.AccessControl.AccessRequiredR\n" + - "attributes\x12>\n" + - "\amembers\x18\x02 \x01(\x0e2$.signal.AccessControl.AccessRequiredR\amembers\x12R\n" + - "\x11addFromInviteLink\x18\x03 \x01(\x0e2$.signal.AccessControl.AccessRequiredR\x11addFromInviteLink\x12F\n" + - "\vmemberLabel\x18\x04 \x01(\x0e2$.signal.AccessControl.AccessRequiredR\vmemberLabel\"X\n" + - "\x0eAccessRequired\x12\v\n" + - "\aUNKNOWN\x10\x00\x12\a\n" + - "\x03ANY\x10\x01\x12\n" + - "\n" + - "\x06MEMBER\x10\x02\x12\x11\n" + - "\rADMINISTRATOR\x10\x03\x12\x11\n" + - "\rUNSATISFIABLE\x10\x04\"\xb9\x05\n" + - "\x05Group\x12\x1c\n" + - "\tpublicKey\x18\x01 \x01(\fR\tpublicKey\x12\x14\n" + - "\x05title\x18\x02 \x01(\fR\x05title\x12 \n" + - "\vdescription\x18\v \x01(\fR\vdescription\x12\x1c\n" + - "\tavatarUrl\x18\x03 \x01(\tR\tavatarUrl\x12<\n" + - "\x19disappearingMessagesTimer\x18\x04 \x01(\fR\x19disappearingMessagesTimer\x12;\n" + - "\raccessControl\x18\x05 \x01(\v2\x15.signal.AccessControlR\raccessControl\x12\x18\n" + - "\aversion\x18\x06 \x01(\rR\aversion\x12(\n" + - "\amembers\x18\a \x03(\v2\x0e.signal.MemberR\amembers\x12[\n" + - "\x18membersPendingProfileKey\x18\b \x03(\v2\x1f.signal.MemberPendingProfileKeyR\x18membersPendingProfileKey\x12d\n" + - "\x1bmembersPendingAdminApproval\x18\t \x03(\v2\".signal.MemberPendingAdminApprovalR\x1bmembersPendingAdminApproval\x12.\n" + - "\x12inviteLinkPassword\x18\n" + - " \x01(\fR\x12inviteLinkPassword\x12-\n" + - "\x12announcements_only\x18\f \x01(\bR\x11announcementsOnly\x12;\n" + - "\x0emembers_banned\x18\r \x03(\v2\x14.signal.MemberBannedR\rmembersBanned\x12\x1e\n" + - "\n" + - "terminated\x18\x0e \x01(\bR\n" + - "terminated\"\xc3\x01\n" + - "\x12GroupAttributeBlob\x12\x16\n" + - "\x05title\x18\x01 \x01(\tH\x00R\x05title\x12\x18\n" + - "\x06avatar\x18\x02 \x01(\fH\x00R\x06avatar\x12D\n" + - "\x1cdisappearingMessagesDuration\x18\x03 \x01(\rH\x00R\x1cdisappearingMessagesDuration\x12*\n" + - "\x0fdescriptionText\x18\x04 \x01(\tH\x00R\x0fdescriptionTextB\t\n" + - "\acontent\"\xe7\x01\n" + - "\x0fGroupInviteLink\x12S\n" + - "\n" + - "contentsV1\x18\x01 \x01(\v21.signal.GroupInviteLink.GroupInviteLinkContentsV1H\x00R\n" + - "contentsV1\x1as\n" + - "\x19GroupInviteLinkContentsV1\x12&\n" + - "\x0egroupMasterKey\x18\x01 \x01(\fR\x0egroupMasterKey\x12.\n" + - "\x12inviteLinkPassword\x18\x02 \x01(\fR\x12inviteLinkPasswordB\n" + - "\n" + - "\bcontents\"\xc1\x02\n" + - "\rGroupJoinInfo\x12\x1c\n" + - "\tpublicKey\x18\x01 \x01(\fR\tpublicKey\x12\x14\n" + - "\x05title\x18\x02 \x01(\fR\x05title\x12 \n" + - "\vdescription\x18\b \x01(\fR\vdescription\x12\x16\n" + - "\x06avatar\x18\x03 \x01(\tR\x06avatar\x12 \n" + - "\vmemberCount\x18\x04 \x01(\rR\vmemberCount\x12R\n" + - "\x11addFromInviteLink\x18\x05 \x01(\x0e2$.signal.AccessControl.AccessRequiredR\x11addFromInviteLink\x12\x18\n" + - "\aversion\x18\x06 \x01(\rR\aversion\x122\n" + - "\x14pendingAdminApproval\x18\a \x01(\bR\x14pendingAdminApproval\"\xa6*\n" + - "\vGroupChange\x12\x18\n" + - "\aactions\x18\x01 \x01(\fR\aactions\x12(\n" + - "\x0fserverSignature\x18\x02 \x01(\fR\x0fserverSignature\x12 \n" + - "\vchangeEpoch\x18\x03 \x01(\rR\vchangeEpoch\x1a\xb0)\n" + - "\aActions\x12\"\n" + - "\fsourceUserId\x18\x01 \x01(\fR\fsourceUserId\x12\x19\n" + - "\bgroup_id\x18\x19 \x01(\fR\agroupId\x12\x18\n" + - "\aversion\x18\x02 \x01(\rR\aversion\x12K\n" + - "\n" + - "addMembers\x18\x03 \x03(\v2+.signal.GroupChange.Actions.AddMemberActionR\n" + - "addMembers\x12T\n" + - "\rdeleteMembers\x18\x04 \x03(\v2..signal.GroupChange.Actions.DeleteMemberActionR\rdeleteMembers\x12`\n" + - "\x11modifyMemberRoles\x18\x05 \x03(\v22.signal.GroupChange.Actions.ModifyMemberRoleActionR\x11modifyMemberRoles\x12r\n" + - "\x17modifyMemberProfileKeys\x18\x06 \x03(\v28.signal.GroupChange.Actions.ModifyMemberProfileKeyActionR\x17modifyMemberProfileKeys\x12~\n" + - "\x1baddMembersPendingProfileKey\x18\a \x03(\v2<.signal.GroupChange.Actions.AddMemberPendingProfileKeyActionR\x1baddMembersPendingProfileKey\x12\x87\x01\n" + - "\x1edeleteMembersPendingProfileKey\x18\b \x03(\v2?.signal.GroupChange.Actions.DeleteMemberPendingProfileKeyActionR\x1edeleteMembersPendingProfileKey\x12\x8a\x01\n" + - "\x1fpromoteMembersPendingProfileKey\x18\t \x03(\v2@.signal.GroupChange.Actions.PromoteMemberPendingProfileKeyActionR\x1fpromoteMembersPendingProfileKey\x12O\n" + - "\vmodifyTitle\x18\n" + - " \x01(\v2-.signal.GroupChange.Actions.ModifyTitleActionR\vmodifyTitle\x12R\n" + - "\fmodifyAvatar\x18\v \x01(\v2..signal.GroupChange.Actions.ModifyAvatarActionR\fmodifyAvatar\x12\x88\x01\n" + - "\x1emodifyDisappearingMessageTimer\x18\f \x01(\v2@.signal.GroupChange.Actions.ModifyDisappearingMessageTimerActionR\x1emodifyDisappearingMessageTimer\x12w\n" + - "\x16modifyAttributesAccess\x18\r \x01(\v2?.signal.GroupChange.Actions.ModifyAttributesAccessControlActionR\x16modifyAttributesAccess\x12l\n" + - "\x12modifyMemberAccess\x18\x0e \x01(\v2<.signal.GroupChange.Actions.ModifyMembersAccessControlActionR\x12modifyMemberAccess\x12\x8c\x01\n" + - "\x1dmodifyAddFromInviteLinkAccess\x18\x0f \x01(\v2F.signal.GroupChange.Actions.ModifyAddFromInviteLinkAccessControlActionR\x1dmodifyAddFromInviteLinkAccess\x12\x87\x01\n" + - "\x1eaddMembersPendingAdminApproval\x18\x10 \x03(\v2?.signal.GroupChange.Actions.AddMemberPendingAdminApprovalActionR\x1eaddMembersPendingAdminApproval\x12\x90\x01\n" + - "!deleteMembersPendingAdminApproval\x18\x11 \x03(\v2B.signal.GroupChange.Actions.DeleteMemberPendingAdminApprovalActionR!deleteMembersPendingAdminApproval\x12\x93\x01\n" + - "\"promoteMembersPendingAdminApproval\x18\x12 \x03(\v2C.signal.GroupChange.Actions.PromoteMemberPendingAdminApprovalActionR\"promoteMembersPendingAdminApproval\x12v\n" + - "\x18modifyInviteLinkPassword\x18\x13 \x01(\v2:.signal.GroupChange.Actions.ModifyInviteLinkPasswordActionR\x18modifyInviteLinkPassword\x12a\n" + - "\x11modifyDescription\x18\x14 \x01(\v23.signal.GroupChange.Actions.ModifyDescriptionActionR\x11modifyDescription\x12u\n" + - "\x19modify_announcements_only\x18\x15 \x01(\v29.signal.GroupChange.Actions.ModifyAnnouncementsOnlyActionR\x17modifyAnnouncementsOnly\x12_\n" + - "\x12add_members_banned\x18\x16 \x03(\v21.signal.GroupChange.Actions.AddMemberBannedActionR\x10addMembersBanned\x12h\n" + - "\x15delete_members_banned\x18\x17 \x03(\v24.signal.GroupChange.Actions.DeleteMemberBannedActionR\x13deleteMembersBanned\x12\xa2\x01\n" + - "+promote_members_pending_pni_aci_profile_key\x18\x18 \x03(\v2F.signal.GroupChange.Actions.PromoteMemberPendingPniAciProfileKeyActionR%promoteMembersPendingPniAciProfileKey\x12c\n" + - "\x12modifyMemberLabels\x18\x1a \x03(\v23.signal.GroupChange.Actions.ModifyMemberLabelActionR\x12modifyMemberLabels\x12z\n" + - "\x17modifyMemberLabelAccess\x18\x1b \x01(\v2@.signal.GroupChange.Actions.ModifyMemberLabelAccessControlActionR\x17modifyMemberLabelAccess\x12Y\n" + - "\x0fterminate_group\x18\x1c \x01(\v20.signal.GroupChange.Actions.TerminateGroupActionR\x0eterminateGroup\x1ag\n" + - "\x0fAddMemberAction\x12$\n" + - "\x05added\x18\x01 \x01(\v2\x0e.signal.MemberR\x05added\x12.\n" + - "\x12joinFromInviteLink\x18\x02 \x01(\bR\x12joinFromInviteLink\x1a:\n" + - "\x12DeleteMemberAction\x12$\n" + - "\rdeletedUserId\x18\x01 \x01(\fR\rdeletedUserId\x1aY\n" + - "\x16ModifyMemberRoleAction\x12\x16\n" + - "\x06userId\x18\x01 \x01(\fR\x06userId\x12'\n" + - "\x04role\x18\x02 \x01(\x0e2\x13.signal.Member.RoleR\x04role\x1as\n" + - "\x17ModifyMemberLabelAction\x12\x16\n" + - "\x06userId\x18\x01 \x01(\fR\x06userId\x12\x1e\n" + - "\n" + - "labelEmoji\x18\x02 \x01(\fR\n" + - "labelEmoji\x12 \n" + - "\vlabelString\x18\x03 \x01(\fR\vlabelString\x1a|\n" + - "\x1cModifyMemberProfileKeyAction\x12\"\n" + - "\fpresentation\x18\x01 \x01(\fR\fpresentation\x12\x17\n" + - "\auser_id\x18\x02 \x01(\fR\x06userId\x12\x1f\n" + - "\vprofile_key\x18\x03 \x01(\fR\n" + - "profileKey\x1aY\n" + - " AddMemberPendingProfileKeyAction\x125\n" + - "\x05added\x18\x01 \x01(\v2\x1f.signal.MemberPendingProfileKeyR\x05added\x1aK\n" + - "#DeleteMemberPendingProfileKeyAction\x12$\n" + - "\rdeletedUserId\x18\x01 \x01(\fR\rdeletedUserId\x1a\x84\x01\n" + - "$PromoteMemberPendingProfileKeyAction\x12\"\n" + - "\fpresentation\x18\x01 \x01(\fR\fpresentation\x12\x17\n" + - "\auser_id\x18\x02 \x01(\fR\x06userId\x12\x1f\n" + - "\vprofile_key\x18\x03 \x01(\fR\n" + - "profileKey\x1a\x9c\x01\n" + - "*PromoteMemberPendingPniAciProfileKeyAction\x12\"\n" + - "\fpresentation\x18\x01 \x01(\fR\fpresentation\x12\x17\n" + - "\auser_id\x18\x02 \x01(\fR\x06userId\x12\x10\n" + - "\x03pni\x18\x03 \x01(\fR\x03pni\x12\x1f\n" + - "\vprofile_key\x18\x04 \x01(\fR\n" + - "profileKey\x1a_\n" + - "#AddMemberPendingAdminApprovalAction\x128\n" + - "\x05added\x18\x01 \x01(\v2\".signal.MemberPendingAdminApprovalR\x05added\x1aN\n" + - "&DeleteMemberPendingAdminApprovalAction\x12$\n" + - "\rdeletedUserId\x18\x01 \x01(\fR\rdeletedUserId\x1aj\n" + - "'PromoteMemberPendingAdminApprovalAction\x12\x16\n" + - "\x06userId\x18\x01 \x01(\fR\x06userId\x12'\n" + - "\x04role\x18\x02 \x01(\x0e2\x13.signal.Member.RoleR\x04role\x1aC\n" + - "\x15AddMemberBannedAction\x12*\n" + - "\x05added\x18\x01 \x01(\v2\x14.signal.MemberBannedR\x05added\x1a@\n" + - "\x18DeleteMemberBannedAction\x12$\n" + - "\rdeletedUserId\x18\x01 \x01(\fR\rdeletedUserId\x1a)\n" + - "\x11ModifyTitleAction\x12\x14\n" + - "\x05title\x18\x01 \x01(\fR\x05title\x1a;\n" + - "\x17ModifyDescriptionAction\x12 \n" + - "\vdescription\x18\x01 \x01(\fR\vdescription\x1a,\n" + - "\x12ModifyAvatarAction\x12\x16\n" + - "\x06avatar\x18\x01 \x01(\tR\x06avatar\x1a<\n" + - "$ModifyDisappearingMessageTimerAction\x12\x14\n" + - "\x05timer\x18\x01 \x01(\fR\x05timer\x1aw\n" + - "#ModifyAttributesAccessControlAction\x12P\n" + - "\x10attributesAccess\x18\x01 \x01(\x0e2$.signal.AccessControl.AccessRequiredR\x10attributesAccess\x1an\n" + - " ModifyMembersAccessControlAction\x12J\n" + - "\rmembersAccess\x18\x01 \x01(\x0e2$.signal.AccessControl.AccessRequiredR\rmembersAccess\x1a\x8c\x01\n" + - "*ModifyAddFromInviteLinkAccessControlAction\x12^\n" + - "\x17addFromInviteLinkAccess\x18\x01 \x01(\x0e2$.signal.AccessControl.AccessRequiredR\x17addFromInviteLinkAccess\x1az\n" + - "$ModifyMemberLabelAccessControlAction\x12R\n" + - "\x11memberLabelAccess\x18\x01 \x01(\x0e2$.signal.AccessControl.AccessRequiredR\x11memberLabelAccess\x1aP\n" + - "\x1eModifyInviteLinkPasswordAction\x12.\n" + - "\x12inviteLinkPassword\x18\x01 \x01(\fR\x12inviteLinkPassword\x1aN\n" + - "\x1dModifyAnnouncementsOnlyAction\x12-\n" + - "\x12announcements_only\x18\x01 \x01(\bR\x11announcementsOnly\x1a\x16\n" + - "\x14TerminateGroupAction\"/\n" + - "\x17ExternalGroupCredential\x12\x14\n" + - "\x05token\x18\x01 \x01(\tR\x05token\"}\n" + - "\rGroupResponse\x12#\n" + - "\x05group\x18\x01 \x01(\v2\r.signal.GroupR\x05group\x12G\n" + - " group_send_endorsements_response\x18\x02 \x01(\fR\x1dgroupSendEndorsementsResponse\"\x9c\x02\n" + - "\fGroupChanges\x12I\n" + - "\fgroupChanges\x18\x01 \x03(\v2%.signal.GroupChanges.GroupChangeStateR\fgroupChanges\x12G\n" + - " group_send_endorsements_response\x18\x02 \x01(\fR\x1dgroupSendEndorsementsResponse\x1ax\n" + - "\x10GroupChangeState\x125\n" + - "\vgroupChange\x18\x01 \x01(\v2\x13.signal.GroupChangeR\vgroupChange\x12-\n" + - "\n" + - "groupState\x18\x02 \x01(\v2\r.signal.GroupR\n" + - "groupState\"\x96\x01\n" + - "\x13GroupChangeResponse\x126\n" + - "\fgroup_change\x18\x01 \x01(\v2\x13.signal.GroupChangeR\vgroupChange\x12G\n" + - " group_send_endorsements_response\x18\x02 \x01(\fR\x1dgroupSendEndorsementsResponseB@\n" + - "/org.signal.storageservice.storage.protos.groupsB\vGroupProtosP\x01b\x06proto3" +var file_Groups_proto_rawDesc = []byte{ + 0x0a, 0x0c, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc4, + 0x01, 0x0a, 0x16, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x41, + 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x1e, 0x0a, 0x0a, 0x63, + 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0a, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x12, 0x10, 0x0a, 0x03, 0x61, + 0x63, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x61, 0x63, 0x6c, 0x12, 0x1c, 0x0a, + 0x09, 0x61, 0x6c, 0x67, 0x6f, 0x72, 0x69, 0x74, 0x68, 0x6d, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x09, 0x61, 0x6c, 0x67, 0x6f, 0x72, 0x69, 0x74, 0x68, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x64, + 0x61, 0x74, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x61, 0x74, 0x65, 0x12, + 0x16, 0x0a, 0x06, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, + 0x74, 0x75, 0x72, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, + 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0xe7, 0x01, 0x0a, 0x06, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, + 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x20, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0c, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x2e, + 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x72, + 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x4b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, + 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x4b, 0x65, 0x79, 0x12, 0x22, 0x0a, 0x0c, 0x70, 0x72, + 0x65, 0x73, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x0c, 0x70, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2a, + 0x0a, 0x10, 0x6a, 0x6f, 0x69, 0x6e, 0x65, 0x64, 0x41, 0x74, 0x52, 0x65, 0x76, 0x69, 0x73, 0x69, + 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x10, 0x6a, 0x6f, 0x69, 0x6e, 0x65, 0x64, + 0x41, 0x74, 0x52, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x33, 0x0a, 0x04, 0x52, 0x6f, + 0x6c, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, + 0x0b, 0x0a, 0x07, 0x44, 0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, + 0x41, 0x44, 0x4d, 0x49, 0x4e, 0x49, 0x53, 0x54, 0x52, 0x41, 0x54, 0x4f, 0x52, 0x10, 0x02, 0x22, + 0x74, 0x0a, 0x0d, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, + 0x12, 0x1f, 0x0a, 0x06, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x07, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x06, 0x6d, 0x65, 0x6d, 0x62, 0x65, + 0x72, 0x12, 0x24, 0x0a, 0x0d, 0x61, 0x64, 0x64, 0x65, 0x64, 0x42, 0x79, 0x55, 0x73, 0x65, 0x72, + 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x61, 0x64, 0x64, 0x65, 0x64, 0x42, + 0x79, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0x8c, 0x01, 0x0a, 0x10, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, + 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, + 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x4b, 0x65, 0x79, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x4b, + 0x65, 0x79, 0x12, 0x22, 0x0a, 0x0c, 0x70, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x70, 0x72, 0x65, 0x73, 0x65, 0x6e, + 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x22, 0x44, 0x0a, 0x0c, 0x42, 0x61, 0x6e, 0x6e, 0x65, 0x64, 0x4d, 0x65, + 0x6d, 0x62, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, + 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0xae, 0x02, 0x0a, 0x0d, 0x41, + 0x63, 0x63, 0x65, 0x73, 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x12, 0x3d, 0x0a, 0x0a, + 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x1d, 0x2e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, + 0x2e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x52, + 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x37, 0x0a, 0x07, 0x6d, + 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1d, 0x2e, 0x41, + 0x63, 0x63, 0x65, 0x73, 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x41, 0x63, 0x63, + 0x65, 0x73, 0x73, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x52, 0x07, 0x6d, 0x65, 0x6d, + 0x62, 0x65, 0x72, 0x73, 0x12, 0x4b, 0x0a, 0x11, 0x61, 0x64, 0x64, 0x46, 0x72, 0x6f, 0x6d, 0x49, + 0x6e, 0x76, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x6e, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x1d, 0x2e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, + 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x52, 0x11, + 0x61, 0x64, 0x64, 0x46, 0x72, 0x6f, 0x6d, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x6e, + 0x6b, 0x22, 0x58, 0x0a, 0x0e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x52, 0x65, 0x71, 0x75, 0x69, + 0x72, 0x65, 0x64, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, + 0x12, 0x07, 0x0a, 0x03, 0x41, 0x4e, 0x59, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x4d, 0x45, 0x4d, + 0x42, 0x45, 0x52, 0x10, 0x02, 0x12, 0x11, 0x0a, 0x0d, 0x41, 0x44, 0x4d, 0x49, 0x4e, 0x49, 0x53, + 0x54, 0x52, 0x41, 0x54, 0x4f, 0x52, 0x10, 0x03, 0x12, 0x11, 0x0a, 0x0d, 0x55, 0x4e, 0x53, 0x41, + 0x54, 0x49, 0x53, 0x46, 0x49, 0x41, 0x42, 0x4c, 0x45, 0x10, 0x04, 0x22, 0xb4, 0x04, 0x0a, 0x05, + 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, + 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, + 0x4b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, + 0x74, 0x61, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, + 0x72, 0x12, 0x3c, 0x0a, 0x19, 0x64, 0x69, 0x73, 0x61, 0x70, 0x70, 0x65, 0x61, 0x72, 0x69, 0x6e, + 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x54, 0x69, 0x6d, 0x65, 0x72, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x19, 0x64, 0x69, 0x73, 0x61, 0x70, 0x70, 0x65, 0x61, 0x72, 0x69, + 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x54, 0x69, 0x6d, 0x65, 0x72, 0x12, + 0x34, 0x0a, 0x0d, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x43, + 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x52, 0x0d, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x43, 0x6f, + 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, + 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, + 0x6e, 0x12, 0x21, 0x0a, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x07, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x07, 0x6d, 0x65, 0x6d, + 0x62, 0x65, 0x72, 0x73, 0x12, 0x36, 0x0a, 0x0e, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x4d, + 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x50, + 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x0e, 0x70, 0x65, + 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x12, 0x3f, 0x0a, 0x11, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, + 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x11, 0x72, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x12, 0x2e, 0x0a, + 0x12, 0x69, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x6e, 0x6b, 0x50, 0x61, 0x73, 0x73, 0x77, + 0x6f, 0x72, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x12, 0x69, 0x6e, 0x76, 0x69, 0x74, + 0x65, 0x4c, 0x69, 0x6e, 0x6b, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x20, 0x0a, + 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0b, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x2c, 0x0a, 0x11, 0x61, 0x6e, 0x6e, 0x6f, 0x75, 0x6e, 0x63, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, + 0x4f, 0x6e, 0x6c, 0x79, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x08, 0x52, 0x11, 0x61, 0x6e, 0x6e, 0x6f, + 0x75, 0x6e, 0x63, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x4f, 0x6e, 0x6c, 0x79, 0x12, 0x33, 0x0a, + 0x0d, 0x62, 0x61, 0x6e, 0x6e, 0x65, 0x64, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x0d, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x42, 0x61, 0x6e, 0x6e, 0x65, 0x64, 0x4d, 0x65, 0x6d, + 0x62, 0x65, 0x72, 0x52, 0x0d, 0x62, 0x61, 0x6e, 0x6e, 0x65, 0x64, 0x4d, 0x65, 0x6d, 0x62, 0x65, + 0x72, 0x73, 0x22, 0xcc, 0x21, 0x0a, 0x0b, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x68, 0x61, 0x6e, + 0x67, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x07, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x28, 0x0a, 0x0f, + 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x69, 0x67, + 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, + 0x45, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0b, 0x63, 0x68, 0x61, + 0x6e, 0x67, 0x65, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x1a, 0xd6, 0x20, 0x0a, 0x07, 0x41, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x28, 0x0a, 0x0f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0f, 0x73, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x1a, + 0x0a, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, + 0x52, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x44, 0x0a, 0x0a, 0x61, 0x64, + 0x64, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, + 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x2e, 0x41, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x41, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x61, 0x64, 0x64, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, + 0x12, 0x4d, 0x0a, 0x0d, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, + 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, + 0x68, 0x61, 0x6e, 0x67, 0x65, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x44, 0x65, + 0x6c, 0x65, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x0d, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x12, + 0x59, 0x0a, 0x11, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, + 0x6f, 0x6c, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x47, 0x72, 0x6f, + 0x75, 0x70, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x2e, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x6f, 0x6c, + 0x65, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x11, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x4d, + 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x6b, 0x0a, 0x17, 0x6d, 0x6f, + 0x64, 0x69, 0x66, 0x79, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, + 0x65, 0x4b, 0x65, 0x79, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x47, 0x72, + 0x6f, 0x75, 0x70, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x2e, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x50, 0x72, + 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x4b, 0x65, 0x79, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x17, + 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x66, + 0x69, 0x6c, 0x65, 0x4b, 0x65, 0x79, 0x73, 0x12, 0x59, 0x0a, 0x11, 0x61, 0x64, 0x64, 0x50, 0x65, + 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x07, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, + 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x65, 0x6e, 0x64, + 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, + 0x11, 0x61, 0x64, 0x64, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, + 0x72, 0x73, 0x12, 0x62, 0x0a, 0x14, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x65, 0x6e, 0x64, + 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x2e, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x2e, 0x41, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x65, 0x6e, + 0x64, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x14, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x4d, + 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x12, 0x65, 0x0a, 0x15, 0x70, 0x72, 0x6f, 0x6d, 0x6f, 0x74, + 0x65, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, + 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x68, 0x61, + 0x6e, 0x67, 0x65, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x50, 0x72, 0x6f, 0x6d, + 0x6f, 0x74, 0x65, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, + 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x15, 0x70, 0x72, 0x6f, 0x6d, 0x6f, 0x74, 0x65, 0x50, + 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x12, 0x48, 0x0a, + 0x0b, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x0a, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, + 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x54, + 0x69, 0x74, 0x6c, 0x65, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x6d, 0x6f, 0x64, 0x69, + 0x66, 0x79, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x4b, 0x0a, 0x0c, 0x6d, 0x6f, 0x64, 0x69, 0x66, + 0x79, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, + 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x2e, 0x41, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x2e, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, + 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x41, 0x76, + 0x61, 0x74, 0x61, 0x72, 0x12, 0x84, 0x01, 0x0a, 0x1f, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x44, + 0x69, 0x73, 0x61, 0x70, 0x70, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x73, 0x54, 0x69, 0x6d, 0x65, 0x72, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x3a, + 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x2e, 0x41, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x44, 0x69, 0x73, 0x61, 0x70, + 0x70, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x54, + 0x69, 0x6d, 0x65, 0x72, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x1f, 0x6d, 0x6f, 0x64, 0x69, + 0x66, 0x79, 0x44, 0x69, 0x73, 0x61, 0x70, 0x70, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x4d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x54, 0x69, 0x6d, 0x65, 0x72, 0x12, 0x70, 0x0a, 0x16, 0x6d, + 0x6f, 0x64, 0x69, 0x66, 0x79, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x41, + 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x38, 0x2e, 0x47, 0x72, + 0x6f, 0x75, 0x70, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x2e, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, + 0x65, 0x73, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x41, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x16, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x41, 0x74, 0x74, + 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x65, 0x0a, + 0x12, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x41, 0x63, 0x63, + 0x65, 0x73, 0x73, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x47, 0x72, 0x6f, 0x75, + 0x70, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, + 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x41, 0x63, 0x63, + 0x65, 0x73, 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x12, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x41, 0x63, + 0x63, 0x65, 0x73, 0x73, 0x12, 0x85, 0x01, 0x0a, 0x1d, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x41, + 0x64, 0x64, 0x46, 0x72, 0x6f, 0x6d, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x6e, 0x6b, + 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x3f, 0x2e, 0x47, + 0x72, 0x6f, 0x75, 0x70, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x2e, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x41, 0x64, 0x64, 0x46, 0x72, 0x6f, 0x6d, + 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x6e, 0x6b, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, + 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x1d, 0x6d, + 0x6f, 0x64, 0x69, 0x66, 0x79, 0x41, 0x64, 0x64, 0x46, 0x72, 0x6f, 0x6d, 0x49, 0x6e, 0x76, 0x69, + 0x74, 0x65, 0x4c, 0x69, 0x6e, 0x6b, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x62, 0x0a, 0x14, + 0x61, 0x64, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, + 0x62, 0x65, 0x72, 0x73, 0x18, 0x10, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x47, 0x72, 0x6f, + 0x75, 0x70, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x2e, 0x41, 0x64, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x4d, 0x65, + 0x6d, 0x62, 0x65, 0x72, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x14, 0x61, 0x64, 0x64, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, + 0x12, 0x6b, 0x0a, 0x17, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x11, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x31, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x2e, + 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x41, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x17, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x12, 0x6e, 0x0a, + 0x18, 0x70, 0x72, 0x6f, 0x6d, 0x6f, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x69, + 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x12, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x32, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x2e, 0x41, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x50, 0x72, 0x6f, 0x6d, 0x6f, 0x74, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x41, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x18, 0x70, 0x72, 0x6f, 0x6d, 0x6f, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x12, 0x6f, 0x0a, + 0x18, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x6e, + 0x6b, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x13, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x33, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x2e, 0x41, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x49, 0x6e, 0x76, 0x69, + 0x74, 0x65, 0x4c, 0x69, 0x6e, 0x6b, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x41, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x18, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x49, 0x6e, 0x76, 0x69, + 0x74, 0x65, 0x4c, 0x69, 0x6e, 0x6b, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x5a, + 0x0a, 0x11, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x14, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x47, 0x72, 0x6f, 0x75, + 0x70, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, + 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x11, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x44, + 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x6c, 0x0a, 0x17, 0x6d, 0x6f, + 0x64, 0x69, 0x66, 0x79, 0x41, 0x6e, 0x6e, 0x6f, 0x75, 0x6e, 0x63, 0x65, 0x6d, 0x65, 0x6e, 0x74, + 0x73, 0x4f, 0x6e, 0x6c, 0x79, 0x18, 0x15, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x47, 0x72, + 0x6f, 0x75, 0x70, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x2e, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x41, 0x6e, 0x6e, 0x6f, 0x75, 0x6e, 0x63, 0x65, + 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x4f, 0x6e, 0x6c, 0x79, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, + 0x17, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x41, 0x6e, 0x6e, 0x6f, 0x75, 0x6e, 0x63, 0x65, 0x6d, + 0x65, 0x6e, 0x74, 0x73, 0x4f, 0x6e, 0x6c, 0x79, 0x12, 0x56, 0x0a, 0x10, 0x61, 0x64, 0x64, 0x42, + 0x61, 0x6e, 0x6e, 0x65, 0x64, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x16, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, + 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x42, 0x61, 0x6e, 0x6e, + 0x65, 0x64, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x10, + 0x61, 0x64, 0x64, 0x42, 0x61, 0x6e, 0x6e, 0x65, 0x64, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, + 0x12, 0x5f, 0x0a, 0x13, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x61, 0x6e, 0x6e, 0x65, 0x64, + 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x17, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, + 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x2e, 0x41, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x61, 0x6e, 0x6e, 0x65, 0x64, + 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x64, 0x65, + 0x6c, 0x65, 0x74, 0x65, 0x42, 0x61, 0x6e, 0x6e, 0x65, 0x64, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, + 0x73, 0x12, 0x81, 0x01, 0x0a, 0x1b, 0x70, 0x72, 0x6f, 0x6d, 0x6f, 0x74, 0x65, 0x50, 0x65, 0x6e, + 0x64, 0x69, 0x6e, 0x67, 0x50, 0x6e, 0x69, 0x41, 0x63, 0x69, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, + 0x73, 0x18, 0x18, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3f, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, + 0x68, 0x61, 0x6e, 0x67, 0x65, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x50, 0x72, + 0x6f, 0x6d, 0x6f, 0x74, 0x65, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x50, 0x6e, 0x69, 0x41, + 0x63, 0x69, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x4b, + 0x65, 0x79, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x1b, 0x70, 0x72, 0x6f, 0x6d, 0x6f, 0x74, + 0x65, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x50, 0x6e, 0x69, 0x41, 0x63, 0x69, 0x4d, 0x65, + 0x6d, 0x62, 0x65, 0x72, 0x73, 0x1a, 0x60, 0x0a, 0x0f, 0x41, 0x64, 0x64, 0x4d, 0x65, 0x6d, 0x62, + 0x65, 0x72, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x05, 0x61, 0x64, 0x64, 0x65, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, + 0x52, 0x05, 0x61, 0x64, 0x64, 0x65, 0x64, 0x12, 0x2e, 0x0a, 0x12, 0x6a, 0x6f, 0x69, 0x6e, 0x46, + 0x72, 0x6f, 0x6d, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x6e, 0x6b, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x12, 0x6a, 0x6f, 0x69, 0x6e, 0x46, 0x72, 0x6f, 0x6d, 0x49, 0x6e, 0x76, + 0x69, 0x74, 0x65, 0x4c, 0x69, 0x6e, 0x6b, 0x1a, 0x3a, 0x0a, 0x12, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x24, 0x0a, + 0x0d, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x55, 0x73, 0x65, + 0x72, 0x49, 0x64, 0x1a, 0x52, 0x0a, 0x16, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x4d, 0x65, 0x6d, + 0x62, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, + 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x75, + 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x20, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x0c, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x2e, 0x52, 0x6f, 0x6c, + 0x65, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x1a, 0x7c, 0x0a, 0x1c, 0x4d, 0x6f, 0x64, 0x69, 0x66, + 0x79, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x4b, 0x65, + 0x79, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x22, 0x0a, 0x0c, 0x70, 0x72, 0x65, 0x73, 0x65, + 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x70, + 0x72, 0x65, 0x73, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x17, 0x0a, 0x07, 0x75, + 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x75, 0x73, + 0x65, 0x72, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x5f, + 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x66, 0x69, + 0x6c, 0x65, 0x4b, 0x65, 0x79, 0x1a, 0x3e, 0x0a, 0x16, 0x41, 0x64, 0x64, 0x50, 0x65, 0x6e, 0x64, + 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x24, 0x0a, 0x05, 0x61, 0x64, 0x64, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, + 0x2e, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x05, + 0x61, 0x64, 0x64, 0x65, 0x64, 0x1a, 0x41, 0x0a, 0x19, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, + 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x41, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x24, 0x0a, 0x0d, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x55, 0x73, 0x65, + 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x64, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x64, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x1a, 0x7a, 0x0a, 0x1a, 0x50, 0x72, 0x6f, 0x6d, + 0x6f, 0x74, 0x65, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, + 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x22, 0x0a, 0x0c, 0x70, 0x72, 0x65, 0x73, 0x65, 0x6e, + 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x70, 0x72, + 0x65, 0x73, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, + 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x75, 0x73, 0x65, + 0x72, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x6b, + 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, + 0x65, 0x4b, 0x65, 0x79, 0x1a, 0x9a, 0x01, 0x0a, 0x2a, 0x50, 0x72, 0x6f, 0x6d, 0x6f, 0x74, 0x65, + 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x50, 0x6e, 0x69, 0x41, 0x63, 0x69, 0x4d, 0x65, 0x6d, + 0x62, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x4b, 0x65, 0x79, 0x41, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x22, 0x0a, 0x0c, 0x70, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x74, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x70, 0x72, 0x65, 0x73, 0x65, + 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, + 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, + 0x10, 0x0a, 0x03, 0x70, 0x6e, 0x69, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x70, 0x6e, + 0x69, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x4b, 0x65, 0x79, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x4b, 0x65, + 0x79, 0x1a, 0x44, 0x0a, 0x19, 0x41, 0x64, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x69, + 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x27, + 0x0a, 0x05, 0x61, 0x64, 0x64, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, + 0x52, 0x05, 0x61, 0x64, 0x64, 0x65, 0x64, 0x1a, 0x44, 0x0a, 0x1c, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, + 0x72, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x24, 0x0a, 0x0d, 0x64, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x64, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, + 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x1a, 0x59, 0x0a, + 0x1d, 0x50, 0x72, 0x6f, 0x6d, 0x6f, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x69, + 0x6e, 0x67, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, + 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, + 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x20, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0c, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x2e, 0x52, 0x6f, + 0x6c, 0x65, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x1a, 0x3c, 0x0a, 0x15, 0x41, 0x64, 0x64, 0x42, + 0x61, 0x6e, 0x6e, 0x65, 0x64, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x41, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x12, 0x23, 0x0a, 0x05, 0x61, 0x64, 0x64, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x0d, 0x2e, 0x42, 0x61, 0x6e, 0x6e, 0x65, 0x64, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, + 0x05, 0x61, 0x64, 0x64, 0x65, 0x64, 0x1a, 0x40, 0x0a, 0x18, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x42, 0x61, 0x6e, 0x6e, 0x65, 0x64, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x41, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x24, 0x0a, 0x0d, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x55, 0x73, 0x65, + 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x64, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x64, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x1a, 0x29, 0x0a, 0x11, 0x4d, 0x6f, 0x64, 0x69, + 0x66, 0x79, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, + 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x74, 0x69, + 0x74, 0x6c, 0x65, 0x1a, 0x3b, 0x0a, 0x17, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x44, 0x65, 0x73, + 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x20, + 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x1a, 0x2c, 0x0a, 0x12, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, + 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x1a, 0x3d, + 0x0a, 0x25, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x44, 0x69, 0x73, 0x61, 0x70, 0x70, 0x65, 0x61, + 0x72, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x54, 0x69, 0x6d, 0x65, + 0x72, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x6d, 0x65, 0x72, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x74, 0x69, 0x6d, 0x65, 0x72, 0x1a, 0x70, 0x0a, + 0x23, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, + 0x73, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x41, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x49, 0x0a, 0x10, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, + 0x65, 0x73, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1d, + 0x2e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x41, + 0x63, 0x63, 0x65, 0x73, 0x73, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x52, 0x10, 0x61, + 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x1a, + 0x67, 0x0a, 0x20, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, + 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x41, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x43, 0x0a, 0x0d, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x41, 0x63, + 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1d, 0x2e, 0x41, 0x63, 0x63, + 0x65, 0x73, 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x41, 0x63, 0x63, 0x65, 0x73, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x52, 0x0d, 0x6d, 0x65, 0x6d, 0x62, 0x65, + 0x72, 0x73, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x1a, 0x85, 0x01, 0x0a, 0x2a, 0x4d, 0x6f, 0x64, + 0x69, 0x66, 0x79, 0x41, 0x64, 0x64, 0x46, 0x72, 0x6f, 0x6d, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, + 0x4c, 0x69, 0x6e, 0x6b, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, + 0x6c, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x57, 0x0a, 0x17, 0x61, 0x64, 0x64, 0x46, 0x72, + 0x6f, 0x6d, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x6e, 0x6b, 0x41, 0x63, 0x63, 0x65, + 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1d, 0x2e, 0x41, 0x63, 0x63, 0x65, 0x73, + 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x52, 0x17, 0x61, 0x64, 0x64, 0x46, 0x72, 0x6f, 0x6d, + 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x6e, 0x6b, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, + 0x1a, 0x50, 0x0a, 0x1e, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, + 0x4c, 0x69, 0x6e, 0x6b, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x41, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x2e, 0x0a, 0x12, 0x69, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x6e, 0x6b, + 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x12, + 0x69, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x6e, 0x6b, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, + 0x72, 0x64, 0x1a, 0x4d, 0x0a, 0x1d, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x41, 0x6e, 0x6e, 0x6f, + 0x75, 0x6e, 0x63, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x4f, 0x6e, 0x6c, 0x79, 0x41, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x2c, 0x0a, 0x11, 0x61, 0x6e, 0x6e, 0x6f, 0x75, 0x6e, 0x63, 0x65, 0x6d, + 0x65, 0x6e, 0x74, 0x73, 0x4f, 0x6e, 0x6c, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x11, + 0x61, 0x6e, 0x6e, 0x6f, 0x75, 0x6e, 0x63, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x4f, 0x6e, 0x6c, + 0x79, 0x22, 0xbe, 0x01, 0x0a, 0x0c, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x68, 0x61, 0x6e, 0x67, + 0x65, 0x73, 0x12, 0x42, 0x0a, 0x0c, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x68, 0x61, 0x6e, 0x67, + 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, + 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x68, 0x61, + 0x6e, 0x67, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x0c, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x43, + 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x1a, 0x6a, 0x0a, 0x10, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, + 0x68, 0x61, 0x6e, 0x67, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x2e, 0x0a, 0x0b, 0x67, 0x72, + 0x6f, 0x75, 0x70, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0c, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x0b, 0x67, + 0x72, 0x6f, 0x75, 0x70, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x26, 0x0a, 0x0a, 0x67, 0x72, + 0x6f, 0x75, 0x70, 0x53, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x06, + 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x0a, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x53, 0x74, 0x61, + 0x74, 0x65, 0x22, 0xbb, 0x01, 0x0a, 0x12, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x41, 0x74, 0x74, 0x72, + 0x69, 0x62, 0x75, 0x74, 0x65, 0x42, 0x6c, 0x6f, 0x62, 0x12, 0x16, 0x0a, 0x05, 0x74, 0x69, 0x74, + 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, + 0x65, 0x12, 0x18, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0c, 0x48, 0x00, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x44, 0x0a, 0x1c, 0x64, + 0x69, 0x73, 0x61, 0x70, 0x70, 0x65, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x73, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0d, 0x48, 0x00, 0x52, 0x1c, 0x64, 0x69, 0x73, 0x61, 0x70, 0x70, 0x65, 0x61, 0x72, 0x69, 0x6e, + 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x12, 0x22, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x09, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, + 0x22, 0xe0, 0x01, 0x0a, 0x0f, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, + 0x4c, 0x69, 0x6e, 0x6b, 0x12, 0x4c, 0x0a, 0x0a, 0x76, 0x31, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, + 0x74, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, + 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x6e, 0x6b, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, + 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x6e, 0x6b, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, + 0x74, 0x73, 0x56, 0x31, 0x48, 0x00, 0x52, 0x0a, 0x76, 0x31, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, + 0x74, 0x73, 0x1a, 0x73, 0x0a, 0x19, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x6e, 0x76, 0x69, 0x74, + 0x65, 0x4c, 0x69, 0x6e, 0x6b, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x56, 0x31, 0x12, + 0x26, 0x0a, 0x0e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x4b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x61, + 0x73, 0x74, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x12, 0x2e, 0x0a, 0x12, 0x69, 0x6e, 0x76, 0x69, 0x74, + 0x65, 0x4c, 0x69, 0x6e, 0x6b, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x12, 0x69, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x6e, 0x6b, 0x50, + 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x42, 0x0a, 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, + 0x6e, 0x74, 0x73, 0x22, 0xbc, 0x02, 0x0a, 0x0d, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4a, 0x6f, 0x69, + 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, + 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, + 0x4b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, + 0x74, 0x61, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, + 0x72, 0x12, 0x20, 0x0a, 0x0b, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x43, 0x6f, 0x75, 0x6e, 0x74, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0b, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x43, 0x6f, + 0x75, 0x6e, 0x74, 0x12, 0x4b, 0x0a, 0x11, 0x61, 0x64, 0x64, 0x46, 0x72, 0x6f, 0x6d, 0x49, 0x6e, + 0x76, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x6e, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1d, + 0x2e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x41, + 0x63, 0x63, 0x65, 0x73, 0x73, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x52, 0x11, 0x61, + 0x64, 0x64, 0x46, 0x72, 0x6f, 0x6d, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x6e, 0x6b, + 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x0d, 0x52, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x14, + 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x41, 0x70, 0x70, 0x72, + 0x6f, 0x76, 0x61, 0x6c, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x14, 0x70, 0x65, 0x6e, 0x64, + 0x69, 0x6e, 0x67, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x41, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x61, 0x6c, + 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0x08, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x22, 0x2f, 0x0a, 0x17, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x45, 0x78, 0x74, 0x65, 0x72, + 0x6e, 0x61, 0x6c, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x12, 0x14, 0x0a, + 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, + 0x6b, 0x65, 0x6e, 0x42, 0x2b, 0x0a, 0x27, 0x6f, 0x72, 0x67, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, + 0x6c, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x50, 0x01, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} var ( file_Groups_proto_rawDescOnce sync.Once - file_Groups_proto_rawDescData []byte + file_Groups_proto_rawDescData = file_Groups_proto_rawDesc ) func file_Groups_proto_rawDescGZIP() []byte { file_Groups_proto_rawDescOnce.Do(func() { - file_Groups_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_Groups_proto_rawDesc), len(file_Groups_proto_rawDesc))) + file_Groups_proto_rawDescData = protoimpl.X.CompressGZIP(file_Groups_proto_rawDescData) }) return file_Groups_proto_rawDescData } var file_Groups_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_Groups_proto_msgTypes = make([]protoimpl.MessageInfo, 43) -var file_Groups_proto_goTypes = []any{ - (Member_Role)(0), // 0: signal.Member.Role - (AccessControl_AccessRequired)(0), // 1: signal.AccessControl.AccessRequired - (*AvatarUploadAttributes)(nil), // 2: signal.AvatarUploadAttributes - (*Member)(nil), // 3: signal.Member - (*MemberPendingProfileKey)(nil), // 4: signal.MemberPendingProfileKey - (*MemberPendingAdminApproval)(nil), // 5: signal.MemberPendingAdminApproval - (*MemberBanned)(nil), // 6: signal.MemberBanned - (*AccessControl)(nil), // 7: signal.AccessControl - (*Group)(nil), // 8: signal.Group - (*GroupAttributeBlob)(nil), // 9: signal.GroupAttributeBlob - (*GroupInviteLink)(nil), // 10: signal.GroupInviteLink - (*GroupJoinInfo)(nil), // 11: signal.GroupJoinInfo - (*GroupChange)(nil), // 12: signal.GroupChange - (*ExternalGroupCredential)(nil), // 13: signal.ExternalGroupCredential - (*GroupResponse)(nil), // 14: signal.GroupResponse - (*GroupChanges)(nil), // 15: signal.GroupChanges - (*GroupChangeResponse)(nil), // 16: signal.GroupChangeResponse - (*GroupInviteLink_GroupInviteLinkContentsV1)(nil), // 17: signal.GroupInviteLink.GroupInviteLinkContentsV1 - (*GroupChange_Actions)(nil), // 18: signal.GroupChange.Actions - (*GroupChange_Actions_AddMemberAction)(nil), // 19: signal.GroupChange.Actions.AddMemberAction - (*GroupChange_Actions_DeleteMemberAction)(nil), // 20: signal.GroupChange.Actions.DeleteMemberAction - (*GroupChange_Actions_ModifyMemberRoleAction)(nil), // 21: signal.GroupChange.Actions.ModifyMemberRoleAction - (*GroupChange_Actions_ModifyMemberLabelAction)(nil), // 22: signal.GroupChange.Actions.ModifyMemberLabelAction - (*GroupChange_Actions_ModifyMemberProfileKeyAction)(nil), // 23: signal.GroupChange.Actions.ModifyMemberProfileKeyAction - (*GroupChange_Actions_AddMemberPendingProfileKeyAction)(nil), // 24: signal.GroupChange.Actions.AddMemberPendingProfileKeyAction - (*GroupChange_Actions_DeleteMemberPendingProfileKeyAction)(nil), // 25: signal.GroupChange.Actions.DeleteMemberPendingProfileKeyAction - (*GroupChange_Actions_PromoteMemberPendingProfileKeyAction)(nil), // 26: signal.GroupChange.Actions.PromoteMemberPendingProfileKeyAction - (*GroupChange_Actions_PromoteMemberPendingPniAciProfileKeyAction)(nil), // 27: signal.GroupChange.Actions.PromoteMemberPendingPniAciProfileKeyAction - (*GroupChange_Actions_AddMemberPendingAdminApprovalAction)(nil), // 28: signal.GroupChange.Actions.AddMemberPendingAdminApprovalAction - (*GroupChange_Actions_DeleteMemberPendingAdminApprovalAction)(nil), // 29: signal.GroupChange.Actions.DeleteMemberPendingAdminApprovalAction - (*GroupChange_Actions_PromoteMemberPendingAdminApprovalAction)(nil), // 30: signal.GroupChange.Actions.PromoteMemberPendingAdminApprovalAction - (*GroupChange_Actions_AddMemberBannedAction)(nil), // 31: signal.GroupChange.Actions.AddMemberBannedAction - (*GroupChange_Actions_DeleteMemberBannedAction)(nil), // 32: signal.GroupChange.Actions.DeleteMemberBannedAction - (*GroupChange_Actions_ModifyTitleAction)(nil), // 33: signal.GroupChange.Actions.ModifyTitleAction - (*GroupChange_Actions_ModifyDescriptionAction)(nil), // 34: signal.GroupChange.Actions.ModifyDescriptionAction - (*GroupChange_Actions_ModifyAvatarAction)(nil), // 35: signal.GroupChange.Actions.ModifyAvatarAction - (*GroupChange_Actions_ModifyDisappearingMessageTimerAction)(nil), // 36: signal.GroupChange.Actions.ModifyDisappearingMessageTimerAction - (*GroupChange_Actions_ModifyAttributesAccessControlAction)(nil), // 37: signal.GroupChange.Actions.ModifyAttributesAccessControlAction - (*GroupChange_Actions_ModifyMembersAccessControlAction)(nil), // 38: signal.GroupChange.Actions.ModifyMembersAccessControlAction - (*GroupChange_Actions_ModifyAddFromInviteLinkAccessControlAction)(nil), // 39: signal.GroupChange.Actions.ModifyAddFromInviteLinkAccessControlAction - (*GroupChange_Actions_ModifyMemberLabelAccessControlAction)(nil), // 40: signal.GroupChange.Actions.ModifyMemberLabelAccessControlAction - (*GroupChange_Actions_ModifyInviteLinkPasswordAction)(nil), // 41: signal.GroupChange.Actions.ModifyInviteLinkPasswordAction - (*GroupChange_Actions_ModifyAnnouncementsOnlyAction)(nil), // 42: signal.GroupChange.Actions.ModifyAnnouncementsOnlyAction - (*GroupChange_Actions_TerminateGroupAction)(nil), // 43: signal.GroupChange.Actions.TerminateGroupAction - (*GroupChanges_GroupChangeState)(nil), // 44: signal.GroupChanges.GroupChangeState +var file_Groups_proto_msgTypes = make([]protoimpl.MessageInfo, 38) +var file_Groups_proto_goTypes = []interface{}{ + (Member_Role)(0), // 0: Member.Role + (AccessControl_AccessRequired)(0), // 1: AccessControl.AccessRequired + (*AvatarUploadAttributes)(nil), // 2: AvatarUploadAttributes + (*Member)(nil), // 3: Member + (*PendingMember)(nil), // 4: PendingMember + (*RequestingMember)(nil), // 5: RequestingMember + (*BannedMember)(nil), // 6: BannedMember + (*AccessControl)(nil), // 7: AccessControl + (*Group)(nil), // 8: Group + (*GroupChange)(nil), // 9: GroupChange + (*GroupChanges)(nil), // 10: GroupChanges + (*GroupAttributeBlob)(nil), // 11: GroupAttributeBlob + (*GroupInviteLink)(nil), // 12: GroupInviteLink + (*GroupJoinInfo)(nil), // 13: GroupJoinInfo + (*GroupExternalCredential)(nil), // 14: GroupExternalCredential + (*GroupChange_Actions)(nil), // 15: GroupChange.Actions + (*GroupChange_Actions_AddMemberAction)(nil), // 16: GroupChange.Actions.AddMemberAction + (*GroupChange_Actions_DeleteMemberAction)(nil), // 17: GroupChange.Actions.DeleteMemberAction + (*GroupChange_Actions_ModifyMemberRoleAction)(nil), // 18: GroupChange.Actions.ModifyMemberRoleAction + (*GroupChange_Actions_ModifyMemberProfileKeyAction)(nil), // 19: GroupChange.Actions.ModifyMemberProfileKeyAction + (*GroupChange_Actions_AddPendingMemberAction)(nil), // 20: GroupChange.Actions.AddPendingMemberAction + (*GroupChange_Actions_DeletePendingMemberAction)(nil), // 21: GroupChange.Actions.DeletePendingMemberAction + (*GroupChange_Actions_PromotePendingMemberAction)(nil), // 22: GroupChange.Actions.PromotePendingMemberAction + (*GroupChange_Actions_PromotePendingPniAciMemberProfileKeyAction)(nil), // 23: GroupChange.Actions.PromotePendingPniAciMemberProfileKeyAction + (*GroupChange_Actions_AddRequestingMemberAction)(nil), // 24: GroupChange.Actions.AddRequestingMemberAction + (*GroupChange_Actions_DeleteRequestingMemberAction)(nil), // 25: GroupChange.Actions.DeleteRequestingMemberAction + (*GroupChange_Actions_PromoteRequestingMemberAction)(nil), // 26: GroupChange.Actions.PromoteRequestingMemberAction + (*GroupChange_Actions_AddBannedMemberAction)(nil), // 27: GroupChange.Actions.AddBannedMemberAction + (*GroupChange_Actions_DeleteBannedMemberAction)(nil), // 28: GroupChange.Actions.DeleteBannedMemberAction + (*GroupChange_Actions_ModifyTitleAction)(nil), // 29: GroupChange.Actions.ModifyTitleAction + (*GroupChange_Actions_ModifyDescriptionAction)(nil), // 30: GroupChange.Actions.ModifyDescriptionAction + (*GroupChange_Actions_ModifyAvatarAction)(nil), // 31: GroupChange.Actions.ModifyAvatarAction + (*GroupChange_Actions_ModifyDisappearingMessagesTimerAction)(nil), // 32: GroupChange.Actions.ModifyDisappearingMessagesTimerAction + (*GroupChange_Actions_ModifyAttributesAccessControlAction)(nil), // 33: GroupChange.Actions.ModifyAttributesAccessControlAction + (*GroupChange_Actions_ModifyMembersAccessControlAction)(nil), // 34: GroupChange.Actions.ModifyMembersAccessControlAction + (*GroupChange_Actions_ModifyAddFromInviteLinkAccessControlAction)(nil), // 35: GroupChange.Actions.ModifyAddFromInviteLinkAccessControlAction + (*GroupChange_Actions_ModifyInviteLinkPasswordAction)(nil), // 36: GroupChange.Actions.ModifyInviteLinkPasswordAction + (*GroupChange_Actions_ModifyAnnouncementsOnlyAction)(nil), // 37: GroupChange.Actions.ModifyAnnouncementsOnlyAction + (*GroupChanges_GroupChangeState)(nil), // 38: GroupChanges.GroupChangeState + (*GroupInviteLink_GroupInviteLinkContentsV1)(nil), // 39: GroupInviteLink.GroupInviteLinkContentsV1 } var file_Groups_proto_depIdxs = []int32{ - 0, // 0: signal.Member.role:type_name -> signal.Member.Role - 3, // 1: signal.MemberPendingProfileKey.member:type_name -> signal.Member - 1, // 2: signal.AccessControl.attributes:type_name -> signal.AccessControl.AccessRequired - 1, // 3: signal.AccessControl.members:type_name -> signal.AccessControl.AccessRequired - 1, // 4: signal.AccessControl.addFromInviteLink:type_name -> signal.AccessControl.AccessRequired - 1, // 5: signal.AccessControl.memberLabel:type_name -> signal.AccessControl.AccessRequired - 7, // 6: signal.Group.accessControl:type_name -> signal.AccessControl - 3, // 7: signal.Group.members:type_name -> signal.Member - 4, // 8: signal.Group.membersPendingProfileKey:type_name -> signal.MemberPendingProfileKey - 5, // 9: signal.Group.membersPendingAdminApproval:type_name -> signal.MemberPendingAdminApproval - 6, // 10: signal.Group.members_banned:type_name -> signal.MemberBanned - 17, // 11: signal.GroupInviteLink.contentsV1:type_name -> signal.GroupInviteLink.GroupInviteLinkContentsV1 - 1, // 12: signal.GroupJoinInfo.addFromInviteLink:type_name -> signal.AccessControl.AccessRequired - 8, // 13: signal.GroupResponse.group:type_name -> signal.Group - 44, // 14: signal.GroupChanges.groupChanges:type_name -> signal.GroupChanges.GroupChangeState - 12, // 15: signal.GroupChangeResponse.group_change:type_name -> signal.GroupChange - 19, // 16: signal.GroupChange.Actions.addMembers:type_name -> signal.GroupChange.Actions.AddMemberAction - 20, // 17: signal.GroupChange.Actions.deleteMembers:type_name -> signal.GroupChange.Actions.DeleteMemberAction - 21, // 18: signal.GroupChange.Actions.modifyMemberRoles:type_name -> signal.GroupChange.Actions.ModifyMemberRoleAction - 23, // 19: signal.GroupChange.Actions.modifyMemberProfileKeys:type_name -> signal.GroupChange.Actions.ModifyMemberProfileKeyAction - 24, // 20: signal.GroupChange.Actions.addMembersPendingProfileKey:type_name -> signal.GroupChange.Actions.AddMemberPendingProfileKeyAction - 25, // 21: signal.GroupChange.Actions.deleteMembersPendingProfileKey:type_name -> signal.GroupChange.Actions.DeleteMemberPendingProfileKeyAction - 26, // 22: signal.GroupChange.Actions.promoteMembersPendingProfileKey:type_name -> signal.GroupChange.Actions.PromoteMemberPendingProfileKeyAction - 33, // 23: signal.GroupChange.Actions.modifyTitle:type_name -> signal.GroupChange.Actions.ModifyTitleAction - 35, // 24: signal.GroupChange.Actions.modifyAvatar:type_name -> signal.GroupChange.Actions.ModifyAvatarAction - 36, // 25: signal.GroupChange.Actions.modifyDisappearingMessageTimer:type_name -> signal.GroupChange.Actions.ModifyDisappearingMessageTimerAction - 37, // 26: signal.GroupChange.Actions.modifyAttributesAccess:type_name -> signal.GroupChange.Actions.ModifyAttributesAccessControlAction - 38, // 27: signal.GroupChange.Actions.modifyMemberAccess:type_name -> signal.GroupChange.Actions.ModifyMembersAccessControlAction - 39, // 28: signal.GroupChange.Actions.modifyAddFromInviteLinkAccess:type_name -> signal.GroupChange.Actions.ModifyAddFromInviteLinkAccessControlAction - 28, // 29: signal.GroupChange.Actions.addMembersPendingAdminApproval:type_name -> signal.GroupChange.Actions.AddMemberPendingAdminApprovalAction - 29, // 30: signal.GroupChange.Actions.deleteMembersPendingAdminApproval:type_name -> signal.GroupChange.Actions.DeleteMemberPendingAdminApprovalAction - 30, // 31: signal.GroupChange.Actions.promoteMembersPendingAdminApproval:type_name -> signal.GroupChange.Actions.PromoteMemberPendingAdminApprovalAction - 41, // 32: signal.GroupChange.Actions.modifyInviteLinkPassword:type_name -> signal.GroupChange.Actions.ModifyInviteLinkPasswordAction - 34, // 33: signal.GroupChange.Actions.modifyDescription:type_name -> signal.GroupChange.Actions.ModifyDescriptionAction - 42, // 34: signal.GroupChange.Actions.modify_announcements_only:type_name -> signal.GroupChange.Actions.ModifyAnnouncementsOnlyAction - 31, // 35: signal.GroupChange.Actions.add_members_banned:type_name -> signal.GroupChange.Actions.AddMemberBannedAction - 32, // 36: signal.GroupChange.Actions.delete_members_banned:type_name -> signal.GroupChange.Actions.DeleteMemberBannedAction - 27, // 37: signal.GroupChange.Actions.promote_members_pending_pni_aci_profile_key:type_name -> signal.GroupChange.Actions.PromoteMemberPendingPniAciProfileKeyAction - 22, // 38: signal.GroupChange.Actions.modifyMemberLabels:type_name -> signal.GroupChange.Actions.ModifyMemberLabelAction - 40, // 39: signal.GroupChange.Actions.modifyMemberLabelAccess:type_name -> signal.GroupChange.Actions.ModifyMemberLabelAccessControlAction - 43, // 40: signal.GroupChange.Actions.terminate_group:type_name -> signal.GroupChange.Actions.TerminateGroupAction - 3, // 41: signal.GroupChange.Actions.AddMemberAction.added:type_name -> signal.Member - 0, // 42: signal.GroupChange.Actions.ModifyMemberRoleAction.role:type_name -> signal.Member.Role - 4, // 43: signal.GroupChange.Actions.AddMemberPendingProfileKeyAction.added:type_name -> signal.MemberPendingProfileKey - 5, // 44: signal.GroupChange.Actions.AddMemberPendingAdminApprovalAction.added:type_name -> signal.MemberPendingAdminApproval - 0, // 45: signal.GroupChange.Actions.PromoteMemberPendingAdminApprovalAction.role:type_name -> signal.Member.Role - 6, // 46: signal.GroupChange.Actions.AddMemberBannedAction.added:type_name -> signal.MemberBanned - 1, // 47: signal.GroupChange.Actions.ModifyAttributesAccessControlAction.attributesAccess:type_name -> signal.AccessControl.AccessRequired - 1, // 48: signal.GroupChange.Actions.ModifyMembersAccessControlAction.membersAccess:type_name -> signal.AccessControl.AccessRequired - 1, // 49: signal.GroupChange.Actions.ModifyAddFromInviteLinkAccessControlAction.addFromInviteLinkAccess:type_name -> signal.AccessControl.AccessRequired - 1, // 50: signal.GroupChange.Actions.ModifyMemberLabelAccessControlAction.memberLabelAccess:type_name -> signal.AccessControl.AccessRequired - 12, // 51: signal.GroupChanges.GroupChangeState.groupChange:type_name -> signal.GroupChange - 8, // 52: signal.GroupChanges.GroupChangeState.groupState:type_name -> signal.Group - 53, // [53:53] is the sub-list for method output_type - 53, // [53:53] is the sub-list for method input_type - 53, // [53:53] is the sub-list for extension type_name - 53, // [53:53] is the sub-list for extension extendee - 0, // [0:53] is the sub-list for field type_name + 0, // 0: Member.role:type_name -> Member.Role + 3, // 1: PendingMember.member:type_name -> Member + 1, // 2: AccessControl.attributes:type_name -> AccessControl.AccessRequired + 1, // 3: AccessControl.members:type_name -> AccessControl.AccessRequired + 1, // 4: AccessControl.addFromInviteLink:type_name -> AccessControl.AccessRequired + 7, // 5: Group.accessControl:type_name -> AccessControl + 3, // 6: Group.members:type_name -> Member + 4, // 7: Group.pendingMembers:type_name -> PendingMember + 5, // 8: Group.requestingMembers:type_name -> RequestingMember + 6, // 9: Group.bannedMembers:type_name -> BannedMember + 38, // 10: GroupChanges.groupChanges:type_name -> GroupChanges.GroupChangeState + 39, // 11: GroupInviteLink.v1Contents:type_name -> GroupInviteLink.GroupInviteLinkContentsV1 + 1, // 12: GroupJoinInfo.addFromInviteLink:type_name -> AccessControl.AccessRequired + 16, // 13: GroupChange.Actions.addMembers:type_name -> GroupChange.Actions.AddMemberAction + 17, // 14: GroupChange.Actions.deleteMembers:type_name -> GroupChange.Actions.DeleteMemberAction + 18, // 15: GroupChange.Actions.modifyMemberRoles:type_name -> GroupChange.Actions.ModifyMemberRoleAction + 19, // 16: GroupChange.Actions.modifyMemberProfileKeys:type_name -> GroupChange.Actions.ModifyMemberProfileKeyAction + 20, // 17: GroupChange.Actions.addPendingMembers:type_name -> GroupChange.Actions.AddPendingMemberAction + 21, // 18: GroupChange.Actions.deletePendingMembers:type_name -> GroupChange.Actions.DeletePendingMemberAction + 22, // 19: GroupChange.Actions.promotePendingMembers:type_name -> GroupChange.Actions.PromotePendingMemberAction + 29, // 20: GroupChange.Actions.modifyTitle:type_name -> GroupChange.Actions.ModifyTitleAction + 31, // 21: GroupChange.Actions.modifyAvatar:type_name -> GroupChange.Actions.ModifyAvatarAction + 32, // 22: GroupChange.Actions.modifyDisappearingMessagesTimer:type_name -> GroupChange.Actions.ModifyDisappearingMessagesTimerAction + 33, // 23: GroupChange.Actions.modifyAttributesAccess:type_name -> GroupChange.Actions.ModifyAttributesAccessControlAction + 34, // 24: GroupChange.Actions.modifyMemberAccess:type_name -> GroupChange.Actions.ModifyMembersAccessControlAction + 35, // 25: GroupChange.Actions.modifyAddFromInviteLinkAccess:type_name -> GroupChange.Actions.ModifyAddFromInviteLinkAccessControlAction + 24, // 26: GroupChange.Actions.addRequestingMembers:type_name -> GroupChange.Actions.AddRequestingMemberAction + 25, // 27: GroupChange.Actions.deleteRequestingMembers:type_name -> GroupChange.Actions.DeleteRequestingMemberAction + 26, // 28: GroupChange.Actions.promoteRequestingMembers:type_name -> GroupChange.Actions.PromoteRequestingMemberAction + 36, // 29: GroupChange.Actions.modifyInviteLinkPassword:type_name -> GroupChange.Actions.ModifyInviteLinkPasswordAction + 30, // 30: GroupChange.Actions.modifyDescription:type_name -> GroupChange.Actions.ModifyDescriptionAction + 37, // 31: GroupChange.Actions.modifyAnnouncementsOnly:type_name -> GroupChange.Actions.ModifyAnnouncementsOnlyAction + 27, // 32: GroupChange.Actions.addBannedMembers:type_name -> GroupChange.Actions.AddBannedMemberAction + 28, // 33: GroupChange.Actions.deleteBannedMembers:type_name -> GroupChange.Actions.DeleteBannedMemberAction + 23, // 34: GroupChange.Actions.promotePendingPniAciMembers:type_name -> GroupChange.Actions.PromotePendingPniAciMemberProfileKeyAction + 3, // 35: GroupChange.Actions.AddMemberAction.added:type_name -> Member + 0, // 36: GroupChange.Actions.ModifyMemberRoleAction.role:type_name -> Member.Role + 4, // 37: GroupChange.Actions.AddPendingMemberAction.added:type_name -> PendingMember + 5, // 38: GroupChange.Actions.AddRequestingMemberAction.added:type_name -> RequestingMember + 0, // 39: GroupChange.Actions.PromoteRequestingMemberAction.role:type_name -> Member.Role + 6, // 40: GroupChange.Actions.AddBannedMemberAction.added:type_name -> BannedMember + 1, // 41: GroupChange.Actions.ModifyAttributesAccessControlAction.attributesAccess:type_name -> AccessControl.AccessRequired + 1, // 42: GroupChange.Actions.ModifyMembersAccessControlAction.membersAccess:type_name -> AccessControl.AccessRequired + 1, // 43: GroupChange.Actions.ModifyAddFromInviteLinkAccessControlAction.addFromInviteLinkAccess:type_name -> AccessControl.AccessRequired + 9, // 44: GroupChanges.GroupChangeState.groupChange:type_name -> GroupChange + 8, // 45: GroupChanges.GroupChangeState.groupState:type_name -> Group + 46, // [46:46] is the sub-list for method output_type + 46, // [46:46] is the sub-list for method input_type + 46, // [46:46] is the sub-list for extension type_name + 46, // [46:46] is the sub-list for extension extendee + 0, // [0:46] is the sub-list for field type_name } func init() { file_Groups_proto_init() } @@ -3153,22 +3146,480 @@ func file_Groups_proto_init() { if File_Groups_proto != nil { return } - file_Groups_proto_msgTypes[7].OneofWrappers = []any{ + if !protoimpl.UnsafeEnabled { + file_Groups_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AvatarUploadAttributes); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Member); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PendingMember); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RequestingMember); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BannedMember); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AccessControl); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Group); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupChange); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupChanges); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupAttributeBlob); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupInviteLink); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupJoinInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupExternalCredential); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupChange_Actions); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupChange_Actions_AddMemberAction); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupChange_Actions_DeleteMemberAction); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupChange_Actions_ModifyMemberRoleAction); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupChange_Actions_ModifyMemberProfileKeyAction); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupChange_Actions_AddPendingMemberAction); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupChange_Actions_DeletePendingMemberAction); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupChange_Actions_PromotePendingMemberAction); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupChange_Actions_PromotePendingPniAciMemberProfileKeyAction); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupChange_Actions_AddRequestingMemberAction); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupChange_Actions_DeleteRequestingMemberAction); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupChange_Actions_PromoteRequestingMemberAction); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupChange_Actions_AddBannedMemberAction); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[26].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupChange_Actions_DeleteBannedMemberAction); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[27].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupChange_Actions_ModifyTitleAction); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[28].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupChange_Actions_ModifyDescriptionAction); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[29].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupChange_Actions_ModifyAvatarAction); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[30].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupChange_Actions_ModifyDisappearingMessagesTimerAction); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[31].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupChange_Actions_ModifyAttributesAccessControlAction); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[32].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupChange_Actions_ModifyMembersAccessControlAction); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[33].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupChange_Actions_ModifyAddFromInviteLinkAccessControlAction); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[34].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupChange_Actions_ModifyInviteLinkPasswordAction); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[35].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupChange_Actions_ModifyAnnouncementsOnlyAction); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[36].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupChanges_GroupChangeState); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Groups_proto_msgTypes[37].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupInviteLink_GroupInviteLinkContentsV1); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_Groups_proto_msgTypes[9].OneofWrappers = []interface{}{ (*GroupAttributeBlob_Title)(nil), (*GroupAttributeBlob_Avatar)(nil), (*GroupAttributeBlob_DisappearingMessagesDuration)(nil), - (*GroupAttributeBlob_DescriptionText)(nil), + (*GroupAttributeBlob_Description)(nil), } - file_Groups_proto_msgTypes[8].OneofWrappers = []any{ - (*GroupInviteLink_ContentsV1)(nil), + file_Groups_proto_msgTypes[10].OneofWrappers = []interface{}{ + (*GroupInviteLink_V1Contents)(nil), } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_Groups_proto_rawDesc), len(file_Groups_proto_rawDesc)), + RawDescriptor: file_Groups_proto_rawDesc, NumEnums: 2, - NumMessages: 43, + NumMessages: 38, NumExtensions: 0, NumServices: 0, }, @@ -3178,6 +3629,7 @@ func file_Groups_proto_init() { MessageInfos: file_Groups_proto_msgTypes, }.Build() File_Groups_proto = out.File + file_Groups_proto_rawDesc = nil file_Groups_proto_goTypes = nil file_Groups_proto_depIdxs = nil } diff --git a/pkg/signalmeow/protobuf/Groups.proto b/pkg/signalmeow/protobuf/Groups.proto index 9843d1c..3f0b730 100644 --- a/pkg/signalmeow/protobuf/Groups.proto +++ b/pkg/signalmeow/protobuf/Groups.proto @@ -1,139 +1,92 @@ -/* - * Copyright 2020 Signal Messenger, LLC - * SPDX-License-Identifier: AGPL-3.0-only +/** + * Copyright (C) 2019 Open Whisper Systems + * + * Licensed according to the LICENSE file in this repository. */ - syntax = "proto3"; -package signal; - -option java_package = "org.signal.storageservice.storage.protos.groups"; -option java_outer_classname = "GroupProtos"; +option java_package = "org.signal.storageservice.protos.groups"; option java_multiple_files = true; message AvatarUploadAttributes { - string key = 1; + string key = 1; string credential = 2; - string acl = 3; - string algorithm = 4; - string date = 5; - string policy = 6; - string signature = 7; + string acl = 3; + string algorithm = 4; + string date = 5; + string policy = 6; + string signature = 7; } -// Stored data - message Member { enum Role { - UNKNOWN = 0; - DEFAULT = 1; + UNKNOWN = 0; + DEFAULT = 1; ADMINISTRATOR = 2; } - bytes userId = 1; - Role role = 2; - bytes profileKey = 3; - bytes presentation = 4; - uint32 joinedAtVersion = 5; - bytes labelEmoji = 6; // decrypts to a UTF-8 string - bytes labelString = 7; // decrypts to a UTF-8 string + bytes userId = 1; + Role role = 2; + bytes profileKey = 3; + bytes presentation = 4; // Only set when sending to server + uint32 joinedAtRevision = 5; } -message MemberPendingProfileKey { - Member member = 1; - bytes addedByUserId = 2; - uint64 timestamp = 3; // ms since epoch +message PendingMember { + Member member = 1; + bytes addedByUserId = 2; + uint64 timestamp = 3; } -message MemberPendingAdminApproval { - bytes userId = 1; - bytes profileKey = 2; - bytes presentation = 3; - uint64 timestamp = 4; // ms since epoch +message RequestingMember { + bytes userId = 1; + bytes profileKey = 2; + bytes presentation = 3; // Only set when sending to server + uint64 timestamp = 4; } -message MemberBanned { - bytes userId = 1; - uint64 timestamp = 2; // ms since epoch +message BannedMember { + bytes userId = 1; + uint64 timestamp = 2; } message AccessControl { enum AccessRequired { - UNKNOWN = 0; - ANY = 1; - MEMBER = 2; + UNKNOWN = 0; + ANY = 1; + MEMBER = 2; ADMINISTRATOR = 3; UNSATISFIABLE = 4; } - AccessRequired attributes = 1; - AccessRequired members = 2; + AccessRequired attributes = 1; + AccessRequired members = 2; AccessRequired addFromInviteLink = 3; - AccessRequired memberLabel = 4; } message Group { - bytes publicKey = 1; - bytes title = 2; - bytes description = 11; - // The URL for this group's avatar. The content at this URL can be - // decrypted/deserialized into a `GroupAttributeBlob`. - string avatarUrl = 3; - bytes disappearingMessagesTimer = 4; - AccessControl accessControl = 5; - uint32 version = 6; - repeated Member members = 7; - repeated MemberPendingProfileKey membersPendingProfileKey = 8; - repeated MemberPendingAdminApproval membersPendingAdminApproval = 9; - bytes inviteLinkPassword = 10; - bool announcements_only = 12; - repeated MemberBanned members_banned = 13; - bool terminated = 14; - // next: 15 + bytes publicKey = 1; + bytes title = 2; + string avatar = 3; + bytes disappearingMessagesTimer = 4; + AccessControl accessControl = 5; + uint32 revision = 6; + repeated Member members = 7; + repeated PendingMember pendingMembers = 8; + repeated RequestingMember requestingMembers = 9; + bytes inviteLinkPassword = 10; + bytes description = 11; + bool announcementsOnly = 12; + repeated BannedMember bannedMembers = 13; } -message GroupAttributeBlob { - oneof content { - string title = 1; - bytes avatar = 2; - uint32 disappearingMessagesDuration = 3; - string descriptionText = 4; - } -} - -message GroupInviteLink { - message GroupInviteLinkContentsV1 { - bytes groupMasterKey = 1; - bytes inviteLinkPassword = 2; - } - - oneof contents { - GroupInviteLinkContentsV1 contentsV1 = 1; - } -} - -message GroupJoinInfo { - bytes publicKey = 1; - bytes title = 2; - bytes description = 8; - string avatar = 3; - uint32 memberCount = 4; - AccessControl.AccessRequired addFromInviteLink = 5; - uint32 version = 6; - bool pendingAdminApproval = 7; - // bool pendingAdminApprovalFull = 9; - // next: 10 -} - -// Deltas - message GroupChange { message Actions { message AddMemberAction { - Member added = 1; - bool joinFromInviteLink = 2; + Member added = 1; + bool joinFromInviteLink = 2; } message DeleteMemberAction { @@ -141,61 +94,55 @@ message GroupChange { } message ModifyMemberRoleAction { - bytes userId = 1; - Member.Role role = 2; - } - - message ModifyMemberLabelAction { - bytes userId = 1; - bytes labelEmoji = 2; // decrypts to a UTF-8 string - bytes labelString = 3; // decrypts to a UTF-8 string + bytes userId = 1; + Member.Role role = 2; } message ModifyMemberProfileKeyAction { - bytes presentation = 1; - bytes user_id = 2; - bytes profile_key = 3; + bytes presentation = 1; // Only set when sending to server + bytes user_id = 2; // Only set when receiving from server + bytes profile_key = 3; // Only set when receiving from server } - message AddMemberPendingProfileKeyAction { - MemberPendingProfileKey added = 1; + message AddPendingMemberAction { + PendingMember added = 1; } - message DeleteMemberPendingProfileKeyAction { + message DeletePendingMemberAction { bytes deletedUserId = 1; } - message PromoteMemberPendingProfileKeyAction { - bytes presentation = 1; - bytes user_id = 2; - bytes profile_key = 3; + message PromotePendingMemberAction { + bytes presentation = 1; // Only set when sending to server + bytes user_id = 2; // Only set when receiving from server + bytes profile_key = 3; // Only set when receiving from server } - message PromoteMemberPendingPniAciProfileKeyAction { - bytes presentation = 1; - bytes user_id = 2; - bytes pni = 3; - bytes profile_key = 4; + message PromotePendingPniAciMemberProfileKeyAction { + bytes presentation = 1; // Only set when sending to server + bytes userId = 2; // Only set when receiving from server + bytes pni = 3; // Only set when receiving from server + bytes profileKey = 4; // Only set when receiving from server } - message AddMemberPendingAdminApprovalAction { - MemberPendingAdminApproval added = 1; + message AddRequestingMemberAction { + RequestingMember added = 1; } - message DeleteMemberPendingAdminApprovalAction { + message DeleteRequestingMemberAction { bytes deletedUserId = 1; } - message PromoteMemberPendingAdminApprovalAction { - bytes userId = 1; - Member.Role role = 2; + message PromoteRequestingMemberAction { + bytes userId = 1; + Member.Role role = 2; } - message AddMemberBannedAction { - MemberBanned added = 1; + message AddBannedMemberAction { + BannedMember added = 1; } - message DeleteMemberBannedAction { + message DeleteBannedMemberAction { bytes deletedUserId = 1; } @@ -211,7 +158,7 @@ message GroupChange { string avatar = 1; } - message ModifyDisappearingMessageTimerAction { + message ModifyDisappearingMessagesTimerAction { bytes timer = 1; } @@ -227,83 +174,85 @@ message GroupChange { AccessControl.AccessRequired addFromInviteLinkAccess = 1; } - message ModifyMemberLabelAccessControlAction { - AccessControl.AccessRequired memberLabelAccess = 1; - } - message ModifyInviteLinkPasswordAction { bytes inviteLinkPassword = 1; } message ModifyAnnouncementsOnlyAction { - bool announcements_only = 1; + bool announcementsOnly = 1; } - message TerminateGroupAction {} - - bytes sourceUserId = 1; - // clients should not provide this value; the server will provide it in the response buffer to ensure the signature is binding to a particular group - // if clients set it during a request the server will respond with 400. - bytes group_id = 25; - uint32 version = 2; - - repeated AddMemberAction addMembers = 3; - repeated DeleteMemberAction deleteMembers = 4; - repeated ModifyMemberRoleAction modifyMemberRoles = 5; - repeated ModifyMemberProfileKeyAction modifyMemberProfileKeys = 6; - repeated AddMemberPendingProfileKeyAction addMembersPendingProfileKey = 7; - repeated DeleteMemberPendingProfileKeyAction deleteMembersPendingProfileKey = 8; - repeated PromoteMemberPendingProfileKeyAction promoteMembersPendingProfileKey = 9; - ModifyTitleAction modifyTitle = 10; - ModifyAvatarAction modifyAvatar = 11; - ModifyDisappearingMessageTimerAction modifyDisappearingMessageTimer = 12; - ModifyAttributesAccessControlAction modifyAttributesAccess = 13; - ModifyMembersAccessControlAction modifyMemberAccess = 14; - ModifyAddFromInviteLinkAccessControlAction modifyAddFromInviteLinkAccess = 15; // change epoch = 1 - repeated AddMemberPendingAdminApprovalAction addMembersPendingAdminApproval = 16; // change epoch = 1 - repeated DeleteMemberPendingAdminApprovalAction deleteMembersPendingAdminApproval = 17; // change epoch = 1 - repeated PromoteMemberPendingAdminApprovalAction promoteMembersPendingAdminApproval = 18; // change epoch = 1 - ModifyInviteLinkPasswordAction modifyInviteLinkPassword = 19; // change epoch = 1 - ModifyDescriptionAction modifyDescription = 20; // change epoch = 2 - ModifyAnnouncementsOnlyAction modify_announcements_only = 21; // change epoch = 3 - repeated AddMemberBannedAction add_members_banned = 22; // change epoch = 4 - repeated DeleteMemberBannedAction delete_members_banned = 23; // change epoch = 4 - repeated PromoteMemberPendingPniAciProfileKeyAction promote_members_pending_pni_aci_profile_key = 24; // change epoch = 5 - repeated ModifyMemberLabelAction modifyMemberLabels = 26; // change epoch = 6; - ModifyMemberLabelAccessControlAction modifyMemberLabelAccess = 27; // change epoch = 6 - TerminateGroupAction terminate_group = 28; // change epoch = 7 - // next: 29 + bytes sourceServiceId = 1; + uint32 revision = 2; + repeated AddMemberAction addMembers = 3; + repeated DeleteMemberAction deleteMembers = 4; + repeated ModifyMemberRoleAction modifyMemberRoles = 5; + repeated ModifyMemberProfileKeyAction modifyMemberProfileKeys = 6; + repeated AddPendingMemberAction addPendingMembers = 7; + repeated DeletePendingMemberAction deletePendingMembers = 8; + repeated PromotePendingMemberAction promotePendingMembers = 9; + ModifyTitleAction modifyTitle = 10; + ModifyAvatarAction modifyAvatar = 11; + ModifyDisappearingMessagesTimerAction modifyDisappearingMessagesTimer = 12; + ModifyAttributesAccessControlAction modifyAttributesAccess = 13; + ModifyMembersAccessControlAction modifyMemberAccess = 14; + ModifyAddFromInviteLinkAccessControlAction modifyAddFromInviteLinkAccess = 15; + repeated AddRequestingMemberAction addRequestingMembers = 16; + repeated DeleteRequestingMemberAction deleteRequestingMembers = 17; + repeated PromoteRequestingMemberAction promoteRequestingMembers = 18; + ModifyInviteLinkPasswordAction modifyInviteLinkPassword = 19; + ModifyDescriptionAction modifyDescription = 20; + ModifyAnnouncementsOnlyAction modifyAnnouncementsOnly = 21; + repeated AddBannedMemberAction addBannedMembers = 22; + repeated DeleteBannedMemberAction deleteBannedMembers = 23; + repeated PromotePendingPniAciMemberProfileKeyAction promotePendingPniAciMembers = 24; } - bytes actions = 1; - bytes serverSignature = 2; - uint32 changeEpoch = 3; -} - -// External credentials - -message ExternalGroupCredential { - string token = 1; -} - -// API responses - -message GroupResponse { - Group group = 1; - bytes group_send_endorsements_response = 2; + bytes actions = 1; + bytes serverSignature = 2; + uint32 changeEpoch = 3; } message GroupChanges { message GroupChangeState { GroupChange groupChange = 1; - Group groupState = 2; + Group groupState = 2; } repeated GroupChangeState groupChanges = 1; - bytes group_send_endorsements_response = 2; } -message GroupChangeResponse { - GroupChange group_change = 1; - bytes group_send_endorsements_response = 2; +message GroupAttributeBlob { + oneof content { + string title = 1; + bytes avatar = 2; + uint32 disappearingMessagesDuration = 3; + string description = 4; + } +} + +message GroupInviteLink { + message GroupInviteLinkContentsV1 { + bytes groupMasterKey = 1; + bytes inviteLinkPassword = 2; + } + + oneof contents { + GroupInviteLinkContentsV1 v1Contents = 1; + } +} + +message GroupJoinInfo { + bytes publicKey = 1; + bytes title = 2; + string avatar = 3; + uint32 memberCount = 4; + AccessControl.AccessRequired addFromInviteLink = 5; + uint32 revision = 6; + bool pendingAdminApproval = 7; + bytes description = 8; +} + +message GroupExternalCredential { + string token = 1; } diff --git a/pkg/signalmeow/protobuf/Provisioning.pb.go b/pkg/signalmeow/protobuf/Provisioning.pb.go index 88ebe90..446162e 100644 --- a/pkg/signalmeow/protobuf/Provisioning.pb.go +++ b/pkg/signalmeow/protobuf/Provisioning.pb.go @@ -1,11 +1,12 @@ +//* +// Copyright (C) 2014-2016 Open Whisper Systems // -// Copyright 2020 Signal Messenger, LLC -// SPDX-License-Identifier: AGPL-3.0-only +// Licensed according to the LICENSE file in this repository. // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.11 -// protoc v7.34.1 +// protoc-gen-go v1.31.0 +// protoc v3.21.12 // source: Provisioning.proto package signalpb @@ -15,7 +16,6 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" - unsafe "unsafe" ) const ( @@ -84,34 +84,32 @@ func (ProvisioningVersion) EnumDescriptor() ([]byte, []int) { return file_Provisioning_proto_rawDescGZIP(), []int{0} } -// An opaque address sent by the server when clients first open a provisioning -// WebSocket -type ProvisioningAddress struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The opaque provisioning address for the active provisioning WebSocket - // session; clients should not attempt to interpret or modify the contents - // of the address string - Address *string `protobuf:"bytes,1,opt,name=address" json:"address,omitempty"` - unknownFields protoimpl.UnknownFields +type ProvisioningUuid struct { + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Uuid *string `protobuf:"bytes,1,opt,name=uuid" json:"uuid,omitempty"` } -func (x *ProvisioningAddress) Reset() { - *x = ProvisioningAddress{} - mi := &file_Provisioning_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) +func (x *ProvisioningUuid) Reset() { + *x = ProvisioningUuid{} + if protoimpl.UnsafeEnabled { + mi := &file_Provisioning_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (x *ProvisioningAddress) String() string { +func (x *ProvisioningUuid) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ProvisioningAddress) ProtoMessage() {} +func (*ProvisioningUuid) ProtoMessage() {} -func (x *ProvisioningAddress) ProtoReflect() protoreflect.Message { +func (x *ProvisioningUuid) ProtoReflect() protoreflect.Message { mi := &file_Provisioning_proto_msgTypes[0] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -121,31 +119,34 @@ func (x *ProvisioningAddress) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ProvisioningAddress.ProtoReflect.Descriptor instead. -func (*ProvisioningAddress) Descriptor() ([]byte, []int) { +// Deprecated: Use ProvisioningUuid.ProtoReflect.Descriptor instead. +func (*ProvisioningUuid) Descriptor() ([]byte, []int) { return file_Provisioning_proto_rawDescGZIP(), []int{0} } -func (x *ProvisioningAddress) GetAddress() string { - if x != nil && x.Address != nil { - return *x.Address +func (x *ProvisioningUuid) GetUuid() string { + if x != nil && x.Uuid != nil { + return *x.Uuid } return "" } type ProvisionEnvelope struct { - state protoimpl.MessageState `protogen:"open.v1"` - PublicKey []byte `protobuf:"bytes,1,opt,name=publicKey" json:"publicKey,omitempty"` - Body []byte `protobuf:"bytes,2,opt,name=body" json:"body,omitempty"` // Encrypted ProvisionMessage - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + PublicKey []byte `protobuf:"bytes,1,opt,name=publicKey" json:"publicKey,omitempty"` + Body []byte `protobuf:"bytes,2,opt,name=body" json:"body,omitempty"` // Encrypted ProvisionMessage } func (x *ProvisionEnvelope) Reset() { *x = ProvisionEnvelope{} - mi := &file_Provisioning_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_Provisioning_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *ProvisionEnvelope) String() string { @@ -156,7 +157,7 @@ func (*ProvisionEnvelope) ProtoMessage() {} func (x *ProvisionEnvelope) ProtoReflect() protoreflect.Message { mi := &file_Provisioning_proto_msgTypes[1] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -186,33 +187,32 @@ func (x *ProvisionEnvelope) GetBody() []byte { } type ProvisionMessage struct { - state protoimpl.MessageState `protogen:"open.v1"` - AciIdentityKeyPublic []byte `protobuf:"bytes,1,opt,name=aciIdentityKeyPublic" json:"aciIdentityKeyPublic,omitempty"` - AciIdentityKeyPrivate []byte `protobuf:"bytes,2,opt,name=aciIdentityKeyPrivate" json:"aciIdentityKeyPrivate,omitempty"` - PniIdentityKeyPublic []byte `protobuf:"bytes,11,opt,name=pniIdentityKeyPublic" json:"pniIdentityKeyPublic,omitempty"` - PniIdentityKeyPrivate []byte `protobuf:"bytes,12,opt,name=pniIdentityKeyPrivate" json:"pniIdentityKeyPrivate,omitempty"` - Aci *string `protobuf:"bytes,8,opt,name=aci" json:"aci,omitempty"` - Pni *string `protobuf:"bytes,10,opt,name=pni" json:"pni,omitempty"` - Number *string `protobuf:"bytes,3,opt,name=number" json:"number,omitempty"` - ProvisioningCode *string `protobuf:"bytes,4,opt,name=provisioningCode" json:"provisioningCode,omitempty"` - UserAgent *string `protobuf:"bytes,5,opt,name=userAgent" json:"userAgent,omitempty"` - ProfileKey []byte `protobuf:"bytes,6,opt,name=profileKey" json:"profileKey,omitempty"` - ReadReceipts *bool `protobuf:"varint,7,opt,name=readReceipts" json:"readReceipts,omitempty"` - ProvisioningVersion *uint32 `protobuf:"varint,9,opt,name=provisioningVersion" json:"provisioningVersion,omitempty"` - EphemeralBackupKey []byte `protobuf:"bytes,14,opt,name=ephemeralBackupKey" json:"ephemeralBackupKey,omitempty"` // 32 bytes - AccountEntropyPool *string `protobuf:"bytes,15,opt,name=accountEntropyPool" json:"accountEntropyPool,omitempty"` - MediaRootBackupKey []byte `protobuf:"bytes,16,opt,name=mediaRootBackupKey" json:"mediaRootBackupKey,omitempty"` // 32-bytes - AciBinary []byte `protobuf:"bytes,17,opt,name=aciBinary" json:"aciBinary,omitempty"` // 16-byte UUID - PniBinary []byte `protobuf:"bytes,18,opt,name=pniBinary" json:"pniBinary,omitempty"` // 16-byte UUID - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AciIdentityKeyPublic []byte `protobuf:"bytes,1,opt,name=aciIdentityKeyPublic" json:"aciIdentityKeyPublic,omitempty"` + AciIdentityKeyPrivate []byte `protobuf:"bytes,2,opt,name=aciIdentityKeyPrivate" json:"aciIdentityKeyPrivate,omitempty"` + PniIdentityKeyPublic []byte `protobuf:"bytes,11,opt,name=pniIdentityKeyPublic" json:"pniIdentityKeyPublic,omitempty"` + PniIdentityKeyPrivate []byte `protobuf:"bytes,12,opt,name=pniIdentityKeyPrivate" json:"pniIdentityKeyPrivate,omitempty"` + Aci *string `protobuf:"bytes,8,opt,name=aci" json:"aci,omitempty"` + Pni *string `protobuf:"bytes,10,opt,name=pni" json:"pni,omitempty"` + Number *string `protobuf:"bytes,3,opt,name=number" json:"number,omitempty"` + ProvisioningCode *string `protobuf:"bytes,4,opt,name=provisioningCode" json:"provisioningCode,omitempty"` + UserAgent *string `protobuf:"bytes,5,opt,name=userAgent" json:"userAgent,omitempty"` + ProfileKey []byte `protobuf:"bytes,6,opt,name=profileKey" json:"profileKey,omitempty"` + ReadReceipts *bool `protobuf:"varint,7,opt,name=readReceipts" json:"readReceipts,omitempty"` + ProvisioningVersion *uint32 `protobuf:"varint,9,opt,name=provisioningVersion" json:"provisioningVersion,omitempty"` + MasterKey []byte `protobuf:"bytes,13,opt,name=masterKey" json:"masterKey,omitempty"` // NEXT ID: 14 } func (x *ProvisionMessage) Reset() { *x = ProvisionMessage{} - mi := &file_Provisioning_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_Provisioning_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *ProvisionMessage) String() string { @@ -223,7 +223,7 @@ func (*ProvisionMessage) ProtoMessage() {} func (x *ProvisionMessage) ProtoReflect() protoreflect.Message { mi := &file_Provisioning_proto_msgTypes[2] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -322,97 +322,88 @@ func (x *ProvisionMessage) GetProvisioningVersion() uint32 { return 0 } -func (x *ProvisionMessage) GetEphemeralBackupKey() []byte { +func (x *ProvisionMessage) GetMasterKey() []byte { if x != nil { - return x.EphemeralBackupKey - } - return nil -} - -func (x *ProvisionMessage) GetAccountEntropyPool() string { - if x != nil && x.AccountEntropyPool != nil { - return *x.AccountEntropyPool - } - return "" -} - -func (x *ProvisionMessage) GetMediaRootBackupKey() []byte { - if x != nil { - return x.MediaRootBackupKey - } - return nil -} - -func (x *ProvisionMessage) GetAciBinary() []byte { - if x != nil { - return x.AciBinary - } - return nil -} - -func (x *ProvisionMessage) GetPniBinary() []byte { - if x != nil { - return x.PniBinary + return x.MasterKey } return nil } var File_Provisioning_proto protoreflect.FileDescriptor -const file_Provisioning_proto_rawDesc = "" + - "\n" + - "\x12Provisioning.proto\x12\rsignalservice\"/\n" + - "\x13ProvisioningAddress\x12\x18\n" + - "\aaddress\x18\x01 \x01(\tR\aaddress\"E\n" + - "\x11ProvisionEnvelope\x12\x1c\n" + - "\tpublicKey\x18\x01 \x01(\fR\tpublicKey\x12\x12\n" + - "\x04body\x18\x02 \x01(\fR\x04body\"\xb4\x05\n" + - "\x10ProvisionMessage\x122\n" + - "\x14aciIdentityKeyPublic\x18\x01 \x01(\fR\x14aciIdentityKeyPublic\x124\n" + - "\x15aciIdentityKeyPrivate\x18\x02 \x01(\fR\x15aciIdentityKeyPrivate\x122\n" + - "\x14pniIdentityKeyPublic\x18\v \x01(\fR\x14pniIdentityKeyPublic\x124\n" + - "\x15pniIdentityKeyPrivate\x18\f \x01(\fR\x15pniIdentityKeyPrivate\x12\x10\n" + - "\x03aci\x18\b \x01(\tR\x03aci\x12\x10\n" + - "\x03pni\x18\n" + - " \x01(\tR\x03pni\x12\x16\n" + - "\x06number\x18\x03 \x01(\tR\x06number\x12*\n" + - "\x10provisioningCode\x18\x04 \x01(\tR\x10provisioningCode\x12\x1c\n" + - "\tuserAgent\x18\x05 \x01(\tR\tuserAgent\x12\x1e\n" + - "\n" + - "profileKey\x18\x06 \x01(\fR\n" + - "profileKey\x12\"\n" + - "\freadReceipts\x18\a \x01(\bR\freadReceipts\x120\n" + - "\x13provisioningVersion\x18\t \x01(\rR\x13provisioningVersion\x12.\n" + - "\x12ephemeralBackupKey\x18\x0e \x01(\fR\x12ephemeralBackupKey\x12.\n" + - "\x12accountEntropyPool\x18\x0f \x01(\tR\x12accountEntropyPool\x12.\n" + - "\x12mediaRootBackupKey\x18\x10 \x01(\fR\x12mediaRootBackupKey\x12\x1c\n" + - "\taciBinary\x18\x11 \x01(\fR\taciBinary\x12\x1c\n" + - "\tpniBinary\x18\x12 \x01(\fR\tpniBinaryJ\x04\b\r\x10\x0e*G\n" + - "\x13ProvisioningVersion\x12\v\n" + - "\aINITIAL\x10\x00\x12\x12\n" + - "\x0eTABLET_SUPPORT\x10\x01\x12\v\n" + - "\aCURRENT\x10\x01\x1a\x02\x10\x01BD\n" + - ".org.whispersystems.signalservice.internal.pushB\x12ProvisioningProtos" +var file_Provisioning_proto_rawDesc = []byte{ + 0x0a, 0x12, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x69, 0x6e, 0x67, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0d, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x22, 0x26, 0x0a, 0x10, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, + 0x69, 0x6e, 0x67, 0x55, 0x75, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x22, 0x45, 0x0a, 0x11, 0x50, + 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, + 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x12, + 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, + 0x64, 0x79, 0x22, 0x80, 0x04, 0x0a, 0x10, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, + 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x32, 0x0a, 0x14, 0x61, 0x63, 0x69, 0x49, 0x64, + 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x14, 0x61, 0x63, 0x69, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, + 0x74, 0x79, 0x4b, 0x65, 0x79, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x12, 0x34, 0x0a, 0x15, 0x61, + 0x63, 0x69, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x50, 0x72, 0x69, + 0x76, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x15, 0x61, 0x63, 0x69, 0x49, + 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, + 0x65, 0x12, 0x32, 0x0a, 0x14, 0x70, 0x6e, 0x69, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, + 0x4b, 0x65, 0x79, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x14, 0x70, 0x6e, 0x69, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x50, + 0x75, 0x62, 0x6c, 0x69, 0x63, 0x12, 0x34, 0x0a, 0x15, 0x70, 0x6e, 0x69, 0x49, 0x64, 0x65, 0x6e, + 0x74, 0x69, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x18, 0x0c, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x15, 0x70, 0x6e, 0x69, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, + 0x79, 0x4b, 0x65, 0x79, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x61, + 0x63, 0x69, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x61, 0x63, 0x69, 0x12, 0x10, 0x0a, + 0x03, 0x70, 0x6e, 0x69, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x70, 0x6e, 0x69, 0x12, + 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x2a, 0x0a, 0x10, 0x70, 0x72, 0x6f, 0x76, 0x69, + 0x73, 0x69, 0x6f, 0x6e, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x10, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x69, 0x6e, 0x67, 0x43, + 0x6f, 0x64, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x75, 0x73, 0x65, 0x72, 0x41, 0x67, 0x65, 0x6e, 0x74, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x75, 0x73, 0x65, 0x72, 0x41, 0x67, 0x65, 0x6e, + 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x4b, 0x65, 0x79, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x4b, 0x65, + 0x79, 0x12, 0x22, 0x0a, 0x0c, 0x72, 0x65, 0x61, 0x64, 0x52, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, + 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x72, 0x65, 0x61, 0x64, 0x52, 0x65, 0x63, + 0x65, 0x69, 0x70, 0x74, 0x73, 0x12, 0x30, 0x0a, 0x13, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, + 0x6f, 0x6e, 0x69, 0x6e, 0x67, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x09, 0x20, 0x01, + 0x28, 0x0d, 0x52, 0x13, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x69, 0x6e, 0x67, + 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x6d, 0x61, 0x73, 0x74, 0x65, + 0x72, 0x4b, 0x65, 0x79, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x6d, 0x61, 0x73, 0x74, + 0x65, 0x72, 0x4b, 0x65, 0x79, 0x2a, 0x47, 0x0a, 0x13, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, + 0x6f, 0x6e, 0x69, 0x6e, 0x67, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x0b, 0x0a, 0x07, + 0x49, 0x4e, 0x49, 0x54, 0x49, 0x41, 0x4c, 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x54, 0x41, 0x42, + 0x4c, 0x45, 0x54, 0x5f, 0x53, 0x55, 0x50, 0x50, 0x4f, 0x52, 0x54, 0x10, 0x01, 0x12, 0x0b, 0x0a, + 0x07, 0x43, 0x55, 0x52, 0x52, 0x45, 0x4e, 0x54, 0x10, 0x01, 0x1a, 0x02, 0x10, 0x01, 0x42, 0x44, + 0x0a, 0x2e, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x68, 0x69, 0x73, 0x70, 0x65, 0x72, 0x73, 0x79, 0x73, + 0x74, 0x65, 0x6d, 0x73, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x75, 0x73, 0x68, + 0x42, 0x12, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x69, 0x6e, 0x67, 0x50, 0x72, + 0x6f, 0x74, 0x6f, 0x73, +} var ( file_Provisioning_proto_rawDescOnce sync.Once - file_Provisioning_proto_rawDescData []byte + file_Provisioning_proto_rawDescData = file_Provisioning_proto_rawDesc ) func file_Provisioning_proto_rawDescGZIP() []byte { file_Provisioning_proto_rawDescOnce.Do(func() { - file_Provisioning_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_Provisioning_proto_rawDesc), len(file_Provisioning_proto_rawDesc))) + file_Provisioning_proto_rawDescData = protoimpl.X.CompressGZIP(file_Provisioning_proto_rawDescData) }) return file_Provisioning_proto_rawDescData } var file_Provisioning_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_Provisioning_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_Provisioning_proto_goTypes = []any{ - (ProvisioningVersion)(0), // 0: signalservice.ProvisioningVersion - (*ProvisioningAddress)(nil), // 1: signalservice.ProvisioningAddress - (*ProvisionEnvelope)(nil), // 2: signalservice.ProvisionEnvelope - (*ProvisionMessage)(nil), // 3: signalservice.ProvisionMessage +var file_Provisioning_proto_goTypes = []interface{}{ + (ProvisioningVersion)(0), // 0: signalservice.ProvisioningVersion + (*ProvisioningUuid)(nil), // 1: signalservice.ProvisioningUuid + (*ProvisionEnvelope)(nil), // 2: signalservice.ProvisionEnvelope + (*ProvisionMessage)(nil), // 3: signalservice.ProvisionMessage } var file_Provisioning_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for method output_type @@ -427,11 +418,49 @@ func file_Provisioning_proto_init() { if File_Provisioning_proto != nil { return } + if !protoimpl.UnsafeEnabled { + file_Provisioning_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ProvisioningUuid); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Provisioning_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ProvisionEnvelope); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_Provisioning_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ProvisionMessage); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_Provisioning_proto_rawDesc), len(file_Provisioning_proto_rawDesc)), + RawDescriptor: file_Provisioning_proto_rawDesc, NumEnums: 1, NumMessages: 3, NumExtensions: 0, @@ -443,6 +472,7 @@ func file_Provisioning_proto_init() { MessageInfos: file_Provisioning_proto_msgTypes, }.Build() File_Provisioning_proto = out.File + file_Provisioning_proto_rawDesc = nil file_Provisioning_proto_goTypes = nil file_Provisioning_proto_depIdxs = nil } diff --git a/pkg/signalmeow/protobuf/Provisioning.proto b/pkg/signalmeow/protobuf/Provisioning.proto index b5eeaf6..2b9bef4 100644 --- a/pkg/signalmeow/protobuf/Provisioning.proto +++ b/pkg/signalmeow/protobuf/Provisioning.proto @@ -1,56 +1,45 @@ -/* - * Copyright 2020 Signal Messenger, LLC - * SPDX-License-Identifier: AGPL-3.0-only +/** + * Copyright (C) 2014-2016 Open Whisper Systems + * + * Licensed according to the LICENSE file in this repository. */ - syntax = "proto2"; package signalservice; -option java_package = "org.whispersystems.signalservice.internal.push"; +option java_package = "org.whispersystems.signalservice.internal.push"; option java_outer_classname = "ProvisioningProtos"; -// An opaque address sent by the server when clients first open a provisioning -// WebSocket -message ProvisioningAddress { - - // The opaque provisioning address for the active provisioning WebSocket - // session; clients should not attempt to interpret or modify the contents - // of the address string - optional string address = 1; +message ProvisioningUuid { + optional string uuid = 1; } message ProvisionEnvelope { optional bytes publicKey = 1; - optional bytes body = 2; // Encrypted ProvisionMessage + optional bytes body = 2; // Encrypted ProvisionMessage } message ProvisionMessage { - optional bytes aciIdentityKeyPublic = 1; - optional bytes aciIdentityKeyPrivate = 2; - optional bytes pniIdentityKeyPublic = 11; - optional bytes pniIdentityKeyPrivate = 12; - optional string aci = 8; - optional string pni = 10; - optional string number = 3; - optional string provisioningCode = 4; - optional string userAgent = 5; - optional bytes profileKey = 6; - optional bool readReceipts = 7; - optional uint32 provisioningVersion = 9; - reserved /*masterKey*/ 13; // Deprecated in favor of accountEntropyPool - optional bytes ephemeralBackupKey = 14; // 32 bytes - optional string accountEntropyPool = 15; - optional bytes mediaRootBackupKey = 16; // 32-bytes - optional bytes aciBinary = 17; // 16-byte UUID - optional bytes pniBinary = 18; // 16-byte UUID - // NEXT ID: 19 + optional bytes aciIdentityKeyPublic = 1; + optional bytes aciIdentityKeyPrivate = 2; + optional bytes pniIdentityKeyPublic = 11; + optional bytes pniIdentityKeyPrivate = 12; + optional string aci = 8; + optional string pni = 10; + optional string number = 3; + optional string provisioningCode = 4; + optional string userAgent = 5; + optional bytes profileKey = 6; + optional bool readReceipts = 7; + optional uint32 provisioningVersion = 9; + optional bytes masterKey = 13; + // NEXT ID: 14 } enum ProvisioningVersion { option allow_alias = true; - INITIAL = 0; - TABLET_SUPPORT = 1; - CURRENT = 1; + INITIAL = 0; + TABLET_SUPPORT = 1; + CURRENT = 1; } diff --git a/pkg/signalmeow/protobuf/SignalService.pb.go b/pkg/signalmeow/protobuf/SignalService.pb.go index c4268dd..671146e 100644 --- a/pkg/signalmeow/protobuf/SignalService.pb.go +++ b/pkg/signalmeow/protobuf/SignalService.pb.go @@ -1,11 +1,12 @@ +//* +// Copyright (C) 2014-2016 Open Whisper Systems // -// Copyright 2020-2022 Signal Messenger, LLC -// SPDX-License-Identifier: AGPL-3.0-only +// Licensed according to the LICENSE file in this repository. // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.11 -// protoc v7.34.1 +// protoc-gen-go v1.31.0 +// protoc v3.21.12 // source: SignalService.proto package signalpb @@ -15,7 +16,6 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" - unsafe "unsafe" ) const ( @@ -28,72 +28,34 @@ const ( type Envelope_Type int32 const ( - Envelope_UNKNOWN Envelope_Type = 0 - // * - // A double-ratchet message represents a "normal," "unsealed-sender" message - // encrypted using the Double Ratchet within an established Signal session. - // Double-ratchet messages include sender information in the plaintext - // portion of the `Envelope`. - Envelope_DOUBLE_RATCHET Envelope_Type = 1 // content => (version byte | SignalMessage{Content}) - // * - // A prekey message begins a new Signal session. The `content` of a prekey - // message is a superset of a double-ratchet message's `content` and - // contains the sender's identity public key and information identifying the - // pre-keys used in the message's ciphertext. Like double-ratchet messages, - // prekey messages contain sender information in the plaintext portion of - // the `Envelope`. - Envelope_PREKEY_MESSAGE Envelope_Type = 3 // content => (version byte | PreKeySignalMessage{Content}) - // * - // Server delivery receipts are generated by the server when - // "unsealed-sender" messages are delivered to and acknowledged by the - // destination device. Server delivery receipts identify the sender in the - // plaintext portion of the `Envelope` and have no `content`. Note that - // receipts for sealed-sender messages are generated by clients as - // `UNIDENTIFIED_SENDER` messages. - // - // Note that, with server delivery receipts, the "client timestamp" on - // the envelope refers to the timestamp of the original message (i.e. the - // message the server just delivered) and not to the time of delivery. The - // "server timestamp" refers to the time of delivery. - Envelope_SERVER_DELIVERY_RECEIPT Envelope_Type = 5 // content => [] - // * - // An unidentified sender message represents a message with no sender - // information in the plaintext portion of the `Envelope`. Unidentified - // sender messages always contain an additional `subtype` in their - // `content`. They may or may not be part of an existing Signal session - // (i.e. an unidentified sender message may have a "prekey message" - // subtype or may indicate an encryption error). - Envelope_UNIDENTIFIED_SENDER Envelope_Type = 6 // content => ((version byte | UnidentifiedSenderMessage) OR (version byte | Multi-Recipient Sealed Sender Format)) - // * - // A plaintext message is used solely to convey encryption error receipts - // and never contains encrypted message content. Encryption error receipts - // must be delivered in plaintext because, encryption/decryption of a prior - // message failed and there is no reason to believe that - // encryption/decryption of subsequent messages with the same key material - // would succeed. - // - // Critically, plaintext messages never have "real" message content - // generated by users. Plaintext messages include sender information. - Envelope_PLAINTEXT_CONTENT Envelope_Type = 8 // content => (marker byte | Content) + Envelope_UNKNOWN Envelope_Type = 0 + Envelope_CIPHERTEXT Envelope_Type = 1 + Envelope_KEY_EXCHANGE Envelope_Type = 2 + Envelope_PREKEY_BUNDLE Envelope_Type = 3 + Envelope_RECEIPT Envelope_Type = 5 + Envelope_UNIDENTIFIED_SENDER Envelope_Type = 6 + Envelope_PLAINTEXT_CONTENT Envelope_Type = 8 ) // Enum value maps for Envelope_Type. var ( Envelope_Type_name = map[int32]string{ 0: "UNKNOWN", - 1: "DOUBLE_RATCHET", - 3: "PREKEY_MESSAGE", - 5: "SERVER_DELIVERY_RECEIPT", + 1: "CIPHERTEXT", + 2: "KEY_EXCHANGE", + 3: "PREKEY_BUNDLE", + 5: "RECEIPT", 6: "UNIDENTIFIED_SENDER", 8: "PLAINTEXT_CONTENT", } Envelope_Type_value = map[string]int32{ - "UNKNOWN": 0, - "DOUBLE_RATCHET": 1, - "PREKEY_MESSAGE": 3, - "SERVER_DELIVERY_RECEIPT": 5, - "UNIDENTIFIED_SENDER": 6, - "PLAINTEXT_CONTENT": 8, + "UNKNOWN": 0, + "CIPHERTEXT": 1, + "KEY_EXCHANGE": 2, + "PREKEY_BUNDLE": 3, + "RECEIPT": 5, + "UNIDENTIFIED_SENDER": 6, + "PLAINTEXT_CONTENT": 8, } ) @@ -311,13 +273,80 @@ func (CallMessage_Opaque_Urgency) EnumDescriptor() ([]byte, []int) { return file_SignalService_proto_rawDescGZIP(), []int{2, 5, 0} } +type BodyRange_Style int32 + +const ( + BodyRange_NONE BodyRange_Style = 0 + BodyRange_BOLD BodyRange_Style = 1 + BodyRange_ITALIC BodyRange_Style = 2 + BodyRange_SPOILER BodyRange_Style = 3 + BodyRange_STRIKETHROUGH BodyRange_Style = 4 + BodyRange_MONOSPACE BodyRange_Style = 5 +) + +// Enum value maps for BodyRange_Style. +var ( + BodyRange_Style_name = map[int32]string{ + 0: "NONE", + 1: "BOLD", + 2: "ITALIC", + 3: "SPOILER", + 4: "STRIKETHROUGH", + 5: "MONOSPACE", + } + BodyRange_Style_value = map[string]int32{ + "NONE": 0, + "BOLD": 1, + "ITALIC": 2, + "SPOILER": 3, + "STRIKETHROUGH": 4, + "MONOSPACE": 5, + } +) + +func (x BodyRange_Style) Enum() *BodyRange_Style { + p := new(BodyRange_Style) + *p = x + return p +} + +func (x BodyRange_Style) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (BodyRange_Style) Descriptor() protoreflect.EnumDescriptor { + return file_SignalService_proto_enumTypes[4].Descriptor() +} + +func (BodyRange_Style) Type() protoreflect.EnumType { + return &file_SignalService_proto_enumTypes[4] +} + +func (x BodyRange_Style) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Do not use. +func (x *BodyRange_Style) UnmarshalJSON(b []byte) error { + num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) + if err != nil { + return err + } + *x = BodyRange_Style(num) + return nil +} + +// Deprecated: Use BodyRange_Style.Descriptor instead. +func (BodyRange_Style) EnumDescriptor() ([]byte, []int) { + return file_SignalService_proto_rawDescGZIP(), []int{3, 0} +} + type DataMessage_Flags int32 const ( DataMessage_END_SESSION DataMessage_Flags = 1 DataMessage_EXPIRATION_TIMER_UPDATE DataMessage_Flags = 2 DataMessage_PROFILE_KEY_UPDATE DataMessage_Flags = 4 - DataMessage_FORWARD DataMessage_Flags = 8 ) // Enum value maps for DataMessage_Flags. @@ -326,13 +355,11 @@ var ( 1: "END_SESSION", 2: "EXPIRATION_TIMER_UPDATE", 4: "PROFILE_KEY_UPDATE", - 8: "FORWARD", } DataMessage_Flags_value = map[string]int32{ "END_SESSION": 1, "EXPIRATION_TIMER_UPDATE": 2, "PROFILE_KEY_UPDATE": 4, - "FORWARD": 8, } ) @@ -347,11 +374,11 @@ func (x DataMessage_Flags) String() string { } func (DataMessage_Flags) Descriptor() protoreflect.EnumDescriptor { - return file_SignalService_proto_enumTypes[4].Descriptor() + return file_SignalService_proto_enumTypes[5].Descriptor() } func (DataMessage_Flags) Type() protoreflect.EnumType { - return &file_SignalService_proto_enumTypes[4] + return &file_SignalService_proto_enumTypes[5] } func (x DataMessage_Flags) Number() protoreflect.EnumNumber { @@ -370,7 +397,7 @@ func (x *DataMessage_Flags) UnmarshalJSON(b []byte) error { // Deprecated: Use DataMessage_Flags.Descriptor instead. func (DataMessage_Flags) EnumDescriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 0} + return file_SignalService_proto_rawDescGZIP(), []int{4, 0} } type DataMessage_ProtocolVersion int32 @@ -384,8 +411,7 @@ const ( DataMessage_CDN_SELECTOR_ATTACHMENTS DataMessage_ProtocolVersion = 5 DataMessage_MENTIONS DataMessage_ProtocolVersion = 6 DataMessage_PAYMENTS DataMessage_ProtocolVersion = 7 - DataMessage_POLLS DataMessage_ProtocolVersion = 8 - DataMessage_CURRENT DataMessage_ProtocolVersion = 8 + DataMessage_CURRENT DataMessage_ProtocolVersion = 7 ) // Enum value maps for DataMessage_ProtocolVersion. @@ -399,8 +425,7 @@ var ( 5: "CDN_SELECTOR_ATTACHMENTS", 6: "MENTIONS", 7: "PAYMENTS", - 8: "POLLS", - // Duplicate value: 8: "CURRENT", + // Duplicate value: 7: "CURRENT", } DataMessage_ProtocolVersion_value = map[string]int32{ "INITIAL": 0, @@ -411,8 +436,7 @@ var ( "CDN_SELECTOR_ATTACHMENTS": 5, "MENTIONS": 6, "PAYMENTS": 7, - "POLLS": 8, - "CURRENT": 8, + "CURRENT": 7, } ) @@ -427,11 +451,11 @@ func (x DataMessage_ProtocolVersion) String() string { } func (DataMessage_ProtocolVersion) Descriptor() protoreflect.EnumDescriptor { - return file_SignalService_proto_enumTypes[5].Descriptor() + return file_SignalService_proto_enumTypes[6].Descriptor() } func (DataMessage_ProtocolVersion) Type() protoreflect.EnumType { - return &file_SignalService_proto_enumTypes[5] + return &file_SignalService_proto_enumTypes[6] } func (x DataMessage_ProtocolVersion) Number() protoreflect.EnumNumber { @@ -450,63 +474,7 @@ func (x *DataMessage_ProtocolVersion) UnmarshalJSON(b []byte) error { // Deprecated: Use DataMessage_ProtocolVersion.Descriptor instead. func (DataMessage_ProtocolVersion) EnumDescriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 1} -} - -type DataMessage_Payment_Activation_Type int32 - -const ( - DataMessage_Payment_Activation_REQUEST DataMessage_Payment_Activation_Type = 0 - DataMessage_Payment_Activation_ACTIVATED DataMessage_Payment_Activation_Type = 1 -) - -// Enum value maps for DataMessage_Payment_Activation_Type. -var ( - DataMessage_Payment_Activation_Type_name = map[int32]string{ - 0: "REQUEST", - 1: "ACTIVATED", - } - DataMessage_Payment_Activation_Type_value = map[string]int32{ - "REQUEST": 0, - "ACTIVATED": 1, - } -) - -func (x DataMessage_Payment_Activation_Type) Enum() *DataMessage_Payment_Activation_Type { - p := new(DataMessage_Payment_Activation_Type) - *p = x - return p -} - -func (x DataMessage_Payment_Activation_Type) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (DataMessage_Payment_Activation_Type) Descriptor() protoreflect.EnumDescriptor { - return file_SignalService_proto_enumTypes[6].Descriptor() -} - -func (DataMessage_Payment_Activation_Type) Type() protoreflect.EnumType { - return &file_SignalService_proto_enumTypes[6] -} - -func (x DataMessage_Payment_Activation_Type) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Do not use. -func (x *DataMessage_Payment_Activation_Type) UnmarshalJSON(b []byte) error { - num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) - if err != nil { - return err - } - *x = DataMessage_Payment_Activation_Type(num) - return nil -} - -// Deprecated: Use DataMessage_Payment_Activation_Type.Descriptor instead. -func (DataMessage_Payment_Activation_Type) EnumDescriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 0, 2, 0} + return file_SignalService_proto_rawDescGZIP(), []int{4, 1} } type DataMessage_Quote_Type int32 @@ -514,7 +482,6 @@ type DataMessage_Quote_Type int32 const ( DataMessage_Quote_NORMAL DataMessage_Quote_Type = 0 DataMessage_Quote_GIFT_BADGE DataMessage_Quote_Type = 1 - DataMessage_Quote_POLL DataMessage_Quote_Type = 2 ) // Enum value maps for DataMessage_Quote_Type. @@ -522,12 +489,10 @@ var ( DataMessage_Quote_Type_name = map[int32]string{ 0: "NORMAL", 1: "GIFT_BADGE", - 2: "POLL", } DataMessage_Quote_Type_value = map[string]int32{ "NORMAL": 0, "GIFT_BADGE": 1, - "POLL": 2, } ) @@ -565,7 +530,7 @@ func (x *DataMessage_Quote_Type) UnmarshalJSON(b []byte) error { // Deprecated: Use DataMessage_Quote_Type.Descriptor instead. func (DataMessage_Quote_Type) EnumDescriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 1, 0} + return file_SignalService_proto_rawDescGZIP(), []int{4, 0, 0} } type DataMessage_Contact_Phone_Type int32 @@ -627,7 +592,7 @@ func (x *DataMessage_Contact_Phone_Type) UnmarshalJSON(b []byte) error { // Deprecated: Use DataMessage_Contact_Phone_Type.Descriptor instead. func (DataMessage_Contact_Phone_Type) EnumDescriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 2, 1, 0} + return file_SignalService_proto_rawDescGZIP(), []int{4, 1, 1, 0} } type DataMessage_Contact_Email_Type int32 @@ -689,7 +654,7 @@ func (x *DataMessage_Contact_Email_Type) UnmarshalJSON(b []byte) error { // Deprecated: Use DataMessage_Contact_Email_Type.Descriptor instead. func (DataMessage_Contact_Email_Type) EnumDescriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 2, 2, 0} + return file_SignalService_proto_rawDescGZIP(), []int{4, 1, 2, 0} } type DataMessage_Contact_PostalAddress_Type int32 @@ -748,7 +713,63 @@ func (x *DataMessage_Contact_PostalAddress_Type) UnmarshalJSON(b []byte) error { // Deprecated: Use DataMessage_Contact_PostalAddress_Type.Descriptor instead. func (DataMessage_Contact_PostalAddress_Type) EnumDescriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 2, 3, 0} + return file_SignalService_proto_rawDescGZIP(), []int{4, 1, 3, 0} +} + +type DataMessage_Payment_Activation_Type int32 + +const ( + DataMessage_Payment_Activation_REQUEST DataMessage_Payment_Activation_Type = 0 + DataMessage_Payment_Activation_ACTIVATED DataMessage_Payment_Activation_Type = 1 +) + +// Enum value maps for DataMessage_Payment_Activation_Type. +var ( + DataMessage_Payment_Activation_Type_name = map[int32]string{ + 0: "REQUEST", + 1: "ACTIVATED", + } + DataMessage_Payment_Activation_Type_value = map[string]int32{ + "REQUEST": 0, + "ACTIVATED": 1, + } +) + +func (x DataMessage_Payment_Activation_Type) Enum() *DataMessage_Payment_Activation_Type { + p := new(DataMessage_Payment_Activation_Type) + *p = x + return p +} + +func (x DataMessage_Payment_Activation_Type) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (DataMessage_Payment_Activation_Type) Descriptor() protoreflect.EnumDescriptor { + return file_SignalService_proto_enumTypes[11].Descriptor() +} + +func (DataMessage_Payment_Activation_Type) Type() protoreflect.EnumType { + return &file_SignalService_proto_enumTypes[11] +} + +func (x DataMessage_Payment_Activation_Type) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Do not use. +func (x *DataMessage_Payment_Activation_Type) UnmarshalJSON(b []byte) error { + num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) + if err != nil { + return err + } + *x = DataMessage_Payment_Activation_Type(num) + return nil +} + +// Deprecated: Use DataMessage_Payment_Activation_Type.Descriptor instead. +func (DataMessage_Payment_Activation_Type) EnumDescriptor() ([]byte, []int) { + return file_SignalService_proto_rawDescGZIP(), []int{4, 7, 2, 0} } type ReceiptMessage_Type int32 @@ -784,11 +805,11 @@ func (x ReceiptMessage_Type) String() string { } func (ReceiptMessage_Type) Descriptor() protoreflect.EnumDescriptor { - return file_SignalService_proto_enumTypes[11].Descriptor() + return file_SignalService_proto_enumTypes[12].Descriptor() } func (ReceiptMessage_Type) Type() protoreflect.EnumType { - return &file_SignalService_proto_enumTypes[11] + return &file_SignalService_proto_enumTypes[12] } func (x ReceiptMessage_Type) Number() protoreflect.EnumNumber { @@ -807,7 +828,7 @@ func (x *ReceiptMessage_Type) UnmarshalJSON(b []byte) error { // Deprecated: Use ReceiptMessage_Type.Descriptor instead. func (ReceiptMessage_Type) EnumDescriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{5, 0} + return file_SignalService_proto_rawDescGZIP(), []int{6, 0} } type TypingMessage_Action int32 @@ -840,11 +861,11 @@ func (x TypingMessage_Action) String() string { } func (TypingMessage_Action) Descriptor() protoreflect.EnumDescriptor { - return file_SignalService_proto_enumTypes[12].Descriptor() + return file_SignalService_proto_enumTypes[13].Descriptor() } func (TypingMessage_Action) Type() protoreflect.EnumType { - return &file_SignalService_proto_enumTypes[12] + return &file_SignalService_proto_enumTypes[13] } func (x TypingMessage_Action) Number() protoreflect.EnumNumber { @@ -863,7 +884,7 @@ func (x *TypingMessage_Action) UnmarshalJSON(b []byte) error { // Deprecated: Use TypingMessage_Action.Descriptor instead. func (TypingMessage_Action) EnumDescriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{6, 0} + return file_SignalService_proto_rawDescGZIP(), []int{7, 0} } type TextAttachment_Style int32 @@ -908,11 +929,11 @@ func (x TextAttachment_Style) String() string { } func (TextAttachment_Style) Descriptor() protoreflect.EnumDescriptor { - return file_SignalService_proto_enumTypes[13].Descriptor() + return file_SignalService_proto_enumTypes[14].Descriptor() } func (TextAttachment_Style) Type() protoreflect.EnumType { - return &file_SignalService_proto_enumTypes[13] + return &file_SignalService_proto_enumTypes[14] } func (x TextAttachment_Style) Number() protoreflect.EnumNumber { @@ -931,7 +952,7 @@ func (x *TextAttachment_Style) UnmarshalJSON(b []byte) error { // Deprecated: Use TextAttachment_Style.Descriptor instead. func (TextAttachment_Style) EnumDescriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{9, 0} + return file_SignalService_proto_rawDescGZIP(), []int{10, 0} } type Verified_State int32 @@ -967,11 +988,11 @@ func (x Verified_State) String() string { } func (Verified_State) Descriptor() protoreflect.EnumDescriptor { - return file_SignalService_proto_enumTypes[14].Descriptor() + return file_SignalService_proto_enumTypes[15].Descriptor() } func (Verified_State) Type() protoreflect.EnumType { - return &file_SignalService_proto_enumTypes[14] + return &file_SignalService_proto_enumTypes[15] } func (x Verified_State) Number() protoreflect.EnumNumber { @@ -990,17 +1011,19 @@ func (x *Verified_State) UnmarshalJSON(b []byte) error { // Deprecated: Use Verified_State.Descriptor instead. func (Verified_State) EnumDescriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{10, 0} + return file_SignalService_proto_rawDescGZIP(), []int{11, 0} } type SyncMessage_Request_Type int32 const ( - SyncMessage_Request_UNKNOWN SyncMessage_Request_Type = 0 - SyncMessage_Request_CONTACTS SyncMessage_Request_Type = 1 + SyncMessage_Request_UNKNOWN SyncMessage_Request_Type = 0 + SyncMessage_Request_CONTACTS SyncMessage_Request_Type = 1 + // GROUPS = 2; SyncMessage_Request_BLOCKED SyncMessage_Request_Type = 3 SyncMessage_Request_CONFIGURATION SyncMessage_Request_Type = 4 SyncMessage_Request_KEYS SyncMessage_Request_Type = 5 + SyncMessage_Request_PNI_IDENTITY SyncMessage_Request_Type = 6 ) // Enum value maps for SyncMessage_Request_Type. @@ -1011,6 +1034,7 @@ var ( 3: "BLOCKED", 4: "CONFIGURATION", 5: "KEYS", + 6: "PNI_IDENTITY", } SyncMessage_Request_Type_value = map[string]int32{ "UNKNOWN": 0, @@ -1018,6 +1042,7 @@ var ( "BLOCKED": 3, "CONFIGURATION": 4, "KEYS": 5, + "PNI_IDENTITY": 6, } ) @@ -1032,11 +1057,11 @@ func (x SyncMessage_Request_Type) String() string { } func (SyncMessage_Request_Type) Descriptor() protoreflect.EnumDescriptor { - return file_SignalService_proto_enumTypes[15].Descriptor() + return file_SignalService_proto_enumTypes[16].Descriptor() } func (SyncMessage_Request_Type) Type() protoreflect.EnumType { - return &file_SignalService_proto_enumTypes[15] + return &file_SignalService_proto_enumTypes[16] } func (x SyncMessage_Request_Type) Number() protoreflect.EnumNumber { @@ -1055,7 +1080,7 @@ func (x *SyncMessage_Request_Type) UnmarshalJSON(b []byte) error { // Deprecated: Use SyncMessage_Request_Type.Descriptor instead. func (SyncMessage_Request_Type) EnumDescriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 3, 0} + return file_SignalService_proto_rawDescGZIP(), []int{12, 3, 0} } type SyncMessage_StickerPackOperation_Type int32 @@ -1088,11 +1113,11 @@ func (x SyncMessage_StickerPackOperation_Type) String() string { } func (SyncMessage_StickerPackOperation_Type) Descriptor() protoreflect.EnumDescriptor { - return file_SignalService_proto_enumTypes[16].Descriptor() + return file_SignalService_proto_enumTypes[17].Descriptor() } func (SyncMessage_StickerPackOperation_Type) Type() protoreflect.EnumType { - return &file_SignalService_proto_enumTypes[16] + return &file_SignalService_proto_enumTypes[17] } func (x SyncMessage_StickerPackOperation_Type) Number() protoreflect.EnumNumber { @@ -1111,7 +1136,7 @@ func (x *SyncMessage_StickerPackOperation_Type) UnmarshalJSON(b []byte) error { // Deprecated: Use SyncMessage_StickerPackOperation_Type.Descriptor instead. func (SyncMessage_StickerPackOperation_Type) EnumDescriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 7, 0} + return file_SignalService_proto_rawDescGZIP(), []int{12, 7, 0} } type SyncMessage_FetchLatest_Type int32 @@ -1150,11 +1175,11 @@ func (x SyncMessage_FetchLatest_Type) String() string { } func (SyncMessage_FetchLatest_Type) Descriptor() protoreflect.EnumDescriptor { - return file_SignalService_proto_enumTypes[17].Descriptor() + return file_SignalService_proto_enumTypes[18].Descriptor() } func (SyncMessage_FetchLatest_Type) Type() protoreflect.EnumType { - return &file_SignalService_proto_enumTypes[17] + return &file_SignalService_proto_enumTypes[18] } func (x SyncMessage_FetchLatest_Type) Number() protoreflect.EnumNumber { @@ -1173,7 +1198,7 @@ func (x *SyncMessage_FetchLatest_Type) UnmarshalJSON(b []byte) error { // Deprecated: Use SyncMessage_FetchLatest_Type.Descriptor instead. func (SyncMessage_FetchLatest_Type) EnumDescriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 9, 0} + return file_SignalService_proto_rawDescGZIP(), []int{12, 9, 0} } type SyncMessage_MessageRequestResponse_Type int32 @@ -1184,8 +1209,6 @@ const ( SyncMessage_MessageRequestResponse_DELETE SyncMessage_MessageRequestResponse_Type = 2 SyncMessage_MessageRequestResponse_BLOCK SyncMessage_MessageRequestResponse_Type = 3 SyncMessage_MessageRequestResponse_BLOCK_AND_DELETE SyncMessage_MessageRequestResponse_Type = 4 - SyncMessage_MessageRequestResponse_SPAM SyncMessage_MessageRequestResponse_Type = 5 - SyncMessage_MessageRequestResponse_BLOCK_AND_SPAM SyncMessage_MessageRequestResponse_Type = 6 ) // Enum value maps for SyncMessage_MessageRequestResponse_Type. @@ -1196,8 +1219,6 @@ var ( 2: "DELETE", 3: "BLOCK", 4: "BLOCK_AND_DELETE", - 5: "SPAM", - 6: "BLOCK_AND_SPAM", } SyncMessage_MessageRequestResponse_Type_value = map[string]int32{ "UNKNOWN": 0, @@ -1205,8 +1226,6 @@ var ( "DELETE": 2, "BLOCK": 3, "BLOCK_AND_DELETE": 4, - "SPAM": 5, - "BLOCK_AND_SPAM": 6, } ) @@ -1221,11 +1240,11 @@ func (x SyncMessage_MessageRequestResponse_Type) String() string { } func (SyncMessage_MessageRequestResponse_Type) Descriptor() protoreflect.EnumDescriptor { - return file_SignalService_proto_enumTypes[18].Descriptor() + return file_SignalService_proto_enumTypes[19].Descriptor() } func (SyncMessage_MessageRequestResponse_Type) Type() protoreflect.EnumType { - return &file_SignalService_proto_enumTypes[18] + return &file_SignalService_proto_enumTypes[19] } func (x SyncMessage_MessageRequestResponse_Type) Number() protoreflect.EnumNumber { @@ -1244,7 +1263,7 @@ func (x *SyncMessage_MessageRequestResponse_Type) UnmarshalJSON(b []byte) error // Deprecated: Use SyncMessage_MessageRequestResponse_Type.Descriptor instead. func (SyncMessage_MessageRequestResponse_Type) EnumDescriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 12, 0} + return file_SignalService_proto_rawDescGZIP(), []int{12, 11, 0} } type SyncMessage_CallEvent_Type int32 @@ -1286,11 +1305,11 @@ func (x SyncMessage_CallEvent_Type) String() string { } func (SyncMessage_CallEvent_Type) Descriptor() protoreflect.EnumDescriptor { - return file_SignalService_proto_enumTypes[19].Descriptor() + return file_SignalService_proto_enumTypes[20].Descriptor() } func (SyncMessage_CallEvent_Type) Type() protoreflect.EnumType { - return &file_SignalService_proto_enumTypes[19] + return &file_SignalService_proto_enumTypes[20] } func (x SyncMessage_CallEvent_Type) Number() protoreflect.EnumNumber { @@ -1309,7 +1328,7 @@ func (x *SyncMessage_CallEvent_Type) UnmarshalJSON(b []byte) error { // Deprecated: Use SyncMessage_CallEvent_Type.Descriptor instead. func (SyncMessage_CallEvent_Type) EnumDescriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 15, 0} + return file_SignalService_proto_rawDescGZIP(), []int{12, 14, 0} } type SyncMessage_CallEvent_Direction int32 @@ -1345,11 +1364,11 @@ func (x SyncMessage_CallEvent_Direction) String() string { } func (SyncMessage_CallEvent_Direction) Descriptor() protoreflect.EnumDescriptor { - return file_SignalService_proto_enumTypes[20].Descriptor() + return file_SignalService_proto_enumTypes[21].Descriptor() } func (SyncMessage_CallEvent_Direction) Type() protoreflect.EnumType { - return &file_SignalService_proto_enumTypes[20] + return &file_SignalService_proto_enumTypes[21] } func (x SyncMessage_CallEvent_Direction) Number() protoreflect.EnumNumber { @@ -1368,34 +1387,31 @@ func (x *SyncMessage_CallEvent_Direction) UnmarshalJSON(b []byte) error { // Deprecated: Use SyncMessage_CallEvent_Direction.Descriptor instead. func (SyncMessage_CallEvent_Direction) EnumDescriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 15, 1} + return file_SignalService_proto_rawDescGZIP(), []int{12, 14, 1} } type SyncMessage_CallEvent_Event int32 const ( - SyncMessage_CallEvent_UNKNOWN_EVENT SyncMessage_CallEvent_Event = 0 - SyncMessage_CallEvent_ACCEPTED SyncMessage_CallEvent_Event = 1 - SyncMessage_CallEvent_NOT_ACCEPTED SyncMessage_CallEvent_Event = 2 - SyncMessage_CallEvent_DELETE SyncMessage_CallEvent_Event = 3 - SyncMessage_CallEvent_OBSERVED SyncMessage_CallEvent_Event = 4 + SyncMessage_CallEvent_UNKNOWN_ACTION SyncMessage_CallEvent_Event = 0 + SyncMessage_CallEvent_ACCEPTED SyncMessage_CallEvent_Event = 1 + SyncMessage_CallEvent_NOT_ACCEPTED SyncMessage_CallEvent_Event = 2 + SyncMessage_CallEvent_DELETE SyncMessage_CallEvent_Event = 3 ) // Enum value maps for SyncMessage_CallEvent_Event. var ( SyncMessage_CallEvent_Event_name = map[int32]string{ - 0: "UNKNOWN_EVENT", + 0: "UNKNOWN_ACTION", 1: "ACCEPTED", 2: "NOT_ACCEPTED", 3: "DELETE", - 4: "OBSERVED", } SyncMessage_CallEvent_Event_value = map[string]int32{ - "UNKNOWN_EVENT": 0, - "ACCEPTED": 1, - "NOT_ACCEPTED": 2, - "DELETE": 3, - "OBSERVED": 4, + "UNKNOWN_ACTION": 0, + "ACCEPTED": 1, + "NOT_ACCEPTED": 2, + "DELETE": 3, } ) @@ -1410,11 +1426,11 @@ func (x SyncMessage_CallEvent_Event) String() string { } func (SyncMessage_CallEvent_Event) Descriptor() protoreflect.EnumDescriptor { - return file_SignalService_proto_enumTypes[21].Descriptor() + return file_SignalService_proto_enumTypes[22].Descriptor() } func (SyncMessage_CallEvent_Event) Type() protoreflect.EnumType { - return &file_SignalService_proto_enumTypes[21] + return &file_SignalService_proto_enumTypes[22] } func (x SyncMessage_CallEvent_Event) Number() protoreflect.EnumNumber { @@ -1433,84 +1449,22 @@ func (x *SyncMessage_CallEvent_Event) UnmarshalJSON(b []byte) error { // Deprecated: Use SyncMessage_CallEvent_Event.Descriptor instead. func (SyncMessage_CallEvent_Event) EnumDescriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 15, 2} -} - -type SyncMessage_CallLinkUpdate_Type int32 - -const ( - SyncMessage_CallLinkUpdate_UPDATE SyncMessage_CallLinkUpdate_Type = 0 -) - -// Enum value maps for SyncMessage_CallLinkUpdate_Type. -var ( - SyncMessage_CallLinkUpdate_Type_name = map[int32]string{ - 0: "UPDATE", - } - SyncMessage_CallLinkUpdate_Type_value = map[string]int32{ - "UPDATE": 0, - } -) - -func (x SyncMessage_CallLinkUpdate_Type) Enum() *SyncMessage_CallLinkUpdate_Type { - p := new(SyncMessage_CallLinkUpdate_Type) - *p = x - return p -} - -func (x SyncMessage_CallLinkUpdate_Type) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (SyncMessage_CallLinkUpdate_Type) Descriptor() protoreflect.EnumDescriptor { - return file_SignalService_proto_enumTypes[22].Descriptor() -} - -func (SyncMessage_CallLinkUpdate_Type) Type() protoreflect.EnumType { - return &file_SignalService_proto_enumTypes[22] -} - -func (x SyncMessage_CallLinkUpdate_Type) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Do not use. -func (x *SyncMessage_CallLinkUpdate_Type) UnmarshalJSON(b []byte) error { - num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) - if err != nil { - return err - } - *x = SyncMessage_CallLinkUpdate_Type(num) - return nil -} - -// Deprecated: Use SyncMessage_CallLinkUpdate_Type.Descriptor instead. -func (SyncMessage_CallLinkUpdate_Type) EnumDescriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 16, 0} + return file_SignalService_proto_rawDescGZIP(), []int{12, 14, 2} } type SyncMessage_CallLogEvent_Type int32 const ( - SyncMessage_CallLogEvent_CLEAR SyncMessage_CallLogEvent_Type = 0 - SyncMessage_CallLogEvent_MARKED_AS_READ SyncMessage_CallLogEvent_Type = 1 - SyncMessage_CallLogEvent_MARKED_AS_READ_IN_CONVERSATION SyncMessage_CallLogEvent_Type = 2 - SyncMessage_CallLogEvent_CLEAR_IN_CONVERSATION SyncMessage_CallLogEvent_Type = 3 + SyncMessage_CallLogEvent_CLEAR SyncMessage_CallLogEvent_Type = 0 ) // Enum value maps for SyncMessage_CallLogEvent_Type. var ( SyncMessage_CallLogEvent_Type_name = map[int32]string{ 0: "CLEAR", - 1: "MARKED_AS_READ", - 2: "MARKED_AS_READ_IN_CONVERSATION", - 3: "CLEAR_IN_CONVERSATION", } SyncMessage_CallLogEvent_Type_value = map[string]int32{ - "CLEAR": 0, - "MARKED_AS_READ": 1, - "MARKED_AS_READ_IN_CONVERSATION": 2, - "CLEAR_IN_CONVERSATION": 3, + "CLEAR": 0, } ) @@ -1548,116 +1502,7 @@ func (x *SyncMessage_CallLogEvent_Type) UnmarshalJSON(b []byte) error { // Deprecated: Use SyncMessage_CallLogEvent_Type.Descriptor instead. func (SyncMessage_CallLogEvent_Type) EnumDescriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 17, 0} -} - -type SyncMessage_AttachmentBackfillResponse_Error int32 - -const ( - SyncMessage_AttachmentBackfillResponse_MESSAGE_NOT_FOUND SyncMessage_AttachmentBackfillResponse_Error = 0 -) - -// Enum value maps for SyncMessage_AttachmentBackfillResponse_Error. -var ( - SyncMessage_AttachmentBackfillResponse_Error_name = map[int32]string{ - 0: "MESSAGE_NOT_FOUND", - } - SyncMessage_AttachmentBackfillResponse_Error_value = map[string]int32{ - "MESSAGE_NOT_FOUND": 0, - } -) - -func (x SyncMessage_AttachmentBackfillResponse_Error) Enum() *SyncMessage_AttachmentBackfillResponse_Error { - p := new(SyncMessage_AttachmentBackfillResponse_Error) - *p = x - return p -} - -func (x SyncMessage_AttachmentBackfillResponse_Error) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (SyncMessage_AttachmentBackfillResponse_Error) Descriptor() protoreflect.EnumDescriptor { - return file_SignalService_proto_enumTypes[24].Descriptor() -} - -func (SyncMessage_AttachmentBackfillResponse_Error) Type() protoreflect.EnumType { - return &file_SignalService_proto_enumTypes[24] -} - -func (x SyncMessage_AttachmentBackfillResponse_Error) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Do not use. -func (x *SyncMessage_AttachmentBackfillResponse_Error) UnmarshalJSON(b []byte) error { - num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) - if err != nil { - return err - } - *x = SyncMessage_AttachmentBackfillResponse_Error(num) - return nil -} - -// Deprecated: Use SyncMessage_AttachmentBackfillResponse_Error.Descriptor instead. -func (SyncMessage_AttachmentBackfillResponse_Error) EnumDescriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 21, 0} -} - -type SyncMessage_AttachmentBackfillResponse_AttachmentData_Status int32 - -const ( - SyncMessage_AttachmentBackfillResponse_AttachmentData_PENDING SyncMessage_AttachmentBackfillResponse_AttachmentData_Status = 0 - SyncMessage_AttachmentBackfillResponse_AttachmentData_TERMINAL_ERROR SyncMessage_AttachmentBackfillResponse_AttachmentData_Status = 1 -) - -// Enum value maps for SyncMessage_AttachmentBackfillResponse_AttachmentData_Status. -var ( - SyncMessage_AttachmentBackfillResponse_AttachmentData_Status_name = map[int32]string{ - 0: "PENDING", - 1: "TERMINAL_ERROR", - } - SyncMessage_AttachmentBackfillResponse_AttachmentData_Status_value = map[string]int32{ - "PENDING": 0, - "TERMINAL_ERROR": 1, - } -) - -func (x SyncMessage_AttachmentBackfillResponse_AttachmentData_Status) Enum() *SyncMessage_AttachmentBackfillResponse_AttachmentData_Status { - p := new(SyncMessage_AttachmentBackfillResponse_AttachmentData_Status) - *p = x - return p -} - -func (x SyncMessage_AttachmentBackfillResponse_AttachmentData_Status) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (SyncMessage_AttachmentBackfillResponse_AttachmentData_Status) Descriptor() protoreflect.EnumDescriptor { - return file_SignalService_proto_enumTypes[25].Descriptor() -} - -func (SyncMessage_AttachmentBackfillResponse_AttachmentData_Status) Type() protoreflect.EnumType { - return &file_SignalService_proto_enumTypes[25] -} - -func (x SyncMessage_AttachmentBackfillResponse_AttachmentData_Status) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Do not use. -func (x *SyncMessage_AttachmentBackfillResponse_AttachmentData_Status) UnmarshalJSON(b []byte) error { - num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) - if err != nil { - return err - } - *x = SyncMessage_AttachmentBackfillResponse_AttachmentData_Status(num) - return nil -} - -// Deprecated: Use SyncMessage_AttachmentBackfillResponse_AttachmentData_Status.Descriptor instead. -func (SyncMessage_AttachmentBackfillResponse_AttachmentData_Status) EnumDescriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 21, 0, 0} + return file_SignalService_proto_rawDescGZIP(), []int{12, 16, 0} } type AttachmentPointer_Flags int32 @@ -1665,7 +1510,7 @@ type AttachmentPointer_Flags int32 const ( AttachmentPointer_VOICE_MESSAGE AttachmentPointer_Flags = 1 AttachmentPointer_BORDERLESS AttachmentPointer_Flags = 2 - AttachmentPointer_GIF AttachmentPointer_Flags = 8 + AttachmentPointer_GIF AttachmentPointer_Flags = 4 ) // Enum value maps for AttachmentPointer_Flags. @@ -1673,12 +1518,12 @@ var ( AttachmentPointer_Flags_name = map[int32]string{ 1: "VOICE_MESSAGE", 2: "BORDERLESS", - 8: "GIF", + 4: "GIF", } AttachmentPointer_Flags_value = map[string]int32{ "VOICE_MESSAGE": 1, "BORDERLESS": 2, - "GIF": 8, + "GIF": 4, } ) @@ -1693,11 +1538,11 @@ func (x AttachmentPointer_Flags) String() string { } func (AttachmentPointer_Flags) Descriptor() protoreflect.EnumDescriptor { - return file_SignalService_proto_enumTypes[26].Descriptor() + return file_SignalService_proto_enumTypes[24].Descriptor() } func (AttachmentPointer_Flags) Type() protoreflect.EnumType { - return &file_SignalService_proto_enumTypes[26] + return &file_SignalService_proto_enumTypes[24] } func (x AttachmentPointer_Flags) Number() protoreflect.EnumNumber { @@ -1716,98 +1561,90 @@ func (x *AttachmentPointer_Flags) UnmarshalJSON(b []byte) error { // Deprecated: Use AttachmentPointer_Flags.Descriptor instead. func (AttachmentPointer_Flags) EnumDescriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{12, 0} + return file_SignalService_proto_rawDescGZIP(), []int{13, 0} } -type BodyRange_Style int32 +type GroupContext_Type int32 const ( - BodyRange_NONE BodyRange_Style = 0 - BodyRange_BOLD BodyRange_Style = 1 - BodyRange_ITALIC BodyRange_Style = 2 - BodyRange_SPOILER BodyRange_Style = 3 - BodyRange_STRIKETHROUGH BodyRange_Style = 4 - BodyRange_MONOSPACE BodyRange_Style = 5 + GroupContext_UNKNOWN GroupContext_Type = 0 + GroupContext_UPDATE GroupContext_Type = 1 + GroupContext_DELIVER GroupContext_Type = 2 + GroupContext_QUIT GroupContext_Type = 3 + GroupContext_REQUEST_INFO GroupContext_Type = 4 ) -// Enum value maps for BodyRange_Style. +// Enum value maps for GroupContext_Type. var ( - BodyRange_Style_name = map[int32]string{ - 0: "NONE", - 1: "BOLD", - 2: "ITALIC", - 3: "SPOILER", - 4: "STRIKETHROUGH", - 5: "MONOSPACE", + GroupContext_Type_name = map[int32]string{ + 0: "UNKNOWN", + 1: "UPDATE", + 2: "DELIVER", + 3: "QUIT", + 4: "REQUEST_INFO", } - BodyRange_Style_value = map[string]int32{ - "NONE": 0, - "BOLD": 1, - "ITALIC": 2, - "SPOILER": 3, - "STRIKETHROUGH": 4, - "MONOSPACE": 5, + GroupContext_Type_value = map[string]int32{ + "UNKNOWN": 0, + "UPDATE": 1, + "DELIVER": 2, + "QUIT": 3, + "REQUEST_INFO": 4, } ) -func (x BodyRange_Style) Enum() *BodyRange_Style { - p := new(BodyRange_Style) +func (x GroupContext_Type) Enum() *GroupContext_Type { + p := new(GroupContext_Type) *p = x return p } -func (x BodyRange_Style) String() string { +func (x GroupContext_Type) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } -func (BodyRange_Style) Descriptor() protoreflect.EnumDescriptor { - return file_SignalService_proto_enumTypes[27].Descriptor() +func (GroupContext_Type) Descriptor() protoreflect.EnumDescriptor { + return file_SignalService_proto_enumTypes[25].Descriptor() } -func (BodyRange_Style) Type() protoreflect.EnumType { - return &file_SignalService_proto_enumTypes[27] +func (GroupContext_Type) Type() protoreflect.EnumType { + return &file_SignalService_proto_enumTypes[25] } -func (x BodyRange_Style) Number() protoreflect.EnumNumber { +func (x GroupContext_Type) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // Deprecated: Do not use. -func (x *BodyRange_Style) UnmarshalJSON(b []byte) error { +func (x *GroupContext_Type) UnmarshalJSON(b []byte) error { num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) if err != nil { return err } - *x = BodyRange_Style(num) + *x = GroupContext_Type(num) return nil } -// Deprecated: Use BodyRange_Style.Descriptor instead. -func (BodyRange_Style) EnumDescriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{19, 0} +// Deprecated: Use GroupContext_Type.Descriptor instead. +func (GroupContext_Type) EnumDescriptor() ([]byte, []int) { + return file_SignalService_proto_rawDescGZIP(), []int{14, 0} } type Envelope struct { - state protoimpl.MessageState `protogen:"open.v1"` - Type *Envelope_Type `protobuf:"varint,1,opt,name=type,enum=signalservice.Envelope_Type" json:"type,omitempty"` - SourceServiceId *string `protobuf:"bytes,11,opt,name=sourceServiceId" json:"sourceServiceId,omitempty"` - SourceDeviceId *uint32 `protobuf:"varint,7,opt,name=sourceDeviceId" json:"sourceDeviceId,omitempty"` - DestinationServiceId *string `protobuf:"bytes,13,opt,name=destinationServiceId" json:"destinationServiceId,omitempty"` - ClientTimestamp *uint64 `protobuf:"varint,5,opt,name=clientTimestamp" json:"clientTimestamp,omitempty"` - Content []byte `protobuf:"bytes,8,opt,name=content" json:"content,omitempty"` // Contains an encrypted Content - ServerGuid *string `protobuf:"bytes,9,opt,name=serverGuid" json:"serverGuid,omitempty"` - ServerTimestamp *uint64 `protobuf:"varint,10,opt,name=serverTimestamp" json:"serverTimestamp,omitempty"` - Ephemeral *bool `protobuf:"varint,12,opt,name=ephemeral" json:"ephemeral,omitempty"` // indicates that the message should not be persisted if the recipient is offline - Urgent *bool `protobuf:"varint,14,opt,name=urgent,def=1" json:"urgent,omitempty"` // indicates that the content is considered timely by the sender; defaults to true so senders have to opt-out to say something isn't time critical - UpdatedPni *string `protobuf:"bytes,15,opt,name=updatedPni" json:"updatedPni,omitempty"` // for number-change synchronization messages, provides the new server-assigned phone number identifier associated with the changed number - Story *bool `protobuf:"varint,16,opt,name=story" json:"story,omitempty"` // indicates that the content is a story. - ReportSpamToken []byte `protobuf:"bytes,17,opt,name=report_spam_token,json=reportSpamToken" json:"report_spam_token,omitempty"` // token sent when reporting spam - SourceServiceIdBinary []byte `protobuf:"bytes,19,opt,name=sourceServiceIdBinary" json:"sourceServiceIdBinary,omitempty"` // service ID binary (i.e. 16 byte UUID for ACI, 1 byte prefix + 16 byte UUID for PNI) - DestinationServiceIdBinary []byte `protobuf:"bytes,20,opt,name=destinationServiceIdBinary" json:"destinationServiceIdBinary,omitempty"` // service ID binary (i.e. 16 byte UUID for ACI, 1 byte prefix + 16 byte UUID for PNI) - ServerGuidBinary []byte `protobuf:"bytes,21,opt,name=serverGuidBinary" json:"serverGuidBinary,omitempty"` // 16-byte UUID - UpdatedPniBinary []byte `protobuf:"bytes,22,opt,name=updatedPniBinary" json:"updatedPniBinary,omitempty"` // 16-byte UUID - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Type *Envelope_Type `protobuf:"varint,1,opt,name=type,enum=signalservice.Envelope_Type" json:"type,omitempty"` + SourceServiceId *string `protobuf:"bytes,11,opt,name=sourceServiceId" json:"sourceServiceId,omitempty"` + SourceDevice *uint32 `protobuf:"varint,7,opt,name=sourceDevice" json:"sourceDevice,omitempty"` + DestinationServiceId *string `protobuf:"bytes,13,opt,name=destinationServiceId" json:"destinationServiceId,omitempty"` + Timestamp *uint64 `protobuf:"varint,5,opt,name=timestamp" json:"timestamp,omitempty"` + Content []byte `protobuf:"bytes,8,opt,name=content" json:"content,omitempty"` // Contains an encrypted Content + ServerGuid *string `protobuf:"bytes,9,opt,name=serverGuid" json:"serverGuid,omitempty"` + ServerTimestamp *uint64 `protobuf:"varint,10,opt,name=serverTimestamp" json:"serverTimestamp,omitempty"` + Urgent *bool `protobuf:"varint,14,opt,name=urgent,def=1" json:"urgent,omitempty"` + Story *bool `protobuf:"varint,16,opt,name=story" json:"story,omitempty"` + ReportingToken []byte `protobuf:"bytes,17,opt,name=reportingToken" json:"reportingToken,omitempty"` // NEXT ID: 18 } // Default values for Envelope fields. @@ -1817,9 +1654,11 @@ const ( func (x *Envelope) Reset() { *x = Envelope{} - mi := &file_SignalService_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *Envelope) String() string { @@ -1830,7 +1669,7 @@ func (*Envelope) ProtoMessage() {} func (x *Envelope) ProtoReflect() protoreflect.Message { mi := &file_SignalService_proto_msgTypes[0] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1859,9 +1698,9 @@ func (x *Envelope) GetSourceServiceId() string { return "" } -func (x *Envelope) GetSourceDeviceId() uint32 { - if x != nil && x.SourceDeviceId != nil { - return *x.SourceDeviceId +func (x *Envelope) GetSourceDevice() uint32 { + if x != nil && x.SourceDevice != nil { + return *x.SourceDevice } return 0 } @@ -1873,9 +1712,9 @@ func (x *Envelope) GetDestinationServiceId() string { return "" } -func (x *Envelope) GetClientTimestamp() uint64 { - if x != nil && x.ClientTimestamp != nil { - return *x.ClientTimestamp +func (x *Envelope) GetTimestamp() uint64 { + if x != nil && x.Timestamp != nil { + return *x.Timestamp } return 0 } @@ -1901,13 +1740,6 @@ func (x *Envelope) GetServerTimestamp() uint64 { return 0 } -func (x *Envelope) GetEphemeral() bool { - if x != nil && x.Ephemeral != nil { - return *x.Ephemeral - } - return false -} - func (x *Envelope) GetUrgent() bool { if x != nil && x.Urgent != nil { return *x.Urgent @@ -1915,13 +1747,6 @@ func (x *Envelope) GetUrgent() bool { return Default_Envelope_Urgent } -func (x *Envelope) GetUpdatedPni() string { - if x != nil && x.UpdatedPni != nil { - return *x.UpdatedPni - } - return "" -} - func (x *Envelope) GetStory() bool { if x != nil && x.Story != nil { return *x.Story @@ -1929,66 +1754,38 @@ func (x *Envelope) GetStory() bool { return false } -func (x *Envelope) GetReportSpamToken() []byte { +func (x *Envelope) GetReportingToken() []byte { if x != nil { - return x.ReportSpamToken - } - return nil -} - -func (x *Envelope) GetSourceServiceIdBinary() []byte { - if x != nil { - return x.SourceServiceIdBinary - } - return nil -} - -func (x *Envelope) GetDestinationServiceIdBinary() []byte { - if x != nil { - return x.DestinationServiceIdBinary - } - return nil -} - -func (x *Envelope) GetServerGuidBinary() []byte { - if x != nil { - return x.ServerGuidBinary - } - return nil -} - -func (x *Envelope) GetUpdatedPniBinary() []byte { - if x != nil { - return x.UpdatedPniBinary + return x.ReportingToken } return nil } type Content struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Types that are valid to be assigned to Content: - // - // *Content_DataMessage - // *Content_SyncMessage - // *Content_CallMessage - // *Content_NullMessage - // *Content_ReceiptMessage - // *Content_TypingMessage - // *Content_DecryptionErrorMessage - // *Content_StoryMessage - // *Content_EditMessage - Content isContent_Content `protobuf_oneof:"content"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + DataMessage *DataMessage `protobuf:"bytes,1,opt,name=dataMessage" json:"dataMessage,omitempty"` + SyncMessage *SyncMessage `protobuf:"bytes,2,opt,name=syncMessage" json:"syncMessage,omitempty"` + CallMessage *CallMessage `protobuf:"bytes,3,opt,name=callMessage" json:"callMessage,omitempty"` + NullMessage *NullMessage `protobuf:"bytes,4,opt,name=nullMessage" json:"nullMessage,omitempty"` + ReceiptMessage *ReceiptMessage `protobuf:"bytes,5,opt,name=receiptMessage" json:"receiptMessage,omitempty"` + TypingMessage *TypingMessage `protobuf:"bytes,6,opt,name=typingMessage" json:"typingMessage,omitempty"` SenderKeyDistributionMessage []byte `protobuf:"bytes,7,opt,name=senderKeyDistributionMessage" json:"senderKeyDistributionMessage,omitempty"` + DecryptionErrorMessage []byte `protobuf:"bytes,8,opt,name=decryptionErrorMessage" json:"decryptionErrorMessage,omitempty"` + StoryMessage *StoryMessage `protobuf:"bytes,9,opt,name=storyMessage" json:"storyMessage,omitempty"` PniSignatureMessage *PniSignatureMessage `protobuf:"bytes,10,opt,name=pniSignatureMessage" json:"pniSignatureMessage,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + EditMessage *EditMessage `protobuf:"bytes,11,opt,name=editMessage" json:"editMessage,omitempty"` } func (x *Content) Reset() { *x = Content{} - mi := &file_SignalService_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *Content) String() string { @@ -1999,7 +1796,7 @@ func (*Content) ProtoMessage() {} func (x *Content) ProtoReflect() protoreflect.Message { mi := &file_SignalService_proto_msgTypes[1] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2014,90 +1811,44 @@ func (*Content) Descriptor() ([]byte, []int) { return file_SignalService_proto_rawDescGZIP(), []int{1} } -func (x *Content) GetContent() isContent_Content { - if x != nil { - return x.Content - } - return nil -} - func (x *Content) GetDataMessage() *DataMessage { if x != nil { - if x, ok := x.Content.(*Content_DataMessage); ok { - return x.DataMessage - } + return x.DataMessage } return nil } func (x *Content) GetSyncMessage() *SyncMessage { if x != nil { - if x, ok := x.Content.(*Content_SyncMessage); ok { - return x.SyncMessage - } + return x.SyncMessage } return nil } func (x *Content) GetCallMessage() *CallMessage { if x != nil { - if x, ok := x.Content.(*Content_CallMessage); ok { - return x.CallMessage - } + return x.CallMessage } return nil } func (x *Content) GetNullMessage() *NullMessage { if x != nil { - if x, ok := x.Content.(*Content_NullMessage); ok { - return x.NullMessage - } + return x.NullMessage } return nil } func (x *Content) GetReceiptMessage() *ReceiptMessage { if x != nil { - if x, ok := x.Content.(*Content_ReceiptMessage); ok { - return x.ReceiptMessage - } + return x.ReceiptMessage } return nil } func (x *Content) GetTypingMessage() *TypingMessage { if x != nil { - if x, ok := x.Content.(*Content_TypingMessage); ok { - return x.TypingMessage - } - } - return nil -} - -func (x *Content) GetDecryptionErrorMessage() []byte { - if x != nil { - if x, ok := x.Content.(*Content_DecryptionErrorMessage); ok { - return x.DecryptionErrorMessage - } - } - return nil -} - -func (x *Content) GetStoryMessage() *StoryMessage { - if x != nil { - if x, ok := x.Content.(*Content_StoryMessage); ok { - return x.StoryMessage - } - } - return nil -} - -func (x *Content) GetEditMessage() *EditMessage { - if x != nil { - if x, ok := x.Content.(*Content_EditMessage); ok { - return x.EditMessage - } + return x.TypingMessage } return nil } @@ -2109,6 +1860,20 @@ func (x *Content) GetSenderKeyDistributionMessage() []byte { return nil } +func (x *Content) GetDecryptionErrorMessage() []byte { + if x != nil { + return x.DecryptionErrorMessage + } + return nil +} + +func (x *Content) GetStoryMessage() *StoryMessage { + if x != nil { + return x.StoryMessage + } + return nil +} + func (x *Content) GetPniSignatureMessage() *PniSignatureMessage { if x != nil { return x.PniSignatureMessage @@ -2116,82 +1881,35 @@ func (x *Content) GetPniSignatureMessage() *PniSignatureMessage { return nil } -type isContent_Content interface { - isContent_Content() +func (x *Content) GetEditMessage() *EditMessage { + if x != nil { + return x.EditMessage + } + return nil } -type Content_DataMessage struct { - DataMessage *DataMessage `protobuf:"bytes,1,opt,name=dataMessage,oneof"` -} - -type Content_SyncMessage struct { - SyncMessage *SyncMessage `protobuf:"bytes,2,opt,name=syncMessage,oneof"` -} - -type Content_CallMessage struct { - CallMessage *CallMessage `protobuf:"bytes,3,opt,name=callMessage,oneof"` -} - -type Content_NullMessage struct { - NullMessage *NullMessage `protobuf:"bytes,4,opt,name=nullMessage,oneof"` -} - -type Content_ReceiptMessage struct { - ReceiptMessage *ReceiptMessage `protobuf:"bytes,5,opt,name=receiptMessage,oneof"` -} - -type Content_TypingMessage struct { - TypingMessage *TypingMessage `protobuf:"bytes,6,opt,name=typingMessage,oneof"` -} - -type Content_DecryptionErrorMessage struct { - DecryptionErrorMessage []byte `protobuf:"bytes,8,opt,name=decryptionErrorMessage,oneof"` -} - -type Content_StoryMessage struct { - StoryMessage *StoryMessage `protobuf:"bytes,9,opt,name=storyMessage,oneof"` -} - -type Content_EditMessage struct { - EditMessage *EditMessage `protobuf:"bytes,11,opt,name=editMessage,oneof"` -} - -func (*Content_DataMessage) isContent_Content() {} - -func (*Content_SyncMessage) isContent_Content() {} - -func (*Content_CallMessage) isContent_Content() {} - -func (*Content_NullMessage) isContent_Content() {} - -func (*Content_ReceiptMessage) isContent_Content() {} - -func (*Content_TypingMessage) isContent_Content() {} - -func (*Content_DecryptionErrorMessage) isContent_Content() {} - -func (*Content_StoryMessage) isContent_Content() {} - -func (*Content_EditMessage) isContent_Content() {} - type CallMessage struct { - state protoimpl.MessageState `protogen:"open.v1"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + Offer *CallMessage_Offer `protobuf:"bytes,1,opt,name=offer" json:"offer,omitempty"` Answer *CallMessage_Answer `protobuf:"bytes,2,opt,name=answer" json:"answer,omitempty"` IceUpdate []*CallMessage_IceUpdate `protobuf:"bytes,3,rep,name=iceUpdate" json:"iceUpdate,omitempty"` + LegacyHangup *CallMessage_Hangup `protobuf:"bytes,4,opt,name=legacyHangup" json:"legacyHangup,omitempty"` Busy *CallMessage_Busy `protobuf:"bytes,5,opt,name=busy" json:"busy,omitempty"` Hangup *CallMessage_Hangup `protobuf:"bytes,7,opt,name=hangup" json:"hangup,omitempty"` DestinationDeviceId *uint32 `protobuf:"varint,9,opt,name=destinationDeviceId" json:"destinationDeviceId,omitempty"` Opaque *CallMessage_Opaque `protobuf:"bytes,10,opt,name=opaque" json:"opaque,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache } func (x *CallMessage) Reset() { *x = CallMessage{} - mi := &file_SignalService_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *CallMessage) String() string { @@ -2202,7 +1920,7 @@ func (*CallMessage) ProtoMessage() {} func (x *CallMessage) ProtoReflect() protoreflect.Message { mi := &file_SignalService_proto_msgTypes[2] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2238,6 +1956,13 @@ func (x *CallMessage) GetIceUpdate() []*CallMessage_IceUpdate { return nil } +func (x *CallMessage) GetLegacyHangup() *CallMessage_Hangup { + if x != nil { + return x.LegacyHangup + } + return nil +} + func (x *CallMessage) GetBusy() *CallMessage_Busy { if x != nil { return x.Busy @@ -2266,14 +1991,113 @@ func (x *CallMessage) GetOpaque() *CallMessage_Opaque { return nil } +type BodyRange struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Start *uint32 `protobuf:"varint,1,opt,name=start" json:"start,omitempty"` + Length *uint32 `protobuf:"varint,2,opt,name=length" json:"length,omitempty"` + // Types that are assignable to AssociatedValue: + // + // *BodyRange_MentionAci + // *BodyRange_Style_ + AssociatedValue isBodyRange_AssociatedValue `protobuf_oneof:"associatedValue"` +} + +func (x *BodyRange) Reset() { + *x = BodyRange{} + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BodyRange) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BodyRange) ProtoMessage() {} + +func (x *BodyRange) ProtoReflect() protoreflect.Message { + mi := &file_SignalService_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BodyRange.ProtoReflect.Descriptor instead. +func (*BodyRange) Descriptor() ([]byte, []int) { + return file_SignalService_proto_rawDescGZIP(), []int{3} +} + +func (x *BodyRange) GetStart() uint32 { + if x != nil && x.Start != nil { + return *x.Start + } + return 0 +} + +func (x *BodyRange) GetLength() uint32 { + if x != nil && x.Length != nil { + return *x.Length + } + return 0 +} + +func (m *BodyRange) GetAssociatedValue() isBodyRange_AssociatedValue { + if m != nil { + return m.AssociatedValue + } + return nil +} + +func (x *BodyRange) GetMentionAci() string { + if x, ok := x.GetAssociatedValue().(*BodyRange_MentionAci); ok { + return x.MentionAci + } + return "" +} + +func (x *BodyRange) GetStyle() BodyRange_Style { + if x, ok := x.GetAssociatedValue().(*BodyRange_Style_); ok { + return x.Style + } + return BodyRange_NONE +} + +type isBodyRange_AssociatedValue interface { + isBodyRange_AssociatedValue() +} + +type BodyRange_MentionAci struct { + MentionAci string `protobuf:"bytes,3,opt,name=mentionAci,oneof"` +} + +type BodyRange_Style_ struct { + Style BodyRange_Style `protobuf:"varint,4,opt,name=style,enum=signalservice.BodyRange_Style,oneof"` +} + +func (*BodyRange_MentionAci) isBodyRange_AssociatedValue() {} + +func (*BodyRange_Style_) isBodyRange_AssociatedValue() {} + type DataMessage struct { - state protoimpl.MessageState `protogen:"open.v1"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + Body *string `protobuf:"bytes,1,opt,name=body" json:"body,omitempty"` Attachments []*AttachmentPointer `protobuf:"bytes,2,rep,name=attachments" json:"attachments,omitempty"` GroupV2 *GroupContextV2 `protobuf:"bytes,15,opt,name=groupV2" json:"groupV2,omitempty"` Flags *uint32 `protobuf:"varint,4,opt,name=flags" json:"flags,omitempty"` ExpireTimer *uint32 `protobuf:"varint,5,opt,name=expireTimer" json:"expireTimer,omitempty"` - ExpireTimerVersion *uint32 `protobuf:"varint,23,opt,name=expireTimerVersion" json:"expireTimerVersion,omitempty"` ProfileKey []byte `protobuf:"bytes,6,opt,name=profileKey" json:"profileKey,omitempty"` Timestamp *uint64 `protobuf:"varint,7,opt,name=timestamp" json:"timestamp,omitempty"` Quote *DataMessage_Quote `protobuf:"bytes,8,opt,name=quote" json:"quote,omitempty"` @@ -2289,21 +2113,15 @@ type DataMessage struct { Payment *DataMessage_Payment `protobuf:"bytes,20,opt,name=payment" json:"payment,omitempty"` StoryContext *DataMessage_StoryContext `protobuf:"bytes,21,opt,name=storyContext" json:"storyContext,omitempty"` GiftBadge *DataMessage_GiftBadge `protobuf:"bytes,22,opt,name=giftBadge" json:"giftBadge,omitempty"` - PollCreate *DataMessage_PollCreate `protobuf:"bytes,24,opt,name=pollCreate" json:"pollCreate,omitempty"` - PollTerminate *DataMessage_PollTerminate `protobuf:"bytes,25,opt,name=pollTerminate" json:"pollTerminate,omitempty"` - PollVote *DataMessage_PollVote `protobuf:"bytes,26,opt,name=pollVote" json:"pollVote,omitempty"` - PinMessage *DataMessage_PinMessage `protobuf:"bytes,27,opt,name=pinMessage" json:"pinMessage,omitempty"` - UnpinMessage *DataMessage_UnpinMessage `protobuf:"bytes,28,opt,name=unpinMessage" json:"unpinMessage,omitempty"` - AdminDelete *DataMessage_AdminDelete `protobuf:"bytes,29,opt,name=adminDelete" json:"adminDelete,omitempty"` // NEXT ID: 30 - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache } func (x *DataMessage) Reset() { *x = DataMessage{} - mi := &file_SignalService_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *DataMessage) String() string { @@ -2313,8 +2131,8 @@ func (x *DataMessage) String() string { func (*DataMessage) ProtoMessage() {} func (x *DataMessage) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[3] - if x != nil { + mi := &file_SignalService_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2326,7 +2144,7 @@ func (x *DataMessage) ProtoReflect() protoreflect.Message { // Deprecated: Use DataMessage.ProtoReflect.Descriptor instead. func (*DataMessage) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3} + return file_SignalService_proto_rawDescGZIP(), []int{4} } func (x *DataMessage) GetBody() string { @@ -2364,13 +2182,6 @@ func (x *DataMessage) GetExpireTimer() uint32 { return 0 } -func (x *DataMessage) GetExpireTimerVersion() uint32 { - if x != nil && x.ExpireTimerVersion != nil { - return *x.ExpireTimerVersion - } - return 0 -} - func (x *DataMessage) GetProfileKey() []byte { if x != nil { return x.ProfileKey @@ -2476,60 +2287,21 @@ func (x *DataMessage) GetGiftBadge() *DataMessage_GiftBadge { return nil } -func (x *DataMessage) GetPollCreate() *DataMessage_PollCreate { - if x != nil { - return x.PollCreate - } - return nil -} - -func (x *DataMessage) GetPollTerminate() *DataMessage_PollTerminate { - if x != nil { - return x.PollTerminate - } - return nil -} - -func (x *DataMessage) GetPollVote() *DataMessage_PollVote { - if x != nil { - return x.PollVote - } - return nil -} - -func (x *DataMessage) GetPinMessage() *DataMessage_PinMessage { - if x != nil { - return x.PinMessage - } - return nil -} - -func (x *DataMessage) GetUnpinMessage() *DataMessage_UnpinMessage { - if x != nil { - return x.UnpinMessage - } - return nil -} - -func (x *DataMessage) GetAdminDelete() *DataMessage_AdminDelete { - if x != nil { - return x.AdminDelete - } - return nil -} - type NullMessage struct { - state protoimpl.MessageState `protogen:"open.v1"` - Padding []byte `protobuf:"bytes,1,opt,name=padding" json:"padding,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Padding []byte `protobuf:"bytes,1,opt,name=padding" json:"padding,omitempty"` } func (x *NullMessage) Reset() { *x = NullMessage{} - mi := &file_SignalService_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *NullMessage) String() string { @@ -2539,8 +2311,8 @@ func (x *NullMessage) String() string { func (*NullMessage) ProtoMessage() {} func (x *NullMessage) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[4] - if x != nil { + mi := &file_SignalService_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2552,7 +2324,7 @@ func (x *NullMessage) ProtoReflect() protoreflect.Message { // Deprecated: Use NullMessage.ProtoReflect.Descriptor instead. func (*NullMessage) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{4} + return file_SignalService_proto_rawDescGZIP(), []int{5} } func (x *NullMessage) GetPadding() []byte { @@ -2563,18 +2335,21 @@ func (x *NullMessage) GetPadding() []byte { } type ReceiptMessage struct { - state protoimpl.MessageState `protogen:"open.v1"` - Type *ReceiptMessage_Type `protobuf:"varint,1,opt,name=type,enum=signalservice.ReceiptMessage_Type" json:"type,omitempty"` - Timestamp []uint64 `protobuf:"varint,2,rep,name=timestamp" json:"timestamp,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Type *ReceiptMessage_Type `protobuf:"varint,1,opt,name=type,enum=signalservice.ReceiptMessage_Type" json:"type,omitempty"` + Timestamp []uint64 `protobuf:"varint,2,rep,name=timestamp" json:"timestamp,omitempty"` } func (x *ReceiptMessage) Reset() { *x = ReceiptMessage{} - mi := &file_SignalService_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *ReceiptMessage) String() string { @@ -2584,8 +2359,8 @@ func (x *ReceiptMessage) String() string { func (*ReceiptMessage) ProtoMessage() {} func (x *ReceiptMessage) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[5] - if x != nil { + mi := &file_SignalService_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2597,7 +2372,7 @@ func (x *ReceiptMessage) ProtoReflect() protoreflect.Message { // Deprecated: Use ReceiptMessage.ProtoReflect.Descriptor instead. func (*ReceiptMessage) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{5} + return file_SignalService_proto_rawDescGZIP(), []int{6} } func (x *ReceiptMessage) GetType() ReceiptMessage_Type { @@ -2615,19 +2390,22 @@ func (x *ReceiptMessage) GetTimestamp() []uint64 { } type TypingMessage struct { - state protoimpl.MessageState `protogen:"open.v1"` - Timestamp *uint64 `protobuf:"varint,1,opt,name=timestamp" json:"timestamp,omitempty"` - Action *TypingMessage_Action `protobuf:"varint,2,opt,name=action,enum=signalservice.TypingMessage_Action" json:"action,omitempty"` - GroupId []byte `protobuf:"bytes,3,opt,name=groupId" json:"groupId,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Timestamp *uint64 `protobuf:"varint,1,opt,name=timestamp" json:"timestamp,omitempty"` + Action *TypingMessage_Action `protobuf:"varint,2,opt,name=action,enum=signalservice.TypingMessage_Action" json:"action,omitempty"` + GroupId []byte `protobuf:"bytes,3,opt,name=groupId" json:"groupId,omitempty"` } func (x *TypingMessage) Reset() { *x = TypingMessage{} - mi := &file_SignalService_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *TypingMessage) String() string { @@ -2637,8 +2415,8 @@ func (x *TypingMessage) String() string { func (*TypingMessage) ProtoMessage() {} func (x *TypingMessage) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[6] - if x != nil { + mi := &file_SignalService_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2650,7 +2428,7 @@ func (x *TypingMessage) ProtoReflect() protoreflect.Message { // Deprecated: Use TypingMessage.ProtoReflect.Descriptor instead. func (*TypingMessage) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{6} + return file_SignalService_proto_rawDescGZIP(), []int{7} } func (x *TypingMessage) GetTimestamp() uint64 { @@ -2675,25 +2453,28 @@ func (x *TypingMessage) GetGroupId() []byte { } type StoryMessage struct { - state protoimpl.MessageState `protogen:"open.v1"` - ProfileKey []byte `protobuf:"bytes,1,opt,name=profileKey" json:"profileKey,omitempty"` - Group *GroupContextV2 `protobuf:"bytes,2,opt,name=group" json:"group,omitempty"` - // Types that are valid to be assigned to Attachment: + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ProfileKey []byte `protobuf:"bytes,1,opt,name=profileKey" json:"profileKey,omitempty"` + Group *GroupContextV2 `protobuf:"bytes,2,opt,name=group" json:"group,omitempty"` + // Types that are assignable to Attachment: // // *StoryMessage_FileAttachment // *StoryMessage_TextAttachment Attachment isStoryMessage_Attachment `protobuf_oneof:"attachment"` AllowsReplies *bool `protobuf:"varint,5,opt,name=allowsReplies" json:"allowsReplies,omitempty"` BodyRanges []*BodyRange `protobuf:"bytes,6,rep,name=bodyRanges" json:"bodyRanges,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache } func (x *StoryMessage) Reset() { *x = StoryMessage{} - mi := &file_SignalService_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *StoryMessage) String() string { @@ -2703,8 +2484,8 @@ func (x *StoryMessage) String() string { func (*StoryMessage) ProtoMessage() {} func (x *StoryMessage) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[7] - if x != nil { + mi := &file_SignalService_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2716,7 +2497,7 @@ func (x *StoryMessage) ProtoReflect() protoreflect.Message { // Deprecated: Use StoryMessage.ProtoReflect.Descriptor instead. func (*StoryMessage) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{7} + return file_SignalService_proto_rawDescGZIP(), []int{8} } func (x *StoryMessage) GetProfileKey() []byte { @@ -2733,27 +2514,23 @@ func (x *StoryMessage) GetGroup() *GroupContextV2 { return nil } -func (x *StoryMessage) GetAttachment() isStoryMessage_Attachment { - if x != nil { - return x.Attachment +func (m *StoryMessage) GetAttachment() isStoryMessage_Attachment { + if m != nil { + return m.Attachment } return nil } func (x *StoryMessage) GetFileAttachment() *AttachmentPointer { - if x != nil { - if x, ok := x.Attachment.(*StoryMessage_FileAttachment); ok { - return x.FileAttachment - } + if x, ok := x.GetAttachment().(*StoryMessage_FileAttachment); ok { + return x.FileAttachment } return nil } func (x *StoryMessage) GetTextAttachment() *TextAttachment { - if x != nil { - if x, ok := x.Attachment.(*StoryMessage_TextAttachment); ok { - return x.TextAttachment - } + if x, ok := x.GetAttachment().(*StoryMessage_TextAttachment); ok { + return x.TextAttachment } return nil } @@ -2789,21 +2566,24 @@ func (*StoryMessage_FileAttachment) isStoryMessage_Attachment() {} func (*StoryMessage_TextAttachment) isStoryMessage_Attachment() {} type Preview struct { - state protoimpl.MessageState `protogen:"open.v1"` - Url *string `protobuf:"bytes,1,opt,name=url" json:"url,omitempty"` - Title *string `protobuf:"bytes,2,opt,name=title" json:"title,omitempty"` - Image *AttachmentPointer `protobuf:"bytes,3,opt,name=image" json:"image,omitempty"` - Description *string `protobuf:"bytes,4,opt,name=description" json:"description,omitempty"` - Date *uint64 `protobuf:"varint,5,opt,name=date" json:"date,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Url *string `protobuf:"bytes,1,opt,name=url" json:"url,omitempty"` + Title *string `protobuf:"bytes,2,opt,name=title" json:"title,omitempty"` + Image *AttachmentPointer `protobuf:"bytes,3,opt,name=image" json:"image,omitempty"` + Description *string `protobuf:"bytes,4,opt,name=description" json:"description,omitempty"` + Date *uint64 `protobuf:"varint,5,opt,name=date" json:"date,omitempty"` } func (x *Preview) Reset() { *x = Preview{} - mi := &file_SignalService_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *Preview) String() string { @@ -2813,8 +2593,8 @@ func (x *Preview) String() string { func (*Preview) ProtoMessage() {} func (x *Preview) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[8] - if x != nil { + mi := &file_SignalService_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2826,7 +2606,7 @@ func (x *Preview) ProtoReflect() protoreflect.Message { // Deprecated: Use Preview.ProtoReflect.Descriptor instead. func (*Preview) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{8} + return file_SignalService_proto_rawDescGZIP(), []int{9} } func (x *Preview) GetUrl() string { @@ -2865,26 +2645,29 @@ func (x *Preview) GetDate() uint64 { } type TextAttachment struct { - state protoimpl.MessageState `protogen:"open.v1"` - Text *string `protobuf:"bytes,1,opt,name=text" json:"text,omitempty"` - TextStyle *TextAttachment_Style `protobuf:"varint,2,opt,name=textStyle,enum=signalservice.TextAttachment_Style" json:"textStyle,omitempty"` - TextForegroundColor *uint32 `protobuf:"varint,3,opt,name=textForegroundColor" json:"textForegroundColor,omitempty"` // integer representation of hex color - TextBackgroundColor *uint32 `protobuf:"varint,4,opt,name=textBackgroundColor" json:"textBackgroundColor,omitempty"` - Preview *Preview `protobuf:"bytes,5,opt,name=preview" json:"preview,omitempty"` - // Types that are valid to be assigned to Background: + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Text *string `protobuf:"bytes,1,opt,name=text" json:"text,omitempty"` + TextStyle *TextAttachment_Style `protobuf:"varint,2,opt,name=textStyle,enum=signalservice.TextAttachment_Style" json:"textStyle,omitempty"` + TextForegroundColor *uint32 `protobuf:"varint,3,opt,name=textForegroundColor" json:"textForegroundColor,omitempty"` // integer representation of hex color + TextBackgroundColor *uint32 `protobuf:"varint,4,opt,name=textBackgroundColor" json:"textBackgroundColor,omitempty"` + Preview *Preview `protobuf:"bytes,5,opt,name=preview" json:"preview,omitempty"` + // Types that are assignable to Background: // // *TextAttachment_Gradient_ // *TextAttachment_Color - Background isTextAttachment_Background `protobuf_oneof:"background"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + Background isTextAttachment_Background `protobuf_oneof:"background"` } func (x *TextAttachment) Reset() { *x = TextAttachment{} - mi := &file_SignalService_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *TextAttachment) String() string { @@ -2894,8 +2677,8 @@ func (x *TextAttachment) String() string { func (*TextAttachment) ProtoMessage() {} func (x *TextAttachment) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[9] - if x != nil { + mi := &file_SignalService_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -2907,7 +2690,7 @@ func (x *TextAttachment) ProtoReflect() protoreflect.Message { // Deprecated: Use TextAttachment.ProtoReflect.Descriptor instead. func (*TextAttachment) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{9} + return file_SignalService_proto_rawDescGZIP(), []int{10} } func (x *TextAttachment) GetText() string { @@ -2945,27 +2728,23 @@ func (x *TextAttachment) GetPreview() *Preview { return nil } -func (x *TextAttachment) GetBackground() isTextAttachment_Background { - if x != nil { - return x.Background +func (m *TextAttachment) GetBackground() isTextAttachment_Background { + if m != nil { + return m.Background } return nil } func (x *TextAttachment) GetGradient() *TextAttachment_Gradient { - if x != nil { - if x, ok := x.Background.(*TextAttachment_Gradient_); ok { - return x.Gradient - } + if x, ok := x.GetBackground().(*TextAttachment_Gradient_); ok { + return x.Gradient } return nil } func (x *TextAttachment) GetColor() uint32 { - if x != nil { - if x, ok := x.Background.(*TextAttachment_Color); ok { - return x.Color - } + if x, ok := x.GetBackground().(*TextAttachment_Color); ok { + return x.Color } return 0 } @@ -2987,21 +2766,23 @@ func (*TextAttachment_Gradient_) isTextAttachment_Background() {} func (*TextAttachment_Color) isTextAttachment_Background() {} type Verified struct { - state protoimpl.MessageState `protogen:"open.v1"` - DestinationAci *string `protobuf:"bytes,5,opt,name=destinationAci" json:"destinationAci,omitempty"` - IdentityKey []byte `protobuf:"bytes,2,opt,name=identityKey" json:"identityKey,omitempty"` - State *Verified_State `protobuf:"varint,3,opt,name=state,enum=signalservice.Verified_State" json:"state,omitempty"` - NullMessage []byte `protobuf:"bytes,4,opt,name=nullMessage" json:"nullMessage,omitempty"` - DestinationAciBinary []byte `protobuf:"bytes,6,opt,name=destinationAciBinary" json:"destinationAciBinary,omitempty"` // 16-byte UUID - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + DestinationAci *string `protobuf:"bytes,5,opt,name=destinationAci" json:"destinationAci,omitempty"` + IdentityKey []byte `protobuf:"bytes,2,opt,name=identityKey" json:"identityKey,omitempty"` + State *Verified_State `protobuf:"varint,3,opt,name=state,enum=signalservice.Verified_State" json:"state,omitempty"` + NullMessage []byte `protobuf:"bytes,4,opt,name=nullMessage" json:"nullMessage,omitempty"` } func (x *Verified) Reset() { *x = Verified{} - mi := &file_SignalService_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *Verified) String() string { @@ -3011,8 +2792,8 @@ func (x *Verified) String() string { func (*Verified) ProtoMessage() {} func (x *Verified) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[10] - if x != nil { + mi := &file_SignalService_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -3024,7 +2805,7 @@ func (x *Verified) ProtoReflect() protoreflect.Message { // Deprecated: Use Verified.ProtoReflect.Descriptor instead. func (*Verified) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{10} + return file_SignalService_proto_rawDescGZIP(), []int{11} } func (x *Verified) GetDestinationAci() string { @@ -3055,53 +2836,39 @@ func (x *Verified) GetNullMessage() []byte { return nil } -func (x *Verified) GetDestinationAciBinary() []byte { - if x != nil { - return x.DestinationAciBinary - } - return nil -} - type SyncMessage struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Types that are valid to be assigned to Content: - // - // *SyncMessage_Sent_ - // *SyncMessage_Contacts_ - // *SyncMessage_Request_ - // *SyncMessage_Blocked_ - // *SyncMessage_Verified - // *SyncMessage_Configuration_ - // *SyncMessage_ViewOnceOpen_ - // *SyncMessage_FetchLatest_ - // *SyncMessage_Keys_ - // *SyncMessage_MessageRequestResponse_ - // *SyncMessage_OutgoingPayment_ - // *SyncMessage_PniChangeNumber_ - // *SyncMessage_CallEvent_ - // *SyncMessage_CallLinkUpdate_ - // *SyncMessage_CallLogEvent_ - // *SyncMessage_DeleteForMe_ - // *SyncMessage_DeviceNameChange_ - // *SyncMessage_AttachmentBackfillRequest_ - // *SyncMessage_AttachmentBackfillResponse_ - Content isSyncMessage_Content `protobuf_oneof:"content"` - // Protobufs don't allow `repeated` fields to be inside of `oneof` so while - // the fields below are mutually exclusive with the rest of the values above - // we have to place them outside of `oneof`. - Read []*SyncMessage_Read `protobuf:"bytes,5,rep,name=read" json:"read,omitempty"` - StickerPackOperation []*SyncMessage_StickerPackOperation `protobuf:"bytes,10,rep,name=stickerPackOperation" json:"stickerPackOperation,omitempty"` - Viewed []*SyncMessage_Viewed `protobuf:"bytes,16,rep,name=viewed" json:"viewed,omitempty"` - Padding []byte `protobuf:"bytes,8,opt,name=padding" json:"padding,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Sent *SyncMessage_Sent `protobuf:"bytes,1,opt,name=sent" json:"sent,omitempty"` + Contacts *SyncMessage_Contacts `protobuf:"bytes,2,opt,name=contacts" json:"contacts,omitempty"` + Request *SyncMessage_Request `protobuf:"bytes,4,opt,name=request" json:"request,omitempty"` + Read []*SyncMessage_Read `protobuf:"bytes,5,rep,name=read" json:"read,omitempty"` + Blocked *SyncMessage_Blocked `protobuf:"bytes,6,opt,name=blocked" json:"blocked,omitempty"` + Verified *Verified `protobuf:"bytes,7,opt,name=verified" json:"verified,omitempty"` + Configuration *SyncMessage_Configuration `protobuf:"bytes,9,opt,name=configuration" json:"configuration,omitempty"` + Padding []byte `protobuf:"bytes,8,opt,name=padding" json:"padding,omitempty"` + StickerPackOperation []*SyncMessage_StickerPackOperation `protobuf:"bytes,10,rep,name=stickerPackOperation" json:"stickerPackOperation,omitempty"` + ViewOnceOpen *SyncMessage_ViewOnceOpen `protobuf:"bytes,11,opt,name=viewOnceOpen" json:"viewOnceOpen,omitempty"` + FetchLatest *SyncMessage_FetchLatest `protobuf:"bytes,12,opt,name=fetchLatest" json:"fetchLatest,omitempty"` + Keys *SyncMessage_Keys `protobuf:"bytes,13,opt,name=keys" json:"keys,omitempty"` + MessageRequestResponse *SyncMessage_MessageRequestResponse `protobuf:"bytes,14,opt,name=messageRequestResponse" json:"messageRequestResponse,omitempty"` + OutgoingPayment *SyncMessage_OutgoingPayment `protobuf:"bytes,15,opt,name=outgoingPayment" json:"outgoingPayment,omitempty"` + Viewed []*SyncMessage_Viewed `protobuf:"bytes,16,rep,name=viewed" json:"viewed,omitempty"` + PniChangeNumber *SyncMessage_PniChangeNumber `protobuf:"bytes,18,opt,name=pniChangeNumber" json:"pniChangeNumber,omitempty"` + CallEvent *SyncMessage_CallEvent `protobuf:"bytes,19,opt,name=callEvent" json:"callEvent,omitempty"` + CallLinkUpdate *SyncMessage_CallLinkUpdate `protobuf:"bytes,20,opt,name=callLinkUpdate" json:"callLinkUpdate,omitempty"` + CallLogEvent *SyncMessage_CallLogEvent `protobuf:"bytes,21,opt,name=callLogEvent" json:"callLogEvent,omitempty"` } func (x *SyncMessage) Reset() { *x = SyncMessage{} - mi := &file_SignalService_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *SyncMessage) String() string { @@ -3111,8 +2878,8 @@ func (x *SyncMessage) String() string { func (*SyncMessage) ProtoMessage() {} func (x *SyncMessage) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[11] - if x != nil { + mi := &file_SignalService_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -3124,183 +2891,26 @@ func (x *SyncMessage) ProtoReflect() protoreflect.Message { // Deprecated: Use SyncMessage.ProtoReflect.Descriptor instead. func (*SyncMessage) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11} -} - -func (x *SyncMessage) GetContent() isSyncMessage_Content { - if x != nil { - return x.Content - } - return nil + return file_SignalService_proto_rawDescGZIP(), []int{12} } func (x *SyncMessage) GetSent() *SyncMessage_Sent { if x != nil { - if x, ok := x.Content.(*SyncMessage_Sent_); ok { - return x.Sent - } + return x.Sent } return nil } func (x *SyncMessage) GetContacts() *SyncMessage_Contacts { if x != nil { - if x, ok := x.Content.(*SyncMessage_Contacts_); ok { - return x.Contacts - } + return x.Contacts } return nil } func (x *SyncMessage) GetRequest() *SyncMessage_Request { if x != nil { - if x, ok := x.Content.(*SyncMessage_Request_); ok { - return x.Request - } - } - return nil -} - -func (x *SyncMessage) GetBlocked() *SyncMessage_Blocked { - if x != nil { - if x, ok := x.Content.(*SyncMessage_Blocked_); ok { - return x.Blocked - } - } - return nil -} - -func (x *SyncMessage) GetVerified() *Verified { - if x != nil { - if x, ok := x.Content.(*SyncMessage_Verified); ok { - return x.Verified - } - } - return nil -} - -func (x *SyncMessage) GetConfiguration() *SyncMessage_Configuration { - if x != nil { - if x, ok := x.Content.(*SyncMessage_Configuration_); ok { - return x.Configuration - } - } - return nil -} - -func (x *SyncMessage) GetViewOnceOpen() *SyncMessage_ViewOnceOpen { - if x != nil { - if x, ok := x.Content.(*SyncMessage_ViewOnceOpen_); ok { - return x.ViewOnceOpen - } - } - return nil -} - -func (x *SyncMessage) GetFetchLatest() *SyncMessage_FetchLatest { - if x != nil { - if x, ok := x.Content.(*SyncMessage_FetchLatest_); ok { - return x.FetchLatest - } - } - return nil -} - -func (x *SyncMessage) GetKeys() *SyncMessage_Keys { - if x != nil { - if x, ok := x.Content.(*SyncMessage_Keys_); ok { - return x.Keys - } - } - return nil -} - -func (x *SyncMessage) GetMessageRequestResponse() *SyncMessage_MessageRequestResponse { - if x != nil { - if x, ok := x.Content.(*SyncMessage_MessageRequestResponse_); ok { - return x.MessageRequestResponse - } - } - return nil -} - -func (x *SyncMessage) GetOutgoingPayment() *SyncMessage_OutgoingPayment { - if x != nil { - if x, ok := x.Content.(*SyncMessage_OutgoingPayment_); ok { - return x.OutgoingPayment - } - } - return nil -} - -func (x *SyncMessage) GetPniChangeNumber() *SyncMessage_PniChangeNumber { - if x != nil { - if x, ok := x.Content.(*SyncMessage_PniChangeNumber_); ok { - return x.PniChangeNumber - } - } - return nil -} - -func (x *SyncMessage) GetCallEvent() *SyncMessage_CallEvent { - if x != nil { - if x, ok := x.Content.(*SyncMessage_CallEvent_); ok { - return x.CallEvent - } - } - return nil -} - -func (x *SyncMessage) GetCallLinkUpdate() *SyncMessage_CallLinkUpdate { - if x != nil { - if x, ok := x.Content.(*SyncMessage_CallLinkUpdate_); ok { - return x.CallLinkUpdate - } - } - return nil -} - -func (x *SyncMessage) GetCallLogEvent() *SyncMessage_CallLogEvent { - if x != nil { - if x, ok := x.Content.(*SyncMessage_CallLogEvent_); ok { - return x.CallLogEvent - } - } - return nil -} - -func (x *SyncMessage) GetDeleteForMe() *SyncMessage_DeleteForMe { - if x != nil { - if x, ok := x.Content.(*SyncMessage_DeleteForMe_); ok { - return x.DeleteForMe - } - } - return nil -} - -func (x *SyncMessage) GetDeviceNameChange() *SyncMessage_DeviceNameChange { - if x != nil { - if x, ok := x.Content.(*SyncMessage_DeviceNameChange_); ok { - return x.DeviceNameChange - } - } - return nil -} - -func (x *SyncMessage) GetAttachmentBackfillRequest() *SyncMessage_AttachmentBackfillRequest { - if x != nil { - if x, ok := x.Content.(*SyncMessage_AttachmentBackfillRequest_); ok { - return x.AttachmentBackfillRequest - } - } - return nil -} - -func (x *SyncMessage) GetAttachmentBackfillResponse() *SyncMessage_AttachmentBackfillResponse { - if x != nil { - if x, ok := x.Content.(*SyncMessage_AttachmentBackfillResponse_); ok { - return x.AttachmentBackfillResponse - } + return x.Request } return nil } @@ -3312,16 +2922,23 @@ func (x *SyncMessage) GetRead() []*SyncMessage_Read { return nil } -func (x *SyncMessage) GetStickerPackOperation() []*SyncMessage_StickerPackOperation { +func (x *SyncMessage) GetBlocked() *SyncMessage_Blocked { if x != nil { - return x.StickerPackOperation + return x.Blocked } return nil } -func (x *SyncMessage) GetViewed() []*SyncMessage_Viewed { +func (x *SyncMessage) GetVerified() *Verified { if x != nil { - return x.Viewed + return x.Verified + } + return nil +} + +func (x *SyncMessage) GetConfiguration() *SyncMessage_Configuration { + if x != nil { + return x.Configuration } return nil } @@ -3333,158 +2950,117 @@ func (x *SyncMessage) GetPadding() []byte { return nil } -type isSyncMessage_Content interface { - isSyncMessage_Content() +func (x *SyncMessage) GetStickerPackOperation() []*SyncMessage_StickerPackOperation { + if x != nil { + return x.StickerPackOperation + } + return nil } -type SyncMessage_Sent_ struct { - Sent *SyncMessage_Sent `protobuf:"bytes,1,opt,name=sent,oneof"` +func (x *SyncMessage) GetViewOnceOpen() *SyncMessage_ViewOnceOpen { + if x != nil { + return x.ViewOnceOpen + } + return nil } -type SyncMessage_Contacts_ struct { - Contacts *SyncMessage_Contacts `protobuf:"bytes,2,opt,name=contacts,oneof"` +func (x *SyncMessage) GetFetchLatest() *SyncMessage_FetchLatest { + if x != nil { + return x.FetchLatest + } + return nil } -type SyncMessage_Request_ struct { - Request *SyncMessage_Request `protobuf:"bytes,4,opt,name=request,oneof"` +func (x *SyncMessage) GetKeys() *SyncMessage_Keys { + if x != nil { + return x.Keys + } + return nil } -type SyncMessage_Blocked_ struct { - Blocked *SyncMessage_Blocked `protobuf:"bytes,6,opt,name=blocked,oneof"` +func (x *SyncMessage) GetMessageRequestResponse() *SyncMessage_MessageRequestResponse { + if x != nil { + return x.MessageRequestResponse + } + return nil } -type SyncMessage_Verified struct { - Verified *Verified `protobuf:"bytes,7,opt,name=verified,oneof"` +func (x *SyncMessage) GetOutgoingPayment() *SyncMessage_OutgoingPayment { + if x != nil { + return x.OutgoingPayment + } + return nil } -type SyncMessage_Configuration_ struct { - Configuration *SyncMessage_Configuration `protobuf:"bytes,9,opt,name=configuration,oneof"` +func (x *SyncMessage) GetViewed() []*SyncMessage_Viewed { + if x != nil { + return x.Viewed + } + return nil } -type SyncMessage_ViewOnceOpen_ struct { - ViewOnceOpen *SyncMessage_ViewOnceOpen `protobuf:"bytes,11,opt,name=viewOnceOpen,oneof"` +func (x *SyncMessage) GetPniChangeNumber() *SyncMessage_PniChangeNumber { + if x != nil { + return x.PniChangeNumber + } + return nil } -type SyncMessage_FetchLatest_ struct { - FetchLatest *SyncMessage_FetchLatest `protobuf:"bytes,12,opt,name=fetchLatest,oneof"` +func (x *SyncMessage) GetCallEvent() *SyncMessage_CallEvent { + if x != nil { + return x.CallEvent + } + return nil } -type SyncMessage_Keys_ struct { - Keys *SyncMessage_Keys `protobuf:"bytes,13,opt,name=keys,oneof"` +func (x *SyncMessage) GetCallLinkUpdate() *SyncMessage_CallLinkUpdate { + if x != nil { + return x.CallLinkUpdate + } + return nil } -type SyncMessage_MessageRequestResponse_ struct { - MessageRequestResponse *SyncMessage_MessageRequestResponse `protobuf:"bytes,14,opt,name=messageRequestResponse,oneof"` +func (x *SyncMessage) GetCallLogEvent() *SyncMessage_CallLogEvent { + if x != nil { + return x.CallLogEvent + } + return nil } -type SyncMessage_OutgoingPayment_ struct { - OutgoingPayment *SyncMessage_OutgoingPayment `protobuf:"bytes,15,opt,name=outgoingPayment,oneof"` -} - -type SyncMessage_PniChangeNumber_ struct { - PniChangeNumber *SyncMessage_PniChangeNumber `protobuf:"bytes,18,opt,name=pniChangeNumber,oneof"` -} - -type SyncMessage_CallEvent_ struct { - CallEvent *SyncMessage_CallEvent `protobuf:"bytes,19,opt,name=callEvent,oneof"` -} - -type SyncMessage_CallLinkUpdate_ struct { - CallLinkUpdate *SyncMessage_CallLinkUpdate `protobuf:"bytes,20,opt,name=callLinkUpdate,oneof"` -} - -type SyncMessage_CallLogEvent_ struct { - CallLogEvent *SyncMessage_CallLogEvent `protobuf:"bytes,21,opt,name=callLogEvent,oneof"` -} - -type SyncMessage_DeleteForMe_ struct { - DeleteForMe *SyncMessage_DeleteForMe `protobuf:"bytes,22,opt,name=deleteForMe,oneof"` -} - -type SyncMessage_DeviceNameChange_ struct { - DeviceNameChange *SyncMessage_DeviceNameChange `protobuf:"bytes,23,opt,name=deviceNameChange,oneof"` -} - -type SyncMessage_AttachmentBackfillRequest_ struct { - AttachmentBackfillRequest *SyncMessage_AttachmentBackfillRequest `protobuf:"bytes,24,opt,name=attachmentBackfillRequest,oneof"` -} - -type SyncMessage_AttachmentBackfillResponse_ struct { - AttachmentBackfillResponse *SyncMessage_AttachmentBackfillResponse `protobuf:"bytes,25,opt,name=attachmentBackfillResponse,oneof"` -} - -func (*SyncMessage_Sent_) isSyncMessage_Content() {} - -func (*SyncMessage_Contacts_) isSyncMessage_Content() {} - -func (*SyncMessage_Request_) isSyncMessage_Content() {} - -func (*SyncMessage_Blocked_) isSyncMessage_Content() {} - -func (*SyncMessage_Verified) isSyncMessage_Content() {} - -func (*SyncMessage_Configuration_) isSyncMessage_Content() {} - -func (*SyncMessage_ViewOnceOpen_) isSyncMessage_Content() {} - -func (*SyncMessage_FetchLatest_) isSyncMessage_Content() {} - -func (*SyncMessage_Keys_) isSyncMessage_Content() {} - -func (*SyncMessage_MessageRequestResponse_) isSyncMessage_Content() {} - -func (*SyncMessage_OutgoingPayment_) isSyncMessage_Content() {} - -func (*SyncMessage_PniChangeNumber_) isSyncMessage_Content() {} - -func (*SyncMessage_CallEvent_) isSyncMessage_Content() {} - -func (*SyncMessage_CallLinkUpdate_) isSyncMessage_Content() {} - -func (*SyncMessage_CallLogEvent_) isSyncMessage_Content() {} - -func (*SyncMessage_DeleteForMe_) isSyncMessage_Content() {} - -func (*SyncMessage_DeviceNameChange_) isSyncMessage_Content() {} - -func (*SyncMessage_AttachmentBackfillRequest_) isSyncMessage_Content() {} - -func (*SyncMessage_AttachmentBackfillResponse_) isSyncMessage_Content() {} - type AttachmentPointer struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Types that are valid to be assigned to AttachmentIdentifier: + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to AttachmentIdentifier: // // *AttachmentPointer_CdnId // *AttachmentPointer_CdnKey - AttachmentIdentifier isAttachmentPointer_AttachmentIdentifier `protobuf_oneof:"attachment_identifier"` - // Cross-client identifier for this attachment among all attachments on the - // owning message. - ClientUuid []byte `protobuf:"bytes,20,opt,name=clientUuid" json:"clientUuid,omitempty"` - ContentType *string `protobuf:"bytes,2,opt,name=contentType" json:"contentType,omitempty"` - Key []byte `protobuf:"bytes,3,opt,name=key" json:"key,omitempty"` - Size *uint32 `protobuf:"varint,4,opt,name=size" json:"size,omitempty"` - Thumbnail []byte `protobuf:"bytes,5,opt,name=thumbnail" json:"thumbnail,omitempty"` - Digest []byte `protobuf:"bytes,6,opt,name=digest" json:"digest,omitempty"` - IncrementalMac []byte `protobuf:"bytes,19,opt,name=incrementalMac" json:"incrementalMac,omitempty"` - ChunkSize *uint32 `protobuf:"varint,17,opt,name=chunkSize" json:"chunkSize,omitempty"` - FileName *string `protobuf:"bytes,7,opt,name=fileName" json:"fileName,omitempty"` - Flags *uint32 `protobuf:"varint,8,opt,name=flags" json:"flags,omitempty"` - Width *uint32 `protobuf:"varint,9,opt,name=width" json:"width,omitempty"` - Height *uint32 `protobuf:"varint,10,opt,name=height" json:"height,omitempty"` - Caption *string `protobuf:"bytes,11,opt,name=caption" json:"caption,omitempty"` - BlurHash *string `protobuf:"bytes,12,opt,name=blurHash" json:"blurHash,omitempty"` - UploadTimestamp *uint64 `protobuf:"varint,13,opt,name=uploadTimestamp" json:"uploadTimestamp,omitempty"` - CdnNumber *uint32 `protobuf:"varint,14,opt,name=cdnNumber" json:"cdnNumber,omitempty"` // Next ID: 21 - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + AttachmentIdentifier isAttachmentPointer_AttachmentIdentifier `protobuf_oneof:"attachment_identifier"` + ContentType *string `protobuf:"bytes,2,opt,name=contentType" json:"contentType,omitempty"` + Key []byte `protobuf:"bytes,3,opt,name=key" json:"key,omitempty"` + Size *uint32 `protobuf:"varint,4,opt,name=size" json:"size,omitempty"` + Thumbnail []byte `protobuf:"bytes,5,opt,name=thumbnail" json:"thumbnail,omitempty"` + Digest []byte `protobuf:"bytes,6,opt,name=digest" json:"digest,omitempty"` + IncrementalMac []byte `protobuf:"bytes,18,opt,name=incrementalMac" json:"incrementalMac,omitempty"` + IncrementalMacChunkSize *uint32 `protobuf:"varint,17,opt,name=incrementalMacChunkSize" json:"incrementalMacChunkSize,omitempty"` + FileName *string `protobuf:"bytes,7,opt,name=fileName" json:"fileName,omitempty"` + Flags *uint32 `protobuf:"varint,8,opt,name=flags" json:"flags,omitempty"` + Width *uint32 `protobuf:"varint,9,opt,name=width" json:"width,omitempty"` + Height *uint32 `protobuf:"varint,10,opt,name=height" json:"height,omitempty"` + Caption *string `protobuf:"bytes,11,opt,name=caption" json:"caption,omitempty"` + BlurHash *string `protobuf:"bytes,12,opt,name=blurHash" json:"blurHash,omitempty"` + UploadTimestamp *uint64 `protobuf:"varint,13,opt,name=uploadTimestamp" json:"uploadTimestamp,omitempty"` + CdnNumber *uint32 `protobuf:"varint,14,opt,name=cdnNumber" json:"cdnNumber,omitempty"` // Next ID: 19 } func (x *AttachmentPointer) Reset() { *x = AttachmentPointer{} - mi := &file_SignalService_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *AttachmentPointer) String() string { @@ -3494,8 +3070,8 @@ func (x *AttachmentPointer) String() string { func (*AttachmentPointer) ProtoMessage() {} func (x *AttachmentPointer) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[12] - if x != nil { + mi := &file_SignalService_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -3507,41 +3083,30 @@ func (x *AttachmentPointer) ProtoReflect() protoreflect.Message { // Deprecated: Use AttachmentPointer.ProtoReflect.Descriptor instead. func (*AttachmentPointer) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{12} + return file_SignalService_proto_rawDescGZIP(), []int{13} } -func (x *AttachmentPointer) GetAttachmentIdentifier() isAttachmentPointer_AttachmentIdentifier { - if x != nil { - return x.AttachmentIdentifier +func (m *AttachmentPointer) GetAttachmentIdentifier() isAttachmentPointer_AttachmentIdentifier { + if m != nil { + return m.AttachmentIdentifier } return nil } func (x *AttachmentPointer) GetCdnId() uint64 { - if x != nil { - if x, ok := x.AttachmentIdentifier.(*AttachmentPointer_CdnId); ok { - return x.CdnId - } + if x, ok := x.GetAttachmentIdentifier().(*AttachmentPointer_CdnId); ok { + return x.CdnId } return 0 } func (x *AttachmentPointer) GetCdnKey() string { - if x != nil { - if x, ok := x.AttachmentIdentifier.(*AttachmentPointer_CdnKey); ok { - return x.CdnKey - } + if x, ok := x.GetAttachmentIdentifier().(*AttachmentPointer_CdnKey); ok { + return x.CdnKey } return "" } -func (x *AttachmentPointer) GetClientUuid() []byte { - if x != nil { - return x.ClientUuid - } - return nil -} - func (x *AttachmentPointer) GetContentType() string { if x != nil && x.ContentType != nil { return *x.ContentType @@ -3584,9 +3149,9 @@ func (x *AttachmentPointer) GetIncrementalMac() []byte { return nil } -func (x *AttachmentPointer) GetChunkSize() uint32 { - if x != nil && x.ChunkSize != nil { - return *x.ChunkSize +func (x *AttachmentPointer) GetIncrementalMacChunkSize() uint32 { + if x != nil && x.IncrementalMacChunkSize != nil { + return *x.IncrementalMacChunkSize } return 0 } @@ -3663,20 +3228,110 @@ func (*AttachmentPointer_CdnId) isAttachmentPointer_AttachmentIdentifier() {} func (*AttachmentPointer_CdnKey) isAttachmentPointer_AttachmentIdentifier() {} -type GroupContextV2 struct { - state protoimpl.MessageState `protogen:"open.v1"` - MasterKey []byte `protobuf:"bytes,1,opt,name=masterKey" json:"masterKey,omitempty"` - Revision *uint32 `protobuf:"varint,2,opt,name=revision" json:"revision,omitempty"` - GroupChange []byte `protobuf:"bytes,3,opt,name=groupChange" json:"groupChange,omitempty"` - unknownFields protoimpl.UnknownFields +type GroupContext struct { + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id []byte `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"` + Type *GroupContext_Type `protobuf:"varint,2,opt,name=type,enum=signalservice.GroupContext_Type" json:"type,omitempty"` + Name *string `protobuf:"bytes,3,opt,name=name" json:"name,omitempty"` + MembersE164 []string `protobuf:"bytes,4,rep,name=membersE164" json:"membersE164,omitempty"` + Members []*GroupContext_Member `protobuf:"bytes,6,rep,name=members" json:"members,omitempty"` + Avatar *AttachmentPointer `protobuf:"bytes,5,opt,name=avatar" json:"avatar,omitempty"` +} + +func (x *GroupContext) Reset() { + *x = GroupContext{} + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GroupContext) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GroupContext) ProtoMessage() {} + +func (x *GroupContext) ProtoReflect() protoreflect.Message { + mi := &file_SignalService_proto_msgTypes[14] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GroupContext.ProtoReflect.Descriptor instead. +func (*GroupContext) Descriptor() ([]byte, []int) { + return file_SignalService_proto_rawDescGZIP(), []int{14} +} + +func (x *GroupContext) GetId() []byte { + if x != nil { + return x.Id + } + return nil +} + +func (x *GroupContext) GetType() GroupContext_Type { + if x != nil && x.Type != nil { + return *x.Type + } + return GroupContext_UNKNOWN +} + +func (x *GroupContext) GetName() string { + if x != nil && x.Name != nil { + return *x.Name + } + return "" +} + +func (x *GroupContext) GetMembersE164() []string { + if x != nil { + return x.MembersE164 + } + return nil +} + +func (x *GroupContext) GetMembers() []*GroupContext_Member { + if x != nil { + return x.Members + } + return nil +} + +func (x *GroupContext) GetAvatar() *AttachmentPointer { + if x != nil { + return x.Avatar + } + return nil +} + +type GroupContextV2 struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + MasterKey []byte `protobuf:"bytes,1,opt,name=masterKey" json:"masterKey,omitempty"` + Revision *uint32 `protobuf:"varint,2,opt,name=revision" json:"revision,omitempty"` + GroupChange []byte `protobuf:"bytes,3,opt,name=groupChange" json:"groupChange,omitempty"` } func (x *GroupContextV2) Reset() { *x = GroupContextV2{} - mi := &file_SignalService_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *GroupContextV2) String() string { @@ -3686,8 +3341,8 @@ func (x *GroupContextV2) String() string { func (*GroupContextV2) ProtoMessage() {} func (x *GroupContextV2) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[13] - if x != nil { + mi := &file_SignalService_proto_msgTypes[15] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -3699,7 +3354,7 @@ func (x *GroupContextV2) ProtoReflect() protoreflect.Message { // Deprecated: Use GroupContextV2.ProtoReflect.Descriptor instead. func (*GroupContextV2) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{13} + return file_SignalService_proto_rawDescGZIP(), []int{15} } func (x *GroupContextV2) GetMasterKey() []byte { @@ -3724,24 +3379,30 @@ func (x *GroupContextV2) GetGroupChange() []byte { } type ContactDetails struct { - state protoimpl.MessageState `protogen:"open.v1"` - Number *string `protobuf:"bytes,1,opt,name=number" json:"number,omitempty"` - Aci *string `protobuf:"bytes,9,opt,name=aci" json:"aci,omitempty"` - AciBinary []byte `protobuf:"bytes,13,opt,name=aciBinary" json:"aciBinary,omitempty"` // 16-byte UUID - Name *string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"` - Avatar *ContactDetails_Avatar `protobuf:"bytes,3,opt,name=avatar" json:"avatar,omitempty"` - ExpireTimer *uint32 `protobuf:"varint,8,opt,name=expireTimer" json:"expireTimer,omitempty"` - ExpireTimerVersion *uint32 `protobuf:"varint,12,opt,name=expireTimerVersion" json:"expireTimerVersion,omitempty"` - InboxPosition *uint32 `protobuf:"varint,10,opt,name=inboxPosition" json:"inboxPosition,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Number *string `protobuf:"bytes,1,opt,name=number" json:"number,omitempty"` + Aci *string `protobuf:"bytes,9,opt,name=aci" json:"aci,omitempty"` + Name *string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"` + Avatar *ContactDetails_Avatar `protobuf:"bytes,3,opt,name=avatar" json:"avatar,omitempty"` + Color *string `protobuf:"bytes,4,opt,name=color" json:"color,omitempty"` + Verified *Verified `protobuf:"bytes,5,opt,name=verified" json:"verified,omitempty"` + ProfileKey []byte `protobuf:"bytes,6,opt,name=profileKey" json:"profileKey,omitempty"` + Blocked *bool `protobuf:"varint,7,opt,name=blocked" json:"blocked,omitempty"` + ExpireTimer *uint32 `protobuf:"varint,8,opt,name=expireTimer" json:"expireTimer,omitempty"` + InboxPosition *uint32 `protobuf:"varint,10,opt,name=inboxPosition" json:"inboxPosition,omitempty"` + Archived *bool `protobuf:"varint,11,opt,name=archived" json:"archived,omitempty"` } func (x *ContactDetails) Reset() { *x = ContactDetails{} - mi := &file_SignalService_proto_msgTypes[14] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *ContactDetails) String() string { @@ -3751,8 +3412,8 @@ func (x *ContactDetails) String() string { func (*ContactDetails) ProtoMessage() {} func (x *ContactDetails) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[14] - if x != nil { + mi := &file_SignalService_proto_msgTypes[16] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -3764,7 +3425,7 @@ func (x *ContactDetails) ProtoReflect() protoreflect.Message { // Deprecated: Use ContactDetails.ProtoReflect.Descriptor instead. func (*ContactDetails) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{14} + return file_SignalService_proto_rawDescGZIP(), []int{16} } func (x *ContactDetails) GetNumber() string { @@ -3781,13 +3442,6 @@ func (x *ContactDetails) GetAci() string { return "" } -func (x *ContactDetails) GetAciBinary() []byte { - if x != nil { - return x.AciBinary - } - return nil -} - func (x *ContactDetails) GetName() string { if x != nil && x.Name != nil { return *x.Name @@ -3802,6 +3456,34 @@ func (x *ContactDetails) GetAvatar() *ContactDetails_Avatar { return nil } +func (x *ContactDetails) GetColor() string { + if x != nil && x.Color != nil { + return *x.Color + } + return "" +} + +func (x *ContactDetails) GetVerified() *Verified { + if x != nil { + return x.Verified + } + return nil +} + +func (x *ContactDetails) GetProfileKey() []byte { + if x != nil { + return x.ProfileKey + } + return nil +} + +func (x *ContactDetails) GetBlocked() bool { + if x != nil && x.Blocked != nil { + return *x.Blocked + } + return false +} + func (x *ContactDetails) GetExpireTimer() uint32 { if x != nil && x.ExpireTimer != nil { return *x.ExpireTimer @@ -3809,13 +3491,6 @@ func (x *ContactDetails) GetExpireTimer() uint32 { return 0 } -func (x *ContactDetails) GetExpireTimerVersion() uint32 { - if x != nil && x.ExpireTimerVersion != nil { - return *x.ExpireTimerVersion - } - return 0 -} - func (x *ContactDetails) GetInboxPosition() uint32 { if x != nil && x.InboxPosition != nil { return *x.InboxPosition @@ -3823,21 +3498,163 @@ func (x *ContactDetails) GetInboxPosition() uint32 { return 0 } -type PaymentAddress struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Types that are valid to be assigned to Address: - // - // *PaymentAddress_MobileCoin_ - Address isPaymentAddress_Address `protobuf_oneof:"Address"` - unknownFields protoimpl.UnknownFields +func (x *ContactDetails) GetArchived() bool { + if x != nil && x.Archived != nil { + return *x.Archived + } + return false +} + +type GroupDetails struct { + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id []byte `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"` + Name *string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"` + MembersE164 []string `protobuf:"bytes,3,rep,name=membersE164" json:"membersE164,omitempty"` + Members []*GroupDetails_Member `protobuf:"bytes,9,rep,name=members" json:"members,omitempty"` + Avatar *GroupDetails_Avatar `protobuf:"bytes,4,opt,name=avatar" json:"avatar,omitempty"` + Active *bool `protobuf:"varint,5,opt,name=active,def=1" json:"active,omitempty"` + ExpireTimer *uint32 `protobuf:"varint,6,opt,name=expireTimer" json:"expireTimer,omitempty"` + Color *string `protobuf:"bytes,7,opt,name=color" json:"color,omitempty"` + Blocked *bool `protobuf:"varint,8,opt,name=blocked" json:"blocked,omitempty"` + InboxPosition *uint32 `protobuf:"varint,10,opt,name=inboxPosition" json:"inboxPosition,omitempty"` + Archived *bool `protobuf:"varint,11,opt,name=archived" json:"archived,omitempty"` +} + +// Default values for GroupDetails fields. +const ( + Default_GroupDetails_Active = bool(true) +) + +func (x *GroupDetails) Reset() { + *x = GroupDetails{} + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GroupDetails) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GroupDetails) ProtoMessage() {} + +func (x *GroupDetails) ProtoReflect() protoreflect.Message { + mi := &file_SignalService_proto_msgTypes[17] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GroupDetails.ProtoReflect.Descriptor instead. +func (*GroupDetails) Descriptor() ([]byte, []int) { + return file_SignalService_proto_rawDescGZIP(), []int{17} +} + +func (x *GroupDetails) GetId() []byte { + if x != nil { + return x.Id + } + return nil +} + +func (x *GroupDetails) GetName() string { + if x != nil && x.Name != nil { + return *x.Name + } + return "" +} + +func (x *GroupDetails) GetMembersE164() []string { + if x != nil { + return x.MembersE164 + } + return nil +} + +func (x *GroupDetails) GetMembers() []*GroupDetails_Member { + if x != nil { + return x.Members + } + return nil +} + +func (x *GroupDetails) GetAvatar() *GroupDetails_Avatar { + if x != nil { + return x.Avatar + } + return nil +} + +func (x *GroupDetails) GetActive() bool { + if x != nil && x.Active != nil { + return *x.Active + } + return Default_GroupDetails_Active +} + +func (x *GroupDetails) GetExpireTimer() uint32 { + if x != nil && x.ExpireTimer != nil { + return *x.ExpireTimer + } + return 0 +} + +func (x *GroupDetails) GetColor() string { + if x != nil && x.Color != nil { + return *x.Color + } + return "" +} + +func (x *GroupDetails) GetBlocked() bool { + if x != nil && x.Blocked != nil { + return *x.Blocked + } + return false +} + +func (x *GroupDetails) GetInboxPosition() uint32 { + if x != nil && x.InboxPosition != nil { + return *x.InboxPosition + } + return 0 +} + +func (x *GroupDetails) GetArchived() bool { + if x != nil && x.Archived != nil { + return *x.Archived + } + return false +} + +type PaymentAddress struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Address: + // + // *PaymentAddress_MobileCoinAddress_ + Address isPaymentAddress_Address `protobuf_oneof:"Address"` } func (x *PaymentAddress) Reset() { *x = PaymentAddress{} - mi := &file_SignalService_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *PaymentAddress) String() string { @@ -3847,8 +3664,8 @@ func (x *PaymentAddress) String() string { func (*PaymentAddress) ProtoMessage() {} func (x *PaymentAddress) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[15] - if x != nil { + mi := &file_SignalService_proto_msgTypes[18] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -3860,21 +3677,19 @@ func (x *PaymentAddress) ProtoReflect() protoreflect.Message { // Deprecated: Use PaymentAddress.ProtoReflect.Descriptor instead. func (*PaymentAddress) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{15} + return file_SignalService_proto_rawDescGZIP(), []int{18} } -func (x *PaymentAddress) GetAddress() isPaymentAddress_Address { - if x != nil { - return x.Address +func (m *PaymentAddress) GetAddress() isPaymentAddress_Address { + if m != nil { + return m.Address } return nil } -func (x *PaymentAddress) GetMobileCoin() *PaymentAddress_MobileCoin { - if x != nil { - if x, ok := x.Address.(*PaymentAddress_MobileCoin_); ok { - return x.MobileCoin - } +func (x *PaymentAddress) GetMobileCoinAddress() *PaymentAddress_MobileCoinAddress { + if x, ok := x.GetAddress().(*PaymentAddress_MobileCoinAddress_); ok { + return x.MobileCoinAddress } return nil } @@ -3883,26 +3698,29 @@ type isPaymentAddress_Address interface { isPaymentAddress_Address() } -type PaymentAddress_MobileCoin_ struct { - MobileCoin *PaymentAddress_MobileCoin `protobuf:"bytes,1,opt,name=mobileCoin,oneof"` +type PaymentAddress_MobileCoinAddress_ struct { + MobileCoinAddress *PaymentAddress_MobileCoinAddress `protobuf:"bytes,1,opt,name=mobileCoinAddress,oneof"` } -func (*PaymentAddress_MobileCoin_) isPaymentAddress_Address() {} +func (*PaymentAddress_MobileCoinAddress_) isPaymentAddress_Address() {} type DecryptionErrorMessage struct { - state protoimpl.MessageState `protogen:"open.v1"` - RatchetKey []byte `protobuf:"bytes,1,opt,name=ratchetKey" json:"ratchetKey,omitempty"` // set to the public ratchet key from the SignalMessage if a 1-1 payload fails to decrypt - Timestamp *uint64 `protobuf:"varint,2,opt,name=timestamp" json:"timestamp,omitempty"` - DeviceId *uint32 `protobuf:"varint,3,opt,name=deviceId" json:"deviceId,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RatchetKey []byte `protobuf:"bytes,1,opt,name=ratchetKey" json:"ratchetKey,omitempty"` + Timestamp *uint64 `protobuf:"varint,2,opt,name=timestamp" json:"timestamp,omitempty"` + DeviceId *uint32 `protobuf:"varint,3,opt,name=deviceId" json:"deviceId,omitempty"` } func (x *DecryptionErrorMessage) Reset() { *x = DecryptionErrorMessage{} - mi := &file_SignalService_proto_msgTypes[16] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *DecryptionErrorMessage) String() string { @@ -3912,8 +3730,8 @@ func (x *DecryptionErrorMessage) String() string { func (*DecryptionErrorMessage) ProtoMessage() {} func (x *DecryptionErrorMessage) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[16] - if x != nil { + mi := &file_SignalService_proto_msgTypes[19] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -3925,7 +3743,7 @@ func (x *DecryptionErrorMessage) ProtoReflect() protoreflect.Message { // Deprecated: Use DecryptionErrorMessage.ProtoReflect.Descriptor instead. func (*DecryptionErrorMessage) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{16} + return file_SignalService_proto_rawDescGZIP(), []int{19} } func (x *DecryptionErrorMessage) GetRatchetKey() []byte { @@ -3950,19 +3768,21 @@ func (x *DecryptionErrorMessage) GetDeviceId() uint32 { } type PniSignatureMessage struct { - state protoimpl.MessageState `protogen:"open.v1"` - Pni []byte `protobuf:"bytes,1,opt,name=pni" json:"pni,omitempty"` - // Signature *by* the PNI identity key *of* the ACI identity key - Signature []byte `protobuf:"bytes,2,opt,name=signature" json:"signature,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Pni []byte `protobuf:"bytes,1,opt,name=pni" json:"pni,omitempty"` + Signature []byte `protobuf:"bytes,2,opt,name=signature" json:"signature,omitempty"` } func (x *PniSignatureMessage) Reset() { *x = PniSignatureMessage{} - mi := &file_SignalService_proto_msgTypes[17] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *PniSignatureMessage) String() string { @@ -3972,8 +3792,8 @@ func (x *PniSignatureMessage) String() string { func (*PniSignatureMessage) ProtoMessage() {} func (x *PniSignatureMessage) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[17] - if x != nil { + mi := &file_SignalService_proto_msgTypes[20] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -3985,7 +3805,7 @@ func (x *PniSignatureMessage) ProtoReflect() protoreflect.Message { // Deprecated: Use PniSignatureMessage.ProtoReflect.Descriptor instead. func (*PniSignatureMessage) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{17} + return file_SignalService_proto_rawDescGZIP(), []int{20} } func (x *PniSignatureMessage) GetPni() []byte { @@ -4003,18 +3823,21 @@ func (x *PniSignatureMessage) GetSignature() []byte { } type EditMessage struct { - state protoimpl.MessageState `protogen:"open.v1"` - TargetSentTimestamp *uint64 `protobuf:"varint,1,opt,name=targetSentTimestamp" json:"targetSentTimestamp,omitempty"` - DataMessage *DataMessage `protobuf:"bytes,2,opt,name=dataMessage" json:"dataMessage,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TargetSentTimestamp *uint64 `protobuf:"varint,1,opt,name=targetSentTimestamp" json:"targetSentTimestamp,omitempty"` + DataMessage *DataMessage `protobuf:"bytes,2,opt,name=dataMessage" json:"dataMessage,omitempty"` } func (x *EditMessage) Reset() { *x = EditMessage{} - mi := &file_SignalService_proto_msgTypes[18] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[21] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *EditMessage) String() string { @@ -4024,8 +3847,8 @@ func (x *EditMessage) String() string { func (*EditMessage) ProtoMessage() {} func (x *EditMessage) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[18] - if x != nil { + mi := &file_SignalService_proto_msgTypes[21] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -4037,7 +3860,7 @@ func (x *EditMessage) ProtoReflect() protoreflect.Message { // Deprecated: Use EditMessage.ProtoReflect.Descriptor instead. func (*EditMessage) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{18} + return file_SignalService_proto_rawDescGZIP(), []int{21} } func (x *EditMessage) GetTargetSentTimestamp() uint64 { @@ -4054,354 +3877,25 @@ func (x *EditMessage) GetDataMessage() *DataMessage { return nil } -type BodyRange struct { - state protoimpl.MessageState `protogen:"open.v1"` - Start *uint32 `protobuf:"varint,1,opt,name=start" json:"start,omitempty"` // Starting index in UTF-16 code units/raw string representation - Length *uint32 `protobuf:"varint,2,opt,name=length" json:"length,omitempty"` // Length of range in UTF-16 code units/raw string representation - // Types that are valid to be assigned to AssociatedValue: - // - // *BodyRange_MentionAci - // *BodyRange_Style_ - // *BodyRange_MentionAciBinary - AssociatedValue isBodyRange_AssociatedValue `protobuf_oneof:"associatedValue"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *BodyRange) Reset() { - *x = BodyRange{} - mi := &file_SignalService_proto_msgTypes[19] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *BodyRange) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*BodyRange) ProtoMessage() {} - -func (x *BodyRange) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[19] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use BodyRange.ProtoReflect.Descriptor instead. -func (*BodyRange) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{19} -} - -func (x *BodyRange) GetStart() uint32 { - if x != nil && x.Start != nil { - return *x.Start - } - return 0 -} - -func (x *BodyRange) GetLength() uint32 { - if x != nil && x.Length != nil { - return *x.Length - } - return 0 -} - -func (x *BodyRange) GetAssociatedValue() isBodyRange_AssociatedValue { - if x != nil { - return x.AssociatedValue - } - return nil -} - -func (x *BodyRange) GetMentionAci() string { - if x != nil { - if x, ok := x.AssociatedValue.(*BodyRange_MentionAci); ok { - return x.MentionAci - } - } - return "" -} - -func (x *BodyRange) GetStyle() BodyRange_Style { - if x != nil { - if x, ok := x.AssociatedValue.(*BodyRange_Style_); ok { - return x.Style - } - } - return BodyRange_NONE -} - -func (x *BodyRange) GetMentionAciBinary() []byte { - if x != nil { - if x, ok := x.AssociatedValue.(*BodyRange_MentionAciBinary); ok { - return x.MentionAciBinary - } - } - return nil -} - -type isBodyRange_AssociatedValue interface { - isBodyRange_AssociatedValue() -} - -type BodyRange_MentionAci struct { - MentionAci string `protobuf:"bytes,3,opt,name=mentionAci,oneof"` -} - -type BodyRange_Style_ struct { - Style BodyRange_Style `protobuf:"varint,4,opt,name=style,enum=signalservice.BodyRange_Style,oneof"` -} - -type BodyRange_MentionAciBinary struct { - MentionAciBinary []byte `protobuf:"bytes,5,opt,name=mentionAciBinary,oneof"` // 16-byte UUID -} - -func (*BodyRange_MentionAci) isBodyRange_AssociatedValue() {} - -func (*BodyRange_Style_) isBodyRange_AssociatedValue() {} - -func (*BodyRange_MentionAciBinary) isBodyRange_AssociatedValue() {} - -type AddressableMessage struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Types that are valid to be assigned to Author: - // - // *AddressableMessage_AuthorServiceId - // *AddressableMessage_AuthorE164 - // *AddressableMessage_AuthorServiceIdBinary - Author isAddressableMessage_Author `protobuf_oneof:"author"` - SentTimestamp *uint64 `protobuf:"varint,3,opt,name=sentTimestamp" json:"sentTimestamp,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AddressableMessage) Reset() { - *x = AddressableMessage{} - mi := &file_SignalService_proto_msgTypes[20] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AddressableMessage) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AddressableMessage) ProtoMessage() {} - -func (x *AddressableMessage) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[20] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AddressableMessage.ProtoReflect.Descriptor instead. -func (*AddressableMessage) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{20} -} - -func (x *AddressableMessage) GetAuthor() isAddressableMessage_Author { - if x != nil { - return x.Author - } - return nil -} - -func (x *AddressableMessage) GetAuthorServiceId() string { - if x != nil { - if x, ok := x.Author.(*AddressableMessage_AuthorServiceId); ok { - return x.AuthorServiceId - } - } - return "" -} - -func (x *AddressableMessage) GetAuthorE164() string { - if x != nil { - if x, ok := x.Author.(*AddressableMessage_AuthorE164); ok { - return x.AuthorE164 - } - } - return "" -} - -func (x *AddressableMessage) GetAuthorServiceIdBinary() []byte { - if x != nil { - if x, ok := x.Author.(*AddressableMessage_AuthorServiceIdBinary); ok { - return x.AuthorServiceIdBinary - } - } - return nil -} - -func (x *AddressableMessage) GetSentTimestamp() uint64 { - if x != nil && x.SentTimestamp != nil { - return *x.SentTimestamp - } - return 0 -} - -type isAddressableMessage_Author interface { - isAddressableMessage_Author() -} - -type AddressableMessage_AuthorServiceId struct { - AuthorServiceId string `protobuf:"bytes,1,opt,name=authorServiceId,oneof"` -} - -type AddressableMessage_AuthorE164 struct { - AuthorE164 string `protobuf:"bytes,2,opt,name=authorE164,oneof"` -} - -type AddressableMessage_AuthorServiceIdBinary struct { - AuthorServiceIdBinary []byte `protobuf:"bytes,4,opt,name=authorServiceIdBinary,oneof"` // service ID binary (i.e. 16 byte UUID for ACI, 1 byte prefix + 16 byte UUID for PNI) -} - -func (*AddressableMessage_AuthorServiceId) isAddressableMessage_Author() {} - -func (*AddressableMessage_AuthorE164) isAddressableMessage_Author() {} - -func (*AddressableMessage_AuthorServiceIdBinary) isAddressableMessage_Author() {} - -type ConversationIdentifier struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Types that are valid to be assigned to Identifier: - // - // *ConversationIdentifier_ThreadServiceId - // *ConversationIdentifier_ThreadGroupId - // *ConversationIdentifier_ThreadE164 - // *ConversationIdentifier_ThreadServiceIdBinary - Identifier isConversationIdentifier_Identifier `protobuf_oneof:"identifier"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ConversationIdentifier) Reset() { - *x = ConversationIdentifier{} - mi := &file_SignalService_proto_msgTypes[21] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ConversationIdentifier) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ConversationIdentifier) ProtoMessage() {} - -func (x *ConversationIdentifier) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[21] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ConversationIdentifier.ProtoReflect.Descriptor instead. -func (*ConversationIdentifier) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{21} -} - -func (x *ConversationIdentifier) GetIdentifier() isConversationIdentifier_Identifier { - if x != nil { - return x.Identifier - } - return nil -} - -func (x *ConversationIdentifier) GetThreadServiceId() string { - if x != nil { - if x, ok := x.Identifier.(*ConversationIdentifier_ThreadServiceId); ok { - return x.ThreadServiceId - } - } - return "" -} - -func (x *ConversationIdentifier) GetThreadGroupId() []byte { - if x != nil { - if x, ok := x.Identifier.(*ConversationIdentifier_ThreadGroupId); ok { - return x.ThreadGroupId - } - } - return nil -} - -func (x *ConversationIdentifier) GetThreadE164() string { - if x != nil { - if x, ok := x.Identifier.(*ConversationIdentifier_ThreadE164); ok { - return x.ThreadE164 - } - } - return "" -} - -func (x *ConversationIdentifier) GetThreadServiceIdBinary() []byte { - if x != nil { - if x, ok := x.Identifier.(*ConversationIdentifier_ThreadServiceIdBinary); ok { - return x.ThreadServiceIdBinary - } - } - return nil -} - -type isConversationIdentifier_Identifier interface { - isConversationIdentifier_Identifier() -} - -type ConversationIdentifier_ThreadServiceId struct { - ThreadServiceId string `protobuf:"bytes,1,opt,name=threadServiceId,oneof"` -} - -type ConversationIdentifier_ThreadGroupId struct { - ThreadGroupId []byte `protobuf:"bytes,2,opt,name=threadGroupId,oneof"` -} - -type ConversationIdentifier_ThreadE164 struct { - ThreadE164 string `protobuf:"bytes,3,opt,name=threadE164,oneof"` -} - -type ConversationIdentifier_ThreadServiceIdBinary struct { - ThreadServiceIdBinary []byte `protobuf:"bytes,4,opt,name=threadServiceIdBinary,oneof"` // service ID binary (i.e. 16 byte UUID for ACI, 1 byte prefix + 16 byte UUID for PNI) -} - -func (*ConversationIdentifier_ThreadServiceId) isConversationIdentifier_Identifier() {} - -func (*ConversationIdentifier_ThreadGroupId) isConversationIdentifier_Identifier() {} - -func (*ConversationIdentifier_ThreadE164) isConversationIdentifier_Identifier() {} - -func (*ConversationIdentifier_ThreadServiceIdBinary) isConversationIdentifier_Identifier() {} - type CallMessage_Offer struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id *uint64 `protobuf:"varint,1,opt,name=id" json:"id,omitempty"` - Type *CallMessage_Offer_Type `protobuf:"varint,3,opt,name=type,enum=signalservice.CallMessage_Offer_Type" json:"type,omitempty"` - Opaque []byte `protobuf:"bytes,4,opt,name=opaque" json:"opaque,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id *uint64 `protobuf:"varint,1,opt,name=id" json:"id,omitempty"` + // Legacy/deprecated; replaced by 'opaque' + Sdp *string `protobuf:"bytes,2,opt,name=sdp" json:"sdp,omitempty"` + Type *CallMessage_Offer_Type `protobuf:"varint,3,opt,name=type,enum=signalservice.CallMessage_Offer_Type" json:"type,omitempty"` + Opaque []byte `protobuf:"bytes,4,opt,name=opaque" json:"opaque,omitempty"` } func (x *CallMessage_Offer) Reset() { *x = CallMessage_Offer{} - mi := &file_SignalService_proto_msgTypes[22] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[22] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *CallMessage_Offer) String() string { @@ -4412,7 +3906,7 @@ func (*CallMessage_Offer) ProtoMessage() {} func (x *CallMessage_Offer) ProtoReflect() protoreflect.Message { mi := &file_SignalService_proto_msgTypes[22] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -4434,6 +3928,13 @@ func (x *CallMessage_Offer) GetId() uint64 { return 0 } +func (x *CallMessage_Offer) GetSdp() string { + if x != nil && x.Sdp != nil { + return *x.Sdp + } + return "" +} + func (x *CallMessage_Offer) GetType() CallMessage_Offer_Type { if x != nil && x.Type != nil { return *x.Type @@ -4449,18 +3950,23 @@ func (x *CallMessage_Offer) GetOpaque() []byte { } type CallMessage_Answer struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id *uint64 `protobuf:"varint,1,opt,name=id" json:"id,omitempty"` - Opaque []byte `protobuf:"bytes,3,opt,name=opaque" json:"opaque,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id *uint64 `protobuf:"varint,1,opt,name=id" json:"id,omitempty"` + // Legacy/deprecated; replaced by 'opaque' + Sdp *string `protobuf:"bytes,2,opt,name=sdp" json:"sdp,omitempty"` + Opaque []byte `protobuf:"bytes,3,opt,name=opaque" json:"opaque,omitempty"` } func (x *CallMessage_Answer) Reset() { *x = CallMessage_Answer{} - mi := &file_SignalService_proto_msgTypes[23] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[23] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *CallMessage_Answer) String() string { @@ -4471,7 +3977,7 @@ func (*CallMessage_Answer) ProtoMessage() {} func (x *CallMessage_Answer) ProtoReflect() protoreflect.Message { mi := &file_SignalService_proto_msgTypes[23] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -4493,6 +3999,13 @@ func (x *CallMessage_Answer) GetId() uint64 { return 0 } +func (x *CallMessage_Answer) GetSdp() string { + if x != nil && x.Sdp != nil { + return *x.Sdp + } + return "" +} + func (x *CallMessage_Answer) GetOpaque() []byte { if x != nil { return x.Opaque @@ -4501,18 +4014,27 @@ func (x *CallMessage_Answer) GetOpaque() []byte { } type CallMessage_IceUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id *uint64 `protobuf:"varint,1,opt,name=id" json:"id,omitempty"` - Opaque []byte `protobuf:"bytes,5,opt,name=opaque" json:"opaque,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id *uint64 `protobuf:"varint,1,opt,name=id" json:"id,omitempty"` + // Legacy/deprecated; remove when old clients are gone. + Mid *string `protobuf:"bytes,2,opt,name=mid" json:"mid,omitempty"` + // Legacy/deprecated; remove when old clients are gone. + Line *uint32 `protobuf:"varint,3,opt,name=line" json:"line,omitempty"` + // Legacy/deprecated; replaced by 'opaque' + Sdp *string `protobuf:"bytes,4,opt,name=sdp" json:"sdp,omitempty"` + Opaque []byte `protobuf:"bytes,5,opt,name=opaque" json:"opaque,omitempty"` } func (x *CallMessage_IceUpdate) Reset() { *x = CallMessage_IceUpdate{} - mi := &file_SignalService_proto_msgTypes[24] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[24] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *CallMessage_IceUpdate) String() string { @@ -4523,7 +4045,7 @@ func (*CallMessage_IceUpdate) ProtoMessage() {} func (x *CallMessage_IceUpdate) ProtoReflect() protoreflect.Message { mi := &file_SignalService_proto_msgTypes[24] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -4545,6 +4067,27 @@ func (x *CallMessage_IceUpdate) GetId() uint64 { return 0 } +func (x *CallMessage_IceUpdate) GetMid() string { + if x != nil && x.Mid != nil { + return *x.Mid + } + return "" +} + +func (x *CallMessage_IceUpdate) GetLine() uint32 { + if x != nil && x.Line != nil { + return *x.Line + } + return 0 +} + +func (x *CallMessage_IceUpdate) GetSdp() string { + if x != nil && x.Sdp != nil { + return *x.Sdp + } + return "" +} + func (x *CallMessage_IceUpdate) GetOpaque() []byte { if x != nil { return x.Opaque @@ -4553,17 +4096,20 @@ func (x *CallMessage_IceUpdate) GetOpaque() []byte { } type CallMessage_Busy struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id *uint64 `protobuf:"varint,1,opt,name=id" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id *uint64 `protobuf:"varint,1,opt,name=id" json:"id,omitempty"` } func (x *CallMessage_Busy) Reset() { *x = CallMessage_Busy{} - mi := &file_SignalService_proto_msgTypes[25] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[25] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *CallMessage_Busy) String() string { @@ -4574,7 +4120,7 @@ func (*CallMessage_Busy) ProtoMessage() {} func (x *CallMessage_Busy) ProtoReflect() protoreflect.Message { mi := &file_SignalService_proto_msgTypes[25] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -4597,19 +4143,22 @@ func (x *CallMessage_Busy) GetId() uint64 { } type CallMessage_Hangup struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id *uint64 `protobuf:"varint,1,opt,name=id" json:"id,omitempty"` - Type *CallMessage_Hangup_Type `protobuf:"varint,2,opt,name=type,enum=signalservice.CallMessage_Hangup_Type" json:"type,omitempty"` - DeviceId *uint32 `protobuf:"varint,3,opt,name=deviceId" json:"deviceId,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id *uint64 `protobuf:"varint,1,opt,name=id" json:"id,omitempty"` + Type *CallMessage_Hangup_Type `protobuf:"varint,2,opt,name=type,enum=signalservice.CallMessage_Hangup_Type" json:"type,omitempty"` + DeviceId *uint32 `protobuf:"varint,3,opt,name=deviceId" json:"deviceId,omitempty"` } func (x *CallMessage_Hangup) Reset() { *x = CallMessage_Hangup{} - mi := &file_SignalService_proto_msgTypes[26] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[26] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *CallMessage_Hangup) String() string { @@ -4620,7 +4169,7 @@ func (*CallMessage_Hangup) ProtoMessage() {} func (x *CallMessage_Hangup) ProtoReflect() protoreflect.Message { mi := &file_SignalService_proto_msgTypes[26] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -4657,18 +4206,21 @@ func (x *CallMessage_Hangup) GetDeviceId() uint32 { } type CallMessage_Opaque struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data []byte `protobuf:"bytes,1,opt,name=data" json:"data,omitempty"` - Urgency *CallMessage_Opaque_Urgency `protobuf:"varint,2,opt,name=urgency,enum=signalservice.CallMessage_Opaque_Urgency" json:"urgency,omitempty"` // If missing, treat as DROPPABLE. - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Data []byte `protobuf:"bytes,1,opt,name=data" json:"data,omitempty"` + Urgency *CallMessage_Opaque_Urgency `protobuf:"varint,2,opt,name=urgency,enum=signalservice.CallMessage_Opaque_Urgency" json:"urgency,omitempty"` } func (x *CallMessage_Opaque) Reset() { *x = CallMessage_Opaque{} - mi := &file_SignalService_proto_msgTypes[27] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[27] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *CallMessage_Opaque) String() string { @@ -4679,7 +4231,7 @@ func (*CallMessage_Opaque) ProtoMessage() {} func (x *CallMessage_Opaque) ProtoReflect() protoreflect.Message { mi := &file_SignalService_proto_msgTypes[27] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -4708,106 +4260,26 @@ func (x *CallMessage_Opaque) GetUrgency() CallMessage_Opaque_Urgency { return CallMessage_Opaque_DROPPABLE } -type DataMessage_Payment struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Types that are valid to be assigned to Item: - // - // *DataMessage_Payment_Notification_ - // *DataMessage_Payment_Activation_ - Item isDataMessage_Payment_Item `protobuf_oneof:"Item"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DataMessage_Payment) Reset() { - *x = DataMessage_Payment{} - mi := &file_SignalService_proto_msgTypes[28] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DataMessage_Payment) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DataMessage_Payment) ProtoMessage() {} - -func (x *DataMessage_Payment) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[28] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DataMessage_Payment.ProtoReflect.Descriptor instead. -func (*DataMessage_Payment) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 0} -} - -func (x *DataMessage_Payment) GetItem() isDataMessage_Payment_Item { - if x != nil { - return x.Item - } - return nil -} - -func (x *DataMessage_Payment) GetNotification() *DataMessage_Payment_Notification { - if x != nil { - if x, ok := x.Item.(*DataMessage_Payment_Notification_); ok { - return x.Notification - } - } - return nil -} - -func (x *DataMessage_Payment) GetActivation() *DataMessage_Payment_Activation { - if x != nil { - if x, ok := x.Item.(*DataMessage_Payment_Activation_); ok { - return x.Activation - } - } - return nil -} - -type isDataMessage_Payment_Item interface { - isDataMessage_Payment_Item() -} - -type DataMessage_Payment_Notification_ struct { - Notification *DataMessage_Payment_Notification `protobuf:"bytes,1,opt,name=notification,oneof"` -} - -type DataMessage_Payment_Activation_ struct { - Activation *DataMessage_Payment_Activation `protobuf:"bytes,2,opt,name=activation,oneof"` -} - -func (*DataMessage_Payment_Notification_) isDataMessage_Payment_Item() {} - -func (*DataMessage_Payment_Activation_) isDataMessage_Payment_Item() {} - type DataMessage_Quote struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id *uint64 `protobuf:"varint,1,opt,name=id" json:"id,omitempty"` - AuthorAci *string `protobuf:"bytes,5,opt,name=authorAci" json:"authorAci,omitempty"` - Text *string `protobuf:"bytes,3,opt,name=text" json:"text,omitempty"` - Attachments []*DataMessage_Quote_QuotedAttachment `protobuf:"bytes,4,rep,name=attachments" json:"attachments,omitempty"` - BodyRanges []*BodyRange `protobuf:"bytes,6,rep,name=bodyRanges" json:"bodyRanges,omitempty"` - Type *DataMessage_Quote_Type `protobuf:"varint,7,opt,name=type,enum=signalservice.DataMessage_Quote_Type" json:"type,omitempty"` - AuthorAciBinary []byte `protobuf:"bytes,8,opt,name=authorAciBinary" json:"authorAciBinary,omitempty"` // 16-byte UUID - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id *uint64 `protobuf:"varint,1,opt,name=id" json:"id,omitempty"` + AuthorAci *string `protobuf:"bytes,5,opt,name=authorAci" json:"authorAci,omitempty"` + Text *string `protobuf:"bytes,3,opt,name=text" json:"text,omitempty"` + Attachments []*DataMessage_Quote_QuotedAttachment `protobuf:"bytes,4,rep,name=attachments" json:"attachments,omitempty"` + BodyRanges []*BodyRange `protobuf:"bytes,6,rep,name=bodyRanges" json:"bodyRanges,omitempty"` + Type *DataMessage_Quote_Type `protobuf:"varint,7,opt,name=type,enum=signalservice.DataMessage_Quote_Type" json:"type,omitempty"` } func (x *DataMessage_Quote) Reset() { *x = DataMessage_Quote{} - mi := &file_SignalService_proto_msgTypes[29] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[28] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *DataMessage_Quote) String() string { @@ -4817,8 +4289,8 @@ func (x *DataMessage_Quote) String() string { func (*DataMessage_Quote) ProtoMessage() {} func (x *DataMessage_Quote) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[29] - if x != nil { + mi := &file_SignalService_proto_msgTypes[28] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -4830,7 +4302,7 @@ func (x *DataMessage_Quote) ProtoReflect() protoreflect.Message { // Deprecated: Use DataMessage_Quote.ProtoReflect.Descriptor instead. func (*DataMessage_Quote) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 1} + return file_SignalService_proto_rawDescGZIP(), []int{4, 0} } func (x *DataMessage_Quote) GetId() uint64 { @@ -4875,30 +4347,26 @@ func (x *DataMessage_Quote) GetType() DataMessage_Quote_Type { return DataMessage_Quote_NORMAL } -func (x *DataMessage_Quote) GetAuthorAciBinary() []byte { - if x != nil { - return x.AuthorAciBinary - } - return nil -} - type DataMessage_Contact struct { - state protoimpl.MessageState `protogen:"open.v1"` - Name *DataMessage_Contact_Name `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` - Number []*DataMessage_Contact_Phone `protobuf:"bytes,3,rep,name=number" json:"number,omitempty"` - Email []*DataMessage_Contact_Email `protobuf:"bytes,4,rep,name=email" json:"email,omitempty"` - Address []*DataMessage_Contact_PostalAddress `protobuf:"bytes,5,rep,name=address" json:"address,omitempty"` - Avatar *DataMessage_Contact_Avatar `protobuf:"bytes,6,opt,name=avatar" json:"avatar,omitempty"` - Organization *string `protobuf:"bytes,7,opt,name=organization" json:"organization,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name *DataMessage_Contact_Name `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Number []*DataMessage_Contact_Phone `protobuf:"bytes,3,rep,name=number" json:"number,omitempty"` + Email []*DataMessage_Contact_Email `protobuf:"bytes,4,rep,name=email" json:"email,omitempty"` + Address []*DataMessage_Contact_PostalAddress `protobuf:"bytes,5,rep,name=address" json:"address,omitempty"` + Avatar *DataMessage_Contact_Avatar `protobuf:"bytes,6,opt,name=avatar" json:"avatar,omitempty"` + Organization *string `protobuf:"bytes,7,opt,name=organization" json:"organization,omitempty"` } func (x *DataMessage_Contact) Reset() { *x = DataMessage_Contact{} - mi := &file_SignalService_proto_msgTypes[30] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[29] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *DataMessage_Contact) String() string { @@ -4908,8 +4376,8 @@ func (x *DataMessage_Contact) String() string { func (*DataMessage_Contact) ProtoMessage() {} func (x *DataMessage_Contact) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[30] - if x != nil { + mi := &file_SignalService_proto_msgTypes[29] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -4921,7 +4389,7 @@ func (x *DataMessage_Contact) ProtoReflect() protoreflect.Message { // Deprecated: Use DataMessage_Contact.ProtoReflect.Descriptor instead. func (*DataMessage_Contact) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 2} + return file_SignalService_proto_rawDescGZIP(), []int{4, 1} } func (x *DataMessage_Contact) GetName() *DataMessage_Contact_Name { @@ -4967,21 +4435,24 @@ func (x *DataMessage_Contact) GetOrganization() string { } type DataMessage_Sticker struct { - state protoimpl.MessageState `protogen:"open.v1"` - PackId []byte `protobuf:"bytes,1,opt,name=packId" json:"packId,omitempty"` - PackKey []byte `protobuf:"bytes,2,opt,name=packKey" json:"packKey,omitempty"` - StickerId *uint32 `protobuf:"varint,3,opt,name=stickerId" json:"stickerId,omitempty"` - Data *AttachmentPointer `protobuf:"bytes,4,opt,name=data" json:"data,omitempty"` - Emoji *string `protobuf:"bytes,5,opt,name=emoji" json:"emoji,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + PackId []byte `protobuf:"bytes,1,opt,name=packId" json:"packId,omitempty"` + PackKey []byte `protobuf:"bytes,2,opt,name=packKey" json:"packKey,omitempty"` + StickerId *uint32 `protobuf:"varint,3,opt,name=stickerId" json:"stickerId,omitempty"` + Data *AttachmentPointer `protobuf:"bytes,4,opt,name=data" json:"data,omitempty"` + Emoji *string `protobuf:"bytes,5,opt,name=emoji" json:"emoji,omitempty"` } func (x *DataMessage_Sticker) Reset() { *x = DataMessage_Sticker{} - mi := &file_SignalService_proto_msgTypes[31] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[30] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *DataMessage_Sticker) String() string { @@ -4991,8 +4462,8 @@ func (x *DataMessage_Sticker) String() string { func (*DataMessage_Sticker) ProtoMessage() {} func (x *DataMessage_Sticker) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[31] - if x != nil { + mi := &file_SignalService_proto_msgTypes[30] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -5004,7 +4475,7 @@ func (x *DataMessage_Sticker) ProtoReflect() protoreflect.Message { // Deprecated: Use DataMessage_Sticker.ProtoReflect.Descriptor instead. func (*DataMessage_Sticker) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 3} + return file_SignalService_proto_rawDescGZIP(), []int{4, 2} } func (x *DataMessage_Sticker) GetPackId() []byte { @@ -5043,21 +4514,23 @@ func (x *DataMessage_Sticker) GetEmoji() string { } type DataMessage_Reaction struct { - state protoimpl.MessageState `protogen:"open.v1"` - Emoji *string `protobuf:"bytes,1,opt,name=emoji" json:"emoji,omitempty"` - Remove *bool `protobuf:"varint,2,opt,name=remove" json:"remove,omitempty"` - TargetAuthorAci *string `protobuf:"bytes,4,opt,name=targetAuthorAci" json:"targetAuthorAci,omitempty"` - TargetSentTimestamp *uint64 `protobuf:"varint,5,opt,name=targetSentTimestamp" json:"targetSentTimestamp,omitempty"` - TargetAuthorAciBinary []byte `protobuf:"bytes,6,opt,name=targetAuthorAciBinary" json:"targetAuthorAciBinary,omitempty"` // 16-byte UUID - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Emoji *string `protobuf:"bytes,1,opt,name=emoji" json:"emoji,omitempty"` + Remove *bool `protobuf:"varint,2,opt,name=remove" json:"remove,omitempty"` + TargetAuthorAci *string `protobuf:"bytes,4,opt,name=targetAuthorAci" json:"targetAuthorAci,omitempty"` + TargetSentTimestamp *uint64 `protobuf:"varint,5,opt,name=targetSentTimestamp" json:"targetSentTimestamp,omitempty"` } func (x *DataMessage_Reaction) Reset() { *x = DataMessage_Reaction{} - mi := &file_SignalService_proto_msgTypes[32] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[31] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *DataMessage_Reaction) String() string { @@ -5067,8 +4540,8 @@ func (x *DataMessage_Reaction) String() string { func (*DataMessage_Reaction) ProtoMessage() {} func (x *DataMessage_Reaction) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[32] - if x != nil { + mi := &file_SignalService_proto_msgTypes[31] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -5080,7 +4553,7 @@ func (x *DataMessage_Reaction) ProtoReflect() protoreflect.Message { // Deprecated: Use DataMessage_Reaction.ProtoReflect.Descriptor instead. func (*DataMessage_Reaction) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 4} + return file_SignalService_proto_rawDescGZIP(), []int{4, 3} } func (x *DataMessage_Reaction) GetEmoji() string { @@ -5111,25 +4584,21 @@ func (x *DataMessage_Reaction) GetTargetSentTimestamp() uint64 { return 0 } -func (x *DataMessage_Reaction) GetTargetAuthorAciBinary() []byte { - if x != nil { - return x.TargetAuthorAciBinary - } - return nil -} - type DataMessage_Delete struct { - state protoimpl.MessageState `protogen:"open.v1"` - TargetSentTimestamp *uint64 `protobuf:"varint,1,opt,name=targetSentTimestamp" json:"targetSentTimestamp,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TargetSentTimestamp *uint64 `protobuf:"varint,1,opt,name=targetSentTimestamp" json:"targetSentTimestamp,omitempty"` } func (x *DataMessage_Delete) Reset() { *x = DataMessage_Delete{} - mi := &file_SignalService_proto_msgTypes[33] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[32] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *DataMessage_Delete) String() string { @@ -5139,8 +4608,8 @@ func (x *DataMessage_Delete) String() string { func (*DataMessage_Delete) ProtoMessage() {} func (x *DataMessage_Delete) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[33] - if x != nil { + mi := &file_SignalService_proto_msgTypes[32] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -5152,7 +4621,7 @@ func (x *DataMessage_Delete) ProtoReflect() protoreflect.Message { // Deprecated: Use DataMessage_Delete.ProtoReflect.Descriptor instead. func (*DataMessage_Delete) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 5} + return file_SignalService_proto_rawDescGZIP(), []int{4, 4} } func (x *DataMessage_Delete) GetTargetSentTimestamp() uint64 { @@ -5163,17 +4632,20 @@ func (x *DataMessage_Delete) GetTargetSentTimestamp() uint64 { } type DataMessage_GroupCallUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - EraId *string `protobuf:"bytes,1,opt,name=eraId" json:"eraId,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + EraId *string `protobuf:"bytes,1,opt,name=eraId" json:"eraId,omitempty"` } func (x *DataMessage_GroupCallUpdate) Reset() { *x = DataMessage_GroupCallUpdate{} - mi := &file_SignalService_proto_msgTypes[34] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[33] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *DataMessage_GroupCallUpdate) String() string { @@ -5183,8 +4655,8 @@ func (x *DataMessage_GroupCallUpdate) String() string { func (*DataMessage_GroupCallUpdate) ProtoMessage() {} func (x *DataMessage_GroupCallUpdate) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[34] - if x != nil { + mi := &file_SignalService_proto_msgTypes[33] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -5196,7 +4668,7 @@ func (x *DataMessage_GroupCallUpdate) ProtoReflect() protoreflect.Message { // Deprecated: Use DataMessage_GroupCallUpdate.ProtoReflect.Descriptor instead. func (*DataMessage_GroupCallUpdate) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 6} + return file_SignalService_proto_rawDescGZIP(), []int{4, 5} } func (x *DataMessage_GroupCallUpdate) GetEraId() string { @@ -5207,19 +4679,21 @@ func (x *DataMessage_GroupCallUpdate) GetEraId() string { } type DataMessage_StoryContext struct { - state protoimpl.MessageState `protogen:"open.v1"` - AuthorAci *string `protobuf:"bytes,1,opt,name=authorAci" json:"authorAci,omitempty"` - SentTimestamp *uint64 `protobuf:"varint,2,opt,name=sentTimestamp" json:"sentTimestamp,omitempty"` - AuthorAciBinary []byte `protobuf:"bytes,3,opt,name=authorAciBinary" json:"authorAciBinary,omitempty"` // 16-byte UUID - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AuthorAci *string `protobuf:"bytes,1,opt,name=authorAci" json:"authorAci,omitempty"` + SentTimestamp *uint64 `protobuf:"varint,2,opt,name=sentTimestamp" json:"sentTimestamp,omitempty"` } func (x *DataMessage_StoryContext) Reset() { *x = DataMessage_StoryContext{} - mi := &file_SignalService_proto_msgTypes[35] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[34] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *DataMessage_StoryContext) String() string { @@ -5229,8 +4703,8 @@ func (x *DataMessage_StoryContext) String() string { func (*DataMessage_StoryContext) ProtoMessage() {} func (x *DataMessage_StoryContext) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[35] - if x != nil { + mi := &file_SignalService_proto_msgTypes[34] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -5242,7 +4716,7 @@ func (x *DataMessage_StoryContext) ProtoReflect() protoreflect.Message { // Deprecated: Use DataMessage_StoryContext.ProtoReflect.Descriptor instead. func (*DataMessage_StoryContext) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 7} + return file_SignalService_proto_rawDescGZIP(), []int{4, 6} } func (x *DataMessage_StoryContext) GetAuthorAci() string { @@ -5259,25 +4733,102 @@ func (x *DataMessage_StoryContext) GetSentTimestamp() uint64 { return 0 } -func (x *DataMessage_StoryContext) GetAuthorAciBinary() []byte { - if x != nil { - return x.AuthorAciBinary +type DataMessage_Payment struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Item: + // + // *DataMessage_Payment_Notification_ + // *DataMessage_Payment_Activation_ + Item isDataMessage_Payment_Item `protobuf_oneof:"Item"` +} + +func (x *DataMessage_Payment) Reset() { + *x = DataMessage_Payment{} + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[35] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DataMessage_Payment) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DataMessage_Payment) ProtoMessage() {} + +func (x *DataMessage_Payment) ProtoReflect() protoreflect.Message { + mi := &file_SignalService_proto_msgTypes[35] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DataMessage_Payment.ProtoReflect.Descriptor instead. +func (*DataMessage_Payment) Descriptor() ([]byte, []int) { + return file_SignalService_proto_rawDescGZIP(), []int{4, 7} +} + +func (m *DataMessage_Payment) GetItem() isDataMessage_Payment_Item { + if m != nil { + return m.Item } return nil } +func (x *DataMessage_Payment) GetNotification() *DataMessage_Payment_Notification { + if x, ok := x.GetItem().(*DataMessage_Payment_Notification_); ok { + return x.Notification + } + return nil +} + +func (x *DataMessage_Payment) GetActivation() *DataMessage_Payment_Activation { + if x, ok := x.GetItem().(*DataMessage_Payment_Activation_); ok { + return x.Activation + } + return nil +} + +type isDataMessage_Payment_Item interface { + isDataMessage_Payment_Item() +} + +type DataMessage_Payment_Notification_ struct { + Notification *DataMessage_Payment_Notification `protobuf:"bytes,1,opt,name=notification,oneof"` +} + +type DataMessage_Payment_Activation_ struct { + Activation *DataMessage_Payment_Activation `protobuf:"bytes,2,opt,name=activation,oneof"` +} + +func (*DataMessage_Payment_Notification_) isDataMessage_Payment_Item() {} + +func (*DataMessage_Payment_Activation_) isDataMessage_Payment_Item() {} + type DataMessage_GiftBadge struct { - state protoimpl.MessageState `protogen:"open.v1"` - ReceiptCredentialPresentation []byte `protobuf:"bytes,1,opt,name=receiptCredentialPresentation" json:"receiptCredentialPresentation,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ReceiptCredentialPresentation []byte `protobuf:"bytes,1,opt,name=receiptCredentialPresentation" json:"receiptCredentialPresentation,omitempty"` } func (x *DataMessage_GiftBadge) Reset() { *x = DataMessage_GiftBadge{} - mi := &file_SignalService_proto_msgTypes[36] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[36] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *DataMessage_GiftBadge) String() string { @@ -5288,7 +4839,7 @@ func (*DataMessage_GiftBadge) ProtoMessage() {} func (x *DataMessage_GiftBadge) ProtoReflect() protoreflect.Message { mi := &file_SignalService_proto_msgTypes[36] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -5300,7 +4851,7 @@ func (x *DataMessage_GiftBadge) ProtoReflect() protoreflect.Message { // Deprecated: Use DataMessage_GiftBadge.ProtoReflect.Descriptor instead. func (*DataMessage_GiftBadge) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 8} + return file_SignalService_proto_rawDescGZIP(), []int{4, 8} } func (x *DataMessage_GiftBadge) GetReceiptCredentialPresentation() []byte { @@ -5310,668 +4861,23 @@ func (x *DataMessage_GiftBadge) GetReceiptCredentialPresentation() []byte { return nil } -type DataMessage_PollCreate struct { - state protoimpl.MessageState `protogen:"open.v1"` - Question *string `protobuf:"bytes,1,opt,name=question" json:"question,omitempty"` - AllowMultiple *bool `protobuf:"varint,2,opt,name=allowMultiple" json:"allowMultiple,omitempty"` - Options []string `protobuf:"bytes,3,rep,name=options" json:"options,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DataMessage_PollCreate) Reset() { - *x = DataMessage_PollCreate{} - mi := &file_SignalService_proto_msgTypes[37] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DataMessage_PollCreate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DataMessage_PollCreate) ProtoMessage() {} - -func (x *DataMessage_PollCreate) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[37] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DataMessage_PollCreate.ProtoReflect.Descriptor instead. -func (*DataMessage_PollCreate) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 9} -} - -func (x *DataMessage_PollCreate) GetQuestion() string { - if x != nil && x.Question != nil { - return *x.Question - } - return "" -} - -func (x *DataMessage_PollCreate) GetAllowMultiple() bool { - if x != nil && x.AllowMultiple != nil { - return *x.AllowMultiple - } - return false -} - -func (x *DataMessage_PollCreate) GetOptions() []string { - if x != nil { - return x.Options - } - return nil -} - -type DataMessage_PollTerminate struct { - state protoimpl.MessageState `protogen:"open.v1"` - TargetSentTimestamp *uint64 `protobuf:"varint,1,opt,name=targetSentTimestamp" json:"targetSentTimestamp,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DataMessage_PollTerminate) Reset() { - *x = DataMessage_PollTerminate{} - mi := &file_SignalService_proto_msgTypes[38] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DataMessage_PollTerminate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DataMessage_PollTerminate) ProtoMessage() {} - -func (x *DataMessage_PollTerminate) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[38] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DataMessage_PollTerminate.ProtoReflect.Descriptor instead. -func (*DataMessage_PollTerminate) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 10} -} - -func (x *DataMessage_PollTerminate) GetTargetSentTimestamp() uint64 { - if x != nil && x.TargetSentTimestamp != nil { - return *x.TargetSentTimestamp - } - return 0 -} - -type DataMessage_PollVote struct { - state protoimpl.MessageState `protogen:"open.v1"` - TargetAuthorAciBinary []byte `protobuf:"bytes,1,opt,name=targetAuthorAciBinary" json:"targetAuthorAciBinary,omitempty"` - TargetSentTimestamp *uint64 `protobuf:"varint,2,opt,name=targetSentTimestamp" json:"targetSentTimestamp,omitempty"` - OptionIndexes []uint32 `protobuf:"varint,3,rep,name=optionIndexes" json:"optionIndexes,omitempty"` - VoteCount *uint32 `protobuf:"varint,4,opt,name=voteCount" json:"voteCount,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DataMessage_PollVote) Reset() { - *x = DataMessage_PollVote{} - mi := &file_SignalService_proto_msgTypes[39] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DataMessage_PollVote) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DataMessage_PollVote) ProtoMessage() {} - -func (x *DataMessage_PollVote) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[39] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DataMessage_PollVote.ProtoReflect.Descriptor instead. -func (*DataMessage_PollVote) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 11} -} - -func (x *DataMessage_PollVote) GetTargetAuthorAciBinary() []byte { - if x != nil { - return x.TargetAuthorAciBinary - } - return nil -} - -func (x *DataMessage_PollVote) GetTargetSentTimestamp() uint64 { - if x != nil && x.TargetSentTimestamp != nil { - return *x.TargetSentTimestamp - } - return 0 -} - -func (x *DataMessage_PollVote) GetOptionIndexes() []uint32 { - if x != nil { - return x.OptionIndexes - } - return nil -} - -func (x *DataMessage_PollVote) GetVoteCount() uint32 { - if x != nil && x.VoteCount != nil { - return *x.VoteCount - } - return 0 -} - -type DataMessage_PinMessage struct { - state protoimpl.MessageState `protogen:"open.v1"` - TargetAuthorAciBinary []byte `protobuf:"bytes,1,opt,name=targetAuthorAciBinary" json:"targetAuthorAciBinary,omitempty"` // 16-byte UUID - TargetSentTimestamp *uint64 `protobuf:"varint,2,opt,name=targetSentTimestamp" json:"targetSentTimestamp,omitempty"` - // Types that are valid to be assigned to PinDuration: - // - // *DataMessage_PinMessage_PinDurationSeconds - // *DataMessage_PinMessage_PinDurationForever - PinDuration isDataMessage_PinMessage_PinDuration `protobuf_oneof:"pinDuration"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DataMessage_PinMessage) Reset() { - *x = DataMessage_PinMessage{} - mi := &file_SignalService_proto_msgTypes[40] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DataMessage_PinMessage) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DataMessage_PinMessage) ProtoMessage() {} - -func (x *DataMessage_PinMessage) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[40] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DataMessage_PinMessage.ProtoReflect.Descriptor instead. -func (*DataMessage_PinMessage) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 12} -} - -func (x *DataMessage_PinMessage) GetTargetAuthorAciBinary() []byte { - if x != nil { - return x.TargetAuthorAciBinary - } - return nil -} - -func (x *DataMessage_PinMessage) GetTargetSentTimestamp() uint64 { - if x != nil && x.TargetSentTimestamp != nil { - return *x.TargetSentTimestamp - } - return 0 -} - -func (x *DataMessage_PinMessage) GetPinDuration() isDataMessage_PinMessage_PinDuration { - if x != nil { - return x.PinDuration - } - return nil -} - -func (x *DataMessage_PinMessage) GetPinDurationSeconds() uint32 { - if x != nil { - if x, ok := x.PinDuration.(*DataMessage_PinMessage_PinDurationSeconds); ok { - return x.PinDurationSeconds - } - } - return 0 -} - -func (x *DataMessage_PinMessage) GetPinDurationForever() bool { - if x != nil { - if x, ok := x.PinDuration.(*DataMessage_PinMessage_PinDurationForever); ok { - return x.PinDurationForever - } - } - return false -} - -type isDataMessage_PinMessage_PinDuration interface { - isDataMessage_PinMessage_PinDuration() -} - -type DataMessage_PinMessage_PinDurationSeconds struct { - PinDurationSeconds uint32 `protobuf:"varint,3,opt,name=pinDurationSeconds,oneof"` -} - -type DataMessage_PinMessage_PinDurationForever struct { - PinDurationForever bool `protobuf:"varint,4,opt,name=pinDurationForever,oneof"` -} - -func (*DataMessage_PinMessage_PinDurationSeconds) isDataMessage_PinMessage_PinDuration() {} - -func (*DataMessage_PinMessage_PinDurationForever) isDataMessage_PinMessage_PinDuration() {} - -type DataMessage_UnpinMessage struct { - state protoimpl.MessageState `protogen:"open.v1"` - TargetAuthorAciBinary []byte `protobuf:"bytes,1,opt,name=targetAuthorAciBinary" json:"targetAuthorAciBinary,omitempty"` // 16-byte UUID - TargetSentTimestamp *uint64 `protobuf:"varint,2,opt,name=targetSentTimestamp" json:"targetSentTimestamp,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DataMessage_UnpinMessage) Reset() { - *x = DataMessage_UnpinMessage{} - mi := &file_SignalService_proto_msgTypes[41] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DataMessage_UnpinMessage) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DataMessage_UnpinMessage) ProtoMessage() {} - -func (x *DataMessage_UnpinMessage) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[41] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DataMessage_UnpinMessage.ProtoReflect.Descriptor instead. -func (*DataMessage_UnpinMessage) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 13} -} - -func (x *DataMessage_UnpinMessage) GetTargetAuthorAciBinary() []byte { - if x != nil { - return x.TargetAuthorAciBinary - } - return nil -} - -func (x *DataMessage_UnpinMessage) GetTargetSentTimestamp() uint64 { - if x != nil && x.TargetSentTimestamp != nil { - return *x.TargetSentTimestamp - } - return 0 -} - -type DataMessage_AdminDelete struct { - state protoimpl.MessageState `protogen:"open.v1"` - TargetAuthorAciBinary []byte `protobuf:"bytes,1,opt,name=targetAuthorAciBinary" json:"targetAuthorAciBinary,omitempty"` // 16-byte UUID - TargetSentTimestamp *uint64 `protobuf:"varint,2,opt,name=targetSentTimestamp" json:"targetSentTimestamp,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DataMessage_AdminDelete) Reset() { - *x = DataMessage_AdminDelete{} - mi := &file_SignalService_proto_msgTypes[42] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DataMessage_AdminDelete) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DataMessage_AdminDelete) ProtoMessage() {} - -func (x *DataMessage_AdminDelete) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[42] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DataMessage_AdminDelete.ProtoReflect.Descriptor instead. -func (*DataMessage_AdminDelete) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 14} -} - -func (x *DataMessage_AdminDelete) GetTargetAuthorAciBinary() []byte { - if x != nil { - return x.TargetAuthorAciBinary - } - return nil -} - -func (x *DataMessage_AdminDelete) GetTargetSentTimestamp() uint64 { - if x != nil && x.TargetSentTimestamp != nil { - return *x.TargetSentTimestamp - } - return 0 -} - -type DataMessage_Payment_Amount struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Types that are valid to be assigned to Amount: - // - // *DataMessage_Payment_Amount_MobileCoin_ - Amount isDataMessage_Payment_Amount_Amount `protobuf_oneof:"Amount"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DataMessage_Payment_Amount) Reset() { - *x = DataMessage_Payment_Amount{} - mi := &file_SignalService_proto_msgTypes[43] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DataMessage_Payment_Amount) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DataMessage_Payment_Amount) ProtoMessage() {} - -func (x *DataMessage_Payment_Amount) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[43] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DataMessage_Payment_Amount.ProtoReflect.Descriptor instead. -func (*DataMessage_Payment_Amount) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 0, 0} -} - -func (x *DataMessage_Payment_Amount) GetAmount() isDataMessage_Payment_Amount_Amount { - if x != nil { - return x.Amount - } - return nil -} - -func (x *DataMessage_Payment_Amount) GetMobileCoin() *DataMessage_Payment_Amount_MobileCoin { - if x != nil { - if x, ok := x.Amount.(*DataMessage_Payment_Amount_MobileCoin_); ok { - return x.MobileCoin - } - } - return nil -} - -type isDataMessage_Payment_Amount_Amount interface { - isDataMessage_Payment_Amount_Amount() -} - -type DataMessage_Payment_Amount_MobileCoin_ struct { - MobileCoin *DataMessage_Payment_Amount_MobileCoin `protobuf:"bytes,1,opt,name=mobileCoin,oneof"` -} - -func (*DataMessage_Payment_Amount_MobileCoin_) isDataMessage_Payment_Amount_Amount() {} - -type DataMessage_Payment_Notification struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Types that are valid to be assigned to Transaction: - // - // *DataMessage_Payment_Notification_MobileCoin_ - Transaction isDataMessage_Payment_Notification_Transaction `protobuf_oneof:"Transaction"` - // Optional, Refers to the PaymentRequest message, if any. - Note *string `protobuf:"bytes,2,opt,name=note" json:"note,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DataMessage_Payment_Notification) Reset() { - *x = DataMessage_Payment_Notification{} - mi := &file_SignalService_proto_msgTypes[44] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DataMessage_Payment_Notification) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DataMessage_Payment_Notification) ProtoMessage() {} - -func (x *DataMessage_Payment_Notification) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[44] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DataMessage_Payment_Notification.ProtoReflect.Descriptor instead. -func (*DataMessage_Payment_Notification) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 0, 1} -} - -func (x *DataMessage_Payment_Notification) GetTransaction() isDataMessage_Payment_Notification_Transaction { - if x != nil { - return x.Transaction - } - return nil -} - -func (x *DataMessage_Payment_Notification) GetMobileCoin() *DataMessage_Payment_Notification_MobileCoin { - if x != nil { - if x, ok := x.Transaction.(*DataMessage_Payment_Notification_MobileCoin_); ok { - return x.MobileCoin - } - } - return nil -} - -func (x *DataMessage_Payment_Notification) GetNote() string { - if x != nil && x.Note != nil { - return *x.Note - } - return "" -} - -type isDataMessage_Payment_Notification_Transaction interface { - isDataMessage_Payment_Notification_Transaction() -} - -type DataMessage_Payment_Notification_MobileCoin_ struct { - MobileCoin *DataMessage_Payment_Notification_MobileCoin `protobuf:"bytes,1,opt,name=mobileCoin,oneof"` -} - -func (*DataMessage_Payment_Notification_MobileCoin_) isDataMessage_Payment_Notification_Transaction() { -} - -type DataMessage_Payment_Activation struct { - state protoimpl.MessageState `protogen:"open.v1"` - Type *DataMessage_Payment_Activation_Type `protobuf:"varint,1,opt,name=type,enum=signalservice.DataMessage_Payment_Activation_Type" json:"type,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DataMessage_Payment_Activation) Reset() { - *x = DataMessage_Payment_Activation{} - mi := &file_SignalService_proto_msgTypes[45] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DataMessage_Payment_Activation) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DataMessage_Payment_Activation) ProtoMessage() {} - -func (x *DataMessage_Payment_Activation) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[45] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DataMessage_Payment_Activation.ProtoReflect.Descriptor instead. -func (*DataMessage_Payment_Activation) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 0, 2} -} - -func (x *DataMessage_Payment_Activation) GetType() DataMessage_Payment_Activation_Type { - if x != nil && x.Type != nil { - return *x.Type - } - return DataMessage_Payment_Activation_REQUEST -} - -type DataMessage_Payment_Amount_MobileCoin struct { - state protoimpl.MessageState `protogen:"open.v1"` - PicoMob *uint64 `protobuf:"varint,1,opt,name=picoMob" json:"picoMob,omitempty"` // 1,000,000,000,000 picoMob per Mob - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DataMessage_Payment_Amount_MobileCoin) Reset() { - *x = DataMessage_Payment_Amount_MobileCoin{} - mi := &file_SignalService_proto_msgTypes[46] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DataMessage_Payment_Amount_MobileCoin) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DataMessage_Payment_Amount_MobileCoin) ProtoMessage() {} - -func (x *DataMessage_Payment_Amount_MobileCoin) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[46] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DataMessage_Payment_Amount_MobileCoin.ProtoReflect.Descriptor instead. -func (*DataMessage_Payment_Amount_MobileCoin) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 0, 0, 0} -} - -func (x *DataMessage_Payment_Amount_MobileCoin) GetPicoMob() uint64 { - if x != nil && x.PicoMob != nil { - return *x.PicoMob - } - return 0 -} - -type DataMessage_Payment_Notification_MobileCoin struct { - state protoimpl.MessageState `protogen:"open.v1"` - Receipt []byte `protobuf:"bytes,1,opt,name=receipt" json:"receipt,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DataMessage_Payment_Notification_MobileCoin) Reset() { - *x = DataMessage_Payment_Notification_MobileCoin{} - mi := &file_SignalService_proto_msgTypes[47] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DataMessage_Payment_Notification_MobileCoin) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DataMessage_Payment_Notification_MobileCoin) ProtoMessage() {} - -func (x *DataMessage_Payment_Notification_MobileCoin) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[47] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DataMessage_Payment_Notification_MobileCoin.ProtoReflect.Descriptor instead. -func (*DataMessage_Payment_Notification_MobileCoin) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 0, 1, 0} -} - -func (x *DataMessage_Payment_Notification_MobileCoin) GetReceipt() []byte { - if x != nil { - return x.Receipt - } - return nil -} - type DataMessage_Quote_QuotedAttachment struct { - state protoimpl.MessageState `protogen:"open.v1"` - ContentType *string `protobuf:"bytes,1,opt,name=contentType" json:"contentType,omitempty"` - FileName *string `protobuf:"bytes,2,opt,name=fileName" json:"fileName,omitempty"` - Thumbnail *AttachmentPointer `protobuf:"bytes,3,opt,name=thumbnail" json:"thumbnail,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ContentType *string `protobuf:"bytes,1,opt,name=contentType" json:"contentType,omitempty"` + FileName *string `protobuf:"bytes,2,opt,name=fileName" json:"fileName,omitempty"` + Thumbnail *AttachmentPointer `protobuf:"bytes,3,opt,name=thumbnail" json:"thumbnail,omitempty"` } func (x *DataMessage_Quote_QuotedAttachment) Reset() { *x = DataMessage_Quote_QuotedAttachment{} - mi := &file_SignalService_proto_msgTypes[48] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[37] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *DataMessage_Quote_QuotedAttachment) String() string { @@ -5981,8 +4887,8 @@ func (x *DataMessage_Quote_QuotedAttachment) String() string { func (*DataMessage_Quote_QuotedAttachment) ProtoMessage() {} func (x *DataMessage_Quote_QuotedAttachment) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[48] - if x != nil { + mi := &file_SignalService_proto_msgTypes[37] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -5994,7 +4900,7 @@ func (x *DataMessage_Quote_QuotedAttachment) ProtoReflect() protoreflect.Message // Deprecated: Use DataMessage_Quote_QuotedAttachment.ProtoReflect.Descriptor instead. func (*DataMessage_Quote_QuotedAttachment) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 1, 0} + return file_SignalService_proto_rawDescGZIP(), []int{4, 0, 0} } func (x *DataMessage_Quote_QuotedAttachment) GetContentType() string { @@ -6019,22 +4925,25 @@ func (x *DataMessage_Quote_QuotedAttachment) GetThumbnail() *AttachmentPointer { } type DataMessage_Contact_Name struct { - state protoimpl.MessageState `protogen:"open.v1"` - GivenName *string `protobuf:"bytes,1,opt,name=givenName" json:"givenName,omitempty"` - FamilyName *string `protobuf:"bytes,2,opt,name=familyName" json:"familyName,omitempty"` - Prefix *string `protobuf:"bytes,3,opt,name=prefix" json:"prefix,omitempty"` - Suffix *string `protobuf:"bytes,4,opt,name=suffix" json:"suffix,omitempty"` - MiddleName *string `protobuf:"bytes,5,opt,name=middleName" json:"middleName,omitempty"` - Nickname *string `protobuf:"bytes,7,opt,name=nickname" json:"nickname,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + GivenName *string `protobuf:"bytes,1,opt,name=givenName" json:"givenName,omitempty"` + FamilyName *string `protobuf:"bytes,2,opt,name=familyName" json:"familyName,omitempty"` + Prefix *string `protobuf:"bytes,3,opt,name=prefix" json:"prefix,omitempty"` + Suffix *string `protobuf:"bytes,4,opt,name=suffix" json:"suffix,omitempty"` + MiddleName *string `protobuf:"bytes,5,opt,name=middleName" json:"middleName,omitempty"` + DisplayName *string `protobuf:"bytes,6,opt,name=displayName" json:"displayName,omitempty"` } func (x *DataMessage_Contact_Name) Reset() { *x = DataMessage_Contact_Name{} - mi := &file_SignalService_proto_msgTypes[49] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[38] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *DataMessage_Contact_Name) String() string { @@ -6044,8 +4953,8 @@ func (x *DataMessage_Contact_Name) String() string { func (*DataMessage_Contact_Name) ProtoMessage() {} func (x *DataMessage_Contact_Name) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[49] - if x != nil { + mi := &file_SignalService_proto_msgTypes[38] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -6057,7 +4966,7 @@ func (x *DataMessage_Contact_Name) ProtoReflect() protoreflect.Message { // Deprecated: Use DataMessage_Contact_Name.ProtoReflect.Descriptor instead. func (*DataMessage_Contact_Name) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 2, 0} + return file_SignalService_proto_rawDescGZIP(), []int{4, 1, 0} } func (x *DataMessage_Contact_Name) GetGivenName() string { @@ -6095,27 +5004,30 @@ func (x *DataMessage_Contact_Name) GetMiddleName() string { return "" } -func (x *DataMessage_Contact_Name) GetNickname() string { - if x != nil && x.Nickname != nil { - return *x.Nickname +func (x *DataMessage_Contact_Name) GetDisplayName() string { + if x != nil && x.DisplayName != nil { + return *x.DisplayName } return "" } type DataMessage_Contact_Phone struct { - state protoimpl.MessageState `protogen:"open.v1"` - Value *string `protobuf:"bytes,1,opt,name=value" json:"value,omitempty"` - Type *DataMessage_Contact_Phone_Type `protobuf:"varint,2,opt,name=type,enum=signalservice.DataMessage_Contact_Phone_Type" json:"type,omitempty"` - Label *string `protobuf:"bytes,3,opt,name=label" json:"label,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Value *string `protobuf:"bytes,1,opt,name=value" json:"value,omitempty"` + Type *DataMessage_Contact_Phone_Type `protobuf:"varint,2,opt,name=type,enum=signalservice.DataMessage_Contact_Phone_Type" json:"type,omitempty"` + Label *string `protobuf:"bytes,3,opt,name=label" json:"label,omitempty"` } func (x *DataMessage_Contact_Phone) Reset() { *x = DataMessage_Contact_Phone{} - mi := &file_SignalService_proto_msgTypes[50] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[39] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *DataMessage_Contact_Phone) String() string { @@ -6125,8 +5037,8 @@ func (x *DataMessage_Contact_Phone) String() string { func (*DataMessage_Contact_Phone) ProtoMessage() {} func (x *DataMessage_Contact_Phone) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[50] - if x != nil { + mi := &file_SignalService_proto_msgTypes[39] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -6138,7 +5050,7 @@ func (x *DataMessage_Contact_Phone) ProtoReflect() protoreflect.Message { // Deprecated: Use DataMessage_Contact_Phone.ProtoReflect.Descriptor instead. func (*DataMessage_Contact_Phone) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 2, 1} + return file_SignalService_proto_rawDescGZIP(), []int{4, 1, 1} } func (x *DataMessage_Contact_Phone) GetValue() string { @@ -6163,19 +5075,22 @@ func (x *DataMessage_Contact_Phone) GetLabel() string { } type DataMessage_Contact_Email struct { - state protoimpl.MessageState `protogen:"open.v1"` - Value *string `protobuf:"bytes,1,opt,name=value" json:"value,omitempty"` - Type *DataMessage_Contact_Email_Type `protobuf:"varint,2,opt,name=type,enum=signalservice.DataMessage_Contact_Email_Type" json:"type,omitempty"` - Label *string `protobuf:"bytes,3,opt,name=label" json:"label,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Value *string `protobuf:"bytes,1,opt,name=value" json:"value,omitempty"` + Type *DataMessage_Contact_Email_Type `protobuf:"varint,2,opt,name=type,enum=signalservice.DataMessage_Contact_Email_Type" json:"type,omitempty"` + Label *string `protobuf:"bytes,3,opt,name=label" json:"label,omitempty"` } func (x *DataMessage_Contact_Email) Reset() { *x = DataMessage_Contact_Email{} - mi := &file_SignalService_proto_msgTypes[51] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[40] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *DataMessage_Contact_Email) String() string { @@ -6185,8 +5100,8 @@ func (x *DataMessage_Contact_Email) String() string { func (*DataMessage_Contact_Email) ProtoMessage() {} func (x *DataMessage_Contact_Email) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[51] - if x != nil { + mi := &file_SignalService_proto_msgTypes[40] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -6198,7 +5113,7 @@ func (x *DataMessage_Contact_Email) ProtoReflect() protoreflect.Message { // Deprecated: Use DataMessage_Contact_Email.ProtoReflect.Descriptor instead. func (*DataMessage_Contact_Email) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 2, 2} + return file_SignalService_proto_rawDescGZIP(), []int{4, 1, 2} } func (x *DataMessage_Contact_Email) GetValue() string { @@ -6223,25 +5138,28 @@ func (x *DataMessage_Contact_Email) GetLabel() string { } type DataMessage_Contact_PostalAddress struct { - state protoimpl.MessageState `protogen:"open.v1"` - Type *DataMessage_Contact_PostalAddress_Type `protobuf:"varint,1,opt,name=type,enum=signalservice.DataMessage_Contact_PostalAddress_Type" json:"type,omitempty"` - Label *string `protobuf:"bytes,2,opt,name=label" json:"label,omitempty"` - Street *string `protobuf:"bytes,3,opt,name=street" json:"street,omitempty"` - Pobox *string `protobuf:"bytes,4,opt,name=pobox" json:"pobox,omitempty"` - Neighborhood *string `protobuf:"bytes,5,opt,name=neighborhood" json:"neighborhood,omitempty"` - City *string `protobuf:"bytes,6,opt,name=city" json:"city,omitempty"` - Region *string `protobuf:"bytes,7,opt,name=region" json:"region,omitempty"` - Postcode *string `protobuf:"bytes,8,opt,name=postcode" json:"postcode,omitempty"` - Country *string `protobuf:"bytes,9,opt,name=country" json:"country,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Type *DataMessage_Contact_PostalAddress_Type `protobuf:"varint,1,opt,name=type,enum=signalservice.DataMessage_Contact_PostalAddress_Type" json:"type,omitempty"` + Label *string `protobuf:"bytes,2,opt,name=label" json:"label,omitempty"` + Street *string `protobuf:"bytes,3,opt,name=street" json:"street,omitempty"` + Pobox *string `protobuf:"bytes,4,opt,name=pobox" json:"pobox,omitempty"` + Neighborhood *string `protobuf:"bytes,5,opt,name=neighborhood" json:"neighborhood,omitempty"` + City *string `protobuf:"bytes,6,opt,name=city" json:"city,omitempty"` + Region *string `protobuf:"bytes,7,opt,name=region" json:"region,omitempty"` + Postcode *string `protobuf:"bytes,8,opt,name=postcode" json:"postcode,omitempty"` + Country *string `protobuf:"bytes,9,opt,name=country" json:"country,omitempty"` } func (x *DataMessage_Contact_PostalAddress) Reset() { *x = DataMessage_Contact_PostalAddress{} - mi := &file_SignalService_proto_msgTypes[52] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[41] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *DataMessage_Contact_PostalAddress) String() string { @@ -6251,8 +5169,8 @@ func (x *DataMessage_Contact_PostalAddress) String() string { func (*DataMessage_Contact_PostalAddress) ProtoMessage() {} func (x *DataMessage_Contact_PostalAddress) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[52] - if x != nil { + mi := &file_SignalService_proto_msgTypes[41] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -6264,7 +5182,7 @@ func (x *DataMessage_Contact_PostalAddress) ProtoReflect() protoreflect.Message // Deprecated: Use DataMessage_Contact_PostalAddress.ProtoReflect.Descriptor instead. func (*DataMessage_Contact_PostalAddress) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 2, 3} + return file_SignalService_proto_rawDescGZIP(), []int{4, 1, 3} } func (x *DataMessage_Contact_PostalAddress) GetType() DataMessage_Contact_PostalAddress_Type { @@ -6331,18 +5249,21 @@ func (x *DataMessage_Contact_PostalAddress) GetCountry() string { } type DataMessage_Contact_Avatar struct { - state protoimpl.MessageState `protogen:"open.v1"` - Avatar *AttachmentPointer `protobuf:"bytes,1,opt,name=avatar" json:"avatar,omitempty"` - IsProfile *bool `protobuf:"varint,2,opt,name=isProfile" json:"isProfile,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Avatar *AttachmentPointer `protobuf:"bytes,1,opt,name=avatar" json:"avatar,omitempty"` + IsProfile *bool `protobuf:"varint,2,opt,name=isProfile" json:"isProfile,omitempty"` } func (x *DataMessage_Contact_Avatar) Reset() { *x = DataMessage_Contact_Avatar{} - mi := &file_SignalService_proto_msgTypes[53] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[42] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *DataMessage_Contact_Avatar) String() string { @@ -6352,8 +5273,8 @@ func (x *DataMessage_Contact_Avatar) String() string { func (*DataMessage_Contact_Avatar) ProtoMessage() {} func (x *DataMessage_Contact_Avatar) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[53] - if x != nil { + mi := &file_SignalService_proto_msgTypes[42] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -6365,7 +5286,7 @@ func (x *DataMessage_Contact_Avatar) ProtoReflect() protoreflect.Message { // Deprecated: Use DataMessage_Contact_Avatar.ProtoReflect.Descriptor instead. func (*DataMessage_Contact_Avatar) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{3, 2, 4} + return file_SignalService_proto_rawDescGZIP(), []int{4, 1, 4} } func (x *DataMessage_Contact_Avatar) GetAvatar() *AttachmentPointer { @@ -6382,22 +5303,309 @@ func (x *DataMessage_Contact_Avatar) GetIsProfile() bool { return false } -type TextAttachment_Gradient struct { - state protoimpl.MessageState `protogen:"open.v1"` - StartColor *uint32 `protobuf:"varint,1,opt,name=startColor" json:"startColor,omitempty"` // deprecated: this field will be removed in a future release. - EndColor *uint32 `protobuf:"varint,2,opt,name=endColor" json:"endColor,omitempty"` // deprecated: this field will be removed in a future release. - Angle *uint32 `protobuf:"varint,3,opt,name=angle" json:"angle,omitempty"` // degrees - Colors []uint32 `protobuf:"varint,4,rep,name=colors" json:"colors,omitempty"` - Positions []float32 `protobuf:"fixed32,5,rep,name=positions" json:"positions,omitempty"` // percent from 0 to 1 - unknownFields protoimpl.UnknownFields +type DataMessage_Payment_Amount struct { + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Amount: + // + // *DataMessage_Payment_Amount_MobileCoin_ + Amount isDataMessage_Payment_Amount_Amount `protobuf_oneof:"Amount"` +} + +func (x *DataMessage_Payment_Amount) Reset() { + *x = DataMessage_Payment_Amount{} + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[43] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DataMessage_Payment_Amount) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DataMessage_Payment_Amount) ProtoMessage() {} + +func (x *DataMessage_Payment_Amount) ProtoReflect() protoreflect.Message { + mi := &file_SignalService_proto_msgTypes[43] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DataMessage_Payment_Amount.ProtoReflect.Descriptor instead. +func (*DataMessage_Payment_Amount) Descriptor() ([]byte, []int) { + return file_SignalService_proto_rawDescGZIP(), []int{4, 7, 0} +} + +func (m *DataMessage_Payment_Amount) GetAmount() isDataMessage_Payment_Amount_Amount { + if m != nil { + return m.Amount + } + return nil +} + +func (x *DataMessage_Payment_Amount) GetMobileCoin() *DataMessage_Payment_Amount_MobileCoin { + if x, ok := x.GetAmount().(*DataMessage_Payment_Amount_MobileCoin_); ok { + return x.MobileCoin + } + return nil +} + +type isDataMessage_Payment_Amount_Amount interface { + isDataMessage_Payment_Amount_Amount() +} + +type DataMessage_Payment_Amount_MobileCoin_ struct { + MobileCoin *DataMessage_Payment_Amount_MobileCoin `protobuf:"bytes,1,opt,name=mobileCoin,oneof"` +} + +func (*DataMessage_Payment_Amount_MobileCoin_) isDataMessage_Payment_Amount_Amount() {} + +type DataMessage_Payment_Notification struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Transaction: + // + // *DataMessage_Payment_Notification_MobileCoin_ + Transaction isDataMessage_Payment_Notification_Transaction `protobuf_oneof:"Transaction"` + Note *string `protobuf:"bytes,2,opt,name=note" json:"note,omitempty"` +} + +func (x *DataMessage_Payment_Notification) Reset() { + *x = DataMessage_Payment_Notification{} + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[44] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DataMessage_Payment_Notification) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DataMessage_Payment_Notification) ProtoMessage() {} + +func (x *DataMessage_Payment_Notification) ProtoReflect() protoreflect.Message { + mi := &file_SignalService_proto_msgTypes[44] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DataMessage_Payment_Notification.ProtoReflect.Descriptor instead. +func (*DataMessage_Payment_Notification) Descriptor() ([]byte, []int) { + return file_SignalService_proto_rawDescGZIP(), []int{4, 7, 1} +} + +func (m *DataMessage_Payment_Notification) GetTransaction() isDataMessage_Payment_Notification_Transaction { + if m != nil { + return m.Transaction + } + return nil +} + +func (x *DataMessage_Payment_Notification) GetMobileCoin() *DataMessage_Payment_Notification_MobileCoin { + if x, ok := x.GetTransaction().(*DataMessage_Payment_Notification_MobileCoin_); ok { + return x.MobileCoin + } + return nil +} + +func (x *DataMessage_Payment_Notification) GetNote() string { + if x != nil && x.Note != nil { + return *x.Note + } + return "" +} + +type isDataMessage_Payment_Notification_Transaction interface { + isDataMessage_Payment_Notification_Transaction() +} + +type DataMessage_Payment_Notification_MobileCoin_ struct { + MobileCoin *DataMessage_Payment_Notification_MobileCoin `protobuf:"bytes,1,opt,name=mobileCoin,oneof"` +} + +func (*DataMessage_Payment_Notification_MobileCoin_) isDataMessage_Payment_Notification_Transaction() { +} + +type DataMessage_Payment_Activation struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Type *DataMessage_Payment_Activation_Type `protobuf:"varint,1,opt,name=type,enum=signalservice.DataMessage_Payment_Activation_Type" json:"type,omitempty"` +} + +func (x *DataMessage_Payment_Activation) Reset() { + *x = DataMessage_Payment_Activation{} + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[45] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DataMessage_Payment_Activation) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DataMessage_Payment_Activation) ProtoMessage() {} + +func (x *DataMessage_Payment_Activation) ProtoReflect() protoreflect.Message { + mi := &file_SignalService_proto_msgTypes[45] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DataMessage_Payment_Activation.ProtoReflect.Descriptor instead. +func (*DataMessage_Payment_Activation) Descriptor() ([]byte, []int) { + return file_SignalService_proto_rawDescGZIP(), []int{4, 7, 2} +} + +func (x *DataMessage_Payment_Activation) GetType() DataMessage_Payment_Activation_Type { + if x != nil && x.Type != nil { + return *x.Type + } + return DataMessage_Payment_Activation_REQUEST +} + +type DataMessage_Payment_Amount_MobileCoin struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + PicoMob *uint64 `protobuf:"varint,1,opt,name=picoMob" json:"picoMob,omitempty"` +} + +func (x *DataMessage_Payment_Amount_MobileCoin) Reset() { + *x = DataMessage_Payment_Amount_MobileCoin{} + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[46] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DataMessage_Payment_Amount_MobileCoin) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DataMessage_Payment_Amount_MobileCoin) ProtoMessage() {} + +func (x *DataMessage_Payment_Amount_MobileCoin) ProtoReflect() protoreflect.Message { + mi := &file_SignalService_proto_msgTypes[46] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DataMessage_Payment_Amount_MobileCoin.ProtoReflect.Descriptor instead. +func (*DataMessage_Payment_Amount_MobileCoin) Descriptor() ([]byte, []int) { + return file_SignalService_proto_rawDescGZIP(), []int{4, 7, 0, 0} +} + +func (x *DataMessage_Payment_Amount_MobileCoin) GetPicoMob() uint64 { + if x != nil && x.PicoMob != nil { + return *x.PicoMob + } + return 0 +} + +type DataMessage_Payment_Notification_MobileCoin struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Receipt []byte `protobuf:"bytes,1,opt,name=receipt" json:"receipt,omitempty"` +} + +func (x *DataMessage_Payment_Notification_MobileCoin) Reset() { + *x = DataMessage_Payment_Notification_MobileCoin{} + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[47] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DataMessage_Payment_Notification_MobileCoin) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DataMessage_Payment_Notification_MobileCoin) ProtoMessage() {} + +func (x *DataMessage_Payment_Notification_MobileCoin) ProtoReflect() protoreflect.Message { + mi := &file_SignalService_proto_msgTypes[47] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DataMessage_Payment_Notification_MobileCoin.ProtoReflect.Descriptor instead. +func (*DataMessage_Payment_Notification_MobileCoin) Descriptor() ([]byte, []int) { + return file_SignalService_proto_rawDescGZIP(), []int{4, 7, 1, 0} +} + +func (x *DataMessage_Payment_Notification_MobileCoin) GetReceipt() []byte { + if x != nil { + return x.Receipt + } + return nil +} + +type TextAttachment_Gradient struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + StartColor *uint32 `protobuf:"varint,1,opt,name=startColor" json:"startColor,omitempty"` // deprecated: this field will be removed in a future release. + EndColor *uint32 `protobuf:"varint,2,opt,name=endColor" json:"endColor,omitempty"` // deprecated: this field will be removed in a future release. + Angle *uint32 `protobuf:"varint,3,opt,name=angle" json:"angle,omitempty"` // degrees + Colors []uint32 `protobuf:"varint,4,rep,name=colors" json:"colors,omitempty"` + Positions []float32 `protobuf:"fixed32,5,rep,name=positions" json:"positions,omitempty"` // percent from 0 to 1 } func (x *TextAttachment_Gradient) Reset() { *x = TextAttachment_Gradient{} - mi := &file_SignalService_proto_msgTypes[54] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[48] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *TextAttachment_Gradient) String() string { @@ -6407,8 +5615,8 @@ func (x *TextAttachment_Gradient) String() string { func (*TextAttachment_Gradient) ProtoMessage() {} func (x *TextAttachment_Gradient) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[54] - if x != nil { + mi := &file_SignalService_proto_msgTypes[48] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -6420,7 +5628,7 @@ func (x *TextAttachment_Gradient) ProtoReflect() protoreflect.Message { // Deprecated: Use TextAttachment_Gradient.ProtoReflect.Descriptor instead. func (*TextAttachment_Gradient) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{9, 0} + return file_SignalService_proto_rawDescGZIP(), []int{10, 0} } func (x *TextAttachment_Gradient) GetStartColor() uint32 { @@ -6459,20 +5667,20 @@ func (x *TextAttachment_Gradient) GetPositions() []float32 { } type SyncMessage_Sent struct { - state protoimpl.MessageState `protogen:"open.v1"` - DestinationE164 *string `protobuf:"bytes,1,opt,name=destinationE164" json:"destinationE164,omitempty"` - DestinationServiceId *string `protobuf:"bytes,7,opt,name=destinationServiceId" json:"destinationServiceId,omitempty"` - Timestamp *uint64 `protobuf:"varint,2,opt,name=timestamp" json:"timestamp,omitempty"` - Message *DataMessage `protobuf:"bytes,3,opt,name=message" json:"message,omitempty"` - ExpirationStartTimestamp *uint64 `protobuf:"varint,4,opt,name=expirationStartTimestamp" json:"expirationStartTimestamp,omitempty"` - UnidentifiedStatus []*SyncMessage_Sent_UnidentifiedDeliveryStatus `protobuf:"bytes,5,rep,name=unidentifiedStatus" json:"unidentifiedStatus,omitempty"` - IsRecipientUpdate *bool `protobuf:"varint,6,opt,name=isRecipientUpdate,def=0" json:"isRecipientUpdate,omitempty"` - StoryMessage *StoryMessage `protobuf:"bytes,8,opt,name=storyMessage" json:"storyMessage,omitempty"` - StoryMessageRecipients []*SyncMessage_Sent_StoryMessageRecipient `protobuf:"bytes,9,rep,name=storyMessageRecipients" json:"storyMessageRecipients,omitempty"` - EditMessage *EditMessage `protobuf:"bytes,10,opt,name=editMessage" json:"editMessage,omitempty"` - DestinationServiceIdBinary []byte `protobuf:"bytes,12,opt,name=destinationServiceIdBinary" json:"destinationServiceIdBinary,omitempty"` // service ID binary (i.e. 16 byte UUID for ACI, 1 byte prefix + 16 byte UUID for PNI) - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + DestinationE164 *string `protobuf:"bytes,1,opt,name=destinationE164" json:"destinationE164,omitempty"` + DestinationServiceId *string `protobuf:"bytes,7,opt,name=destinationServiceId" json:"destinationServiceId,omitempty"` + Timestamp *uint64 `protobuf:"varint,2,opt,name=timestamp" json:"timestamp,omitempty"` + Message *DataMessage `protobuf:"bytes,3,opt,name=message" json:"message,omitempty"` + ExpirationStartTimestamp *uint64 `protobuf:"varint,4,opt,name=expirationStartTimestamp" json:"expirationStartTimestamp,omitempty"` + UnidentifiedStatus []*SyncMessage_Sent_UnidentifiedDeliveryStatus `protobuf:"bytes,5,rep,name=unidentifiedStatus" json:"unidentifiedStatus,omitempty"` + IsRecipientUpdate *bool `protobuf:"varint,6,opt,name=isRecipientUpdate,def=0" json:"isRecipientUpdate,omitempty"` + StoryMessage *StoryMessage `protobuf:"bytes,8,opt,name=storyMessage" json:"storyMessage,omitempty"` + StoryMessageRecipients []*SyncMessage_Sent_StoryMessageRecipient `protobuf:"bytes,9,rep,name=storyMessageRecipients" json:"storyMessageRecipients,omitempty"` + EditMessage *EditMessage `protobuf:"bytes,10,opt,name=editMessage" json:"editMessage,omitempty"` } // Default values for SyncMessage_Sent fields. @@ -6482,9 +5690,11 @@ const ( func (x *SyncMessage_Sent) Reset() { *x = SyncMessage_Sent{} - mi := &file_SignalService_proto_msgTypes[55] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[49] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *SyncMessage_Sent) String() string { @@ -6494,8 +5704,8 @@ func (x *SyncMessage_Sent) String() string { func (*SyncMessage_Sent) ProtoMessage() {} func (x *SyncMessage_Sent) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[55] - if x != nil { + mi := &file_SignalService_proto_msgTypes[49] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -6507,7 +5717,7 @@ func (x *SyncMessage_Sent) ProtoReflect() protoreflect.Message { // Deprecated: Use SyncMessage_Sent.ProtoReflect.Descriptor instead. func (*SyncMessage_Sent) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 0} + return file_SignalService_proto_rawDescGZIP(), []int{12, 0} } func (x *SyncMessage_Sent) GetDestinationE164() string { @@ -6580,19 +5790,13 @@ func (x *SyncMessage_Sent) GetEditMessage() *EditMessage { return nil } -func (x *SyncMessage_Sent) GetDestinationServiceIdBinary() []byte { - if x != nil { - return x.DestinationServiceIdBinary - } - return nil -} - type SyncMessage_Contacts struct { - state protoimpl.MessageState `protogen:"open.v1"` - Blob *AttachmentPointer `protobuf:"bytes,1,opt,name=blob" json:"blob,omitempty"` - Complete *bool `protobuf:"varint,2,opt,name=complete,def=0" json:"complete,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Blob *AttachmentPointer `protobuf:"bytes,1,opt,name=blob" json:"blob,omitempty"` + Complete *bool `protobuf:"varint,2,opt,name=complete,def=0" json:"complete,omitempty"` } // Default values for SyncMessage_Contacts fields. @@ -6602,9 +5806,11 @@ const ( func (x *SyncMessage_Contacts) Reset() { *x = SyncMessage_Contacts{} - mi := &file_SignalService_proto_msgTypes[56] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[50] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *SyncMessage_Contacts) String() string { @@ -6614,8 +5820,8 @@ func (x *SyncMessage_Contacts) String() string { func (*SyncMessage_Contacts) ProtoMessage() {} func (x *SyncMessage_Contacts) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[56] - if x != nil { + mi := &file_SignalService_proto_msgTypes[50] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -6627,7 +5833,7 @@ func (x *SyncMessage_Contacts) ProtoReflect() protoreflect.Message { // Deprecated: Use SyncMessage_Contacts.ProtoReflect.Descriptor instead. func (*SyncMessage_Contacts) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 1} + return file_SignalService_proto_rawDescGZIP(), []int{12, 1} } func (x *SyncMessage_Contacts) GetBlob() *AttachmentPointer { @@ -6645,20 +5851,22 @@ func (x *SyncMessage_Contacts) GetComplete() bool { } type SyncMessage_Blocked struct { - state protoimpl.MessageState `protogen:"open.v1"` - Numbers []string `protobuf:"bytes,1,rep,name=numbers" json:"numbers,omitempty"` - Acis []string `protobuf:"bytes,3,rep,name=acis" json:"acis,omitempty"` - GroupIds [][]byte `protobuf:"bytes,2,rep,name=groupIds" json:"groupIds,omitempty"` - AcisBinary [][]byte `protobuf:"bytes,4,rep,name=acisBinary" json:"acisBinary,omitempty"` // 16-byte UUID - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Numbers []string `protobuf:"bytes,1,rep,name=numbers" json:"numbers,omitempty"` + Acis []string `protobuf:"bytes,3,rep,name=acis" json:"acis,omitempty"` + GroupIds [][]byte `protobuf:"bytes,2,rep,name=groupIds" json:"groupIds,omitempty"` } func (x *SyncMessage_Blocked) Reset() { *x = SyncMessage_Blocked{} - mi := &file_SignalService_proto_msgTypes[57] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[51] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *SyncMessage_Blocked) String() string { @@ -6668,8 +5876,8 @@ func (x *SyncMessage_Blocked) String() string { func (*SyncMessage_Blocked) ProtoMessage() {} func (x *SyncMessage_Blocked) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[57] - if x != nil { + mi := &file_SignalService_proto_msgTypes[51] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -6681,7 +5889,7 @@ func (x *SyncMessage_Blocked) ProtoReflect() protoreflect.Message { // Deprecated: Use SyncMessage_Blocked.ProtoReflect.Descriptor instead. func (*SyncMessage_Blocked) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 2} + return file_SignalService_proto_rawDescGZIP(), []int{12, 2} } func (x *SyncMessage_Blocked) GetNumbers() []string { @@ -6705,25 +5913,21 @@ func (x *SyncMessage_Blocked) GetGroupIds() [][]byte { return nil } -func (x *SyncMessage_Blocked) GetAcisBinary() [][]byte { - if x != nil { - return x.AcisBinary - } - return nil -} - type SyncMessage_Request struct { - state protoimpl.MessageState `protogen:"open.v1"` - Type *SyncMessage_Request_Type `protobuf:"varint,1,opt,name=type,enum=signalservice.SyncMessage_Request_Type" json:"type,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Type *SyncMessage_Request_Type `protobuf:"varint,1,opt,name=type,enum=signalservice.SyncMessage_Request_Type" json:"type,omitempty"` } func (x *SyncMessage_Request) Reset() { *x = SyncMessage_Request{} - mi := &file_SignalService_proto_msgTypes[58] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[52] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *SyncMessage_Request) String() string { @@ -6733,8 +5937,8 @@ func (x *SyncMessage_Request) String() string { func (*SyncMessage_Request) ProtoMessage() {} func (x *SyncMessage_Request) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[58] - if x != nil { + mi := &file_SignalService_proto_msgTypes[52] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -6746,7 +5950,7 @@ func (x *SyncMessage_Request) ProtoReflect() protoreflect.Message { // Deprecated: Use SyncMessage_Request.ProtoReflect.Descriptor instead. func (*SyncMessage_Request) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 3} + return file_SignalService_proto_rawDescGZIP(), []int{12, 3} } func (x *SyncMessage_Request) GetType() SyncMessage_Request_Type { @@ -6757,19 +5961,21 @@ func (x *SyncMessage_Request) GetType() SyncMessage_Request_Type { } type SyncMessage_Read struct { - state protoimpl.MessageState `protogen:"open.v1"` - SenderAci *string `protobuf:"bytes,3,opt,name=senderAci" json:"senderAci,omitempty"` - Timestamp *uint64 `protobuf:"varint,2,opt,name=timestamp" json:"timestamp,omitempty"` - SenderAciBinary []byte `protobuf:"bytes,4,opt,name=senderAciBinary" json:"senderAciBinary,omitempty"` // 16-byte UUID - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SenderAci *string `protobuf:"bytes,3,opt,name=senderAci" json:"senderAci,omitempty"` + Timestamp *uint64 `protobuf:"varint,2,opt,name=timestamp" json:"timestamp,omitempty"` } func (x *SyncMessage_Read) Reset() { *x = SyncMessage_Read{} - mi := &file_SignalService_proto_msgTypes[59] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[53] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *SyncMessage_Read) String() string { @@ -6779,8 +5985,8 @@ func (x *SyncMessage_Read) String() string { func (*SyncMessage_Read) ProtoMessage() {} func (x *SyncMessage_Read) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[59] - if x != nil { + mi := &file_SignalService_proto_msgTypes[53] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -6792,7 +5998,7 @@ func (x *SyncMessage_Read) ProtoReflect() protoreflect.Message { // Deprecated: Use SyncMessage_Read.ProtoReflect.Descriptor instead. func (*SyncMessage_Read) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 4} + return file_SignalService_proto_rawDescGZIP(), []int{12, 4} } func (x *SyncMessage_Read) GetSenderAci() string { @@ -6809,27 +6015,22 @@ func (x *SyncMessage_Read) GetTimestamp() uint64 { return 0 } -func (x *SyncMessage_Read) GetSenderAciBinary() []byte { - if x != nil { - return x.SenderAciBinary - } - return nil -} - type SyncMessage_Viewed struct { - state protoimpl.MessageState `protogen:"open.v1"` - SenderAci *string `protobuf:"bytes,3,opt,name=senderAci" json:"senderAci,omitempty"` - Timestamp *uint64 `protobuf:"varint,2,opt,name=timestamp" json:"timestamp,omitempty"` - SenderAciBinary []byte `protobuf:"bytes,4,opt,name=senderAciBinary" json:"senderAciBinary,omitempty"` // 16-byte UUID - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SenderAci *string `protobuf:"bytes,3,opt,name=senderAci" json:"senderAci,omitempty"` + Timestamp *uint64 `protobuf:"varint,2,opt,name=timestamp" json:"timestamp,omitempty"` } func (x *SyncMessage_Viewed) Reset() { *x = SyncMessage_Viewed{} - mi := &file_SignalService_proto_msgTypes[60] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[54] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *SyncMessage_Viewed) String() string { @@ -6839,8 +6040,8 @@ func (x *SyncMessage_Viewed) String() string { func (*SyncMessage_Viewed) ProtoMessage() {} func (x *SyncMessage_Viewed) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[60] - if x != nil { + mi := &file_SignalService_proto_msgTypes[54] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -6852,7 +6053,7 @@ func (x *SyncMessage_Viewed) ProtoReflect() protoreflect.Message { // Deprecated: Use SyncMessage_Viewed.ProtoReflect.Descriptor instead. func (*SyncMessage_Viewed) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 5} + return file_SignalService_proto_rawDescGZIP(), []int{12, 5} } func (x *SyncMessage_Viewed) GetSenderAci() string { @@ -6869,28 +6070,25 @@ func (x *SyncMessage_Viewed) GetTimestamp() uint64 { return 0 } -func (x *SyncMessage_Viewed) GetSenderAciBinary() []byte { - if x != nil { - return x.SenderAciBinary - } - return nil -} - type SyncMessage_Configuration struct { - state protoimpl.MessageState `protogen:"open.v1"` - ReadReceipts *bool `protobuf:"varint,1,opt,name=readReceipts" json:"readReceipts,omitempty"` - UnidentifiedDeliveryIndicators *bool `protobuf:"varint,2,opt,name=unidentifiedDeliveryIndicators" json:"unidentifiedDeliveryIndicators,omitempty"` - TypingIndicators *bool `protobuf:"varint,3,opt,name=typingIndicators" json:"typingIndicators,omitempty"` - LinkPreviews *bool `protobuf:"varint,6,opt,name=linkPreviews" json:"linkPreviews,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ReadReceipts *bool `protobuf:"varint,1,opt,name=readReceipts" json:"readReceipts,omitempty"` + UnidentifiedDeliveryIndicators *bool `protobuf:"varint,2,opt,name=unidentifiedDeliveryIndicators" json:"unidentifiedDeliveryIndicators,omitempty"` + TypingIndicators *bool `protobuf:"varint,3,opt,name=typingIndicators" json:"typingIndicators,omitempty"` + ProvisioningVersion *uint32 `protobuf:"varint,5,opt,name=provisioningVersion" json:"provisioningVersion,omitempty"` + LinkPreviews *bool `protobuf:"varint,6,opt,name=linkPreviews" json:"linkPreviews,omitempty"` } func (x *SyncMessage_Configuration) Reset() { *x = SyncMessage_Configuration{} - mi := &file_SignalService_proto_msgTypes[61] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[55] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *SyncMessage_Configuration) String() string { @@ -6900,8 +6098,8 @@ func (x *SyncMessage_Configuration) String() string { func (*SyncMessage_Configuration) ProtoMessage() {} func (x *SyncMessage_Configuration) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[61] - if x != nil { + mi := &file_SignalService_proto_msgTypes[55] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -6913,7 +6111,7 @@ func (x *SyncMessage_Configuration) ProtoReflect() protoreflect.Message { // Deprecated: Use SyncMessage_Configuration.ProtoReflect.Descriptor instead. func (*SyncMessage_Configuration) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 6} + return file_SignalService_proto_rawDescGZIP(), []int{12, 6} } func (x *SyncMessage_Configuration) GetReadReceipts() bool { @@ -6937,6 +6135,13 @@ func (x *SyncMessage_Configuration) GetTypingIndicators() bool { return false } +func (x *SyncMessage_Configuration) GetProvisioningVersion() uint32 { + if x != nil && x.ProvisioningVersion != nil { + return *x.ProvisioningVersion + } + return 0 +} + func (x *SyncMessage_Configuration) GetLinkPreviews() bool { if x != nil && x.LinkPreviews != nil { return *x.LinkPreviews @@ -6945,19 +6150,22 @@ func (x *SyncMessage_Configuration) GetLinkPreviews() bool { } type SyncMessage_StickerPackOperation struct { - state protoimpl.MessageState `protogen:"open.v1"` - PackId []byte `protobuf:"bytes,1,opt,name=packId" json:"packId,omitempty"` - PackKey []byte `protobuf:"bytes,2,opt,name=packKey" json:"packKey,omitempty"` - Type *SyncMessage_StickerPackOperation_Type `protobuf:"varint,3,opt,name=type,enum=signalservice.SyncMessage_StickerPackOperation_Type" json:"type,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + PackId []byte `protobuf:"bytes,1,opt,name=packId" json:"packId,omitempty"` + PackKey []byte `protobuf:"bytes,2,opt,name=packKey" json:"packKey,omitempty"` + Type *SyncMessage_StickerPackOperation_Type `protobuf:"varint,3,opt,name=type,enum=signalservice.SyncMessage_StickerPackOperation_Type" json:"type,omitempty"` } func (x *SyncMessage_StickerPackOperation) Reset() { *x = SyncMessage_StickerPackOperation{} - mi := &file_SignalService_proto_msgTypes[62] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[56] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *SyncMessage_StickerPackOperation) String() string { @@ -6967,8 +6175,8 @@ func (x *SyncMessage_StickerPackOperation) String() string { func (*SyncMessage_StickerPackOperation) ProtoMessage() {} func (x *SyncMessage_StickerPackOperation) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[62] - if x != nil { + mi := &file_SignalService_proto_msgTypes[56] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -6980,7 +6188,7 @@ func (x *SyncMessage_StickerPackOperation) ProtoReflect() protoreflect.Message { // Deprecated: Use SyncMessage_StickerPackOperation.ProtoReflect.Descriptor instead. func (*SyncMessage_StickerPackOperation) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 7} + return file_SignalService_proto_rawDescGZIP(), []int{12, 7} } func (x *SyncMessage_StickerPackOperation) GetPackId() []byte { @@ -7005,19 +6213,21 @@ func (x *SyncMessage_StickerPackOperation) GetType() SyncMessage_StickerPackOper } type SyncMessage_ViewOnceOpen struct { - state protoimpl.MessageState `protogen:"open.v1"` - SenderAci *string `protobuf:"bytes,3,opt,name=senderAci" json:"senderAci,omitempty"` - Timestamp *uint64 `protobuf:"varint,2,opt,name=timestamp" json:"timestamp,omitempty"` - SenderAciBinary []byte `protobuf:"bytes,4,opt,name=senderAciBinary" json:"senderAciBinary,omitempty"` // 16-byte UUID - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SenderAci *string `protobuf:"bytes,3,opt,name=senderAci" json:"senderAci,omitempty"` + Timestamp *uint64 `protobuf:"varint,2,opt,name=timestamp" json:"timestamp,omitempty"` } func (x *SyncMessage_ViewOnceOpen) Reset() { *x = SyncMessage_ViewOnceOpen{} - mi := &file_SignalService_proto_msgTypes[63] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[57] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *SyncMessage_ViewOnceOpen) String() string { @@ -7027,8 +6237,8 @@ func (x *SyncMessage_ViewOnceOpen) String() string { func (*SyncMessage_ViewOnceOpen) ProtoMessage() {} func (x *SyncMessage_ViewOnceOpen) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[63] - if x != nil { + mi := &file_SignalService_proto_msgTypes[57] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -7040,7 +6250,7 @@ func (x *SyncMessage_ViewOnceOpen) ProtoReflect() protoreflect.Message { // Deprecated: Use SyncMessage_ViewOnceOpen.ProtoReflect.Descriptor instead. func (*SyncMessage_ViewOnceOpen) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 8} + return file_SignalService_proto_rawDescGZIP(), []int{12, 8} } func (x *SyncMessage_ViewOnceOpen) GetSenderAci() string { @@ -7057,25 +6267,21 @@ func (x *SyncMessage_ViewOnceOpen) GetTimestamp() uint64 { return 0 } -func (x *SyncMessage_ViewOnceOpen) GetSenderAciBinary() []byte { - if x != nil { - return x.SenderAciBinary - } - return nil -} - type SyncMessage_FetchLatest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Type *SyncMessage_FetchLatest_Type `protobuf:"varint,1,opt,name=type,enum=signalservice.SyncMessage_FetchLatest_Type" json:"type,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Type *SyncMessage_FetchLatest_Type `protobuf:"varint,1,opt,name=type,enum=signalservice.SyncMessage_FetchLatest_Type" json:"type,omitempty"` } func (x *SyncMessage_FetchLatest) Reset() { *x = SyncMessage_FetchLatest{} - mi := &file_SignalService_proto_msgTypes[64] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[58] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *SyncMessage_FetchLatest) String() string { @@ -7085,8 +6291,8 @@ func (x *SyncMessage_FetchLatest) String() string { func (*SyncMessage_FetchLatest) ProtoMessage() {} func (x *SyncMessage_FetchLatest) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[64] - if x != nil { + mi := &file_SignalService_proto_msgTypes[58] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -7098,7 +6304,7 @@ func (x *SyncMessage_FetchLatest) ProtoReflect() protoreflect.Message { // Deprecated: Use SyncMessage_FetchLatest.ProtoReflect.Descriptor instead. func (*SyncMessage_FetchLatest) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 9} + return file_SignalService_proto_rawDescGZIP(), []int{12, 9} } func (x *SyncMessage_FetchLatest) GetType() SyncMessage_FetchLatest_Type { @@ -7109,18 +6315,22 @@ func (x *SyncMessage_FetchLatest) GetType() SyncMessage_FetchLatest_Type { } type SyncMessage_Keys struct { - state protoimpl.MessageState `protogen:"open.v1"` - AccountEntropyPool *string `protobuf:"bytes,3,opt,name=accountEntropyPool" json:"accountEntropyPool,omitempty"` - MediaRootBackupKey []byte `protobuf:"bytes,4,opt,name=mediaRootBackupKey" json:"mediaRootBackupKey,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // @deprecated + StorageService []byte `protobuf:"bytes,1,opt,name=storageService" json:"storageService,omitempty"` + Master []byte `protobuf:"bytes,2,opt,name=master" json:"master,omitempty"` } func (x *SyncMessage_Keys) Reset() { *x = SyncMessage_Keys{} - mi := &file_SignalService_proto_msgTypes[65] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[59] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *SyncMessage_Keys) String() string { @@ -7130,8 +6340,8 @@ func (x *SyncMessage_Keys) String() string { func (*SyncMessage_Keys) ProtoMessage() {} func (x *SyncMessage_Keys) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[65] - if x != nil { + mi := &file_SignalService_proto_msgTypes[59] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -7143,90 +6353,40 @@ func (x *SyncMessage_Keys) ProtoReflect() protoreflect.Message { // Deprecated: Use SyncMessage_Keys.ProtoReflect.Descriptor instead. func (*SyncMessage_Keys) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 10} + return file_SignalService_proto_rawDescGZIP(), []int{12, 10} } -func (x *SyncMessage_Keys) GetAccountEntropyPool() string { - if x != nil && x.AccountEntropyPool != nil { - return *x.AccountEntropyPool - } - return "" -} - -func (x *SyncMessage_Keys) GetMediaRootBackupKey() []byte { +func (x *SyncMessage_Keys) GetStorageService() []byte { if x != nil { - return x.MediaRootBackupKey + return x.StorageService } return nil } -type SyncMessage_PniIdentity struct { - state protoimpl.MessageState `protogen:"open.v1"` - PublicKey []byte `protobuf:"bytes,1,opt,name=publicKey" json:"publicKey,omitempty"` - PrivateKey []byte `protobuf:"bytes,2,opt,name=privateKey" json:"privateKey,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *SyncMessage_PniIdentity) Reset() { - *x = SyncMessage_PniIdentity{} - mi := &file_SignalService_proto_msgTypes[66] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *SyncMessage_PniIdentity) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SyncMessage_PniIdentity) ProtoMessage() {} - -func (x *SyncMessage_PniIdentity) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[66] +func (x *SyncMessage_Keys) GetMaster() []byte { if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SyncMessage_PniIdentity.ProtoReflect.Descriptor instead. -func (*SyncMessage_PniIdentity) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 11} -} - -func (x *SyncMessage_PniIdentity) GetPublicKey() []byte { - if x != nil { - return x.PublicKey - } - return nil -} - -func (x *SyncMessage_PniIdentity) GetPrivateKey() []byte { - if x != nil { - return x.PrivateKey + return x.Master } return nil } type SyncMessage_MessageRequestResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - ThreadAci *string `protobuf:"bytes,2,opt,name=threadAci" json:"threadAci,omitempty"` - GroupId []byte `protobuf:"bytes,3,opt,name=groupId" json:"groupId,omitempty"` - Type *SyncMessage_MessageRequestResponse_Type `protobuf:"varint,4,opt,name=type,enum=signalservice.SyncMessage_MessageRequestResponse_Type" json:"type,omitempty"` - ThreadAciBinary []byte `protobuf:"bytes,5,opt,name=threadAciBinary" json:"threadAciBinary,omitempty"` // 16-byte UUID - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ThreadAci *string `protobuf:"bytes,2,opt,name=threadAci" json:"threadAci,omitempty"` + GroupId []byte `protobuf:"bytes,3,opt,name=groupId" json:"groupId,omitempty"` + Type *SyncMessage_MessageRequestResponse_Type `protobuf:"varint,4,opt,name=type,enum=signalservice.SyncMessage_MessageRequestResponse_Type" json:"type,omitempty"` } func (x *SyncMessage_MessageRequestResponse) Reset() { *x = SyncMessage_MessageRequestResponse{} - mi := &file_SignalService_proto_msgTypes[67] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[60] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *SyncMessage_MessageRequestResponse) String() string { @@ -7236,8 +6396,8 @@ func (x *SyncMessage_MessageRequestResponse) String() string { func (*SyncMessage_MessageRequestResponse) ProtoMessage() {} func (x *SyncMessage_MessageRequestResponse) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[67] - if x != nil { + mi := &file_SignalService_proto_msgTypes[60] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -7249,7 +6409,7 @@ func (x *SyncMessage_MessageRequestResponse) ProtoReflect() protoreflect.Message // Deprecated: Use SyncMessage_MessageRequestResponse.ProtoReflect.Descriptor instead. func (*SyncMessage_MessageRequestResponse) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 12} + return file_SignalService_proto_rawDescGZIP(), []int{12, 11} } func (x *SyncMessage_MessageRequestResponse) GetThreadAci() string { @@ -7273,30 +6433,26 @@ func (x *SyncMessage_MessageRequestResponse) GetType() SyncMessage_MessageReques return SyncMessage_MessageRequestResponse_UNKNOWN } -func (x *SyncMessage_MessageRequestResponse) GetThreadAciBinary() []byte { - if x != nil { - return x.ThreadAciBinary - } - return nil -} - type SyncMessage_OutgoingPayment struct { - state protoimpl.MessageState `protogen:"open.v1"` - RecipientServiceId *string `protobuf:"bytes,1,opt,name=recipientServiceId" json:"recipientServiceId,omitempty"` - Note *string `protobuf:"bytes,2,opt,name=note" json:"note,omitempty"` - // Types that are valid to be assigned to AttachmentIdentifier: + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RecipientServiceId *string `protobuf:"bytes,1,opt,name=recipientServiceId" json:"recipientServiceId,omitempty"` + Note *string `protobuf:"bytes,2,opt,name=note" json:"note,omitempty"` + // Types that are assignable to PaymentDetail: // // *SyncMessage_OutgoingPayment_MobileCoin_ - AttachmentIdentifier isSyncMessage_OutgoingPayment_AttachmentIdentifier `protobuf_oneof:"attachment_identifier"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + PaymentDetail isSyncMessage_OutgoingPayment_PaymentDetail `protobuf_oneof:"paymentDetail"` } func (x *SyncMessage_OutgoingPayment) Reset() { *x = SyncMessage_OutgoingPayment{} - mi := &file_SignalService_proto_msgTypes[68] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[61] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *SyncMessage_OutgoingPayment) String() string { @@ -7306,8 +6462,8 @@ func (x *SyncMessage_OutgoingPayment) String() string { func (*SyncMessage_OutgoingPayment) ProtoMessage() {} func (x *SyncMessage_OutgoingPayment) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[68] - if x != nil { + mi := &file_SignalService_proto_msgTypes[61] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -7319,7 +6475,7 @@ func (x *SyncMessage_OutgoingPayment) ProtoReflect() protoreflect.Message { // Deprecated: Use SyncMessage_OutgoingPayment.ProtoReflect.Descriptor instead. func (*SyncMessage_OutgoingPayment) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 13} + return file_SignalService_proto_rawDescGZIP(), []int{12, 12} } func (x *SyncMessage_OutgoingPayment) GetRecipientServiceId() string { @@ -7336,49 +6492,49 @@ func (x *SyncMessage_OutgoingPayment) GetNote() string { return "" } -func (x *SyncMessage_OutgoingPayment) GetAttachmentIdentifier() isSyncMessage_OutgoingPayment_AttachmentIdentifier { - if x != nil { - return x.AttachmentIdentifier +func (m *SyncMessage_OutgoingPayment) GetPaymentDetail() isSyncMessage_OutgoingPayment_PaymentDetail { + if m != nil { + return m.PaymentDetail } return nil } func (x *SyncMessage_OutgoingPayment) GetMobileCoin() *SyncMessage_OutgoingPayment_MobileCoin { - if x != nil { - if x, ok := x.AttachmentIdentifier.(*SyncMessage_OutgoingPayment_MobileCoin_); ok { - return x.MobileCoin - } + if x, ok := x.GetPaymentDetail().(*SyncMessage_OutgoingPayment_MobileCoin_); ok { + return x.MobileCoin } return nil } -type isSyncMessage_OutgoingPayment_AttachmentIdentifier interface { - isSyncMessage_OutgoingPayment_AttachmentIdentifier() +type isSyncMessage_OutgoingPayment_PaymentDetail interface { + isSyncMessage_OutgoingPayment_PaymentDetail() } type SyncMessage_OutgoingPayment_MobileCoin_ struct { MobileCoin *SyncMessage_OutgoingPayment_MobileCoin `protobuf:"bytes,3,opt,name=mobileCoin,oneof"` } -func (*SyncMessage_OutgoingPayment_MobileCoin_) isSyncMessage_OutgoingPayment_AttachmentIdentifier() { -} +func (*SyncMessage_OutgoingPayment_MobileCoin_) isSyncMessage_OutgoingPayment_PaymentDetail() {} type SyncMessage_PniChangeNumber struct { - state protoimpl.MessageState `protogen:"open.v1"` - IdentityKeyPair []byte `protobuf:"bytes,1,opt,name=identityKeyPair" json:"identityKeyPair,omitempty"` // Serialized libsignal-client IdentityKeyPair - SignedPreKey []byte `protobuf:"bytes,2,opt,name=signedPreKey" json:"signedPreKey,omitempty"` // Serialized libsignal-client SignedPreKeyRecord - LastResortKyberPreKey []byte `protobuf:"bytes,5,opt,name=lastResortKyberPreKey" json:"lastResortKyberPreKey,omitempty"` // Serialized libsignal-client KyberPreKeyRecord - RegistrationId *uint32 `protobuf:"varint,3,opt,name=registrationId" json:"registrationId,omitempty"` - NewE164 *string `protobuf:"bytes,4,opt,name=newE164" json:"newE164,omitempty"` // The e164 we have changed our number to - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + IdentityKeyPair []byte `protobuf:"bytes,1,opt,name=identityKeyPair" json:"identityKeyPair,omitempty"` // Serialized libsignal-client IdentityKeyPair + SignedPreKey []byte `protobuf:"bytes,2,opt,name=signedPreKey" json:"signedPreKey,omitempty"` // Serialized libsignal-client SignedPreKeyRecord + LastResortKyberPreKey []byte `protobuf:"bytes,5,opt,name=lastResortKyberPreKey" json:"lastResortKyberPreKey,omitempty"` // Serialized libsignal-client KyberPreKeyRecord + RegistrationId *uint32 `protobuf:"varint,3,opt,name=registrationId" json:"registrationId,omitempty"` + NewE164 *string `protobuf:"bytes,4,opt,name=newE164" json:"newE164,omitempty"` // The e164 we have changed our number to } func (x *SyncMessage_PniChangeNumber) Reset() { *x = SyncMessage_PniChangeNumber{} - mi := &file_SignalService_proto_msgTypes[69] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[62] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *SyncMessage_PniChangeNumber) String() string { @@ -7388,8 +6544,8 @@ func (x *SyncMessage_PniChangeNumber) String() string { func (*SyncMessage_PniChangeNumber) ProtoMessage() {} func (x *SyncMessage_PniChangeNumber) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[69] - if x != nil { + mi := &file_SignalService_proto_msgTypes[62] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -7401,7 +6557,7 @@ func (x *SyncMessage_PniChangeNumber) ProtoReflect() protoreflect.Message { // Deprecated: Use SyncMessage_PniChangeNumber.ProtoReflect.Descriptor instead. func (*SyncMessage_PniChangeNumber) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 14} + return file_SignalService_proto_rawDescGZIP(), []int{12, 13} } func (x *SyncMessage_PniChangeNumber) GetIdentityKeyPair() []byte { @@ -7440,27 +6596,25 @@ func (x *SyncMessage_PniChangeNumber) GetNewE164() string { } type SyncMessage_CallEvent struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Data identifying a conversation. The service ID for 1:1, the group ID for - // group, or the room ID for an ad-hoc call. See also - // `CallLogEvent/conversationId`. - ConversationId []byte `protobuf:"bytes,1,opt,name=conversationId" json:"conversationId,omitempty"` - // An identifier for a call. Generated directly for 1:1, or derived from - // the era ID for group and ad-hoc calls. See also `CallLogEvent/callId`. - CallId *uint64 `protobuf:"varint,2,opt,name=callId" json:"callId,omitempty"` - Timestamp *uint64 `protobuf:"varint,3,opt,name=timestamp" json:"timestamp,omitempty"` - Type *SyncMessage_CallEvent_Type `protobuf:"varint,4,opt,name=type,enum=signalservice.SyncMessage_CallEvent_Type" json:"type,omitempty"` - Direction *SyncMessage_CallEvent_Direction `protobuf:"varint,5,opt,name=direction,enum=signalservice.SyncMessage_CallEvent_Direction" json:"direction,omitempty"` - Event *SyncMessage_CallEvent_Event `protobuf:"varint,6,opt,name=event,enum=signalservice.SyncMessage_CallEvent_Event" json:"event,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ConversationId []byte `protobuf:"bytes,1,opt,name=conversationId" json:"conversationId,omitempty"` + Id *uint64 `protobuf:"varint,2,opt,name=id" json:"id,omitempty"` + Timestamp *uint64 `protobuf:"varint,3,opt,name=timestamp" json:"timestamp,omitempty"` + Type *SyncMessage_CallEvent_Type `protobuf:"varint,4,opt,name=type,enum=signalservice.SyncMessage_CallEvent_Type" json:"type,omitempty"` + Direction *SyncMessage_CallEvent_Direction `protobuf:"varint,5,opt,name=direction,enum=signalservice.SyncMessage_CallEvent_Direction" json:"direction,omitempty"` + Event *SyncMessage_CallEvent_Event `protobuf:"varint,6,opt,name=event,enum=signalservice.SyncMessage_CallEvent_Event" json:"event,omitempty"` } func (x *SyncMessage_CallEvent) Reset() { *x = SyncMessage_CallEvent{} - mi := &file_SignalService_proto_msgTypes[70] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[63] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *SyncMessage_CallEvent) String() string { @@ -7470,8 +6624,8 @@ func (x *SyncMessage_CallEvent) String() string { func (*SyncMessage_CallEvent) ProtoMessage() {} func (x *SyncMessage_CallEvent) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[70] - if x != nil { + mi := &file_SignalService_proto_msgTypes[63] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -7483,7 +6637,7 @@ func (x *SyncMessage_CallEvent) ProtoReflect() protoreflect.Message { // Deprecated: Use SyncMessage_CallEvent.ProtoReflect.Descriptor instead. func (*SyncMessage_CallEvent) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 15} + return file_SignalService_proto_rawDescGZIP(), []int{12, 14} } func (x *SyncMessage_CallEvent) GetConversationId() []byte { @@ -7493,9 +6647,9 @@ func (x *SyncMessage_CallEvent) GetConversationId() []byte { return nil } -func (x *SyncMessage_CallEvent) GetCallId() uint64 { - if x != nil && x.CallId != nil { - return *x.CallId +func (x *SyncMessage_CallEvent) GetId() uint64 { + if x != nil && x.Id != nil { + return *x.Id } return 0 } @@ -7525,23 +6679,25 @@ func (x *SyncMessage_CallEvent) GetEvent() SyncMessage_CallEvent_Event { if x != nil && x.Event != nil { return *x.Event } - return SyncMessage_CallEvent_UNKNOWN_EVENT + return SyncMessage_CallEvent_UNKNOWN_ACTION } type SyncMessage_CallLinkUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - RootKey []byte `protobuf:"bytes,1,opt,name=rootKey" json:"rootKey,omitempty"` - AdminPasskey []byte `protobuf:"bytes,2,opt,name=adminPasskey" json:"adminPasskey,omitempty"` - Type *SyncMessage_CallLinkUpdate_Type `protobuf:"varint,3,opt,name=type,enum=signalservice.SyncMessage_CallLinkUpdate_Type" json:"type,omitempty"` // defaults to UPDATE - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RootKey []byte `protobuf:"bytes,1,opt,name=rootKey" json:"rootKey,omitempty"` + AdminPassKey []byte `protobuf:"bytes,2,opt,name=adminPassKey" json:"adminPassKey,omitempty"` } func (x *SyncMessage_CallLinkUpdate) Reset() { *x = SyncMessage_CallLinkUpdate{} - mi := &file_SignalService_proto_msgTypes[71] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[64] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *SyncMessage_CallLinkUpdate) String() string { @@ -7551,8 +6707,8 @@ func (x *SyncMessage_CallLinkUpdate) String() string { func (*SyncMessage_CallLinkUpdate) ProtoMessage() {} func (x *SyncMessage_CallLinkUpdate) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[71] - if x != nil { + mi := &file_SignalService_proto_msgTypes[64] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -7564,7 +6720,7 @@ func (x *SyncMessage_CallLinkUpdate) ProtoReflect() protoreflect.Message { // Deprecated: Use SyncMessage_CallLinkUpdate.ProtoReflect.Descriptor instead. func (*SyncMessage_CallLinkUpdate) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 16} + return file_SignalService_proto_rawDescGZIP(), []int{12, 15} } func (x *SyncMessage_CallLinkUpdate) GetRootKey() []byte { @@ -7574,40 +6730,29 @@ func (x *SyncMessage_CallLinkUpdate) GetRootKey() []byte { return nil } -func (x *SyncMessage_CallLinkUpdate) GetAdminPasskey() []byte { +func (x *SyncMessage_CallLinkUpdate) GetAdminPassKey() []byte { if x != nil { - return x.AdminPasskey + return x.AdminPassKey } return nil } -func (x *SyncMessage_CallLinkUpdate) GetType() SyncMessage_CallLinkUpdate_Type { - if x != nil && x.Type != nil { - return *x.Type - } - return SyncMessage_CallLinkUpdate_UPDATE -} - type SyncMessage_CallLogEvent struct { - state protoimpl.MessageState `protogen:"open.v1"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + Type *SyncMessage_CallLogEvent_Type `protobuf:"varint,1,opt,name=type,enum=signalservice.SyncMessage_CallLogEvent_Type" json:"type,omitempty"` Timestamp *uint64 `protobuf:"varint,2,opt,name=timestamp" json:"timestamp,omitempty"` - // Data identifying a conversation. The service ID for 1:1, the group ID for - // group, or the room ID for an ad-hoc call. See also - // `CallEvent/conversationId`. - ConversationId []byte `protobuf:"bytes,3,opt,name=conversationId" json:"conversationId,omitempty"` - // An identifier for a call. Generated directly for 1:1, or derived from - // the era ID for group and ad-hoc calls. See also `CallEvent/callId`. - CallId *uint64 `protobuf:"varint,4,opt,name=callId" json:"callId,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache } func (x *SyncMessage_CallLogEvent) Reset() { *x = SyncMessage_CallLogEvent{} - mi := &file_SignalService_proto_msgTypes[72] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[65] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *SyncMessage_CallLogEvent) String() string { @@ -7617,8 +6762,8 @@ func (x *SyncMessage_CallLogEvent) String() string { func (*SyncMessage_CallLogEvent) ProtoMessage() {} func (x *SyncMessage_CallLogEvent) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[72] - if x != nil { + mi := &file_SignalService_proto_msgTypes[65] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -7630,7 +6775,7 @@ func (x *SyncMessage_CallLogEvent) ProtoReflect() protoreflect.Message { // Deprecated: Use SyncMessage_CallLogEvent.ProtoReflect.Descriptor instead. func (*SyncMessage_CallLogEvent) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 17} + return file_SignalService_proto_rawDescGZIP(), []int{12, 16} } func (x *SyncMessage_CallLogEvent) GetType() SyncMessage_CallLogEvent_Type { @@ -7647,299 +6792,22 @@ func (x *SyncMessage_CallLogEvent) GetTimestamp() uint64 { return 0 } -func (x *SyncMessage_CallLogEvent) GetConversationId() []byte { - if x != nil { - return x.ConversationId - } - return nil -} - -func (x *SyncMessage_CallLogEvent) GetCallId() uint64 { - if x != nil && x.CallId != nil { - return *x.CallId - } - return 0 -} - -type SyncMessage_DeleteForMe struct { - state protoimpl.MessageState `protogen:"open.v1"` - MessageDeletes []*SyncMessage_DeleteForMe_MessageDeletes `protobuf:"bytes,1,rep,name=messageDeletes" json:"messageDeletes,omitempty"` - ConversationDeletes []*SyncMessage_DeleteForMe_ConversationDelete `protobuf:"bytes,2,rep,name=conversationDeletes" json:"conversationDeletes,omitempty"` - LocalOnlyConversationDeletes []*SyncMessage_DeleteForMe_LocalOnlyConversationDelete `protobuf:"bytes,3,rep,name=localOnlyConversationDeletes" json:"localOnlyConversationDeletes,omitempty"` - AttachmentDeletes []*SyncMessage_DeleteForMe_AttachmentDelete `protobuf:"bytes,4,rep,name=attachmentDeletes" json:"attachmentDeletes,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *SyncMessage_DeleteForMe) Reset() { - *x = SyncMessage_DeleteForMe{} - mi := &file_SignalService_proto_msgTypes[73] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *SyncMessage_DeleteForMe) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SyncMessage_DeleteForMe) ProtoMessage() {} - -func (x *SyncMessage_DeleteForMe) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[73] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SyncMessage_DeleteForMe.ProtoReflect.Descriptor instead. -func (*SyncMessage_DeleteForMe) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 18} -} - -func (x *SyncMessage_DeleteForMe) GetMessageDeletes() []*SyncMessage_DeleteForMe_MessageDeletes { - if x != nil { - return x.MessageDeletes - } - return nil -} - -func (x *SyncMessage_DeleteForMe) GetConversationDeletes() []*SyncMessage_DeleteForMe_ConversationDelete { - if x != nil { - return x.ConversationDeletes - } - return nil -} - -func (x *SyncMessage_DeleteForMe) GetLocalOnlyConversationDeletes() []*SyncMessage_DeleteForMe_LocalOnlyConversationDelete { - if x != nil { - return x.LocalOnlyConversationDeletes - } - return nil -} - -func (x *SyncMessage_DeleteForMe) GetAttachmentDeletes() []*SyncMessage_DeleteForMe_AttachmentDelete { - if x != nil { - return x.AttachmentDeletes - } - return nil -} - -type SyncMessage_DeviceNameChange struct { - state protoimpl.MessageState `protogen:"open.v1"` - DeviceId *uint32 `protobuf:"varint,2,opt,name=deviceId" json:"deviceId,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *SyncMessage_DeviceNameChange) Reset() { - *x = SyncMessage_DeviceNameChange{} - mi := &file_SignalService_proto_msgTypes[74] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *SyncMessage_DeviceNameChange) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SyncMessage_DeviceNameChange) ProtoMessage() {} - -func (x *SyncMessage_DeviceNameChange) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[74] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SyncMessage_DeviceNameChange.ProtoReflect.Descriptor instead. -func (*SyncMessage_DeviceNameChange) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 19} -} - -func (x *SyncMessage_DeviceNameChange) GetDeviceId() uint32 { - if x != nil && x.DeviceId != nil { - return *x.DeviceId - } - return 0 -} - -type SyncMessage_AttachmentBackfillRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - TargetMessage *AddressableMessage `protobuf:"bytes,1,opt,name=targetMessage" json:"targetMessage,omitempty"` - TargetConversation *ConversationIdentifier `protobuf:"bytes,2,opt,name=targetConversation" json:"targetConversation,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *SyncMessage_AttachmentBackfillRequest) Reset() { - *x = SyncMessage_AttachmentBackfillRequest{} - mi := &file_SignalService_proto_msgTypes[75] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *SyncMessage_AttachmentBackfillRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SyncMessage_AttachmentBackfillRequest) ProtoMessage() {} - -func (x *SyncMessage_AttachmentBackfillRequest) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[75] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SyncMessage_AttachmentBackfillRequest.ProtoReflect.Descriptor instead. -func (*SyncMessage_AttachmentBackfillRequest) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 20} -} - -func (x *SyncMessage_AttachmentBackfillRequest) GetTargetMessage() *AddressableMessage { - if x != nil { - return x.TargetMessage - } - return nil -} - -func (x *SyncMessage_AttachmentBackfillRequest) GetTargetConversation() *ConversationIdentifier { - if x != nil { - return x.TargetConversation - } - return nil -} - -type SyncMessage_AttachmentBackfillResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - TargetMessage *AddressableMessage `protobuf:"bytes,1,opt,name=targetMessage" json:"targetMessage,omitempty"` - TargetConversation *ConversationIdentifier `protobuf:"bytes,2,opt,name=targetConversation" json:"targetConversation,omitempty"` - // Types that are valid to be assigned to Data: - // - // *SyncMessage_AttachmentBackfillResponse_Attachments - // *SyncMessage_AttachmentBackfillResponse_Error_ - Data isSyncMessage_AttachmentBackfillResponse_Data `protobuf_oneof:"data"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *SyncMessage_AttachmentBackfillResponse) Reset() { - *x = SyncMessage_AttachmentBackfillResponse{} - mi := &file_SignalService_proto_msgTypes[76] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *SyncMessage_AttachmentBackfillResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SyncMessage_AttachmentBackfillResponse) ProtoMessage() {} - -func (x *SyncMessage_AttachmentBackfillResponse) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[76] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SyncMessage_AttachmentBackfillResponse.ProtoReflect.Descriptor instead. -func (*SyncMessage_AttachmentBackfillResponse) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 21} -} - -func (x *SyncMessage_AttachmentBackfillResponse) GetTargetMessage() *AddressableMessage { - if x != nil { - return x.TargetMessage - } - return nil -} - -func (x *SyncMessage_AttachmentBackfillResponse) GetTargetConversation() *ConversationIdentifier { - if x != nil { - return x.TargetConversation - } - return nil -} - -func (x *SyncMessage_AttachmentBackfillResponse) GetData() isSyncMessage_AttachmentBackfillResponse_Data { - if x != nil { - return x.Data - } - return nil -} - -func (x *SyncMessage_AttachmentBackfillResponse) GetAttachments() *SyncMessage_AttachmentBackfillResponse_AttachmentDataList { - if x != nil { - if x, ok := x.Data.(*SyncMessage_AttachmentBackfillResponse_Attachments); ok { - return x.Attachments - } - } - return nil -} - -func (x *SyncMessage_AttachmentBackfillResponse) GetError() SyncMessage_AttachmentBackfillResponse_Error { - if x != nil { - if x, ok := x.Data.(*SyncMessage_AttachmentBackfillResponse_Error_); ok { - return x.Error - } - } - return SyncMessage_AttachmentBackfillResponse_MESSAGE_NOT_FOUND -} - -type isSyncMessage_AttachmentBackfillResponse_Data interface { - isSyncMessage_AttachmentBackfillResponse_Data() -} - -type SyncMessage_AttachmentBackfillResponse_Attachments struct { - Attachments *SyncMessage_AttachmentBackfillResponse_AttachmentDataList `protobuf:"bytes,3,opt,name=attachments,oneof"` -} - -type SyncMessage_AttachmentBackfillResponse_Error_ struct { - Error SyncMessage_AttachmentBackfillResponse_Error `protobuf:"varint,4,opt,name=error,enum=signalservice.SyncMessage_AttachmentBackfillResponse_Error,oneof"` -} - -func (*SyncMessage_AttachmentBackfillResponse_Attachments) isSyncMessage_AttachmentBackfillResponse_Data() { -} - -func (*SyncMessage_AttachmentBackfillResponse_Error_) isSyncMessage_AttachmentBackfillResponse_Data() { -} - type SyncMessage_Sent_UnidentifiedDeliveryStatus struct { - state protoimpl.MessageState `protogen:"open.v1"` - DestinationServiceId *string `protobuf:"bytes,3,opt,name=destinationServiceId" json:"destinationServiceId,omitempty"` - Unidentified *bool `protobuf:"varint,2,opt,name=unidentified" json:"unidentified,omitempty"` - DestinationPniIdentityKey []byte `protobuf:"bytes,5,opt,name=destinationPniIdentityKey" json:"destinationPniIdentityKey,omitempty"` // Only set for PNI destinations - DestinationServiceIdBinary []byte `protobuf:"bytes,6,opt,name=destinationServiceIdBinary" json:"destinationServiceIdBinary,omitempty"` // service ID binary (i.e. 16 byte UUID for ACI, 1 byte prefix + 16 byte UUID for PNI) - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + DestinationServiceId *string `protobuf:"bytes,3,opt,name=destinationServiceId" json:"destinationServiceId,omitempty"` + Unidentified *bool `protobuf:"varint,2,opt,name=unidentified" json:"unidentified,omitempty"` } func (x *SyncMessage_Sent_UnidentifiedDeliveryStatus) Reset() { *x = SyncMessage_Sent_UnidentifiedDeliveryStatus{} - mi := &file_SignalService_proto_msgTypes[77] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[66] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *SyncMessage_Sent_UnidentifiedDeliveryStatus) String() string { @@ -7949,8 +6817,8 @@ func (x *SyncMessage_Sent_UnidentifiedDeliveryStatus) String() string { func (*SyncMessage_Sent_UnidentifiedDeliveryStatus) ProtoMessage() {} func (x *SyncMessage_Sent_UnidentifiedDeliveryStatus) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[77] - if x != nil { + mi := &file_SignalService_proto_msgTypes[66] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -7962,7 +6830,7 @@ func (x *SyncMessage_Sent_UnidentifiedDeliveryStatus) ProtoReflect() protoreflec // Deprecated: Use SyncMessage_Sent_UnidentifiedDeliveryStatus.ProtoReflect.Descriptor instead. func (*SyncMessage_Sent_UnidentifiedDeliveryStatus) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 0, 0} + return file_SignalService_proto_rawDescGZIP(), []int{12, 0, 0} } func (x *SyncMessage_Sent_UnidentifiedDeliveryStatus) GetDestinationServiceId() string { @@ -7979,35 +6847,23 @@ func (x *SyncMessage_Sent_UnidentifiedDeliveryStatus) GetUnidentified() bool { return false } -func (x *SyncMessage_Sent_UnidentifiedDeliveryStatus) GetDestinationPniIdentityKey() []byte { - if x != nil { - return x.DestinationPniIdentityKey - } - return nil -} - -func (x *SyncMessage_Sent_UnidentifiedDeliveryStatus) GetDestinationServiceIdBinary() []byte { - if x != nil { - return x.DestinationServiceIdBinary - } - return nil -} - type SyncMessage_Sent_StoryMessageRecipient struct { - state protoimpl.MessageState `protogen:"open.v1"` - DestinationServiceId *string `protobuf:"bytes,1,opt,name=destinationServiceId" json:"destinationServiceId,omitempty"` - DistributionListIds []string `protobuf:"bytes,2,rep,name=distributionListIds" json:"distributionListIds,omitempty"` - IsAllowedToReply *bool `protobuf:"varint,3,opt,name=isAllowedToReply" json:"isAllowedToReply,omitempty"` - DestinationServiceIdBinary []byte `protobuf:"bytes,5,opt,name=destinationServiceIdBinary" json:"destinationServiceIdBinary,omitempty"` // service ID binary (i.e. 16 byte UUID for ACI, 1 byte prefix + 16 byte UUID for PNI) - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + DestinationServiceId *string `protobuf:"bytes,1,opt,name=destinationServiceId" json:"destinationServiceId,omitempty"` + DistributionListIds []string `protobuf:"bytes,2,rep,name=distributionListIds" json:"distributionListIds,omitempty"` + IsAllowedToReply *bool `protobuf:"varint,3,opt,name=isAllowedToReply" json:"isAllowedToReply,omitempty"` } func (x *SyncMessage_Sent_StoryMessageRecipient) Reset() { *x = SyncMessage_Sent_StoryMessageRecipient{} - mi := &file_SignalService_proto_msgTypes[78] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[67] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *SyncMessage_Sent_StoryMessageRecipient) String() string { @@ -8017,8 +6873,8 @@ func (x *SyncMessage_Sent_StoryMessageRecipient) String() string { func (*SyncMessage_Sent_StoryMessageRecipient) ProtoMessage() {} func (x *SyncMessage_Sent_StoryMessageRecipient) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[78] - if x != nil { + mi := &file_SignalService_proto_msgTypes[67] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -8030,7 +6886,7 @@ func (x *SyncMessage_Sent_StoryMessageRecipient) ProtoReflect() protoreflect.Mes // Deprecated: Use SyncMessage_Sent_StoryMessageRecipient.ProtoReflect.Descriptor instead. func (*SyncMessage_Sent_StoryMessageRecipient) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 0, 1} + return file_SignalService_proto_rawDescGZIP(), []int{12, 0, 1} } func (x *SyncMessage_Sent_StoryMessageRecipient) GetDestinationServiceId() string { @@ -8054,32 +6910,31 @@ func (x *SyncMessage_Sent_StoryMessageRecipient) GetIsAllowedToReply() bool { return false } -func (x *SyncMessage_Sent_StoryMessageRecipient) GetDestinationServiceIdBinary() []byte { - if x != nil { - return x.DestinationServiceIdBinary - } - return nil -} - type SyncMessage_OutgoingPayment_MobileCoin struct { - state protoimpl.MessageState `protogen:"open.v1"` - RecipientAddress []byte `protobuf:"bytes,1,opt,name=recipientAddress" json:"recipientAddress,omitempty"` - AmountPicoMob *uint64 `protobuf:"varint,2,opt,name=amountPicoMob" json:"amountPicoMob,omitempty"` - FeePicoMob *uint64 `protobuf:"varint,3,opt,name=feePicoMob" json:"feePicoMob,omitempty"` - Receipt []byte `protobuf:"bytes,4,opt,name=receipt" json:"receipt,omitempty"` - LedgerBlockTimestamp *uint64 `protobuf:"varint,5,opt,name=ledgerBlockTimestamp" json:"ledgerBlockTimestamp,omitempty"` - LedgerBlockIndex *uint64 `protobuf:"varint,6,opt,name=ledgerBlockIndex" json:"ledgerBlockIndex,omitempty"` - SpentKeyImages [][]byte `protobuf:"bytes,7,rep,name=spentKeyImages" json:"spentKeyImages,omitempty"` - OutputPublicKeys [][]byte `protobuf:"bytes,8,rep,name=outputPublicKeys" json:"outputPublicKeys,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RecipientAddress []byte `protobuf:"bytes,1,opt,name=recipientAddress" json:"recipientAddress,omitempty"` + // @required + AmountPicoMob *uint64 `protobuf:"varint,2,opt,name=amountPicoMob" json:"amountPicoMob,omitempty"` + // @required + FeePicoMob *uint64 `protobuf:"varint,3,opt,name=feePicoMob" json:"feePicoMob,omitempty"` + Receipt []byte `protobuf:"bytes,4,opt,name=receipt" json:"receipt,omitempty"` + LedgerBlockTimestamp *uint64 `protobuf:"varint,5,opt,name=ledgerBlockTimestamp" json:"ledgerBlockTimestamp,omitempty"` + // @required + LedgerBlockIndex *uint64 `protobuf:"varint,6,opt,name=ledgerBlockIndex" json:"ledgerBlockIndex,omitempty"` + SpentKeyImages [][]byte `protobuf:"bytes,7,rep,name=spentKeyImages" json:"spentKeyImages,omitempty"` + OutputPublicKeys [][]byte `protobuf:"bytes,8,rep,name=outputPublicKeys" json:"outputPublicKeys,omitempty"` } func (x *SyncMessage_OutgoingPayment_MobileCoin) Reset() { *x = SyncMessage_OutgoingPayment_MobileCoin{} - mi := &file_SignalService_proto_msgTypes[79] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[68] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *SyncMessage_OutgoingPayment_MobileCoin) String() string { @@ -8089,8 +6944,8 @@ func (x *SyncMessage_OutgoingPayment_MobileCoin) String() string { func (*SyncMessage_OutgoingPayment_MobileCoin) ProtoMessage() {} func (x *SyncMessage_OutgoingPayment_MobileCoin) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[79] - if x != nil { + mi := &file_SignalService_proto_msgTypes[68] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -8102,7 +6957,7 @@ func (x *SyncMessage_OutgoingPayment_MobileCoin) ProtoReflect() protoreflect.Mes // Deprecated: Use SyncMessage_OutgoingPayment_MobileCoin.ProtoReflect.Descriptor instead. func (*SyncMessage_OutgoingPayment_MobileCoin) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 13, 0} + return file_SignalService_proto_rawDescGZIP(), []int{12, 12, 0} } func (x *SyncMessage_OutgoingPayment_MobileCoin) GetRecipientAddress() []byte { @@ -8161,228 +7016,32 @@ func (x *SyncMessage_OutgoingPayment_MobileCoin) GetOutputPublicKeys() [][]byte return nil } -type SyncMessage_DeleteForMe_MessageDeletes struct { - state protoimpl.MessageState `protogen:"open.v1"` - Conversation *ConversationIdentifier `protobuf:"bytes,1,opt,name=conversation" json:"conversation,omitempty"` - Messages []*AddressableMessage `protobuf:"bytes,2,rep,name=messages" json:"messages,omitempty"` - unknownFields protoimpl.UnknownFields +type GroupContext_Member struct { + state protoimpl.MessageState sizeCache protoimpl.SizeCache -} - -func (x *SyncMessage_DeleteForMe_MessageDeletes) Reset() { - *x = SyncMessage_DeleteForMe_MessageDeletes{} - mi := &file_SignalService_proto_msgTypes[80] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *SyncMessage_DeleteForMe_MessageDeletes) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SyncMessage_DeleteForMe_MessageDeletes) ProtoMessage() {} - -func (x *SyncMessage_DeleteForMe_MessageDeletes) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[80] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SyncMessage_DeleteForMe_MessageDeletes.ProtoReflect.Descriptor instead. -func (*SyncMessage_DeleteForMe_MessageDeletes) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 18, 0} -} - -func (x *SyncMessage_DeleteForMe_MessageDeletes) GetConversation() *ConversationIdentifier { - if x != nil { - return x.Conversation - } - return nil -} - -func (x *SyncMessage_DeleteForMe_MessageDeletes) GetMessages() []*AddressableMessage { - if x != nil { - return x.Messages - } - return nil -} - -type SyncMessage_DeleteForMe_AttachmentDelete struct { - state protoimpl.MessageState `protogen:"open.v1"` - Conversation *ConversationIdentifier `protobuf:"bytes,1,opt,name=conversation" json:"conversation,omitempty"` - TargetMessage *AddressableMessage `protobuf:"bytes,2,opt,name=targetMessage" json:"targetMessage,omitempty"` - // The `clientUuid` from `AttachmentPointer`. - ClientUuid []byte `protobuf:"bytes,3,opt,name=clientUuid" json:"clientUuid,omitempty"` - // SHA256 hash of the (encrypted, padded, etc.) attachment blob on the CDN. - FallbackDigest []byte `protobuf:"bytes,4,opt,name=fallbackDigest" json:"fallbackDigest,omitempty"` - // SHA256 hash of the plaintext content of the attachment. - FallbackPlaintextHash []byte `protobuf:"bytes,5,opt,name=fallbackPlaintextHash" json:"fallbackPlaintextHash,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *SyncMessage_DeleteForMe_AttachmentDelete) Reset() { - *x = SyncMessage_DeleteForMe_AttachmentDelete{} - mi := &file_SignalService_proto_msgTypes[81] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *SyncMessage_DeleteForMe_AttachmentDelete) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SyncMessage_DeleteForMe_AttachmentDelete) ProtoMessage() {} - -func (x *SyncMessage_DeleteForMe_AttachmentDelete) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[81] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SyncMessage_DeleteForMe_AttachmentDelete.ProtoReflect.Descriptor instead. -func (*SyncMessage_DeleteForMe_AttachmentDelete) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 18, 1} -} - -func (x *SyncMessage_DeleteForMe_AttachmentDelete) GetConversation() *ConversationIdentifier { - if x != nil { - return x.Conversation - } - return nil -} - -func (x *SyncMessage_DeleteForMe_AttachmentDelete) GetTargetMessage() *AddressableMessage { - if x != nil { - return x.TargetMessage - } - return nil -} - -func (x *SyncMessage_DeleteForMe_AttachmentDelete) GetClientUuid() []byte { - if x != nil { - return x.ClientUuid - } - return nil -} - -func (x *SyncMessage_DeleteForMe_AttachmentDelete) GetFallbackDigest() []byte { - if x != nil { - return x.FallbackDigest - } - return nil -} - -func (x *SyncMessage_DeleteForMe_AttachmentDelete) GetFallbackPlaintextHash() []byte { - if x != nil { - return x.FallbackPlaintextHash - } - return nil -} - -type SyncMessage_DeleteForMe_ConversationDelete struct { - state protoimpl.MessageState `protogen:"open.v1"` - Conversation *ConversationIdentifier `protobuf:"bytes,1,opt,name=conversation" json:"conversation,omitempty"` - MostRecentMessages []*AddressableMessage `protobuf:"bytes,2,rep,name=mostRecentMessages" json:"mostRecentMessages,omitempty"` - IsFullDelete *bool `protobuf:"varint,3,opt,name=isFullDelete" json:"isFullDelete,omitempty"` - MostRecentNonExpiringMessages []*AddressableMessage `protobuf:"bytes,4,rep,name=mostRecentNonExpiringMessages" json:"mostRecentNonExpiringMessages,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *SyncMessage_DeleteForMe_ConversationDelete) Reset() { - *x = SyncMessage_DeleteForMe_ConversationDelete{} - mi := &file_SignalService_proto_msgTypes[82] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *SyncMessage_DeleteForMe_ConversationDelete) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SyncMessage_DeleteForMe_ConversationDelete) ProtoMessage() {} - -func (x *SyncMessage_DeleteForMe_ConversationDelete) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[82] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SyncMessage_DeleteForMe_ConversationDelete.ProtoReflect.Descriptor instead. -func (*SyncMessage_DeleteForMe_ConversationDelete) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 18, 2} -} - -func (x *SyncMessage_DeleteForMe_ConversationDelete) GetConversation() *ConversationIdentifier { - if x != nil { - return x.Conversation - } - return nil -} - -func (x *SyncMessage_DeleteForMe_ConversationDelete) GetMostRecentMessages() []*AddressableMessage { - if x != nil { - return x.MostRecentMessages - } - return nil -} - -func (x *SyncMessage_DeleteForMe_ConversationDelete) GetIsFullDelete() bool { - if x != nil && x.IsFullDelete != nil { - return *x.IsFullDelete - } - return false -} - -func (x *SyncMessage_DeleteForMe_ConversationDelete) GetMostRecentNonExpiringMessages() []*AddressableMessage { - if x != nil { - return x.MostRecentNonExpiringMessages - } - return nil -} - -type SyncMessage_DeleteForMe_LocalOnlyConversationDelete struct { - state protoimpl.MessageState `protogen:"open.v1"` - Conversation *ConversationIdentifier `protobuf:"bytes,1,opt,name=conversation" json:"conversation,omitempty"` unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + + E164 *string `protobuf:"bytes,2,opt,name=e164" json:"e164,omitempty"` } -func (x *SyncMessage_DeleteForMe_LocalOnlyConversationDelete) Reset() { - *x = SyncMessage_DeleteForMe_LocalOnlyConversationDelete{} - mi := &file_SignalService_proto_msgTypes[83] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) +func (x *GroupContext_Member) Reset() { + *x = GroupContext_Member{} + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[69] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (x *SyncMessage_DeleteForMe_LocalOnlyConversationDelete) String() string { +func (x *GroupContext_Member) String() string { return protoimpl.X.MessageStringOf(x) } -func (*SyncMessage_DeleteForMe_LocalOnlyConversationDelete) ProtoMessage() {} +func (*GroupContext_Member) ProtoMessage() {} -func (x *SyncMessage_DeleteForMe_LocalOnlyConversationDelete) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[83] - if x != nil { +func (x *GroupContext_Member) ProtoReflect() protoreflect.Message { + mi := &file_SignalService_proto_msgTypes[69] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -8392,167 +7051,34 @@ func (x *SyncMessage_DeleteForMe_LocalOnlyConversationDelete) ProtoReflect() pro return mi.MessageOf(x) } -// Deprecated: Use SyncMessage_DeleteForMe_LocalOnlyConversationDelete.ProtoReflect.Descriptor instead. -func (*SyncMessage_DeleteForMe_LocalOnlyConversationDelete) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 18, 3} +// Deprecated: Use GroupContext_Member.ProtoReflect.Descriptor instead. +func (*GroupContext_Member) Descriptor() ([]byte, []int) { + return file_SignalService_proto_rawDescGZIP(), []int{14, 0} } -func (x *SyncMessage_DeleteForMe_LocalOnlyConversationDelete) GetConversation() *ConversationIdentifier { - if x != nil { - return x.Conversation +func (x *GroupContext_Member) GetE164() string { + if x != nil && x.E164 != nil { + return *x.E164 } - return nil -} - -type SyncMessage_AttachmentBackfillResponse_AttachmentData struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Types that are valid to be assigned to Data: - // - // *SyncMessage_AttachmentBackfillResponse_AttachmentData_Attachment - // *SyncMessage_AttachmentBackfillResponse_AttachmentData_Status_ - Data isSyncMessage_AttachmentBackfillResponse_AttachmentData_Data `protobuf_oneof:"data"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *SyncMessage_AttachmentBackfillResponse_AttachmentData) Reset() { - *x = SyncMessage_AttachmentBackfillResponse_AttachmentData{} - mi := &file_SignalService_proto_msgTypes[84] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *SyncMessage_AttachmentBackfillResponse_AttachmentData) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SyncMessage_AttachmentBackfillResponse_AttachmentData) ProtoMessage() {} - -func (x *SyncMessage_AttachmentBackfillResponse_AttachmentData) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[84] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SyncMessage_AttachmentBackfillResponse_AttachmentData.ProtoReflect.Descriptor instead. -func (*SyncMessage_AttachmentBackfillResponse_AttachmentData) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 21, 0} -} - -func (x *SyncMessage_AttachmentBackfillResponse_AttachmentData) GetData() isSyncMessage_AttachmentBackfillResponse_AttachmentData_Data { - if x != nil { - return x.Data - } - return nil -} - -func (x *SyncMessage_AttachmentBackfillResponse_AttachmentData) GetAttachment() *AttachmentPointer { - if x != nil { - if x, ok := x.Data.(*SyncMessage_AttachmentBackfillResponse_AttachmentData_Attachment); ok { - return x.Attachment - } - } - return nil -} - -func (x *SyncMessage_AttachmentBackfillResponse_AttachmentData) GetStatus() SyncMessage_AttachmentBackfillResponse_AttachmentData_Status { - if x != nil { - if x, ok := x.Data.(*SyncMessage_AttachmentBackfillResponse_AttachmentData_Status_); ok { - return x.Status - } - } - return SyncMessage_AttachmentBackfillResponse_AttachmentData_PENDING -} - -type isSyncMessage_AttachmentBackfillResponse_AttachmentData_Data interface { - isSyncMessage_AttachmentBackfillResponse_AttachmentData_Data() -} - -type SyncMessage_AttachmentBackfillResponse_AttachmentData_Attachment struct { - Attachment *AttachmentPointer `protobuf:"bytes,1,opt,name=attachment,oneof"` -} - -type SyncMessage_AttachmentBackfillResponse_AttachmentData_Status_ struct { - Status SyncMessage_AttachmentBackfillResponse_AttachmentData_Status `protobuf:"varint,2,opt,name=status,enum=signalservice.SyncMessage_AttachmentBackfillResponse_AttachmentData_Status,oneof"` -} - -func (*SyncMessage_AttachmentBackfillResponse_AttachmentData_Attachment) isSyncMessage_AttachmentBackfillResponse_AttachmentData_Data() { -} - -func (*SyncMessage_AttachmentBackfillResponse_AttachmentData_Status_) isSyncMessage_AttachmentBackfillResponse_AttachmentData_Data() { -} - -type SyncMessage_AttachmentBackfillResponse_AttachmentDataList struct { - state protoimpl.MessageState `protogen:"open.v1"` - Attachments []*SyncMessage_AttachmentBackfillResponse_AttachmentData `protobuf:"bytes,1,rep,name=attachments" json:"attachments,omitempty"` - LongText *SyncMessage_AttachmentBackfillResponse_AttachmentData `protobuf:"bytes,2,opt,name=longText" json:"longText,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *SyncMessage_AttachmentBackfillResponse_AttachmentDataList) Reset() { - *x = SyncMessage_AttachmentBackfillResponse_AttachmentDataList{} - mi := &file_SignalService_proto_msgTypes[85] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *SyncMessage_AttachmentBackfillResponse_AttachmentDataList) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SyncMessage_AttachmentBackfillResponse_AttachmentDataList) ProtoMessage() {} - -func (x *SyncMessage_AttachmentBackfillResponse_AttachmentDataList) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[85] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SyncMessage_AttachmentBackfillResponse_AttachmentDataList.ProtoReflect.Descriptor instead. -func (*SyncMessage_AttachmentBackfillResponse_AttachmentDataList) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{11, 21, 1} -} - -func (x *SyncMessage_AttachmentBackfillResponse_AttachmentDataList) GetAttachments() []*SyncMessage_AttachmentBackfillResponse_AttachmentData { - if x != nil { - return x.Attachments - } - return nil -} - -func (x *SyncMessage_AttachmentBackfillResponse_AttachmentDataList) GetLongText() *SyncMessage_AttachmentBackfillResponse_AttachmentData { - if x != nil { - return x.LongText - } - return nil + return "" } type ContactDetails_Avatar struct { - state protoimpl.MessageState `protogen:"open.v1"` - ContentType *string `protobuf:"bytes,1,opt,name=contentType" json:"contentType,omitempty"` - Length *uint32 `protobuf:"varint,2,opt,name=length" json:"length,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ContentType *string `protobuf:"bytes,1,opt,name=contentType" json:"contentType,omitempty"` + Length *uint32 `protobuf:"varint,2,opt,name=length" json:"length,omitempty"` } func (x *ContactDetails_Avatar) Reset() { *x = ContactDetails_Avatar{} - mi := &file_SignalService_proto_msgTypes[86] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[70] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *ContactDetails_Avatar) String() string { @@ -8562,8 +7088,8 @@ func (x *ContactDetails_Avatar) String() string { func (*ContactDetails_Avatar) ProtoMessage() {} func (x *ContactDetails_Avatar) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[86] - if x != nil { + mi := &file_SignalService_proto_msgTypes[70] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -8575,7 +7101,7 @@ func (x *ContactDetails_Avatar) ProtoReflect() protoreflect.Message { // Deprecated: Use ContactDetails_Avatar.ProtoReflect.Descriptor instead. func (*ContactDetails_Avatar) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{14, 0} + return file_SignalService_proto_rawDescGZIP(), []int{16, 0} } func (x *ContactDetails_Avatar) GetContentType() string { @@ -8592,30 +7118,33 @@ func (x *ContactDetails_Avatar) GetLength() uint32 { return 0 } -type PaymentAddress_MobileCoin struct { - state protoimpl.MessageState `protogen:"open.v1"` - PublicAddress []byte `protobuf:"bytes,1,opt,name=publicAddress" json:"publicAddress,omitempty"` - Signature []byte `protobuf:"bytes,2,opt,name=signature" json:"signature,omitempty"` - unknownFields protoimpl.UnknownFields +type GroupDetails_Avatar struct { + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ContentType *string `protobuf:"bytes,1,opt,name=contentType" json:"contentType,omitempty"` + Length *uint32 `protobuf:"varint,2,opt,name=length" json:"length,omitempty"` } -func (x *PaymentAddress_MobileCoin) Reset() { - *x = PaymentAddress_MobileCoin{} - mi := &file_SignalService_proto_msgTypes[87] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) +func (x *GroupDetails_Avatar) Reset() { + *x = GroupDetails_Avatar{} + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[71] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (x *PaymentAddress_MobileCoin) String() string { +func (x *GroupDetails_Avatar) String() string { return protoimpl.X.MessageStringOf(x) } -func (*PaymentAddress_MobileCoin) ProtoMessage() {} +func (*GroupDetails_Avatar) ProtoMessage() {} -func (x *PaymentAddress_MobileCoin) ProtoReflect() protoreflect.Message { - mi := &file_SignalService_proto_msgTypes[87] - if x != nil { +func (x *GroupDetails_Avatar) ProtoReflect() protoreflect.Message { + mi := &file_SignalService_proto_msgTypes[71] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -8625,19 +7154,121 @@ func (x *PaymentAddress_MobileCoin) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use PaymentAddress_MobileCoin.ProtoReflect.Descriptor instead. -func (*PaymentAddress_MobileCoin) Descriptor() ([]byte, []int) { - return file_SignalService_proto_rawDescGZIP(), []int{15, 0} +// Deprecated: Use GroupDetails_Avatar.ProtoReflect.Descriptor instead. +func (*GroupDetails_Avatar) Descriptor() ([]byte, []int) { + return file_SignalService_proto_rawDescGZIP(), []int{17, 0} } -func (x *PaymentAddress_MobileCoin) GetPublicAddress() []byte { +func (x *GroupDetails_Avatar) GetContentType() string { + if x != nil && x.ContentType != nil { + return *x.ContentType + } + return "" +} + +func (x *GroupDetails_Avatar) GetLength() uint32 { + if x != nil && x.Length != nil { + return *x.Length + } + return 0 +} + +type GroupDetails_Member struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + E164 *string `protobuf:"bytes,2,opt,name=e164" json:"e164,omitempty"` +} + +func (x *GroupDetails_Member) Reset() { + *x = GroupDetails_Member{} + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[72] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GroupDetails_Member) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GroupDetails_Member) ProtoMessage() {} + +func (x *GroupDetails_Member) ProtoReflect() protoreflect.Message { + mi := &file_SignalService_proto_msgTypes[72] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GroupDetails_Member.ProtoReflect.Descriptor instead. +func (*GroupDetails_Member) Descriptor() ([]byte, []int) { + return file_SignalService_proto_rawDescGZIP(), []int{17, 1} +} + +func (x *GroupDetails_Member) GetE164() string { + if x != nil && x.E164 != nil { + return *x.E164 + } + return "" +} + +type PaymentAddress_MobileCoinAddress struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Address []byte `protobuf:"bytes,1,opt,name=address" json:"address,omitempty"` + Signature []byte `protobuf:"bytes,2,opt,name=signature" json:"signature,omitempty"` +} + +func (x *PaymentAddress_MobileCoinAddress) Reset() { + *x = PaymentAddress_MobileCoinAddress{} + if protoimpl.UnsafeEnabled { + mi := &file_SignalService_proto_msgTypes[73] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PaymentAddress_MobileCoinAddress) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PaymentAddress_MobileCoinAddress) ProtoMessage() {} + +func (x *PaymentAddress_MobileCoinAddress) ProtoReflect() protoreflect.Message { + mi := &file_SignalService_proto_msgTypes[73] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PaymentAddress_MobileCoinAddress.ProtoReflect.Descriptor instead. +func (*PaymentAddress_MobileCoinAddress) Descriptor() ([]byte, []int) { + return file_SignalService_proto_rawDescGZIP(), []int{18, 0} +} + +func (x *PaymentAddress_MobileCoinAddress) GetAddress() []byte { if x != nil { - return x.PublicAddress + return x.Address } return nil } -func (x *PaymentAddress_MobileCoin) GetSignature() []byte { +func (x *PaymentAddress_MobileCoinAddress) GetSignature() []byte { if x != nil { return x.Signature } @@ -8646,988 +7277,1295 @@ func (x *PaymentAddress_MobileCoin) GetSignature() []byte { var File_SignalService_proto protoreflect.FileDescriptor -const file_SignalService_proto_rawDesc = "" + - "\n" + - "\x13SignalService.proto\x12\rsignalservice\"\x8c\a\n" + - "\bEnvelope\x120\n" + - "\x04type\x18\x01 \x01(\x0e2\x1c.signalservice.Envelope.TypeR\x04type\x12(\n" + - "\x0fsourceServiceId\x18\v \x01(\tR\x0fsourceServiceId\x12&\n" + - "\x0esourceDeviceId\x18\a \x01(\rR\x0esourceDeviceId\x122\n" + - "\x14destinationServiceId\x18\r \x01(\tR\x14destinationServiceId\x12(\n" + - "\x0fclientTimestamp\x18\x05 \x01(\x04R\x0fclientTimestamp\x12\x18\n" + - "\acontent\x18\b \x01(\fR\acontent\x12\x1e\n" + - "\n" + - "serverGuid\x18\t \x01(\tR\n" + - "serverGuid\x12(\n" + - "\x0fserverTimestamp\x18\n" + - " \x01(\x04R\x0fserverTimestamp\x12\x1c\n" + - "\tephemeral\x18\f \x01(\bR\tephemeral\x12\x1c\n" + - "\x06urgent\x18\x0e \x01(\b:\x04trueR\x06urgent\x12\x1e\n" + - "\n" + - "updatedPni\x18\x0f \x01(\tR\n" + - "updatedPni\x12\x14\n" + - "\x05story\x18\x10 \x01(\bR\x05story\x12*\n" + - "\x11report_spam_token\x18\x11 \x01(\fR\x0freportSpamToken\x124\n" + - "\x15sourceServiceIdBinary\x18\x13 \x01(\fR\x15sourceServiceIdBinary\x12>\n" + - "\x1adestinationServiceIdBinary\x18\x14 \x01(\fR\x1adestinationServiceIdBinary\x12*\n" + - "\x10serverGuidBinary\x18\x15 \x01(\fR\x10serverGuidBinary\x12*\n" + - "\x10updatedPniBinary\x18\x16 \x01(\fR\x10updatedPniBinary\"\xb5\x01\n" + - "\x04Type\x12\v\n" + - "\aUNKNOWN\x10\x00\x12\x12\n" + - "\x0eDOUBLE_RATCHET\x10\x01\x12\x12\n" + - "\x0ePREKEY_MESSAGE\x10\x03\x12\x1b\n" + - "\x17SERVER_DELIVERY_RECEIPT\x10\x05\x12\x17\n" + - "\x13UNIDENTIFIED_SENDER\x10\x06\x12\x15\n" + - "\x11PLAINTEXT_CONTENT\x10\b\"\x04\b\x02\x10\x02\"\x04\b\a\x10\a*\fKEY_EXCHANGE*\x11SENDERKEY_MESSAGEJ\x04\b\x02\x10\x03J\x04\b\x03\x10\x04J\x04\b\x06\x10\aJ\x04\b\x12\x10\x13\"\xfa\x05\n" + - "\aContent\x12>\n" + - "\vdataMessage\x18\x01 \x01(\v2\x1a.signalservice.DataMessageH\x00R\vdataMessage\x12>\n" + - "\vsyncMessage\x18\x02 \x01(\v2\x1a.signalservice.SyncMessageH\x00R\vsyncMessage\x12>\n" + - "\vcallMessage\x18\x03 \x01(\v2\x1a.signalservice.CallMessageH\x00R\vcallMessage\x12>\n" + - "\vnullMessage\x18\x04 \x01(\v2\x1a.signalservice.NullMessageH\x00R\vnullMessage\x12G\n" + - "\x0ereceiptMessage\x18\x05 \x01(\v2\x1d.signalservice.ReceiptMessageH\x00R\x0ereceiptMessage\x12D\n" + - "\rtypingMessage\x18\x06 \x01(\v2\x1c.signalservice.TypingMessageH\x00R\rtypingMessage\x128\n" + - "\x16decryptionErrorMessage\x18\b \x01(\fH\x00R\x16decryptionErrorMessage\x12A\n" + - "\fstoryMessage\x18\t \x01(\v2\x1b.signalservice.StoryMessageH\x00R\fstoryMessage\x12>\n" + - "\veditMessage\x18\v \x01(\v2\x1a.signalservice.EditMessageH\x00R\veditMessage\x12B\n" + - "\x1csenderKeyDistributionMessage\x18\a \x01(\fR\x1csenderKeyDistributionMessage\x12T\n" + - "\x13pniSignatureMessage\x18\n" + - " \x01(\v2\".signalservice.PniSignatureMessageR\x13pniSignatureMessageB\t\n" + - "\acontent\"\xf2\b\n" + - "\vCallMessage\x126\n" + - "\x05offer\x18\x01 \x01(\v2 .signalservice.CallMessage.OfferR\x05offer\x129\n" + - "\x06answer\x18\x02 \x01(\v2!.signalservice.CallMessage.AnswerR\x06answer\x12B\n" + - "\ticeUpdate\x18\x03 \x03(\v2$.signalservice.CallMessage.IceUpdateR\ticeUpdate\x123\n" + - "\x04busy\x18\x05 \x01(\v2\x1f.signalservice.CallMessage.BusyR\x04busy\x129\n" + - "\x06hangup\x18\a \x01(\v2!.signalservice.CallMessage.HangupR\x06hangup\x120\n" + - "\x13destinationDeviceId\x18\t \x01(\rR\x13destinationDeviceId\x129\n" + - "\x06opaque\x18\n" + - " \x01(\v2!.signalservice.CallMessage.OpaqueR\x06opaque\x1a\xaa\x01\n" + - "\x05Offer\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x04R\x02id\x129\n" + - "\x04type\x18\x03 \x01(\x0e2%.signalservice.CallMessage.Offer.TypeR\x04type\x12\x16\n" + - "\x06opaque\x18\x04 \x01(\fR\x06opaque\"8\n" + - "\x04Type\x12\x14\n" + - "\x10OFFER_AUDIO_CALL\x10\x00\x12\x14\n" + - "\x10OFFER_VIDEO_CALL\x10\x01\"\x04\b\x02\x10\x02J\x04\b\x02\x10\x03\x1a6\n" + - "\x06Answer\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x04R\x02id\x12\x16\n" + - "\x06opaque\x18\x03 \x01(\fR\x06opaqueJ\x04\b\x02\x10\x03\x1aE\n" + - "\tIceUpdate\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x04R\x02id\x12\x16\n" + - "\x06opaque\x18\x05 \x01(\fR\x06opaqueJ\x04\b\x02\x10\x03J\x04\b\x03\x10\x04J\x04\b\x04\x10\x05\x1a\x16\n" + - "\x04Busy\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x04R\x02id\x1a\xe2\x01\n" + - "\x06Hangup\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x04R\x02id\x12:\n" + - "\x04type\x18\x02 \x01(\x0e2&.signalservice.CallMessage.Hangup.TypeR\x04type\x12\x1a\n" + - "\bdeviceId\x18\x03 \x01(\rR\bdeviceId\"p\n" + - "\x04Type\x12\x11\n" + - "\rHANGUP_NORMAL\x10\x00\x12\x13\n" + - "\x0fHANGUP_ACCEPTED\x10\x01\x12\x13\n" + - "\x0fHANGUP_DECLINED\x10\x02\x12\x0f\n" + - "\vHANGUP_BUSY\x10\x03\x12\x1a\n" + - "\x16HANGUP_NEED_PERMISSION\x10\x04\x1a\x93\x01\n" + - "\x06Opaque\x12\x12\n" + - "\x04data\x18\x01 \x01(\fR\x04data\x12C\n" + - "\aurgency\x18\x02 \x01(\x0e2).signalservice.CallMessage.Opaque.UrgencyR\aurgency\"0\n" + - "\aUrgency\x12\r\n" + - "\tDROPPABLE\x10\x00\x12\x16\n" + - "\x12HANDLE_IMMEDIATELY\x10\x01J\x04\b\x04\x10\x05J\x04\b\x06\x10\aJ\x04\b\b\x10\t\"\x8b.\n" + - "\vDataMessage\x12\x12\n" + - "\x04body\x18\x01 \x01(\tR\x04body\x12B\n" + - "\vattachments\x18\x02 \x03(\v2 .signalservice.AttachmentPointerR\vattachments\x127\n" + - "\agroupV2\x18\x0f \x01(\v2\x1d.signalservice.GroupContextV2R\agroupV2\x12\x14\n" + - "\x05flags\x18\x04 \x01(\rR\x05flags\x12 \n" + - "\vexpireTimer\x18\x05 \x01(\rR\vexpireTimer\x12.\n" + - "\x12expireTimerVersion\x18\x17 \x01(\rR\x12expireTimerVersion\x12\x1e\n" + - "\n" + - "profileKey\x18\x06 \x01(\fR\n" + - "profileKey\x12\x1c\n" + - "\ttimestamp\x18\a \x01(\x04R\ttimestamp\x126\n" + - "\x05quote\x18\b \x01(\v2 .signalservice.DataMessage.QuoteR\x05quote\x12<\n" + - "\acontact\x18\t \x03(\v2\".signalservice.DataMessage.ContactR\acontact\x120\n" + - "\apreview\x18\n" + - " \x03(\v2\x16.signalservice.PreviewR\apreview\x12<\n" + - "\asticker\x18\v \x01(\v2\".signalservice.DataMessage.StickerR\asticker\x128\n" + - "\x17requiredProtocolVersion\x18\f \x01(\rR\x17requiredProtocolVersion\x12\x1e\n" + - "\n" + - "isViewOnce\x18\x0e \x01(\bR\n" + - "isViewOnce\x12?\n" + - "\breaction\x18\x10 \x01(\v2#.signalservice.DataMessage.ReactionR\breaction\x129\n" + - "\x06delete\x18\x11 \x01(\v2!.signalservice.DataMessage.DeleteR\x06delete\x128\n" + - "\n" + - "bodyRanges\x18\x12 \x03(\v2\x18.signalservice.BodyRangeR\n" + - "bodyRanges\x12T\n" + - "\x0fgroupCallUpdate\x18\x13 \x01(\v2*.signalservice.DataMessage.GroupCallUpdateR\x0fgroupCallUpdate\x12<\n" + - "\apayment\x18\x14 \x01(\v2\".signalservice.DataMessage.PaymentR\apayment\x12K\n" + - "\fstoryContext\x18\x15 \x01(\v2'.signalservice.DataMessage.StoryContextR\fstoryContext\x12B\n" + - "\tgiftBadge\x18\x16 \x01(\v2$.signalservice.DataMessage.GiftBadgeR\tgiftBadge\x12E\n" + - "\n" + - "pollCreate\x18\x18 \x01(\v2%.signalservice.DataMessage.PollCreateR\n" + - "pollCreate\x12N\n" + - "\rpollTerminate\x18\x19 \x01(\v2(.signalservice.DataMessage.PollTerminateR\rpollTerminate\x12?\n" + - "\bpollVote\x18\x1a \x01(\v2#.signalservice.DataMessage.PollVoteR\bpollVote\x12E\n" + - "\n" + - "pinMessage\x18\x1b \x01(\v2%.signalservice.DataMessage.PinMessageR\n" + - "pinMessage\x12K\n" + - "\funpinMessage\x18\x1c \x01(\v2'.signalservice.DataMessage.UnpinMessageR\funpinMessage\x12H\n" + - "\vadminDelete\x18\x1d \x01(\v2&.signalservice.DataMessage.AdminDeleteR\vadminDelete\x1a\x9a\x05\n" + - "\aPayment\x12U\n" + - "\fnotification\x18\x01 \x01(\v2/.signalservice.DataMessage.Payment.NotificationH\x00R\fnotification\x12O\n" + - "\n" + - "activation\x18\x02 \x01(\v2-.signalservice.DataMessage.Payment.ActivationH\x00R\n" + - "activation\x1a\x92\x01\n" + - "\x06Amount\x12V\n" + - "\n" + - "mobileCoin\x18\x01 \x01(\v24.signalservice.DataMessage.Payment.Amount.MobileCoinH\x00R\n" + - "mobileCoin\x1a&\n" + - "\n" + - "MobileCoin\x12\x18\n" + - "\apicoMob\x18\x01 \x01(\x04R\apicoMobB\b\n" + - "\x06Amount\x1a\xbf\x01\n" + - "\fNotification\x12\\\n" + - "\n" + - "mobileCoin\x18\x01 \x01(\v2:.signalservice.DataMessage.Payment.Notification.MobileCoinH\x00R\n" + - "mobileCoin\x12\x12\n" + - "\x04note\x18\x02 \x01(\tR\x04note\x1a&\n" + - "\n" + - "MobileCoin\x12\x18\n" + - "\areceipt\x18\x01 \x01(\fR\areceiptB\r\n" + - "\vTransactionJ\x06\b\xeb\a\x10\xec\a\x1ax\n" + - "\n" + - "Activation\x12F\n" + - "\x04type\x18\x01 \x01(\x0e22.signalservice.DataMessage.Payment.Activation.TypeR\x04type\"\"\n" + - "\x04Type\x12\v\n" + - "\aREQUEST\x10\x00\x12\r\n" + - "\tACTIVATED\x10\x01B\x06\n" + - "\x04ItemJ\x06\b\xea\a\x10\xeb\aJ\x06\b\xeb\a\x10\xec\a\x1a\x84\x04\n" + - "\x05Quote\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x04R\x02id\x12\x1c\n" + - "\tauthorAci\x18\x05 \x01(\tR\tauthorAci\x12\x12\n" + - "\x04text\x18\x03 \x01(\tR\x04text\x12S\n" + - "\vattachments\x18\x04 \x03(\v21.signalservice.DataMessage.Quote.QuotedAttachmentR\vattachments\x128\n" + - "\n" + - "bodyRanges\x18\x06 \x03(\v2\x18.signalservice.BodyRangeR\n" + - "bodyRanges\x129\n" + - "\x04type\x18\a \x01(\x0e2%.signalservice.DataMessage.Quote.TypeR\x04type\x12(\n" + - "\x0fauthorAciBinary\x18\b \x01(\fR\x0fauthorAciBinary\x1a\x90\x01\n" + - "\x10QuotedAttachment\x12 \n" + - "\vcontentType\x18\x01 \x01(\tR\vcontentType\x12\x1a\n" + - "\bfileName\x18\x02 \x01(\tR\bfileName\x12>\n" + - "\tthumbnail\x18\x03 \x01(\v2 .signalservice.AttachmentPointerR\tthumbnail\",\n" + - "\x04Type\x12\n" + - "\n" + - "\x06NORMAL\x10\x00\x12\x0e\n" + - "\n" + - "GIFT_BADGE\x10\x01\x12\b\n" + - "\x04POLL\x10\x02J\x04\b\x02\x10\x03\x1a\xbf\n" + - "\n" + - "\aContact\x12;\n" + - "\x04name\x18\x01 \x01(\v2'.signalservice.DataMessage.Contact.NameR\x04name\x12@\n" + - "\x06number\x18\x03 \x03(\v2(.signalservice.DataMessage.Contact.PhoneR\x06number\x12>\n" + - "\x05email\x18\x04 \x03(\v2(.signalservice.DataMessage.Contact.EmailR\x05email\x12J\n" + - "\aaddress\x18\x05 \x03(\v20.signalservice.DataMessage.Contact.PostalAddressR\aaddress\x12A\n" + - "\x06avatar\x18\x06 \x01(\v2).signalservice.DataMessage.Contact.AvatarR\x06avatar\x12\"\n" + - "\forganization\x18\a \x01(\tR\forganization\x1a\xb6\x01\n" + - "\x04Name\x12\x1c\n" + - "\tgivenName\x18\x01 \x01(\tR\tgivenName\x12\x1e\n" + - "\n" + - "familyName\x18\x02 \x01(\tR\n" + - "familyName\x12\x16\n" + - "\x06prefix\x18\x03 \x01(\tR\x06prefix\x12\x16\n" + - "\x06suffix\x18\x04 \x01(\tR\x06suffix\x12\x1e\n" + - "\n" + - "middleName\x18\x05 \x01(\tR\n" + - "middleName\x12\x1a\n" + - "\bnickname\x18\a \x01(\tR\bnicknameJ\x04\b\x06\x10\a\x1a\xaa\x01\n" + - "\x05Phone\x12\x14\n" + - "\x05value\x18\x01 \x01(\tR\x05value\x12A\n" + - "\x04type\x18\x02 \x01(\x0e2-.signalservice.DataMessage.Contact.Phone.TypeR\x04type\x12\x14\n" + - "\x05label\x18\x03 \x01(\tR\x05label\"2\n" + - "\x04Type\x12\b\n" + - "\x04HOME\x10\x01\x12\n" + - "\n" + - "\x06MOBILE\x10\x02\x12\b\n" + - "\x04WORK\x10\x03\x12\n" + - "\n" + - "\x06CUSTOM\x10\x04\x1a\xaa\x01\n" + - "\x05Email\x12\x14\n" + - "\x05value\x18\x01 \x01(\tR\x05value\x12A\n" + - "\x04type\x18\x02 \x01(\x0e2-.signalservice.DataMessage.Contact.Email.TypeR\x04type\x12\x14\n" + - "\x05label\x18\x03 \x01(\tR\x05label\"2\n" + - "\x04Type\x12\b\n" + - "\x04HOME\x10\x01\x12\n" + - "\n" + - "\x06MOBILE\x10\x02\x12\b\n" + - "\x04WORK\x10\x03\x12\n" + - "\n" + - "\x06CUSTOM\x10\x04\x1a\xcc\x02\n" + - "\rPostalAddress\x12I\n" + - "\x04type\x18\x01 \x01(\x0e25.signalservice.DataMessage.Contact.PostalAddress.TypeR\x04type\x12\x14\n" + - "\x05label\x18\x02 \x01(\tR\x05label\x12\x16\n" + - "\x06street\x18\x03 \x01(\tR\x06street\x12\x14\n" + - "\x05pobox\x18\x04 \x01(\tR\x05pobox\x12\"\n" + - "\fneighborhood\x18\x05 \x01(\tR\fneighborhood\x12\x12\n" + - "\x04city\x18\x06 \x01(\tR\x04city\x12\x16\n" + - "\x06region\x18\a \x01(\tR\x06region\x12\x1a\n" + - "\bpostcode\x18\b \x01(\tR\bpostcode\x12\x18\n" + - "\acountry\x18\t \x01(\tR\acountry\"&\n" + - "\x04Type\x12\b\n" + - "\x04HOME\x10\x01\x12\b\n" + - "\x04WORK\x10\x02\x12\n" + - "\n" + - "\x06CUSTOM\x10\x03\x1a`\n" + - "\x06Avatar\x128\n" + - "\x06avatar\x18\x01 \x01(\v2 .signalservice.AttachmentPointerR\x06avatar\x12\x1c\n" + - "\tisProfile\x18\x02 \x01(\bR\tisProfile\x1a\xa5\x01\n" + - "\aSticker\x12\x16\n" + - "\x06packId\x18\x01 \x01(\fR\x06packId\x12\x18\n" + - "\apackKey\x18\x02 \x01(\fR\apackKey\x12\x1c\n" + - "\tstickerId\x18\x03 \x01(\rR\tstickerId\x124\n" + - "\x04data\x18\x04 \x01(\v2 .signalservice.AttachmentPointerR\x04data\x12\x14\n" + - "\x05emoji\x18\x05 \x01(\tR\x05emoji\x1a\xd0\x01\n" + - "\bReaction\x12\x14\n" + - "\x05emoji\x18\x01 \x01(\tR\x05emoji\x12\x16\n" + - "\x06remove\x18\x02 \x01(\bR\x06remove\x12(\n" + - "\x0ftargetAuthorAci\x18\x04 \x01(\tR\x0ftargetAuthorAci\x120\n" + - "\x13targetSentTimestamp\x18\x05 \x01(\x04R\x13targetSentTimestamp\x124\n" + - "\x15targetAuthorAciBinary\x18\x06 \x01(\fR\x15targetAuthorAciBinaryJ\x04\b\x03\x10\x04\x1a:\n" + - "\x06Delete\x120\n" + - "\x13targetSentTimestamp\x18\x01 \x01(\x04R\x13targetSentTimestamp\x1a'\n" + - "\x0fGroupCallUpdate\x12\x14\n" + - "\x05eraId\x18\x01 \x01(\tR\x05eraId\x1a|\n" + - "\fStoryContext\x12\x1c\n" + - "\tauthorAci\x18\x01 \x01(\tR\tauthorAci\x12$\n" + - "\rsentTimestamp\x18\x02 \x01(\x04R\rsentTimestamp\x12(\n" + - "\x0fauthorAciBinary\x18\x03 \x01(\fR\x0fauthorAciBinary\x1aQ\n" + - "\tGiftBadge\x12D\n" + - "\x1dreceiptCredentialPresentation\x18\x01 \x01(\fR\x1dreceiptCredentialPresentation\x1ah\n" + - "\n" + - "PollCreate\x12\x1a\n" + - "\bquestion\x18\x01 \x01(\tR\bquestion\x12$\n" + - "\rallowMultiple\x18\x02 \x01(\bR\rallowMultiple\x12\x18\n" + - "\aoptions\x18\x03 \x03(\tR\aoptions\x1aA\n" + - "\rPollTerminate\x120\n" + - "\x13targetSentTimestamp\x18\x01 \x01(\x04R\x13targetSentTimestamp\x1a\xb6\x01\n" + - "\bPollVote\x124\n" + - "\x15targetAuthorAciBinary\x18\x01 \x01(\fR\x15targetAuthorAciBinary\x120\n" + - "\x13targetSentTimestamp\x18\x02 \x01(\x04R\x13targetSentTimestamp\x12$\n" + - "\roptionIndexes\x18\x03 \x03(\rR\roptionIndexes\x12\x1c\n" + - "\tvoteCount\x18\x04 \x01(\rR\tvoteCount\x1a\xe7\x01\n" + - "\n" + - "PinMessage\x124\n" + - "\x15targetAuthorAciBinary\x18\x01 \x01(\fR\x15targetAuthorAciBinary\x120\n" + - "\x13targetSentTimestamp\x18\x02 \x01(\x04R\x13targetSentTimestamp\x120\n" + - "\x12pinDurationSeconds\x18\x03 \x01(\rH\x00R\x12pinDurationSeconds\x120\n" + - "\x12pinDurationForever\x18\x04 \x01(\bH\x00R\x12pinDurationForeverB\r\n" + - "\vpinDuration\x1av\n" + - "\fUnpinMessage\x124\n" + - "\x15targetAuthorAciBinary\x18\x01 \x01(\fR\x15targetAuthorAciBinary\x120\n" + - "\x13targetSentTimestamp\x18\x02 \x01(\x04R\x13targetSentTimestamp\x1au\n" + - "\vAdminDelete\x124\n" + - "\x15targetAuthorAciBinary\x18\x01 \x01(\fR\x15targetAuthorAciBinary\x120\n" + - "\x13targetSentTimestamp\x18\x02 \x01(\x04R\x13targetSentTimestamp\"Z\n" + - "\x05Flags\x12\x0f\n" + - "\vEND_SESSION\x10\x01\x12\x1b\n" + - "\x17EXPIRATION_TIMER_UPDATE\x10\x02\x12\x16\n" + - "\x12PROFILE_KEY_UPDATE\x10\x04\x12\v\n" + - "\aFORWARD\x10\b\"\xbb\x01\n" + - "\x0fProtocolVersion\x12\v\n" + - "\aINITIAL\x10\x00\x12\x12\n" + - "\x0eMESSAGE_TIMERS\x10\x01\x12\r\n" + - "\tVIEW_ONCE\x10\x02\x12\x13\n" + - "\x0fVIEW_ONCE_VIDEO\x10\x03\x12\r\n" + - "\tREACTIONS\x10\x04\x12\x1c\n" + - "\x18CDN_SELECTOR_ATTACHMENTS\x10\x05\x12\f\n" + - "\bMENTIONS\x10\x06\x12\f\n" + - "\bPAYMENTS\x10\a\x12\t\n" + - "\x05POLLS\x10\b\x12\v\n" + - "\aCURRENT\x10\b\x1a\x02\x10\x01J\x04\b\x03\x10\x04\"'\n" + - "\vNullMessage\x12\x18\n" + - "\apadding\x18\x01 \x01(\fR\apadding\"\x92\x01\n" + - "\x0eReceiptMessage\x126\n" + - "\x04type\x18\x01 \x01(\x0e2\".signalservice.ReceiptMessage.TypeR\x04type\x12\x1c\n" + - "\ttimestamp\x18\x02 \x03(\x04R\ttimestamp\"*\n" + - "\x04Type\x12\f\n" + - "\bDELIVERY\x10\x00\x12\b\n" + - "\x04READ\x10\x01\x12\n" + - "\n" + - "\x06VIEWED\x10\x02\"\xa8\x01\n" + - "\rTypingMessage\x12\x1c\n" + - "\ttimestamp\x18\x01 \x01(\x04R\ttimestamp\x12;\n" + - "\x06action\x18\x02 \x01(\x0e2#.signalservice.TypingMessage.ActionR\x06action\x12\x18\n" + - "\agroupId\x18\x03 \x01(\fR\agroupId\"\"\n" + - "\x06Action\x12\v\n" + - "\aSTARTED\x10\x00\x12\v\n" + - "\aSTOPPED\x10\x01\"\xe6\x02\n" + - "\fStoryMessage\x12\x1e\n" + - "\n" + - "profileKey\x18\x01 \x01(\fR\n" + - "profileKey\x123\n" + - "\x05group\x18\x02 \x01(\v2\x1d.signalservice.GroupContextV2R\x05group\x12J\n" + - "\x0efileAttachment\x18\x03 \x01(\v2 .signalservice.AttachmentPointerH\x00R\x0efileAttachment\x12G\n" + - "\x0etextAttachment\x18\x04 \x01(\v2\x1d.signalservice.TextAttachmentH\x00R\x0etextAttachment\x12$\n" + - "\rallowsReplies\x18\x05 \x01(\bR\rallowsReplies\x128\n" + - "\n" + - "bodyRanges\x18\x06 \x03(\v2\x18.signalservice.BodyRangeR\n" + - "bodyRangesB\f\n" + - "\n" + - "attachment\"\x9f\x01\n" + - "\aPreview\x12\x10\n" + - "\x03url\x18\x01 \x01(\tR\x03url\x12\x14\n" + - "\x05title\x18\x02 \x01(\tR\x05title\x126\n" + - "\x05image\x18\x03 \x01(\v2 .signalservice.AttachmentPointerR\x05image\x12 \n" + - "\vdescription\x18\x04 \x01(\tR\vdescription\x12\x12\n" + - "\x04date\x18\x05 \x01(\x04R\x04date\"\xd1\x04\n" + - "\x0eTextAttachment\x12\x12\n" + - "\x04text\x18\x01 \x01(\tR\x04text\x12A\n" + - "\ttextStyle\x18\x02 \x01(\x0e2#.signalservice.TextAttachment.StyleR\ttextStyle\x120\n" + - "\x13textForegroundColor\x18\x03 \x01(\rR\x13textForegroundColor\x120\n" + - "\x13textBackgroundColor\x18\x04 \x01(\rR\x13textBackgroundColor\x120\n" + - "\apreview\x18\x05 \x01(\v2\x16.signalservice.PreviewR\apreview\x12D\n" + - "\bgradient\x18\x06 \x01(\v2&.signalservice.TextAttachment.GradientH\x00R\bgradient\x12\x16\n" + - "\x05color\x18\a \x01(\rH\x00R\x05color\x1a\x92\x01\n" + - "\bGradient\x12\x1e\n" + - "\n" + - "startColor\x18\x01 \x01(\rR\n" + - "startColor\x12\x1a\n" + - "\bendColor\x18\x02 \x01(\rR\bendColor\x12\x14\n" + - "\x05angle\x18\x03 \x01(\rR\x05angle\x12\x16\n" + - "\x06colors\x18\x04 \x03(\rR\x06colors\x12\x1c\n" + - "\tpositions\x18\x05 \x03(\x02R\tpositions\"Q\n" + - "\x05Style\x12\v\n" + - "\aDEFAULT\x10\x00\x12\v\n" + - "\aREGULAR\x10\x01\x12\b\n" + - "\x04BOLD\x10\x02\x12\t\n" + - "\x05SERIF\x10\x03\x12\n" + - "\n" + - "\x06SCRIPT\x10\x04\x12\r\n" + - "\tCONDENSED\x10\x05B\f\n" + - "\n" + - "background\"\x99\x02\n" + - "\bVerified\x12&\n" + - "\x0edestinationAci\x18\x05 \x01(\tR\x0edestinationAci\x12 \n" + - "\videntityKey\x18\x02 \x01(\fR\videntityKey\x123\n" + - "\x05state\x18\x03 \x01(\x0e2\x1d.signalservice.Verified.StateR\x05state\x12 \n" + - "\vnullMessage\x18\x04 \x01(\fR\vnullMessage\x122\n" + - "\x14destinationAciBinary\x18\x06 \x01(\fR\x14destinationAciBinary\"2\n" + - "\x05State\x12\v\n" + - "\aDEFAULT\x10\x00\x12\f\n" + - "\bVERIFIED\x10\x01\x12\x0e\n" + - "\n" + - "UNVERIFIED\x10\x02J\x04\b\x01\x10\x02\"\xf1F\n" + - "\vSyncMessage\x125\n" + - "\x04sent\x18\x01 \x01(\v2\x1f.signalservice.SyncMessage.SentH\x00R\x04sent\x12A\n" + - "\bcontacts\x18\x02 \x01(\v2#.signalservice.SyncMessage.ContactsH\x00R\bcontacts\x12>\n" + - "\arequest\x18\x04 \x01(\v2\".signalservice.SyncMessage.RequestH\x00R\arequest\x12>\n" + - "\ablocked\x18\x06 \x01(\v2\".signalservice.SyncMessage.BlockedH\x00R\ablocked\x125\n" + - "\bverified\x18\a \x01(\v2\x17.signalservice.VerifiedH\x00R\bverified\x12P\n" + - "\rconfiguration\x18\t \x01(\v2(.signalservice.SyncMessage.ConfigurationH\x00R\rconfiguration\x12M\n" + - "\fviewOnceOpen\x18\v \x01(\v2'.signalservice.SyncMessage.ViewOnceOpenH\x00R\fviewOnceOpen\x12J\n" + - "\vfetchLatest\x18\f \x01(\v2&.signalservice.SyncMessage.FetchLatestH\x00R\vfetchLatest\x125\n" + - "\x04keys\x18\r \x01(\v2\x1f.signalservice.SyncMessage.KeysH\x00R\x04keys\x12k\n" + - "\x16messageRequestResponse\x18\x0e \x01(\v21.signalservice.SyncMessage.MessageRequestResponseH\x00R\x16messageRequestResponse\x12V\n" + - "\x0foutgoingPayment\x18\x0f \x01(\v2*.signalservice.SyncMessage.OutgoingPaymentH\x00R\x0foutgoingPayment\x12V\n" + - "\x0fpniChangeNumber\x18\x12 \x01(\v2*.signalservice.SyncMessage.PniChangeNumberH\x00R\x0fpniChangeNumber\x12D\n" + - "\tcallEvent\x18\x13 \x01(\v2$.signalservice.SyncMessage.CallEventH\x00R\tcallEvent\x12S\n" + - "\x0ecallLinkUpdate\x18\x14 \x01(\v2).signalservice.SyncMessage.CallLinkUpdateH\x00R\x0ecallLinkUpdate\x12M\n" + - "\fcallLogEvent\x18\x15 \x01(\v2'.signalservice.SyncMessage.CallLogEventH\x00R\fcallLogEvent\x12J\n" + - "\vdeleteForMe\x18\x16 \x01(\v2&.signalservice.SyncMessage.DeleteForMeH\x00R\vdeleteForMe\x12Y\n" + - "\x10deviceNameChange\x18\x17 \x01(\v2+.signalservice.SyncMessage.DeviceNameChangeH\x00R\x10deviceNameChange\x12t\n" + - "\x19attachmentBackfillRequest\x18\x18 \x01(\v24.signalservice.SyncMessage.AttachmentBackfillRequestH\x00R\x19attachmentBackfillRequest\x12w\n" + - "\x1aattachmentBackfillResponse\x18\x19 \x01(\v25.signalservice.SyncMessage.AttachmentBackfillResponseH\x00R\x1aattachmentBackfillResponse\x123\n" + - "\x04read\x18\x05 \x03(\v2\x1f.signalservice.SyncMessage.ReadR\x04read\x12c\n" + - "\x14stickerPackOperation\x18\n" + - " \x03(\v2/.signalservice.SyncMessage.StickerPackOperationR\x14stickerPackOperation\x129\n" + - "\x06viewed\x18\x10 \x03(\v2!.signalservice.SyncMessage.ViewedR\x06viewed\x12\x18\n" + - "\apadding\x18\b \x01(\fR\apadding\x1a\xbc\t\n" + - "\x04Sent\x12(\n" + - "\x0fdestinationE164\x18\x01 \x01(\tR\x0fdestinationE164\x122\n" + - "\x14destinationServiceId\x18\a \x01(\tR\x14destinationServiceId\x12\x1c\n" + - "\ttimestamp\x18\x02 \x01(\x04R\ttimestamp\x124\n" + - "\amessage\x18\x03 \x01(\v2\x1a.signalservice.DataMessageR\amessage\x12:\n" + - "\x18expirationStartTimestamp\x18\x04 \x01(\x04R\x18expirationStartTimestamp\x12j\n" + - "\x12unidentifiedStatus\x18\x05 \x03(\v2:.signalservice.SyncMessage.Sent.UnidentifiedDeliveryStatusR\x12unidentifiedStatus\x123\n" + - "\x11isRecipientUpdate\x18\x06 \x01(\b:\x05falseR\x11isRecipientUpdate\x12?\n" + - "\fstoryMessage\x18\b \x01(\v2\x1b.signalservice.StoryMessageR\fstoryMessage\x12m\n" + - "\x16storyMessageRecipients\x18\t \x03(\v25.signalservice.SyncMessage.Sent.StoryMessageRecipientR\x16storyMessageRecipients\x12<\n" + - "\veditMessage\x18\n" + - " \x01(\v2\x1a.signalservice.EditMessageR\veditMessage\x12>\n" + - "\x1adestinationServiceIdBinary\x18\f \x01(\fR\x1adestinationServiceIdBinary\x1a\xfe\x01\n" + - "\x1aUnidentifiedDeliveryStatus\x122\n" + - "\x14destinationServiceId\x18\x03 \x01(\tR\x14destinationServiceId\x12\"\n" + - "\funidentified\x18\x02 \x01(\bR\funidentified\x12<\n" + - "\x19destinationPniIdentityKey\x18\x05 \x01(\fR\x19destinationPniIdentityKey\x12>\n" + - "\x1adestinationServiceIdBinary\x18\x06 \x01(\fR\x1adestinationServiceIdBinaryJ\x04\b\x01\x10\x02J\x04\b\x04\x10\x05\x1a\xef\x01\n" + - "\x15StoryMessageRecipient\x122\n" + - "\x14destinationServiceId\x18\x01 \x01(\tR\x14destinationServiceId\x120\n" + - "\x13distributionListIds\x18\x02 \x03(\tR\x13distributionListIds\x12*\n" + - "\x10isAllowedToReply\x18\x03 \x01(\bR\x10isAllowedToReply\x12>\n" + - "\x1adestinationServiceIdBinary\x18\x05 \x01(\fR\x1adestinationServiceIdBinaryJ\x04\b\x04\x10\x05J\x04\b\v\x10\f\x1ac\n" + - "\bContacts\x124\n" + - "\x04blob\x18\x01 \x01(\v2 .signalservice.AttachmentPointerR\x04blob\x12!\n" + - "\bcomplete\x18\x02 \x01(\b:\x05falseR\bcomplete\x1as\n" + - "\aBlocked\x12\x18\n" + - "\anumbers\x18\x01 \x03(\tR\anumbers\x12\x12\n" + - "\x04acis\x18\x03 \x03(\tR\x04acis\x12\x1a\n" + - "\bgroupIds\x18\x02 \x03(\fR\bgroupIds\x12\x1e\n" + - "\n" + - "acisBinary\x18\x04 \x03(\fR\n" + - "acisBinary\x1a\x9f\x01\n" + - "\aRequest\x12;\n" + - "\x04type\x18\x01 \x01(\x0e2'.signalservice.SyncMessage.Request.TypeR\x04type\"W\n" + - "\x04Type\x12\v\n" + - "\aUNKNOWN\x10\x00\x12\f\n" + - "\bCONTACTS\x10\x01\x12\v\n" + - "\aBLOCKED\x10\x03\x12\x11\n" + - "\rCONFIGURATION\x10\x04\x12\b\n" + - "\x04KEYS\x10\x05\"\x04\b\x02\x10\x02\"\x04\b\x06\x10\x06\x1ar\n" + - "\x04Read\x12\x1c\n" + - "\tsenderAci\x18\x03 \x01(\tR\tsenderAci\x12\x1c\n" + - "\ttimestamp\x18\x02 \x01(\x04R\ttimestamp\x12(\n" + - "\x0fsenderAciBinary\x18\x04 \x01(\fR\x0fsenderAciBinaryJ\x04\b\x01\x10\x02\x1at\n" + - "\x06Viewed\x12\x1c\n" + - "\tsenderAci\x18\x03 \x01(\tR\tsenderAci\x12\x1c\n" + - "\ttimestamp\x18\x02 \x01(\x04R\ttimestamp\x12(\n" + - "\x0fsenderAciBinary\x18\x04 \x01(\fR\x0fsenderAciBinaryJ\x04\b\x01\x10\x02\x1a\xd7\x01\n" + - "\rConfiguration\x12\"\n" + - "\freadReceipts\x18\x01 \x01(\bR\freadReceipts\x12F\n" + - "\x1eunidentifiedDeliveryIndicators\x18\x02 \x01(\bR\x1eunidentifiedDeliveryIndicators\x12*\n" + - "\x10typingIndicators\x18\x03 \x01(\bR\x10typingIndicators\x12\"\n" + - "\flinkPreviews\x18\x06 \x01(\bR\flinkPreviewsJ\x04\b\x04\x10\x05J\x04\b\x05\x10\x06\x1a\xb3\x01\n" + - "\x14StickerPackOperation\x12\x16\n" + - "\x06packId\x18\x01 \x01(\fR\x06packId\x12\x18\n" + - "\apackKey\x18\x02 \x01(\fR\apackKey\x12H\n" + - "\x04type\x18\x03 \x01(\x0e24.signalservice.SyncMessage.StickerPackOperation.TypeR\x04type\"\x1f\n" + - "\x04Type\x12\v\n" + - "\aINSTALL\x10\x00\x12\n" + - "\n" + - "\x06REMOVE\x10\x01\x1az\n" + - "\fViewOnceOpen\x12\x1c\n" + - "\tsenderAci\x18\x03 \x01(\tR\tsenderAci\x12\x1c\n" + - "\ttimestamp\x18\x02 \x01(\x04R\ttimestamp\x12(\n" + - "\x0fsenderAciBinary\x18\x04 \x01(\fR\x0fsenderAciBinaryJ\x04\b\x01\x10\x02\x1a\xa5\x01\n" + - "\vFetchLatest\x12?\n" + - "\x04type\x18\x01 \x01(\x0e2+.signalservice.SyncMessage.FetchLatest.TypeR\x04type\"U\n" + - "\x04Type\x12\v\n" + - "\aUNKNOWN\x10\x00\x12\x11\n" + - "\rLOCAL_PROFILE\x10\x01\x12\x14\n" + - "\x10STORAGE_MANIFEST\x10\x02\x12\x17\n" + - "\x13SUBSCRIPTION_STATUS\x10\x03\x1ar\n" + - "\x04Keys\x12.\n" + - "\x12accountEntropyPool\x18\x03 \x01(\tR\x12accountEntropyPool\x12.\n" + - "\x12mediaRootBackupKey\x18\x04 \x01(\fR\x12mediaRootBackupKeyJ\x04\b\x01\x10\x02J\x04\b\x02\x10\x03\x1aK\n" + - "\vPniIdentity\x12\x1c\n" + - "\tpublicKey\x18\x01 \x01(\fR\tpublicKey\x12\x1e\n" + - "\n" + - "privateKey\x18\x02 \x01(\fR\n" + - "privateKey\x1a\xb8\x02\n" + - "\x16MessageRequestResponse\x12\x1c\n" + - "\tthreadAci\x18\x02 \x01(\tR\tthreadAci\x12\x18\n" + - "\agroupId\x18\x03 \x01(\fR\agroupId\x12J\n" + - "\x04type\x18\x04 \x01(\x0e26.signalservice.SyncMessage.MessageRequestResponse.TypeR\x04type\x12(\n" + - "\x0fthreadAciBinary\x18\x05 \x01(\fR\x0fthreadAciBinary\"j\n" + - "\x04Type\x12\v\n" + - "\aUNKNOWN\x10\x00\x12\n" + - "\n" + - "\x06ACCEPT\x10\x01\x12\n" + - "\n" + - "\x06DELETE\x10\x02\x12\t\n" + - "\x05BLOCK\x10\x03\x12\x14\n" + - "\x10BLOCK_AND_DELETE\x10\x04\x12\b\n" + - "\x04SPAM\x10\x05\x12\x12\n" + - "\x0eBLOCK_AND_SPAM\x10\x06J\x04\b\x01\x10\x02\x1a\x96\x04\n" + - "\x0fOutgoingPayment\x12.\n" + - "\x12recipientServiceId\x18\x01 \x01(\tR\x12recipientServiceId\x12\x12\n" + - "\x04note\x18\x02 \x01(\tR\x04note\x12W\n" + - "\n" + - "mobileCoin\x18\x03 \x01(\v25.signalservice.SyncMessage.OutgoingPayment.MobileCoinH\x00R\n" + - "mobileCoin\x1a\xcc\x02\n" + - "\n" + - "MobileCoin\x12*\n" + - "\x10recipientAddress\x18\x01 \x01(\fR\x10recipientAddress\x12$\n" + - "\ramountPicoMob\x18\x02 \x01(\x04R\ramountPicoMob\x12\x1e\n" + - "\n" + - "feePicoMob\x18\x03 \x01(\x04R\n" + - "feePicoMob\x12\x18\n" + - "\areceipt\x18\x04 \x01(\fR\areceipt\x122\n" + - "\x14ledgerBlockTimestamp\x18\x05 \x01(\x04R\x14ledgerBlockTimestamp\x12*\n" + - "\x10ledgerBlockIndex\x18\x06 \x01(\x04R\x10ledgerBlockIndex\x12&\n" + - "\x0espentKeyImages\x18\a \x03(\fR\x0espentKeyImages\x12*\n" + - "\x10outputPublicKeys\x18\b \x03(\fR\x10outputPublicKeysB\x17\n" + - "\x15attachment_identifier\x1a\xd7\x01\n" + - "\x0fPniChangeNumber\x12(\n" + - "\x0fidentityKeyPair\x18\x01 \x01(\fR\x0fidentityKeyPair\x12\"\n" + - "\fsignedPreKey\x18\x02 \x01(\fR\fsignedPreKey\x124\n" + - "\x15lastResortKyberPreKey\x18\x05 \x01(\fR\x15lastResortKyberPreKey\x12&\n" + - "\x0eregistrationId\x18\x03 \x01(\rR\x0eregistrationId\x12\x18\n" + - "\anewE164\x18\x04 \x01(\tR\anewE164\x1a\xa9\x04\n" + - "\tCallEvent\x12&\n" + - "\x0econversationId\x18\x01 \x01(\fR\x0econversationId\x12\x16\n" + - "\x06callId\x18\x02 \x01(\x04R\x06callId\x12\x1c\n" + - "\ttimestamp\x18\x03 \x01(\x04R\ttimestamp\x12=\n" + - "\x04type\x18\x04 \x01(\x0e2).signalservice.SyncMessage.CallEvent.TypeR\x04type\x12L\n" + - "\tdirection\x18\x05 \x01(\x0e2..signalservice.SyncMessage.CallEvent.DirectionR\tdirection\x12@\n" + - "\x05event\x18\x06 \x01(\x0e2*.signalservice.SyncMessage.CallEvent.EventR\x05event\"Y\n" + - "\x04Type\x12\x10\n" + - "\fUNKNOWN_TYPE\x10\x00\x12\x0e\n" + - "\n" + - "AUDIO_CALL\x10\x01\x12\x0e\n" + - "\n" + - "VIDEO_CALL\x10\x02\x12\x0e\n" + - "\n" + - "GROUP_CALL\x10\x03\x12\x0f\n" + - "\vAD_HOC_CALL\x10\x04\">\n" + - "\tDirection\x12\x15\n" + - "\x11UNKNOWN_DIRECTION\x10\x00\x12\f\n" + - "\bINCOMING\x10\x01\x12\f\n" + - "\bOUTGOING\x10\x02\"T\n" + - "\x05Event\x12\x11\n" + - "\rUNKNOWN_EVENT\x10\x00\x12\f\n" + - "\bACCEPTED\x10\x01\x12\x10\n" + - "\fNOT_ACCEPTED\x10\x02\x12\n" + - "\n" + - "\x06DELETE\x10\x03\x12\f\n" + - "\bOBSERVED\x10\x04\x1a\xb2\x01\n" + - "\x0eCallLinkUpdate\x12\x18\n" + - "\arootKey\x18\x01 \x01(\fR\arootKey\x12\"\n" + - "\fadminPasskey\x18\x02 \x01(\fR\fadminPasskey\x12B\n" + - "\x04type\x18\x03 \x01(\x0e2..signalservice.SyncMessage.CallLinkUpdate.TypeR\x04type\"\x18\n" + - "\x04Type\x12\n" + - "\n" + - "\x06UPDATE\x10\x00\"\x04\b\x01\x10\x01J\x04\b\x04\x10\x05\x1a\x94\x02\n" + - "\fCallLogEvent\x12@\n" + - "\x04type\x18\x01 \x01(\x0e2,.signalservice.SyncMessage.CallLogEvent.TypeR\x04type\x12\x1c\n" + - "\ttimestamp\x18\x02 \x01(\x04R\ttimestamp\x12&\n" + - "\x0econversationId\x18\x03 \x01(\fR\x0econversationId\x12\x16\n" + - "\x06callId\x18\x04 \x01(\x04R\x06callId\"d\n" + - "\x04Type\x12\t\n" + - "\x05CLEAR\x10\x00\x12\x12\n" + - "\x0eMARKED_AS_READ\x10\x01\x12\"\n" + - "\x1eMARKED_AS_READ_IN_CONVERSATION\x10\x02\x12\x19\n" + - "\x15CLEAR_IN_CONVERSATION\x10\x03\x1a\xb9\n" + - "\n" + - "\vDeleteForMe\x12]\n" + - "\x0emessageDeletes\x18\x01 \x03(\v25.signalservice.SyncMessage.DeleteForMe.MessageDeletesR\x0emessageDeletes\x12k\n" + - "\x13conversationDeletes\x18\x02 \x03(\v29.signalservice.SyncMessage.DeleteForMe.ConversationDeleteR\x13conversationDeletes\x12\x86\x01\n" + - "\x1clocalOnlyConversationDeletes\x18\x03 \x03(\v2B.signalservice.SyncMessage.DeleteForMe.LocalOnlyConversationDeleteR\x1clocalOnlyConversationDeletes\x12e\n" + - "\x11attachmentDeletes\x18\x04 \x03(\v27.signalservice.SyncMessage.DeleteForMe.AttachmentDeleteR\x11attachmentDeletes\x1a\x9a\x01\n" + - "\x0eMessageDeletes\x12I\n" + - "\fconversation\x18\x01 \x01(\v2%.signalservice.ConversationIdentifierR\fconversation\x12=\n" + - "\bmessages\x18\x02 \x03(\v2!.signalservice.AddressableMessageR\bmessages\x1a\xa4\x02\n" + - "\x10AttachmentDelete\x12I\n" + - "\fconversation\x18\x01 \x01(\v2%.signalservice.ConversationIdentifierR\fconversation\x12G\n" + - "\rtargetMessage\x18\x02 \x01(\v2!.signalservice.AddressableMessageR\rtargetMessage\x12\x1e\n" + - "\n" + - "clientUuid\x18\x03 \x01(\fR\n" + - "clientUuid\x12&\n" + - "\x0efallbackDigest\x18\x04 \x01(\fR\x0efallbackDigest\x124\n" + - "\x15fallbackPlaintextHash\x18\x05 \x01(\fR\x15fallbackPlaintextHash\x1a\xbf\x02\n" + - "\x12ConversationDelete\x12I\n" + - "\fconversation\x18\x01 \x01(\v2%.signalservice.ConversationIdentifierR\fconversation\x12Q\n" + - "\x12mostRecentMessages\x18\x02 \x03(\v2!.signalservice.AddressableMessageR\x12mostRecentMessages\x12\"\n" + - "\fisFullDelete\x18\x03 \x01(\bR\fisFullDelete\x12g\n" + - "\x1dmostRecentNonExpiringMessages\x18\x04 \x03(\v2!.signalservice.AddressableMessageR\x1dmostRecentNonExpiringMessages\x1ah\n" + - "\x1bLocalOnlyConversationDelete\x12I\n" + - "\fconversation\x18\x01 \x01(\v2%.signalservice.ConversationIdentifierR\fconversation\x1a4\n" + - "\x10DeviceNameChange\x12\x1a\n" + - "\bdeviceId\x18\x02 \x01(\rR\bdeviceIdJ\x04\b\x01\x10\x02\x1a\xbb\x01\n" + - "\x19AttachmentBackfillRequest\x12G\n" + - "\rtargetMessage\x18\x01 \x01(\v2!.signalservice.AddressableMessageR\rtargetMessage\x12U\n" + - "\x12targetConversation\x18\x02 \x01(\v2%.signalservice.ConversationIdentifierR\x12targetConversation\x1a\xf9\x06\n" + - "\x1aAttachmentBackfillResponse\x12G\n" + - "\rtargetMessage\x18\x01 \x01(\v2!.signalservice.AddressableMessageR\rtargetMessage\x12U\n" + - "\x12targetConversation\x18\x02 \x01(\v2%.signalservice.ConversationIdentifierR\x12targetConversation\x12l\n" + - "\vattachments\x18\x03 \x01(\v2H.signalservice.SyncMessage.AttachmentBackfillResponse.AttachmentDataListH\x00R\vattachments\x12S\n" + - "\x05error\x18\x04 \x01(\x0e2;.signalservice.SyncMessage.AttachmentBackfillResponse.ErrorH\x00R\x05error\x1a\xee\x01\n" + - "\x0eAttachmentData\x12B\n" + - "\n" + - "attachment\x18\x01 \x01(\v2 .signalservice.AttachmentPointerH\x00R\n" + - "attachment\x12e\n" + - "\x06status\x18\x02 \x01(\x0e2K.signalservice.SyncMessage.AttachmentBackfillResponse.AttachmentData.StatusH\x00R\x06status\")\n" + - "\x06Status\x12\v\n" + - "\aPENDING\x10\x00\x12\x12\n" + - "\x0eTERMINAL_ERROR\x10\x01B\x06\n" + - "\x04data\x1a\xde\x01\n" + - "\x12AttachmentDataList\x12f\n" + - "\vattachments\x18\x01 \x03(\v2D.signalservice.SyncMessage.AttachmentBackfillResponse.AttachmentDataR\vattachments\x12`\n" + - "\blongText\x18\x02 \x01(\v2D.signalservice.SyncMessage.AttachmentBackfillResponse.AttachmentDataR\blongText\"\x1e\n" + - "\x05Error\x12\x15\n" + - "\x11MESSAGE_NOT_FOUND\x10\x00B\x06\n" + - "\x04dataB\t\n" + - "\acontentJ\x04\b\x03\x10\x04J\x04\b\x11\x10\x12\"\xe7\x04\n" + - "\x11AttachmentPointer\x12\x16\n" + - "\x05cdnId\x18\x01 \x01(\x06H\x00R\x05cdnId\x12\x18\n" + - "\x06cdnKey\x18\x0f \x01(\tH\x00R\x06cdnKey\x12\x1e\n" + - "\n" + - "clientUuid\x18\x14 \x01(\fR\n" + - "clientUuid\x12 \n" + - "\vcontentType\x18\x02 \x01(\tR\vcontentType\x12\x10\n" + - "\x03key\x18\x03 \x01(\fR\x03key\x12\x12\n" + - "\x04size\x18\x04 \x01(\rR\x04size\x12\x1c\n" + - "\tthumbnail\x18\x05 \x01(\fR\tthumbnail\x12\x16\n" + - "\x06digest\x18\x06 \x01(\fR\x06digest\x12&\n" + - "\x0eincrementalMac\x18\x13 \x01(\fR\x0eincrementalMac\x12\x1c\n" + - "\tchunkSize\x18\x11 \x01(\rR\tchunkSize\x12\x1a\n" + - "\bfileName\x18\a \x01(\tR\bfileName\x12\x14\n" + - "\x05flags\x18\b \x01(\rR\x05flags\x12\x14\n" + - "\x05width\x18\t \x01(\rR\x05width\x12\x16\n" + - "\x06height\x18\n" + - " \x01(\rR\x06height\x12\x18\n" + - "\acaption\x18\v \x01(\tR\acaption\x12\x1a\n" + - "\bblurHash\x18\f \x01(\tR\bblurHash\x12(\n" + - "\x0fuploadTimestamp\x18\r \x01(\x04R\x0fuploadTimestamp\x12\x1c\n" + - "\tcdnNumber\x18\x0e \x01(\rR\tcdnNumber\"9\n" + - "\x05Flags\x12\x11\n" + - "\rVOICE_MESSAGE\x10\x01\x12\x0e\n" + - "\n" + - "BORDERLESS\x10\x02\x12\a\n" + - "\x03GIF\x10\b\"\x04\b\x04\x10\x04B\x17\n" + - "\x15attachment_identifierJ\x04\b\x10\x10\x11J\x04\b\x12\x10\x13\"l\n" + - "\x0eGroupContextV2\x12\x1c\n" + - "\tmasterKey\x18\x01 \x01(\fR\tmasterKey\x12\x1a\n" + - "\brevision\x18\x02 \x01(\rR\brevision\x12 \n" + - "\vgroupChange\x18\x03 \x01(\fR\vgroupChange\"\x84\x03\n" + - "\x0eContactDetails\x12\x16\n" + - "\x06number\x18\x01 \x01(\tR\x06number\x12\x10\n" + - "\x03aci\x18\t \x01(\tR\x03aci\x12\x1c\n" + - "\taciBinary\x18\r \x01(\fR\taciBinary\x12\x12\n" + - "\x04name\x18\x02 \x01(\tR\x04name\x12<\n" + - "\x06avatar\x18\x03 \x01(\v2$.signalservice.ContactDetails.AvatarR\x06avatar\x12 \n" + - "\vexpireTimer\x18\b \x01(\rR\vexpireTimer\x12.\n" + - "\x12expireTimerVersion\x18\f \x01(\rR\x12expireTimerVersion\x12$\n" + - "\rinboxPosition\x18\n" + - " \x01(\rR\rinboxPosition\x1aB\n" + - "\x06Avatar\x12 \n" + - "\vcontentType\x18\x01 \x01(\tR\vcontentType\x12\x16\n" + - "\x06length\x18\x02 \x01(\rR\x06lengthJ\x04\b\x04\x10\x05J\x04\b\x05\x10\x06J\x04\b\x06\x10\aJ\x04\b\a\x10\bJ\x04\b\v\x10\f\"\xb9\x01\n" + - "\x0ePaymentAddress\x12J\n" + - "\n" + - "mobileCoin\x18\x01 \x01(\v2(.signalservice.PaymentAddress.MobileCoinH\x00R\n" + - "mobileCoin\x1aP\n" + - "\n" + - "MobileCoin\x12$\n" + - "\rpublicAddress\x18\x01 \x01(\fR\rpublicAddress\x12\x1c\n" + - "\tsignature\x18\x02 \x01(\fR\tsignatureB\t\n" + - "\aAddress\"r\n" + - "\x16DecryptionErrorMessage\x12\x1e\n" + - "\n" + - "ratchetKey\x18\x01 \x01(\fR\n" + - "ratchetKey\x12\x1c\n" + - "\ttimestamp\x18\x02 \x01(\x04R\ttimestamp\x12\x1a\n" + - "\bdeviceId\x18\x03 \x01(\rR\bdeviceId\"E\n" + - "\x13PniSignatureMessage\x12\x10\n" + - "\x03pni\x18\x01 \x01(\fR\x03pni\x12\x1c\n" + - "\tsignature\x18\x02 \x01(\fR\tsignature\"}\n" + - "\vEditMessage\x120\n" + - "\x13targetSentTimestamp\x18\x01 \x01(\x04R\x13targetSentTimestamp\x12<\n" + - "\vdataMessage\x18\x02 \x01(\v2\x1a.signalservice.DataMessageR\vdataMessage\"\xac\x02\n" + - "\tBodyRange\x12\x14\n" + - "\x05start\x18\x01 \x01(\rR\x05start\x12\x16\n" + - "\x06length\x18\x02 \x01(\rR\x06length\x12 \n" + - "\n" + - "mentionAci\x18\x03 \x01(\tH\x00R\n" + - "mentionAci\x126\n" + - "\x05style\x18\x04 \x01(\x0e2\x1e.signalservice.BodyRange.StyleH\x00R\x05style\x12,\n" + - "\x10mentionAciBinary\x18\x05 \x01(\fH\x00R\x10mentionAciBinary\"V\n" + - "\x05Style\x12\b\n" + - "\x04NONE\x10\x00\x12\b\n" + - "\x04BOLD\x10\x01\x12\n" + - "\n" + - "\x06ITALIC\x10\x02\x12\v\n" + - "\aSPOILER\x10\x03\x12\x11\n" + - "\rSTRIKETHROUGH\x10\x04\x12\r\n" + - "\tMONOSPACE\x10\x05B\x11\n" + - "\x0fassociatedValue\"\xca\x01\n" + - "\x12AddressableMessage\x12*\n" + - "\x0fauthorServiceId\x18\x01 \x01(\tH\x00R\x0fauthorServiceId\x12 \n" + - "\n" + - "authorE164\x18\x02 \x01(\tH\x00R\n" + - "authorE164\x126\n" + - "\x15authorServiceIdBinary\x18\x04 \x01(\fH\x00R\x15authorServiceIdBinary\x12$\n" + - "\rsentTimestamp\x18\x03 \x01(\x04R\rsentTimestampB\b\n" + - "\x06author\"\xd4\x01\n" + - "\x16ConversationIdentifier\x12*\n" + - "\x0fthreadServiceId\x18\x01 \x01(\tH\x00R\x0fthreadServiceId\x12&\n" + - "\rthreadGroupId\x18\x02 \x01(\fH\x00R\rthreadGroupId\x12 \n" + - "\n" + - "threadE164\x18\x03 \x01(\tH\x00R\n" + - "threadE164\x126\n" + - "\x15threadServiceIdBinary\x18\x04 \x01(\fH\x00R\x15threadServiceIdBinaryB\f\n" + - "\n" + - "identifierBE\n" + - ".org.whispersystems.signalservice.internal.pushB\x13SignalServiceProtos" +var file_SignalService_proto_rawDesc = []byte{ + 0x0a, 0x13, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0d, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x22, 0xc2, 0x04, 0x0a, 0x08, 0x45, 0x6e, 0x76, 0x65, 0x6c, 0x6f, 0x70, + 0x65, 0x12, 0x30, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x1c, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, + 0x45, 0x6e, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, + 0x79, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x0f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x22, 0x0a, + 0x0c, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x18, 0x07, 0x20, + 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x44, 0x65, 0x76, 0x69, 0x63, + 0x65, 0x12, 0x32, 0x0a, 0x14, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x14, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x08, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x1e, 0x0a, + 0x0a, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x47, 0x75, 0x69, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x47, 0x75, 0x69, 0x64, 0x12, 0x28, 0x0a, + 0x0f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x18, 0x0a, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x54, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x1c, 0x0a, 0x06, 0x75, 0x72, 0x67, 0x65, 0x6e, + 0x74, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x04, 0x74, 0x72, 0x75, 0x65, 0x52, 0x06, 0x75, + 0x72, 0x67, 0x65, 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x10, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x26, 0x0a, 0x0e, 0x72, + 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x11, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x54, 0x6f, + 0x6b, 0x65, 0x6e, 0x22, 0x8b, 0x01, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, + 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0e, 0x0a, 0x0a, 0x43, 0x49, 0x50, + 0x48, 0x45, 0x52, 0x54, 0x45, 0x58, 0x54, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x4b, 0x45, 0x59, + 0x5f, 0x45, 0x58, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x10, 0x02, 0x12, 0x11, 0x0a, 0x0d, 0x50, + 0x52, 0x45, 0x4b, 0x45, 0x59, 0x5f, 0x42, 0x55, 0x4e, 0x44, 0x4c, 0x45, 0x10, 0x03, 0x12, 0x0b, + 0x0a, 0x07, 0x52, 0x45, 0x43, 0x45, 0x49, 0x50, 0x54, 0x10, 0x05, 0x12, 0x17, 0x0a, 0x13, 0x55, + 0x4e, 0x49, 0x44, 0x45, 0x4e, 0x54, 0x49, 0x46, 0x49, 0x45, 0x44, 0x5f, 0x53, 0x45, 0x4e, 0x44, + 0x45, 0x52, 0x10, 0x06, 0x12, 0x15, 0x0a, 0x11, 0x50, 0x4c, 0x41, 0x49, 0x4e, 0x54, 0x45, 0x58, + 0x54, 0x5f, 0x43, 0x4f, 0x4e, 0x54, 0x45, 0x4e, 0x54, 0x10, 0x08, 0x22, 0x04, 0x08, 0x07, 0x10, + 0x07, 0x4a, 0x04, 0x08, 0x02, 0x10, 0x03, 0x4a, 0x04, 0x08, 0x03, 0x10, 0x04, 0x4a, 0x04, 0x08, + 0x06, 0x10, 0x07, 0x4a, 0x04, 0x08, 0x0f, 0x10, 0x10, 0x22, 0xdd, 0x05, 0x0a, 0x07, 0x43, 0x6f, + 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x3c, 0x0a, 0x0b, 0x64, 0x61, 0x74, 0x61, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x73, 0x69, 0x67, + 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x0b, 0x64, 0x61, 0x74, 0x61, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x12, 0x3c, 0x0a, 0x0b, 0x73, 0x79, 0x6e, 0x63, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, + 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x52, 0x0b, 0x73, 0x79, 0x6e, 0x63, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x12, 0x3c, 0x0a, 0x0b, 0x63, 0x61, 0x6c, 0x6c, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x52, 0x0b, 0x63, 0x61, 0x6c, 0x6c, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, + 0x3c, 0x0a, 0x0b, 0x6e, 0x75, 0x6c, 0x6c, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x2e, 0x4e, 0x75, 0x6c, 0x6c, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x52, 0x0b, 0x6e, 0x75, 0x6c, 0x6c, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x45, 0x0a, + 0x0e, 0x72, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x52, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x52, 0x0e, 0x72, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x12, 0x42, 0x0a, 0x0d, 0x74, 0x79, 0x70, 0x69, 0x6e, 0x67, 0x4d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x73, 0x69, + 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x54, 0x79, 0x70, 0x69, + 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x0d, 0x74, 0x79, 0x70, 0x69, 0x6e, + 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x42, 0x0a, 0x1c, 0x73, 0x65, 0x6e, 0x64, + 0x65, 0x72, 0x4b, 0x65, 0x79, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, + 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x1c, + 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, + 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x36, 0x0a, 0x16, + 0x64, 0x65, 0x63, 0x72, 0x79, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x16, 0x64, 0x65, + 0x63, 0x72, 0x79, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x12, 0x3f, 0x0a, 0x0c, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x73, 0x69, 0x67, + 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x79, + 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x0c, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x4d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x54, 0x0a, 0x13, 0x70, 0x6e, 0x69, 0x53, 0x69, 0x67, 0x6e, + 0x61, 0x74, 0x75, 0x72, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x0a, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x2e, 0x50, 0x6e, 0x69, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x13, 0x70, 0x6e, 0x69, 0x53, 0x69, 0x67, 0x6e, 0x61, + 0x74, 0x75, 0x72, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x3c, 0x0a, 0x0b, 0x65, + 0x64, 0x69, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1a, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x2e, 0x45, 0x64, 0x69, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x0b, 0x65, 0x64, + 0x69, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xf1, 0x09, 0x0a, 0x0b, 0x43, 0x61, + 0x6c, 0x6c, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x36, 0x0a, 0x05, 0x6f, 0x66, 0x66, + 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, + 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4f, 0x66, 0x66, 0x65, 0x72, 0x52, 0x05, 0x6f, 0x66, 0x66, 0x65, + 0x72, 0x12, 0x39, 0x0a, 0x06, 0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x41, 0x6e, + 0x73, 0x77, 0x65, 0x72, 0x52, 0x06, 0x61, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x12, 0x42, 0x0a, 0x09, + 0x69, 0x63, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x24, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, + 0x43, 0x61, 0x6c, 0x6c, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x49, 0x63, 0x65, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x09, 0x69, 0x63, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x12, 0x45, 0x0a, 0x0c, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x48, 0x61, 0x6e, 0x67, 0x75, 0x70, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x2e, 0x48, 0x61, 0x6e, 0x67, 0x75, 0x70, 0x52, 0x0c, 0x6c, 0x65, 0x67, 0x61, 0x63, + 0x79, 0x48, 0x61, 0x6e, 0x67, 0x75, 0x70, 0x12, 0x33, 0x0a, 0x04, 0x62, 0x75, 0x73, 0x79, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x2e, 0x42, 0x75, 0x73, 0x79, 0x52, 0x04, 0x62, 0x75, 0x73, 0x79, 0x12, 0x39, 0x0a, 0x06, + 0x68, 0x61, 0x6e, 0x67, 0x75, 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, + 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x43, 0x61, 0x6c, + 0x6c, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x48, 0x61, 0x6e, 0x67, 0x75, 0x70, 0x52, + 0x06, 0x68, 0x61, 0x6e, 0x67, 0x75, 0x70, 0x12, 0x30, 0x0a, 0x13, 0x64, 0x65, 0x73, 0x74, 0x69, + 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x09, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x13, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x39, 0x0a, 0x06, 0x6f, 0x70, 0x61, + 0x71, 0x75, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x69, 0x67, 0x6e, + 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x4d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x52, 0x06, 0x6f, 0x70, + 0x61, 0x71, 0x75, 0x65, 0x1a, 0xb6, 0x01, 0x0a, 0x05, 0x4f, 0x66, 0x66, 0x65, 0x72, 0x12, 0x0e, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, + 0x0a, 0x03, 0x73, 0x64, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x64, 0x70, + 0x12, 0x39, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x25, + 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x43, + 0x61, 0x6c, 0x6c, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4f, 0x66, 0x66, 0x65, 0x72, + 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6f, + 0x70, 0x61, 0x71, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x6f, 0x70, 0x61, + 0x71, 0x75, 0x65, 0x22, 0x38, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x10, 0x4f, + 0x46, 0x46, 0x45, 0x52, 0x5f, 0x41, 0x55, 0x44, 0x49, 0x4f, 0x5f, 0x43, 0x41, 0x4c, 0x4c, 0x10, + 0x00, 0x12, 0x14, 0x0a, 0x10, 0x4f, 0x46, 0x46, 0x45, 0x52, 0x5f, 0x56, 0x49, 0x44, 0x45, 0x4f, + 0x5f, 0x43, 0x41, 0x4c, 0x4c, 0x10, 0x01, 0x22, 0x04, 0x08, 0x02, 0x10, 0x02, 0x1a, 0x42, 0x0a, + 0x06, 0x41, 0x6e, 0x73, 0x77, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x64, 0x70, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x64, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x70, 0x61, + 0x71, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x6f, 0x70, 0x61, 0x71, 0x75, + 0x65, 0x1a, 0x6b, 0x0a, 0x09, 0x49, 0x63, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x0e, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, + 0x0a, 0x03, 0x6d, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x69, 0x64, + 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, + 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x64, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x73, 0x64, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x70, 0x61, 0x71, 0x75, 0x65, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x6f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x1a, 0x16, + 0x0a, 0x04, 0x42, 0x75, 0x73, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x1a, 0xe2, 0x01, 0x0a, 0x06, 0x48, 0x61, 0x6e, 0x67, 0x75, + 0x70, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, + 0x64, 0x12, 0x3a, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x26, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, + 0x43, 0x61, 0x6c, 0x6c, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x48, 0x61, 0x6e, 0x67, + 0x75, 0x70, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, + 0x08, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x08, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x22, 0x70, 0x0a, 0x04, 0x54, 0x79, 0x70, + 0x65, 0x12, 0x11, 0x0a, 0x0d, 0x48, 0x41, 0x4e, 0x47, 0x55, 0x50, 0x5f, 0x4e, 0x4f, 0x52, 0x4d, + 0x41, 0x4c, 0x10, 0x00, 0x12, 0x13, 0x0a, 0x0f, 0x48, 0x41, 0x4e, 0x47, 0x55, 0x50, 0x5f, 0x41, + 0x43, 0x43, 0x45, 0x50, 0x54, 0x45, 0x44, 0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, 0x48, 0x41, 0x4e, + 0x47, 0x55, 0x50, 0x5f, 0x44, 0x45, 0x43, 0x4c, 0x49, 0x4e, 0x45, 0x44, 0x10, 0x02, 0x12, 0x0f, + 0x0a, 0x0b, 0x48, 0x41, 0x4e, 0x47, 0x55, 0x50, 0x5f, 0x42, 0x55, 0x53, 0x59, 0x10, 0x03, 0x12, + 0x1a, 0x0a, 0x16, 0x48, 0x41, 0x4e, 0x47, 0x55, 0x50, 0x5f, 0x4e, 0x45, 0x45, 0x44, 0x5f, 0x50, + 0x45, 0x52, 0x4d, 0x49, 0x53, 0x53, 0x49, 0x4f, 0x4e, 0x10, 0x04, 0x1a, 0x93, 0x01, 0x0a, 0x06, + 0x4f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x43, 0x0a, 0x07, 0x75, 0x72, + 0x67, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x29, 0x2e, 0x73, 0x69, + 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x43, 0x61, 0x6c, 0x6c, + 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x2e, 0x55, + 0x72, 0x67, 0x65, 0x6e, 0x63, 0x79, 0x52, 0x07, 0x75, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x79, 0x22, + 0x30, 0x0a, 0x07, 0x55, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x0d, 0x0a, 0x09, 0x44, 0x52, + 0x4f, 0x50, 0x50, 0x41, 0x42, 0x4c, 0x45, 0x10, 0x00, 0x12, 0x16, 0x0a, 0x12, 0x48, 0x41, 0x4e, + 0x44, 0x4c, 0x45, 0x5f, 0x49, 0x4d, 0x4d, 0x45, 0x44, 0x49, 0x41, 0x54, 0x45, 0x4c, 0x59, 0x10, + 0x01, 0x4a, 0x04, 0x08, 0x06, 0x10, 0x07, 0x4a, 0x04, 0x08, 0x08, 0x10, 0x09, 0x22, 0xfe, 0x01, + 0x0a, 0x09, 0x42, 0x6f, 0x64, 0x79, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x73, + 0x74, 0x61, 0x72, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x73, 0x74, 0x61, 0x72, + 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0d, 0x52, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x20, 0x0a, 0x0a, 0x6d, 0x65, 0x6e, + 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x63, 0x69, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, + 0x0a, 0x6d, 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x63, 0x69, 0x12, 0x36, 0x0a, 0x05, 0x73, + 0x74, 0x79, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x73, 0x69, 0x67, + 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x42, 0x6f, 0x64, 0x79, 0x52, + 0x61, 0x6e, 0x67, 0x65, 0x2e, 0x53, 0x74, 0x79, 0x6c, 0x65, 0x48, 0x00, 0x52, 0x05, 0x73, 0x74, + 0x79, 0x6c, 0x65, 0x22, 0x56, 0x0a, 0x05, 0x53, 0x74, 0x79, 0x6c, 0x65, 0x12, 0x08, 0x0a, 0x04, + 0x4e, 0x4f, 0x4e, 0x45, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x42, 0x4f, 0x4c, 0x44, 0x10, 0x01, + 0x12, 0x0a, 0x0a, 0x06, 0x49, 0x54, 0x41, 0x4c, 0x49, 0x43, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, + 0x53, 0x50, 0x4f, 0x49, 0x4c, 0x45, 0x52, 0x10, 0x03, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x54, 0x52, + 0x49, 0x4b, 0x45, 0x54, 0x48, 0x52, 0x4f, 0x55, 0x47, 0x48, 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, + 0x4d, 0x4f, 0x4e, 0x4f, 0x53, 0x50, 0x41, 0x43, 0x45, 0x10, 0x05, 0x42, 0x11, 0x0a, 0x0f, 0x61, + 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x65, 0x64, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xba, + 0x22, 0x0a, 0x0b, 0x44, 0x61, 0x74, 0x61, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, + 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x62, 0x6f, + 0x64, 0x79, 0x12, 0x42, 0x0a, 0x0b, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, + 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, + 0x6e, 0x74, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x52, 0x0b, 0x61, 0x74, 0x74, 0x61, 0x63, + 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x37, 0x0a, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x56, + 0x32, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x6f, 0x6e, + 0x74, 0x65, 0x78, 0x74, 0x56, 0x32, 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x56, 0x32, 0x12, + 0x14, 0x0a, 0x05, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, + 0x66, 0x6c, 0x61, 0x67, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x54, + 0x69, 0x6d, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0b, 0x65, 0x78, 0x70, 0x69, + 0x72, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x66, 0x69, + 0x6c, 0x65, 0x4b, 0x65, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x70, 0x72, 0x6f, + 0x66, 0x69, 0x6c, 0x65, 0x4b, 0x65, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x36, 0x0a, 0x05, 0x71, 0x75, 0x6f, 0x74, 0x65, 0x18, 0x08, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x2e, 0x51, 0x75, 0x6f, 0x74, 0x65, 0x52, 0x05, 0x71, 0x75, 0x6f, 0x74, 0x65, 0x12, 0x3c, 0x0a, + 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, + 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x44, + 0x61, 0x74, 0x61, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x61, + 0x63, 0x74, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x12, 0x30, 0x0a, 0x07, 0x70, + 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x73, + 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x50, 0x72, 0x65, + 0x76, 0x69, 0x65, 0x77, 0x52, 0x07, 0x70, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x12, 0x3c, 0x0a, + 0x07, 0x73, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x72, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, + 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x44, + 0x61, 0x74, 0x61, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x53, 0x74, 0x69, 0x63, 0x6b, + 0x65, 0x72, 0x52, 0x07, 0x73, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x72, 0x12, 0x38, 0x0a, 0x17, 0x72, + 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x56, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x17, 0x72, 0x65, + 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x56, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x73, 0x56, 0x69, 0x65, 0x77, 0x4f, + 0x6e, 0x63, 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x69, 0x73, 0x56, 0x69, 0x65, + 0x77, 0x4f, 0x6e, 0x63, 0x65, 0x12, 0x3f, 0x0a, 0x08, 0x72, 0x65, 0x61, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x18, 0x10, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x2e, 0x52, 0x65, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x72, 0x65, + 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x39, 0x0a, 0x06, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x18, 0x11, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x06, 0x64, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x12, 0x38, 0x0a, 0x0a, 0x62, 0x6f, 0x64, 0x79, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x18, + 0x12, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x42, 0x6f, 0x64, 0x79, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x52, + 0x0a, 0x62, 0x6f, 0x64, 0x79, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x12, 0x54, 0x0a, 0x0f, 0x67, + 0x72, 0x6f, 0x75, 0x70, 0x43, 0x61, 0x6c, 0x6c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x18, 0x13, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x61, 0x6c, 0x6c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x52, 0x0f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x61, 0x6c, 0x6c, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x12, 0x3c, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x14, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x50, + 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x12, + 0x4b, 0x0a, 0x0c, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, + 0x15, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x79, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x52, 0x0c, + 0x73, 0x74, 0x6f, 0x72, 0x79, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x42, 0x0a, 0x09, + 0x67, 0x69, 0x66, 0x74, 0x42, 0x61, 0x64, 0x67, 0x65, 0x18, 0x16, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x24, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, + 0x44, 0x61, 0x74, 0x61, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x47, 0x69, 0x66, 0x74, + 0x42, 0x61, 0x64, 0x67, 0x65, 0x52, 0x09, 0x67, 0x69, 0x66, 0x74, 0x42, 0x61, 0x64, 0x67, 0x65, + 0x1a, 0xd0, 0x03, 0x0a, 0x05, 0x51, 0x75, 0x6f, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x75, + 0x74, 0x68, 0x6f, 0x72, 0x41, 0x63, 0x69, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, + 0x75, 0x74, 0x68, 0x6f, 0x72, 0x41, 0x63, 0x69, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x12, 0x53, 0x0a, 0x0b, + 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x31, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x51, 0x75, + 0x6f, 0x74, 0x65, 0x2e, 0x51, 0x75, 0x6f, 0x74, 0x65, 0x64, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, + 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x0b, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, + 0x73, 0x12, 0x38, 0x0a, 0x0a, 0x62, 0x6f, 0x64, 0x79, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x18, + 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x42, 0x6f, 0x64, 0x79, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x52, + 0x0a, 0x62, 0x6f, 0x64, 0x79, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x12, 0x39, 0x0a, 0x04, 0x74, + 0x79, 0x70, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x25, 0x2e, 0x73, 0x69, 0x67, 0x6e, + 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x4d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x51, 0x75, 0x6f, 0x74, 0x65, 0x2e, 0x54, 0x79, 0x70, 0x65, + 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x1a, 0x90, 0x01, 0x0a, 0x10, 0x51, 0x75, 0x6f, 0x74, 0x65, + 0x64, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x63, + 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, + 0x08, 0x66, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x66, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x3e, 0x0a, 0x09, 0x74, 0x68, 0x75, + 0x6d, 0x62, 0x6e, 0x61, 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x73, + 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x41, 0x74, 0x74, + 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x52, 0x09, + 0x74, 0x68, 0x75, 0x6d, 0x62, 0x6e, 0x61, 0x69, 0x6c, 0x22, 0x22, 0x0a, 0x04, 0x54, 0x79, 0x70, + 0x65, 0x12, 0x0a, 0x0a, 0x06, 0x4e, 0x4f, 0x52, 0x4d, 0x41, 0x4c, 0x10, 0x00, 0x12, 0x0e, 0x0a, + 0x0a, 0x47, 0x49, 0x46, 0x54, 0x5f, 0x42, 0x41, 0x44, 0x47, 0x45, 0x10, 0x01, 0x4a, 0x04, 0x08, + 0x02, 0x10, 0x03, 0x1a, 0xbf, 0x0a, 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x12, + 0x3b, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, + 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x44, 0x61, + 0x74, 0x61, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x63, + 0x74, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x40, 0x0a, 0x06, + 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x73, + 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x44, 0x61, 0x74, + 0x61, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, + 0x2e, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x3e, + 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, + 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x44, 0x61, + 0x74, 0x61, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x63, + 0x74, 0x2e, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x4a, + 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x30, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, + 0x44, 0x61, 0x74, 0x61, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x43, 0x6f, 0x6e, 0x74, + 0x61, 0x63, 0x74, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x61, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x41, 0x0a, 0x06, 0x61, 0x76, + 0x61, 0x74, 0x61, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x73, 0x69, 0x67, + 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x2e, 0x41, + 0x76, 0x61, 0x74, 0x61, 0x72, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x22, 0x0a, + 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x1a, 0xb6, 0x01, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x67, 0x69, + 0x76, 0x65, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x67, + 0x69, 0x76, 0x65, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x66, 0x61, 0x6d, 0x69, + 0x6c, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x66, 0x61, + 0x6d, 0x69, 0x6c, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x72, 0x65, 0x66, + 0x69, 0x78, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, + 0x12, 0x16, 0x0a, 0x06, 0x73, 0x75, 0x66, 0x66, 0x69, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x73, 0x75, 0x66, 0x66, 0x69, 0x78, 0x12, 0x1e, 0x0a, 0x0a, 0x6d, 0x69, 0x64, 0x64, + 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6d, 0x69, + 0x64, 0x64, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x69, 0x73, 0x70, + 0x6c, 0x61, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, + 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x1a, 0xaa, 0x01, 0x0a, 0x05, 0x50, + 0x68, 0x6f, 0x6e, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x41, 0x0a, 0x04, 0x74, 0x79, + 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2d, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, + 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x2e, 0x50, 0x68, 0x6f, + 0x6e, 0x65, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, + 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x61, + 0x62, 0x65, 0x6c, 0x22, 0x32, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x48, + 0x4f, 0x4d, 0x45, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x4d, 0x4f, 0x42, 0x49, 0x4c, 0x45, 0x10, + 0x02, 0x12, 0x08, 0x0a, 0x04, 0x57, 0x4f, 0x52, 0x4b, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x43, + 0x55, 0x53, 0x54, 0x4f, 0x4d, 0x10, 0x04, 0x1a, 0xaa, 0x01, 0x0a, 0x05, 0x45, 0x6d, 0x61, 0x69, + 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x41, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2d, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x2e, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x2e, + 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x61, + 0x62, 0x65, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, + 0x22, 0x32, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x4f, 0x4d, 0x45, + 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x4d, 0x4f, 0x42, 0x49, 0x4c, 0x45, 0x10, 0x02, 0x12, 0x08, + 0x0a, 0x04, 0x57, 0x4f, 0x52, 0x4b, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x43, 0x55, 0x53, 0x54, + 0x4f, 0x4d, 0x10, 0x04, 0x1a, 0xcc, 0x02, 0x0a, 0x0d, 0x50, 0x6f, 0x73, 0x74, 0x61, 0x6c, 0x41, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x49, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x35, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x61, 0x6c, 0x41, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, + 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x72, 0x65, 0x65, + 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x72, 0x65, 0x65, 0x74, 0x12, + 0x14, 0x0a, 0x05, 0x70, 0x6f, 0x62, 0x6f, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x70, 0x6f, 0x62, 0x6f, 0x78, 0x12, 0x22, 0x0a, 0x0c, 0x6e, 0x65, 0x69, 0x67, 0x68, 0x62, 0x6f, + 0x72, 0x68, 0x6f, 0x6f, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x65, 0x69, + 0x67, 0x68, 0x62, 0x6f, 0x72, 0x68, 0x6f, 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x69, 0x74, + 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, + 0x06, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, + 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x74, 0x63, 0x6f, 0x64, + 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x74, 0x63, 0x6f, 0x64, + 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x09, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x22, 0x26, 0x0a, 0x04, 0x54, + 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x4f, 0x4d, 0x45, 0x10, 0x01, 0x12, 0x08, 0x0a, + 0x04, 0x57, 0x4f, 0x52, 0x4b, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x43, 0x55, 0x53, 0x54, 0x4f, + 0x4d, 0x10, 0x03, 0x1a, 0x60, 0x0a, 0x06, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x38, 0x0a, + 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, + 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x41, 0x74, + 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x52, + 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x73, 0x50, 0x72, 0x6f, + 0x66, 0x69, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x50, 0x72, + 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x1a, 0xa5, 0x01, 0x0a, 0x07, 0x53, 0x74, 0x69, 0x63, 0x6b, 0x65, + 0x72, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x63, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x06, 0x70, 0x61, 0x63, 0x6b, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x63, + 0x6b, 0x4b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, 0x63, 0x6b, + 0x4b, 0x65, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x72, 0x49, 0x64, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x73, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x72, 0x49, + 0x64, 0x12, 0x34, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x20, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, + 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x6f, 0x6a, 0x69, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x6f, 0x6a, 0x69, 0x1a, 0x9a, 0x01, + 0x0a, 0x08, 0x52, 0x65, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, + 0x6f, 0x6a, 0x69, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x6f, 0x6a, 0x69, + 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x06, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x12, 0x28, 0x0a, 0x0f, 0x74, 0x61, 0x72, 0x67, + 0x65, 0x74, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x41, 0x63, 0x69, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x41, + 0x63, 0x69, 0x12, 0x30, 0x0a, 0x13, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x53, 0x65, 0x6e, 0x74, + 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x13, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x53, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x4a, 0x04, 0x08, 0x03, 0x10, 0x04, 0x1a, 0x3a, 0x0a, 0x06, 0x44, 0x65, + 0x6c, 0x65, 0x74, 0x65, 0x12, 0x30, 0x0a, 0x13, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x53, 0x65, + 0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x13, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x53, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x1a, 0x27, 0x0a, 0x0f, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, + 0x61, 0x6c, 0x6c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x61, + 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x61, 0x49, 0x64, 0x1a, + 0x52, 0x0a, 0x0c, 0x53, 0x74, 0x6f, 0x72, 0x79, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, + 0x1c, 0x0a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x41, 0x63, 0x69, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x41, 0x63, 0x69, 0x12, 0x24, 0x0a, + 0x0d, 0x73, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x73, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x1a, 0x9a, 0x05, 0x0a, 0x07, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x12, + 0x55, 0x0a, 0x0c, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x2e, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x0c, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x4f, 0x0a, 0x0a, 0x61, 0x63, 0x74, 0x69, 0x76, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x73, 0x69, 0x67, + 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x41, + 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x0a, 0x61, 0x63, 0x74, + 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x92, 0x01, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, + 0x6e, 0x74, 0x12, 0x56, 0x0a, 0x0a, 0x6d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x69, 0x6e, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x34, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x2e, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x41, 0x6d, 0x6f, 0x75, 0x6e, + 0x74, 0x2e, 0x4d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x69, 0x6e, 0x48, 0x00, 0x52, 0x0a, + 0x6d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x69, 0x6e, 0x1a, 0x26, 0x0a, 0x0a, 0x4d, 0x6f, + 0x62, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x69, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x69, 0x63, 0x6f, + 0x4d, 0x6f, 0x62, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x70, 0x69, 0x63, 0x6f, 0x4d, + 0x6f, 0x62, 0x42, 0x08, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x1a, 0xbf, 0x01, 0x0a, + 0x0c, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x5c, 0x0a, + 0x0a, 0x6d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x3a, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x50, 0x61, + 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x2e, 0x4d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x69, 0x6e, 0x48, 0x00, 0x52, + 0x0a, 0x6d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x69, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x6f, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x6f, 0x74, 0x65, 0x1a, + 0x26, 0x0a, 0x0a, 0x4d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x69, 0x6e, 0x12, 0x18, 0x0a, + 0x07, 0x72, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, + 0x72, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x42, 0x0d, 0x0a, 0x0b, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4a, 0x06, 0x08, 0xeb, 0x07, 0x10, 0xec, 0x07, 0x1a, 0x78, + 0x0a, 0x0a, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x46, 0x0a, 0x04, + 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x32, 0x2e, 0x73, 0x69, 0x67, + 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x41, + 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, + 0x74, 0x79, 0x70, 0x65, 0x22, 0x22, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, + 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, 0x54, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x41, 0x43, 0x54, + 0x49, 0x56, 0x41, 0x54, 0x45, 0x44, 0x10, 0x01, 0x42, 0x06, 0x0a, 0x04, 0x49, 0x74, 0x65, 0x6d, + 0x4a, 0x06, 0x08, 0xea, 0x07, 0x10, 0xeb, 0x07, 0x4a, 0x06, 0x08, 0xeb, 0x07, 0x10, 0xec, 0x07, + 0x1a, 0x51, 0x0a, 0x09, 0x47, 0x69, 0x66, 0x74, 0x42, 0x61, 0x64, 0x67, 0x65, 0x12, 0x44, 0x0a, + 0x1d, 0x72, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, + 0x61, 0x6c, 0x50, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x1d, 0x72, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x43, 0x72, 0x65, + 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x50, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x74, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x22, 0x4d, 0x0a, 0x05, 0x46, 0x6c, 0x61, 0x67, 0x73, 0x12, 0x0f, 0x0a, 0x0b, + 0x45, 0x4e, 0x44, 0x5f, 0x53, 0x45, 0x53, 0x53, 0x49, 0x4f, 0x4e, 0x10, 0x01, 0x12, 0x1b, 0x0a, + 0x17, 0x45, 0x58, 0x50, 0x49, 0x52, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x54, 0x49, 0x4d, 0x45, + 0x52, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x02, 0x12, 0x16, 0x0a, 0x12, 0x50, 0x52, + 0x4f, 0x46, 0x49, 0x4c, 0x45, 0x5f, 0x4b, 0x45, 0x59, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, + 0x10, 0x04, 0x22, 0xb0, 0x01, 0x0a, 0x0f, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x56, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x0b, 0x0a, 0x07, 0x49, 0x4e, 0x49, 0x54, 0x49, 0x41, + 0x4c, 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45, 0x5f, 0x54, + 0x49, 0x4d, 0x45, 0x52, 0x53, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x56, 0x49, 0x45, 0x57, 0x5f, + 0x4f, 0x4e, 0x43, 0x45, 0x10, 0x02, 0x12, 0x13, 0x0a, 0x0f, 0x56, 0x49, 0x45, 0x57, 0x5f, 0x4f, + 0x4e, 0x43, 0x45, 0x5f, 0x56, 0x49, 0x44, 0x45, 0x4f, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x52, + 0x45, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x53, 0x10, 0x04, 0x12, 0x1c, 0x0a, 0x18, 0x43, 0x44, + 0x4e, 0x5f, 0x53, 0x45, 0x4c, 0x45, 0x43, 0x54, 0x4f, 0x52, 0x5f, 0x41, 0x54, 0x54, 0x41, 0x43, + 0x48, 0x4d, 0x45, 0x4e, 0x54, 0x53, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x4d, 0x45, 0x4e, 0x54, + 0x49, 0x4f, 0x4e, 0x53, 0x10, 0x06, 0x12, 0x0c, 0x0a, 0x08, 0x50, 0x41, 0x59, 0x4d, 0x45, 0x4e, + 0x54, 0x53, 0x10, 0x07, 0x12, 0x0b, 0x0a, 0x07, 0x43, 0x55, 0x52, 0x52, 0x45, 0x4e, 0x54, 0x10, + 0x07, 0x1a, 0x02, 0x10, 0x01, 0x4a, 0x04, 0x08, 0x03, 0x10, 0x04, 0x22, 0x27, 0x0a, 0x0b, 0x4e, + 0x75, 0x6c, 0x6c, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, + 0x64, 0x64, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, 0x64, + 0x64, 0x69, 0x6e, 0x67, 0x22, 0x92, 0x01, 0x0a, 0x0e, 0x52, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, + 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x36, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x22, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x52, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, + 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x03, + 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0x2a, 0x0a, + 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0c, 0x0a, 0x08, 0x44, 0x45, 0x4c, 0x49, 0x56, 0x45, 0x52, + 0x59, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x52, 0x45, 0x41, 0x44, 0x10, 0x01, 0x12, 0x0a, 0x0a, + 0x06, 0x56, 0x49, 0x45, 0x57, 0x45, 0x44, 0x10, 0x02, 0x22, 0xa8, 0x01, 0x0a, 0x0d, 0x54, 0x79, + 0x70, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, + 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x3b, 0x0a, 0x06, 0x61, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x73, 0x69, 0x67, 0x6e, + 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x54, 0x79, 0x70, 0x69, 0x6e, 0x67, + 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x06, + 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, + 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, + 0x22, 0x22, 0x0a, 0x06, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x54, + 0x41, 0x52, 0x54, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x54, 0x4f, 0x50, 0x50, + 0x45, 0x44, 0x10, 0x01, 0x22, 0xe6, 0x02, 0x0a, 0x0c, 0x53, 0x74, 0x6f, 0x72, 0x79, 0x4d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, + 0x4b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x66, 0x69, + 0x6c, 0x65, 0x4b, 0x65, 0x79, 0x12, 0x33, 0x0a, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, + 0x74, 0x56, 0x32, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x4a, 0x0a, 0x0e, 0x66, 0x69, + 0x6c, 0x65, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x2e, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x50, 0x6f, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x48, 0x00, 0x52, 0x0e, 0x66, 0x69, 0x6c, 0x65, 0x41, 0x74, 0x74, 0x61, + 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x47, 0x0a, 0x0e, 0x74, 0x65, 0x78, 0x74, 0x41, 0x74, + 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, + 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x54, + 0x65, 0x78, 0x74, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, + 0x0e, 0x74, 0x65, 0x78, 0x74, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x12, + 0x24, 0x0a, 0x0d, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x73, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x65, 0x73, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x73, 0x52, 0x65, + 0x70, 0x6c, 0x69, 0x65, 0x73, 0x12, 0x38, 0x0a, 0x0a, 0x62, 0x6f, 0x64, 0x79, 0x52, 0x61, 0x6e, + 0x67, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x73, 0x69, 0x67, 0x6e, + 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x42, 0x6f, 0x64, 0x79, 0x52, 0x61, + 0x6e, 0x67, 0x65, 0x52, 0x0a, 0x62, 0x6f, 0x64, 0x79, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x42, + 0x0c, 0x0a, 0x0a, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x9f, 0x01, + 0x0a, 0x07, 0x50, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x74, + 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, + 0x65, 0x12, 0x36, 0x0a, 0x05, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x20, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x2e, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x50, 0x6f, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x52, 0x05, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, + 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, + 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x64, + 0x61, 0x74, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x64, 0x61, 0x74, 0x65, 0x22, + 0xd1, 0x04, 0x0a, 0x0e, 0x54, 0x65, 0x78, 0x74, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, + 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x12, 0x41, 0x0a, 0x09, 0x74, 0x65, 0x78, 0x74, 0x53, 0x74, + 0x79, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x73, 0x69, 0x67, 0x6e, + 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x54, 0x65, 0x78, 0x74, 0x41, 0x74, + 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x53, 0x74, 0x79, 0x6c, 0x65, 0x52, 0x09, + 0x74, 0x65, 0x78, 0x74, 0x53, 0x74, 0x79, 0x6c, 0x65, 0x12, 0x30, 0x0a, 0x13, 0x74, 0x65, 0x78, + 0x74, 0x46, 0x6f, 0x72, 0x65, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x43, 0x6f, 0x6c, 0x6f, 0x72, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x13, 0x74, 0x65, 0x78, 0x74, 0x46, 0x6f, 0x72, 0x65, + 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x12, 0x30, 0x0a, 0x13, 0x74, + 0x65, 0x78, 0x74, 0x42, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x43, 0x6f, 0x6c, + 0x6f, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x13, 0x74, 0x65, 0x78, 0x74, 0x42, 0x61, + 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x12, 0x30, 0x0a, + 0x07, 0x70, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, + 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x50, + 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x52, 0x07, 0x70, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x12, + 0x44, 0x0a, 0x08, 0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x26, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x2e, 0x54, 0x65, 0x78, 0x74, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, + 0x2e, 0x47, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x08, 0x67, 0x72, 0x61, + 0x64, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x05, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x0d, 0x48, 0x00, 0x52, 0x05, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x1a, 0x92, 0x01, + 0x0a, 0x08, 0x47, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x74, + 0x61, 0x72, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, + 0x73, 0x74, 0x61, 0x72, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, + 0x64, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x65, 0x6e, + 0x64, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x6e, 0x67, 0x6c, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x61, 0x6e, 0x67, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x06, + 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0d, 0x52, 0x06, 0x63, 0x6f, + 0x6c, 0x6f, 0x72, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x02, 0x52, 0x09, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x22, 0x51, 0x0a, 0x05, 0x53, 0x74, 0x79, 0x6c, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x44, + 0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x52, 0x45, 0x47, 0x55, + 0x4c, 0x41, 0x52, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x42, 0x4f, 0x4c, 0x44, 0x10, 0x02, 0x12, + 0x09, 0x0a, 0x05, 0x53, 0x45, 0x52, 0x49, 0x46, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x43, + 0x52, 0x49, 0x50, 0x54, 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x4f, 0x4e, 0x44, 0x45, 0x4e, + 0x53, 0x45, 0x44, 0x10, 0x05, 0x42, 0x0c, 0x0a, 0x0a, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, + 0x75, 0x6e, 0x64, 0x22, 0xe5, 0x01, 0x0a, 0x08, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x64, + 0x12, 0x26, 0x0a, 0x0e, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, + 0x63, 0x69, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x63, 0x69, 0x12, 0x20, 0x0a, 0x0b, 0x69, 0x64, 0x65, 0x6e, + 0x74, 0x69, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x69, + 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x12, 0x33, 0x0a, 0x05, 0x73, 0x74, + 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1d, 0x2e, 0x73, 0x69, 0x67, 0x6e, + 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, + 0x65, 0x64, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, + 0x20, 0x0a, 0x0b, 0x6e, 0x75, 0x6c, 0x6c, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x6e, 0x75, 0x6c, 0x6c, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x22, 0x32, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x44, 0x45, + 0x46, 0x41, 0x55, 0x4c, 0x54, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x56, 0x45, 0x52, 0x49, 0x46, + 0x49, 0x45, 0x44, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x55, 0x4e, 0x56, 0x45, 0x52, 0x49, 0x46, + 0x49, 0x45, 0x44, 0x10, 0x02, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x22, 0xb3, 0x29, 0x0a, 0x0b, + 0x53, 0x79, 0x6e, 0x63, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x33, 0x0a, 0x04, 0x73, + 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x73, 0x69, 0x67, 0x6e, + 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x4d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x53, 0x65, 0x6e, 0x74, 0x52, 0x04, 0x73, 0x65, 0x6e, 0x74, + 0x12, 0x3f, 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x43, + 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x73, 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, + 0x73, 0x12, 0x3c, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x33, 0x0a, 0x04, 0x72, 0x65, 0x61, 0x64, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, + 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x79, + 0x6e, 0x63, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x04, + 0x72, 0x65, 0x61, 0x64, 0x12, 0x3c, 0x0a, 0x07, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x52, 0x07, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x65, 0x64, 0x12, 0x33, 0x0a, 0x08, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x64, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x2e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x64, 0x52, 0x08, 0x76, + 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x64, 0x12, 0x4e, 0x0a, 0x0d, 0x63, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, + 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, + 0x79, 0x6e, 0x63, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0d, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x64, 0x64, 0x69, + 0x6e, 0x67, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, + 0x67, 0x12, 0x63, 0x0a, 0x14, 0x73, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x72, 0x50, 0x61, 0x63, 0x6b, + 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x2f, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, + 0x53, 0x79, 0x6e, 0x63, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x53, 0x74, 0x69, 0x63, + 0x6b, 0x65, 0x72, 0x50, 0x61, 0x63, 0x6b, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x14, 0x73, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x72, 0x50, 0x61, 0x63, 0x6b, 0x4f, 0x70, 0x65, + 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x4b, 0x0a, 0x0c, 0x76, 0x69, 0x65, 0x77, 0x4f, 0x6e, + 0x63, 0x65, 0x4f, 0x70, 0x65, 0x6e, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, + 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x79, 0x6e, + 0x63, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x56, 0x69, 0x65, 0x77, 0x4f, 0x6e, 0x63, + 0x65, 0x4f, 0x70, 0x65, 0x6e, 0x52, 0x0c, 0x76, 0x69, 0x65, 0x77, 0x4f, 0x6e, 0x63, 0x65, 0x4f, + 0x70, 0x65, 0x6e, 0x12, 0x48, 0x0a, 0x0b, 0x66, 0x65, 0x74, 0x63, 0x68, 0x4c, 0x61, 0x74, 0x65, + 0x73, 0x74, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, + 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x2e, 0x46, 0x65, 0x74, 0x63, 0x68, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, + 0x52, 0x0b, 0x66, 0x65, 0x74, 0x63, 0x68, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x12, 0x33, 0x0a, + 0x04, 0x6b, 0x65, 0x79, 0x73, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x73, 0x69, + 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x79, 0x6e, 0x63, + 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4b, 0x65, 0x79, 0x73, 0x52, 0x04, 0x6b, 0x65, + 0x79, 0x73, 0x12, 0x69, 0x0a, 0x16, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x0e, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x16, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x54, 0x0a, + 0x0f, 0x6f, 0x75, 0x74, 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, + 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x2e, 0x4f, 0x75, 0x74, 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x50, 0x61, 0x79, 0x6d, 0x65, + 0x6e, 0x74, 0x52, 0x0f, 0x6f, 0x75, 0x74, 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x50, 0x61, 0x79, 0x6d, + 0x65, 0x6e, 0x74, 0x12, 0x39, 0x0a, 0x06, 0x76, 0x69, 0x65, 0x77, 0x65, 0x64, 0x18, 0x10, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, + 0x56, 0x69, 0x65, 0x77, 0x65, 0x64, 0x52, 0x06, 0x76, 0x69, 0x65, 0x77, 0x65, 0x64, 0x12, 0x54, + 0x0a, 0x0f, 0x70, 0x6e, 0x69, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, + 0x72, 0x18, 0x12, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x2e, 0x50, 0x6e, 0x69, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x4e, 0x75, 0x6d, + 0x62, 0x65, 0x72, 0x52, 0x0f, 0x70, 0x6e, 0x69, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x4e, 0x75, + 0x6d, 0x62, 0x65, 0x72, 0x12, 0x42, 0x0a, 0x09, 0x63, 0x61, 0x6c, 0x6c, 0x45, 0x76, 0x65, 0x6e, + 0x74, 0x18, 0x13, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x09, 0x63, + 0x61, 0x6c, 0x6c, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x51, 0x0a, 0x0e, 0x63, 0x61, 0x6c, 0x6c, + 0x4c, 0x69, 0x6e, 0x6b, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x18, 0x14, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x29, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x43, 0x61, 0x6c, + 0x6c, 0x4c, 0x69, 0x6e, 0x6b, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x0e, 0x63, 0x61, 0x6c, + 0x6c, 0x4c, 0x69, 0x6e, 0x6b, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x4b, 0x0a, 0x0c, 0x63, + 0x61, 0x6c, 0x6c, 0x4c, 0x6f, 0x67, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x15, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x43, 0x61, + 0x6c, 0x6c, 0x4c, 0x6f, 0x67, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x0c, 0x63, 0x61, 0x6c, 0x6c, + 0x4c, 0x6f, 0x67, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x1a, 0xab, 0x07, 0x0a, 0x04, 0x53, 0x65, 0x6e, + 0x74, 0x12, 0x28, 0x0a, 0x0f, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x45, 0x31, 0x36, 0x34, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x64, 0x65, 0x73, 0x74, + 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x31, 0x36, 0x34, 0x12, 0x32, 0x0a, 0x14, 0x64, + 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x49, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, 0x64, 0x65, 0x73, 0x74, 0x69, + 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, + 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x34, 0x0a, + 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, + 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x44, + 0x61, 0x74, 0x61, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x12, 0x3a, 0x0a, 0x18, 0x65, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x18, 0x65, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, + 0x6a, 0x0a, 0x12, 0x75, 0x6e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x64, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3a, 0x2e, 0x73, 0x69, + 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x79, 0x6e, 0x63, + 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x53, 0x65, 0x6e, 0x74, 0x2e, 0x55, 0x6e, 0x69, + 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x64, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, + 0x79, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x12, 0x75, 0x6e, 0x69, 0x64, 0x65, 0x6e, 0x74, + 0x69, 0x66, 0x69, 0x65, 0x64, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x33, 0x0a, 0x11, 0x69, + 0x73, 0x52, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x52, 0x11, 0x69, + 0x73, 0x52, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x12, 0x3f, 0x0a, 0x0c, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x79, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x52, 0x0c, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x12, 0x6d, 0x0a, 0x16, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x52, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x35, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x53, 0x65, + 0x6e, 0x74, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x79, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, + 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x52, 0x16, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x73, + 0x12, 0x3c, 0x0a, 0x0b, 0x65, 0x64, 0x69, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, + 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x45, 0x64, 0x69, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x52, 0x0b, 0x65, 0x64, 0x69, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x7a, + 0x0a, 0x1a, 0x55, 0x6e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x64, 0x44, 0x65, + 0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x32, 0x0a, 0x14, + 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, 0x64, 0x65, 0x73, 0x74, + 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, + 0x12, 0x22, 0x0a, 0x0c, 0x75, 0x6e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x64, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x75, 0x6e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, + 0x66, 0x69, 0x65, 0x64, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x1a, 0xa9, 0x01, 0x0a, 0x15, 0x53, + 0x74, 0x6f, 0x72, 0x79, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x63, 0x69, 0x70, + 0x69, 0x65, 0x6e, 0x74, 0x12, 0x32, 0x0a, 0x14, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x14, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x30, 0x0a, 0x13, 0x64, 0x69, 0x73, 0x74, + 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x64, 0x73, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x13, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, + 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x64, 0x73, 0x12, 0x2a, 0x0a, 0x10, 0x69, 0x73, + 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x54, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x69, 0x73, 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x54, + 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x1a, 0x63, 0x0a, 0x08, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x63, + 0x74, 0x73, 0x12, 0x34, 0x0a, 0x04, 0x62, 0x6c, 0x6f, 0x62, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x20, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x2e, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x50, 0x6f, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x52, 0x04, 0x62, 0x6c, 0x6f, 0x62, 0x12, 0x21, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x70, + 0x6c, 0x65, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, + 0x65, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x1a, 0x53, 0x0a, 0x07, 0x42, + 0x6c, 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x73, + 0x12, 0x12, 0x0a, 0x04, 0x61, 0x63, 0x69, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, + 0x61, 0x63, 0x69, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x73, + 0x18, 0x02, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x08, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x73, + 0x1a, 0xa5, 0x01, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x3b, 0x0a, 0x04, + 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x73, 0x69, 0x67, + 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x54, + 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x5d, 0x0a, 0x04, 0x54, 0x79, 0x70, + 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0c, + 0x0a, 0x08, 0x43, 0x4f, 0x4e, 0x54, 0x41, 0x43, 0x54, 0x53, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, + 0x42, 0x4c, 0x4f, 0x43, 0x4b, 0x45, 0x44, 0x10, 0x03, 0x12, 0x11, 0x0a, 0x0d, 0x43, 0x4f, 0x4e, + 0x46, 0x49, 0x47, 0x55, 0x52, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0x04, 0x12, 0x08, 0x0a, 0x04, + 0x4b, 0x45, 0x59, 0x53, 0x10, 0x05, 0x12, 0x10, 0x0a, 0x0c, 0x50, 0x4e, 0x49, 0x5f, 0x49, 0x44, + 0x45, 0x4e, 0x54, 0x49, 0x54, 0x59, 0x10, 0x06, 0x1a, 0x48, 0x0a, 0x04, 0x52, 0x65, 0x61, 0x64, + 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x41, 0x63, 0x69, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x41, 0x63, 0x69, 0x12, 0x1c, + 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x4a, 0x04, 0x08, 0x01, + 0x10, 0x02, 0x1a, 0x4a, 0x0a, 0x06, 0x56, 0x69, 0x65, 0x77, 0x65, 0x64, 0x12, 0x1c, 0x0a, 0x09, + 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x41, 0x63, 0x69, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x09, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x41, 0x63, 0x69, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x1a, 0x83, + 0x02, 0x0a, 0x0d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x22, 0x0a, 0x0c, 0x72, 0x65, 0x61, 0x64, 0x52, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x73, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x72, 0x65, 0x61, 0x64, 0x52, 0x65, 0x63, 0x65, + 0x69, 0x70, 0x74, 0x73, 0x12, 0x46, 0x0a, 0x1e, 0x75, 0x6e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, + 0x66, 0x69, 0x65, 0x64, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, 0x49, 0x6e, 0x64, 0x69, + 0x63, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1e, 0x75, 0x6e, + 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x64, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, + 0x72, 0x79, 0x49, 0x6e, 0x64, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x2a, 0x0a, 0x10, + 0x74, 0x79, 0x70, 0x69, 0x6e, 0x67, 0x49, 0x6e, 0x64, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x73, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x74, 0x79, 0x70, 0x69, 0x6e, 0x67, 0x49, 0x6e, + 0x64, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x30, 0x0a, 0x13, 0x70, 0x72, 0x6f, 0x76, + 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x69, 0x6e, 0x67, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x13, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, + 0x69, 0x6e, 0x67, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x22, 0x0a, 0x0c, 0x6c, 0x69, + 0x6e, 0x6b, 0x50, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x0c, 0x6c, 0x69, 0x6e, 0x6b, 0x50, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x73, 0x4a, 0x04, + 0x08, 0x04, 0x10, 0x05, 0x1a, 0xb3, 0x01, 0x0a, 0x14, 0x53, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x72, + 0x50, 0x61, 0x63, 0x6b, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, + 0x06, 0x70, 0x61, 0x63, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x70, + 0x61, 0x63, 0x6b, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x63, 0x6b, 0x4b, 0x65, 0x79, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, 0x63, 0x6b, 0x4b, 0x65, 0x79, 0x12, + 0x48, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x34, 0x2e, + 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x79, + 0x6e, 0x63, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x53, 0x74, 0x69, 0x63, 0x6b, 0x65, + 0x72, 0x50, 0x61, 0x63, 0x6b, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x54, + 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x1f, 0x0a, 0x04, 0x54, 0x79, 0x70, + 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x49, 0x4e, 0x53, 0x54, 0x41, 0x4c, 0x4c, 0x10, 0x00, 0x12, 0x0a, + 0x0a, 0x06, 0x52, 0x45, 0x4d, 0x4f, 0x56, 0x45, 0x10, 0x01, 0x1a, 0x50, 0x0a, 0x0c, 0x56, 0x69, + 0x65, 0x77, 0x4f, 0x6e, 0x63, 0x65, 0x4f, 0x70, 0x65, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x65, + 0x6e, 0x64, 0x65, 0x72, 0x41, 0x63, 0x69, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, + 0x65, 0x6e, 0x64, 0x65, 0x72, 0x41, 0x63, 0x69, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x1a, 0xa5, 0x01, 0x0a, + 0x0b, 0x46, 0x65, 0x74, 0x63, 0x68, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x12, 0x3f, 0x0a, 0x04, + 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2b, 0x2e, 0x73, 0x69, 0x67, + 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x46, 0x65, 0x74, 0x63, 0x68, 0x4c, 0x61, 0x74, 0x65, + 0x73, 0x74, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x55, 0x0a, + 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, + 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x4c, 0x4f, 0x43, 0x41, 0x4c, 0x5f, 0x50, 0x52, 0x4f, 0x46, + 0x49, 0x4c, 0x45, 0x10, 0x01, 0x12, 0x14, 0x0a, 0x10, 0x53, 0x54, 0x4f, 0x52, 0x41, 0x47, 0x45, + 0x5f, 0x4d, 0x41, 0x4e, 0x49, 0x46, 0x45, 0x53, 0x54, 0x10, 0x02, 0x12, 0x17, 0x0a, 0x13, 0x53, + 0x55, 0x42, 0x53, 0x43, 0x52, 0x49, 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x53, 0x54, 0x41, 0x54, + 0x55, 0x53, 0x10, 0x03, 0x1a, 0x46, 0x0a, 0x04, 0x4b, 0x65, 0x79, 0x73, 0x12, 0x26, 0x0a, 0x0e, + 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x1a, 0xf0, 0x01, 0x0a, + 0x16, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x68, 0x72, 0x65, 0x61, + 0x64, 0x41, 0x63, 0x69, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x68, 0x72, 0x65, + 0x61, 0x64, 0x41, 0x63, 0x69, 0x12, 0x18, 0x0a, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x12, + 0x4a, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x36, 0x2e, + 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x79, + 0x6e, 0x63, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x4c, 0x0a, 0x04, 0x54, + 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, + 0x12, 0x0a, 0x0a, 0x06, 0x41, 0x43, 0x43, 0x45, 0x50, 0x54, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, + 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x42, 0x4c, 0x4f, 0x43, + 0x4b, 0x10, 0x03, 0x12, 0x14, 0x0a, 0x10, 0x42, 0x4c, 0x4f, 0x43, 0x4b, 0x5f, 0x41, 0x4e, 0x44, + 0x5f, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x04, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x1a, + 0x8e, 0x04, 0x0a, 0x0f, 0x4f, 0x75, 0x74, 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x50, 0x61, 0x79, 0x6d, + 0x65, 0x6e, 0x74, 0x12, 0x2e, 0x0a, 0x12, 0x72, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x12, 0x72, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x6f, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x6e, 0x6f, 0x74, 0x65, 0x12, 0x57, 0x0a, 0x0a, 0x6d, 0x6f, 0x62, 0x69, 0x6c, + 0x65, 0x43, 0x6f, 0x69, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x73, 0x69, + 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x79, 0x6e, 0x63, + 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4f, 0x75, 0x74, 0x67, 0x6f, 0x69, 0x6e, 0x67, + 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x4d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x43, 0x6f, + 0x69, 0x6e, 0x48, 0x00, 0x52, 0x0a, 0x6d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x69, 0x6e, + 0x1a, 0xcc, 0x02, 0x0a, 0x0a, 0x4d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x69, 0x6e, 0x12, + 0x2a, 0x0a, 0x10, 0x72, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x41, 0x64, 0x64, 0x72, + 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x10, 0x72, 0x65, 0x63, 0x69, 0x70, + 0x69, 0x65, 0x6e, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x61, + 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x50, 0x69, 0x63, 0x6f, 0x4d, 0x6f, 0x62, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x0d, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x50, 0x69, 0x63, 0x6f, 0x4d, 0x6f, + 0x62, 0x12, 0x1e, 0x0a, 0x0a, 0x66, 0x65, 0x65, 0x50, 0x69, 0x63, 0x6f, 0x4d, 0x6f, 0x62, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x66, 0x65, 0x65, 0x50, 0x69, 0x63, 0x6f, 0x4d, 0x6f, + 0x62, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x07, 0x72, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x12, 0x32, 0x0a, 0x14, 0x6c, + 0x65, 0x64, 0x67, 0x65, 0x72, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x14, 0x6c, 0x65, 0x64, 0x67, 0x65, + 0x72, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, + 0x2a, 0x0a, 0x10, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x72, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x6e, + 0x64, 0x65, 0x78, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x10, 0x6c, 0x65, 0x64, 0x67, 0x65, + 0x72, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x26, 0x0a, 0x0e, 0x73, + 0x70, 0x65, 0x6e, 0x74, 0x4b, 0x65, 0x79, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x73, 0x18, 0x07, 0x20, + 0x03, 0x28, 0x0c, 0x52, 0x0e, 0x73, 0x70, 0x65, 0x6e, 0x74, 0x4b, 0x65, 0x79, 0x49, 0x6d, 0x61, + 0x67, 0x65, 0x73, 0x12, 0x2a, 0x0a, 0x10, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x50, 0x75, 0x62, + 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x10, 0x6f, + 0x75, 0x74, 0x70, 0x75, 0x74, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x73, 0x42, + 0x0f, 0x0a, 0x0d, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, + 0x1a, 0xd7, 0x01, 0x0a, 0x0f, 0x50, 0x6e, 0x69, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x4e, 0x75, + 0x6d, 0x62, 0x65, 0x72, 0x12, 0x28, 0x0a, 0x0f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, + 0x4b, 0x65, 0x79, 0x50, 0x61, 0x69, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0f, 0x69, + 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x50, 0x61, 0x69, 0x72, 0x12, 0x22, + 0x0a, 0x0c, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x50, 0x72, 0x65, 0x4b, 0x65, 0x79, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x50, 0x72, 0x65, 0x4b, + 0x65, 0x79, 0x12, 0x34, 0x0a, 0x15, 0x6c, 0x61, 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x72, 0x74, + 0x4b, 0x79, 0x62, 0x65, 0x72, 0x50, 0x72, 0x65, 0x4b, 0x65, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x15, 0x6c, 0x61, 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x72, 0x74, 0x4b, 0x79, 0x62, + 0x65, 0x72, 0x50, 0x72, 0x65, 0x4b, 0x65, 0x79, 0x12, 0x26, 0x0a, 0x0e, 0x72, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, + 0x52, 0x0e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, + 0x12, 0x18, 0x0a, 0x07, 0x6e, 0x65, 0x77, 0x45, 0x31, 0x36, 0x34, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x6e, 0x65, 0x77, 0x45, 0x31, 0x36, 0x34, 0x1a, 0x94, 0x04, 0x0a, 0x09, 0x43, + 0x61, 0x6c, 0x6c, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x26, 0x0a, 0x0e, 0x63, 0x6f, 0x6e, 0x76, + 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x0e, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, + 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, + 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x3d, + 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x29, 0x2e, 0x73, + 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x79, 0x6e, + 0x63, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x45, 0x76, 0x65, + 0x6e, 0x74, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x4c, 0x0a, + 0x09, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x2e, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x43, 0x61, 0x6c, + 0x6c, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x09, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x40, 0x0a, 0x05, 0x65, + 0x76, 0x65, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2a, 0x2e, 0x73, 0x69, 0x67, + 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x45, 0x76, 0x65, 0x6e, 0x74, + 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x22, 0x59, 0x0a, + 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, 0x0c, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, + 0x5f, 0x54, 0x59, 0x50, 0x45, 0x10, 0x00, 0x12, 0x0e, 0x0a, 0x0a, 0x41, 0x55, 0x44, 0x49, 0x4f, + 0x5f, 0x43, 0x41, 0x4c, 0x4c, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x56, 0x49, 0x44, 0x45, 0x4f, + 0x5f, 0x43, 0x41, 0x4c, 0x4c, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x47, 0x52, 0x4f, 0x55, 0x50, + 0x5f, 0x43, 0x41, 0x4c, 0x4c, 0x10, 0x03, 0x12, 0x0f, 0x0a, 0x0b, 0x41, 0x44, 0x5f, 0x48, 0x4f, + 0x43, 0x5f, 0x43, 0x41, 0x4c, 0x4c, 0x10, 0x04, 0x22, 0x3e, 0x0a, 0x09, 0x44, 0x69, 0x72, 0x65, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x15, 0x0a, 0x11, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, + 0x5f, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, + 0x49, 0x4e, 0x43, 0x4f, 0x4d, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x4f, 0x55, + 0x54, 0x47, 0x4f, 0x49, 0x4e, 0x47, 0x10, 0x02, 0x22, 0x47, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, + 0x74, 0x12, 0x12, 0x0a, 0x0e, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x5f, 0x41, 0x43, 0x54, + 0x49, 0x4f, 0x4e, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x41, 0x43, 0x43, 0x45, 0x50, 0x54, 0x45, + 0x44, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x4e, 0x4f, 0x54, 0x5f, 0x41, 0x43, 0x43, 0x45, 0x50, + 0x54, 0x45, 0x44, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, + 0x03, 0x1a, 0x4e, 0x0a, 0x0e, 0x43, 0x61, 0x6c, 0x6c, 0x4c, 0x69, 0x6e, 0x6b, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x6f, 0x6f, 0x74, 0x4b, 0x65, 0x79, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x72, 0x6f, 0x6f, 0x74, 0x4b, 0x65, 0x79, 0x12, 0x22, 0x0a, + 0x0c, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x50, 0x61, 0x73, 0x73, 0x4b, 0x65, 0x79, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x50, 0x61, 0x73, 0x73, 0x4b, 0x65, + 0x79, 0x1a, 0x81, 0x01, 0x0a, 0x0c, 0x43, 0x61, 0x6c, 0x6c, 0x4c, 0x6f, 0x67, 0x45, 0x76, 0x65, + 0x6e, 0x74, 0x12, 0x40, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x2c, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x43, 0x61, 0x6c, + 0x6c, 0x4c, 0x6f, 0x67, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, + 0x74, 0x79, 0x70, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x22, 0x11, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x43, 0x4c, + 0x45, 0x41, 0x52, 0x10, 0x00, 0x4a, 0x04, 0x08, 0x03, 0x10, 0x04, 0x4a, 0x04, 0x08, 0x11, 0x10, + 0x12, 0x22, 0xdd, 0x04, 0x0a, 0x11, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, + 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x05, 0x63, 0x64, 0x6e, 0x49, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x06, 0x48, 0x00, 0x52, 0x05, 0x63, 0x64, 0x6e, 0x49, 0x64, 0x12, + 0x18, 0x0a, 0x06, 0x63, 0x64, 0x6e, 0x4b, 0x65, 0x79, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x48, + 0x00, 0x52, 0x06, 0x63, 0x64, 0x6e, 0x4b, 0x65, 0x79, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, + 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, + 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6b, + 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x12, 0x0a, + 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x73, 0x69, 0x7a, + 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x68, 0x75, 0x6d, 0x62, 0x6e, 0x61, 0x69, 0x6c, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x74, 0x68, 0x75, 0x6d, 0x62, 0x6e, 0x61, 0x69, 0x6c, 0x12, + 0x16, 0x0a, 0x06, 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x06, 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, 0x12, 0x26, 0x0a, 0x0e, 0x69, 0x6e, 0x63, 0x72, 0x65, + 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x4d, 0x61, 0x63, 0x18, 0x12, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x0e, 0x69, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x4d, 0x61, 0x63, 0x12, + 0x38, 0x0a, 0x17, 0x69, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x4d, 0x61, + 0x63, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x11, 0x20, 0x01, 0x28, 0x0d, + 0x52, 0x17, 0x69, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, 0x4d, 0x61, 0x63, + 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6c, + 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, + 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x18, 0x08, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x77, + 0x69, 0x64, 0x74, 0x68, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x77, 0x69, 0x64, 0x74, + 0x68, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, + 0x0d, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x61, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x61, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x62, 0x6c, 0x75, 0x72, 0x48, 0x61, 0x73, 0x68, 0x18, + 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x62, 0x6c, 0x75, 0x72, 0x48, 0x61, 0x73, 0x68, 0x12, + 0x28, 0x0a, 0x0f, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, + 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x64, 0x6e, + 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x63, 0x64, + 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x39, 0x0a, 0x05, 0x46, 0x6c, 0x61, 0x67, 0x73, + 0x12, 0x11, 0x0a, 0x0d, 0x56, 0x4f, 0x49, 0x43, 0x45, 0x5f, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, + 0x45, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x42, 0x4f, 0x52, 0x44, 0x45, 0x52, 0x4c, 0x45, 0x53, + 0x53, 0x10, 0x02, 0x12, 0x07, 0x0a, 0x03, 0x47, 0x49, 0x46, 0x10, 0x04, 0x22, 0x04, 0x08, 0x03, + 0x10, 0x03, 0x42, 0x17, 0x0a, 0x15, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, + 0x5f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x4a, 0x04, 0x08, 0x10, 0x10, + 0x11, 0x22, 0xf0, 0x02, 0x0a, 0x0c, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x6f, 0x6e, 0x74, 0x65, + 0x78, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, + 0x69, 0x64, 0x12, 0x34, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x20, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2e, 0x54, 0x79, + 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, + 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x45, 0x31, 0x36, 0x34, 0x18, 0x04, 0x20, 0x03, 0x28, + 0x09, 0x52, 0x0b, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x45, 0x31, 0x36, 0x34, 0x12, 0x3c, + 0x0a, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x22, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, + 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2e, 0x4d, 0x65, 0x6d, + 0x62, 0x65, 0x72, 0x52, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x12, 0x38, 0x0a, 0x06, + 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x73, + 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x41, 0x74, 0x74, + 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x52, 0x06, + 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x1a, 0x22, 0x0a, 0x06, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, + 0x12, 0x12, 0x0a, 0x04, 0x65, 0x31, 0x36, 0x34, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x65, 0x31, 0x36, 0x34, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x22, 0x48, 0x0a, 0x04, 0x54, 0x79, + 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, + 0x0a, 0x0a, 0x06, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x44, + 0x45, 0x4c, 0x49, 0x56, 0x45, 0x52, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x51, 0x55, 0x49, 0x54, + 0x10, 0x03, 0x12, 0x10, 0x0a, 0x0c, 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, 0x54, 0x5f, 0x49, 0x4e, + 0x46, 0x4f, 0x10, 0x04, 0x22, 0x6c, 0x0a, 0x0e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x6f, 0x6e, + 0x74, 0x65, 0x78, 0x74, 0x56, 0x32, 0x12, 0x1c, 0x0a, 0x09, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, + 0x4b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x6d, 0x61, 0x73, 0x74, 0x65, + 0x72, 0x4b, 0x65, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, + 0x12, 0x20, 0x0a, 0x0b, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x68, 0x61, 0x6e, + 0x67, 0x65, 0x22, 0xb9, 0x03, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x44, 0x65, + 0x74, 0x61, 0x69, 0x6c, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x10, 0x0a, + 0x03, 0x61, 0x63, 0x69, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x61, 0x63, 0x69, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x3c, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, + 0x6c, 0x73, 0x2e, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, + 0x72, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x12, 0x33, 0x0a, 0x08, 0x76, 0x65, 0x72, 0x69, 0x66, + 0x69, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x73, 0x69, 0x67, 0x6e, + 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, + 0x65, 0x64, 0x52, 0x08, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x64, 0x12, 0x1e, 0x0a, 0x0a, + 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x4b, 0x65, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x4b, 0x65, 0x79, 0x12, 0x18, 0x0a, 0x07, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, + 0x54, 0x69, 0x6d, 0x65, 0x72, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0b, 0x65, 0x78, 0x70, + 0x69, 0x72, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x72, 0x12, 0x24, 0x0a, 0x0d, 0x69, 0x6e, 0x62, 0x6f, + 0x78, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x0d, 0x69, 0x6e, 0x62, 0x6f, 0x78, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, + 0x0a, 0x08, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x08, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x64, 0x1a, 0x42, 0x0a, 0x06, 0x41, 0x76, + 0x61, 0x74, 0x61, 0x72, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, + 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, + 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x22, 0xe8, + 0x03, 0x0a, 0x0c, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x12, + 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, 0x69, 0x64, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x45, 0x31, + 0x36, 0x34, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, + 0x73, 0x45, 0x31, 0x36, 0x34, 0x12, 0x3c, 0x0a, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, + 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x44, 0x65, 0x74, 0x61, + 0x69, 0x6c, 0x73, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x07, 0x6d, 0x65, 0x6d, 0x62, + 0x65, 0x72, 0x73, 0x12, 0x3a, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, + 0x2e, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, + 0x1c, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x3a, + 0x04, 0x74, 0x72, 0x75, 0x65, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x12, 0x20, 0x0a, + 0x0b, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x0d, 0x52, 0x0b, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x72, 0x12, + 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x65, 0x64, + 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x12, + 0x24, 0x0a, 0x0d, 0x69, 0x6e, 0x62, 0x6f, 0x78, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0d, 0x69, 0x6e, 0x62, 0x6f, 0x78, 0x50, 0x6f, 0x73, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, + 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, + 0x64, 0x1a, 0x42, 0x0a, 0x06, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x20, 0x0a, 0x0b, 0x63, + 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, + 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x6c, + 0x65, 0x6e, 0x67, 0x74, 0x68, 0x1a, 0x22, 0x0a, 0x06, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x12, + 0x12, 0x0a, 0x04, 0x65, 0x31, 0x36, 0x34, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x65, + 0x31, 0x36, 0x34, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x22, 0xc9, 0x01, 0x0a, 0x0e, 0x50, 0x61, + 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x5f, 0x0a, 0x11, + 0x6d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x69, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x41, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x2e, 0x4d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x69, + 0x6e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x48, 0x00, 0x52, 0x11, 0x6d, 0x6f, 0x62, 0x69, + 0x6c, 0x65, 0x43, 0x6f, 0x69, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x1a, 0x4b, 0x0a, + 0x11, 0x4d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x69, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1c, 0x0a, 0x09, + 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x42, 0x09, 0x0a, 0x07, 0x41, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x72, 0x0a, 0x16, 0x44, 0x65, 0x63, 0x72, 0x79, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, + 0x1e, 0x0a, 0x0a, 0x72, 0x61, 0x74, 0x63, 0x68, 0x65, 0x74, 0x4b, 0x65, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x72, 0x61, 0x74, 0x63, 0x68, 0x65, 0x74, 0x4b, 0x65, 0x79, 0x12, + 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x1a, 0x0a, + 0x08, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x08, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x22, 0x45, 0x0a, 0x13, 0x50, 0x6e, 0x69, + 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x12, 0x10, 0x0a, 0x03, 0x70, 0x6e, 0x69, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x70, + 0x6e, 0x69, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, + 0x22, 0x7d, 0x0a, 0x0b, 0x45, 0x64, 0x69, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, + 0x30, 0x0a, 0x13, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x53, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x13, 0x74, 0x61, + 0x72, 0x67, 0x65, 0x74, 0x53, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x12, 0x3c, 0x0a, 0x0b, 0x64, 0x61, 0x74, 0x61, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x52, 0x0b, 0x64, 0x61, 0x74, 0x61, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, + 0x45, 0x0a, 0x2e, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x68, 0x69, 0x73, 0x70, 0x65, 0x72, 0x73, 0x79, + 0x73, 0x74, 0x65, 0x6d, 0x73, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x75, 0x73, + 0x68, 0x42, 0x13, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x73, +} var ( file_SignalService_proto_rawDescOnce sync.Once - file_SignalService_proto_rawDescData []byte + file_SignalService_proto_rawDescData = file_SignalService_proto_rawDesc ) func file_SignalService_proto_rawDescGZIP() []byte { file_SignalService_proto_rawDescOnce.Do(func() { - file_SignalService_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_SignalService_proto_rawDesc), len(file_SignalService_proto_rawDesc))) + file_SignalService_proto_rawDescData = protoimpl.X.CompressGZIP(file_SignalService_proto_rawDescData) }) return file_SignalService_proto_rawDescData } -var file_SignalService_proto_enumTypes = make([]protoimpl.EnumInfo, 28) -var file_SignalService_proto_msgTypes = make([]protoimpl.MessageInfo, 88) -var file_SignalService_proto_goTypes = []any{ - (Envelope_Type)(0), // 0: signalservice.Envelope.Type - (CallMessage_Offer_Type)(0), // 1: signalservice.CallMessage.Offer.Type - (CallMessage_Hangup_Type)(0), // 2: signalservice.CallMessage.Hangup.Type - (CallMessage_Opaque_Urgency)(0), // 3: signalservice.CallMessage.Opaque.Urgency - (DataMessage_Flags)(0), // 4: signalservice.DataMessage.Flags - (DataMessage_ProtocolVersion)(0), // 5: signalservice.DataMessage.ProtocolVersion - (DataMessage_Payment_Activation_Type)(0), // 6: signalservice.DataMessage.Payment.Activation.Type - (DataMessage_Quote_Type)(0), // 7: signalservice.DataMessage.Quote.Type - (DataMessage_Contact_Phone_Type)(0), // 8: signalservice.DataMessage.Contact.Phone.Type - (DataMessage_Contact_Email_Type)(0), // 9: signalservice.DataMessage.Contact.Email.Type - (DataMessage_Contact_PostalAddress_Type)(0), // 10: signalservice.DataMessage.Contact.PostalAddress.Type - (ReceiptMessage_Type)(0), // 11: signalservice.ReceiptMessage.Type - (TypingMessage_Action)(0), // 12: signalservice.TypingMessage.Action - (TextAttachment_Style)(0), // 13: signalservice.TextAttachment.Style - (Verified_State)(0), // 14: signalservice.Verified.State - (SyncMessage_Request_Type)(0), // 15: signalservice.SyncMessage.Request.Type - (SyncMessage_StickerPackOperation_Type)(0), // 16: signalservice.SyncMessage.StickerPackOperation.Type - (SyncMessage_FetchLatest_Type)(0), // 17: signalservice.SyncMessage.FetchLatest.Type - (SyncMessage_MessageRequestResponse_Type)(0), // 18: signalservice.SyncMessage.MessageRequestResponse.Type - (SyncMessage_CallEvent_Type)(0), // 19: signalservice.SyncMessage.CallEvent.Type - (SyncMessage_CallEvent_Direction)(0), // 20: signalservice.SyncMessage.CallEvent.Direction - (SyncMessage_CallEvent_Event)(0), // 21: signalservice.SyncMessage.CallEvent.Event - (SyncMessage_CallLinkUpdate_Type)(0), // 22: signalservice.SyncMessage.CallLinkUpdate.Type - (SyncMessage_CallLogEvent_Type)(0), // 23: signalservice.SyncMessage.CallLogEvent.Type - (SyncMessage_AttachmentBackfillResponse_Error)(0), // 24: signalservice.SyncMessage.AttachmentBackfillResponse.Error - (SyncMessage_AttachmentBackfillResponse_AttachmentData_Status)(0), // 25: signalservice.SyncMessage.AttachmentBackfillResponse.AttachmentData.Status - (AttachmentPointer_Flags)(0), // 26: signalservice.AttachmentPointer.Flags - (BodyRange_Style)(0), // 27: signalservice.BodyRange.Style - (*Envelope)(nil), // 28: signalservice.Envelope - (*Content)(nil), // 29: signalservice.Content - (*CallMessage)(nil), // 30: signalservice.CallMessage - (*DataMessage)(nil), // 31: signalservice.DataMessage - (*NullMessage)(nil), // 32: signalservice.NullMessage - (*ReceiptMessage)(nil), // 33: signalservice.ReceiptMessage - (*TypingMessage)(nil), // 34: signalservice.TypingMessage - (*StoryMessage)(nil), // 35: signalservice.StoryMessage - (*Preview)(nil), // 36: signalservice.Preview - (*TextAttachment)(nil), // 37: signalservice.TextAttachment - (*Verified)(nil), // 38: signalservice.Verified - (*SyncMessage)(nil), // 39: signalservice.SyncMessage - (*AttachmentPointer)(nil), // 40: signalservice.AttachmentPointer - (*GroupContextV2)(nil), // 41: signalservice.GroupContextV2 - (*ContactDetails)(nil), // 42: signalservice.ContactDetails - (*PaymentAddress)(nil), // 43: signalservice.PaymentAddress - (*DecryptionErrorMessage)(nil), // 44: signalservice.DecryptionErrorMessage - (*PniSignatureMessage)(nil), // 45: signalservice.PniSignatureMessage - (*EditMessage)(nil), // 46: signalservice.EditMessage - (*BodyRange)(nil), // 47: signalservice.BodyRange - (*AddressableMessage)(nil), // 48: signalservice.AddressableMessage - (*ConversationIdentifier)(nil), // 49: signalservice.ConversationIdentifier - (*CallMessage_Offer)(nil), // 50: signalservice.CallMessage.Offer - (*CallMessage_Answer)(nil), // 51: signalservice.CallMessage.Answer - (*CallMessage_IceUpdate)(nil), // 52: signalservice.CallMessage.IceUpdate - (*CallMessage_Busy)(nil), // 53: signalservice.CallMessage.Busy - (*CallMessage_Hangup)(nil), // 54: signalservice.CallMessage.Hangup - (*CallMessage_Opaque)(nil), // 55: signalservice.CallMessage.Opaque - (*DataMessage_Payment)(nil), // 56: signalservice.DataMessage.Payment - (*DataMessage_Quote)(nil), // 57: signalservice.DataMessage.Quote - (*DataMessage_Contact)(nil), // 58: signalservice.DataMessage.Contact - (*DataMessage_Sticker)(nil), // 59: signalservice.DataMessage.Sticker - (*DataMessage_Reaction)(nil), // 60: signalservice.DataMessage.Reaction - (*DataMessage_Delete)(nil), // 61: signalservice.DataMessage.Delete - (*DataMessage_GroupCallUpdate)(nil), // 62: signalservice.DataMessage.GroupCallUpdate - (*DataMessage_StoryContext)(nil), // 63: signalservice.DataMessage.StoryContext - (*DataMessage_GiftBadge)(nil), // 64: signalservice.DataMessage.GiftBadge - (*DataMessage_PollCreate)(nil), // 65: signalservice.DataMessage.PollCreate - (*DataMessage_PollTerminate)(nil), // 66: signalservice.DataMessage.PollTerminate - (*DataMessage_PollVote)(nil), // 67: signalservice.DataMessage.PollVote - (*DataMessage_PinMessage)(nil), // 68: signalservice.DataMessage.PinMessage - (*DataMessage_UnpinMessage)(nil), // 69: signalservice.DataMessage.UnpinMessage - (*DataMessage_AdminDelete)(nil), // 70: signalservice.DataMessage.AdminDelete - (*DataMessage_Payment_Amount)(nil), // 71: signalservice.DataMessage.Payment.Amount - (*DataMessage_Payment_Notification)(nil), // 72: signalservice.DataMessage.Payment.Notification - (*DataMessage_Payment_Activation)(nil), // 73: signalservice.DataMessage.Payment.Activation - (*DataMessage_Payment_Amount_MobileCoin)(nil), // 74: signalservice.DataMessage.Payment.Amount.MobileCoin - (*DataMessage_Payment_Notification_MobileCoin)(nil), // 75: signalservice.DataMessage.Payment.Notification.MobileCoin - (*DataMessage_Quote_QuotedAttachment)(nil), // 76: signalservice.DataMessage.Quote.QuotedAttachment - (*DataMessage_Contact_Name)(nil), // 77: signalservice.DataMessage.Contact.Name - (*DataMessage_Contact_Phone)(nil), // 78: signalservice.DataMessage.Contact.Phone - (*DataMessage_Contact_Email)(nil), // 79: signalservice.DataMessage.Contact.Email - (*DataMessage_Contact_PostalAddress)(nil), // 80: signalservice.DataMessage.Contact.PostalAddress - (*DataMessage_Contact_Avatar)(nil), // 81: signalservice.DataMessage.Contact.Avatar - (*TextAttachment_Gradient)(nil), // 82: signalservice.TextAttachment.Gradient - (*SyncMessage_Sent)(nil), // 83: signalservice.SyncMessage.Sent - (*SyncMessage_Contacts)(nil), // 84: signalservice.SyncMessage.Contacts - (*SyncMessage_Blocked)(nil), // 85: signalservice.SyncMessage.Blocked - (*SyncMessage_Request)(nil), // 86: signalservice.SyncMessage.Request - (*SyncMessage_Read)(nil), // 87: signalservice.SyncMessage.Read - (*SyncMessage_Viewed)(nil), // 88: signalservice.SyncMessage.Viewed - (*SyncMessage_Configuration)(nil), // 89: signalservice.SyncMessage.Configuration - (*SyncMessage_StickerPackOperation)(nil), // 90: signalservice.SyncMessage.StickerPackOperation - (*SyncMessage_ViewOnceOpen)(nil), // 91: signalservice.SyncMessage.ViewOnceOpen - (*SyncMessage_FetchLatest)(nil), // 92: signalservice.SyncMessage.FetchLatest - (*SyncMessage_Keys)(nil), // 93: signalservice.SyncMessage.Keys - (*SyncMessage_PniIdentity)(nil), // 94: signalservice.SyncMessage.PniIdentity - (*SyncMessage_MessageRequestResponse)(nil), // 95: signalservice.SyncMessage.MessageRequestResponse - (*SyncMessage_OutgoingPayment)(nil), // 96: signalservice.SyncMessage.OutgoingPayment - (*SyncMessage_PniChangeNumber)(nil), // 97: signalservice.SyncMessage.PniChangeNumber - (*SyncMessage_CallEvent)(nil), // 98: signalservice.SyncMessage.CallEvent - (*SyncMessage_CallLinkUpdate)(nil), // 99: signalservice.SyncMessage.CallLinkUpdate - (*SyncMessage_CallLogEvent)(nil), // 100: signalservice.SyncMessage.CallLogEvent - (*SyncMessage_DeleteForMe)(nil), // 101: signalservice.SyncMessage.DeleteForMe - (*SyncMessage_DeviceNameChange)(nil), // 102: signalservice.SyncMessage.DeviceNameChange - (*SyncMessage_AttachmentBackfillRequest)(nil), // 103: signalservice.SyncMessage.AttachmentBackfillRequest - (*SyncMessage_AttachmentBackfillResponse)(nil), // 104: signalservice.SyncMessage.AttachmentBackfillResponse - (*SyncMessage_Sent_UnidentifiedDeliveryStatus)(nil), // 105: signalservice.SyncMessage.Sent.UnidentifiedDeliveryStatus - (*SyncMessage_Sent_StoryMessageRecipient)(nil), // 106: signalservice.SyncMessage.Sent.StoryMessageRecipient - (*SyncMessage_OutgoingPayment_MobileCoin)(nil), // 107: signalservice.SyncMessage.OutgoingPayment.MobileCoin - (*SyncMessage_DeleteForMe_MessageDeletes)(nil), // 108: signalservice.SyncMessage.DeleteForMe.MessageDeletes - (*SyncMessage_DeleteForMe_AttachmentDelete)(nil), // 109: signalservice.SyncMessage.DeleteForMe.AttachmentDelete - (*SyncMessage_DeleteForMe_ConversationDelete)(nil), // 110: signalservice.SyncMessage.DeleteForMe.ConversationDelete - (*SyncMessage_DeleteForMe_LocalOnlyConversationDelete)(nil), // 111: signalservice.SyncMessage.DeleteForMe.LocalOnlyConversationDelete - (*SyncMessage_AttachmentBackfillResponse_AttachmentData)(nil), // 112: signalservice.SyncMessage.AttachmentBackfillResponse.AttachmentData - (*SyncMessage_AttachmentBackfillResponse_AttachmentDataList)(nil), // 113: signalservice.SyncMessage.AttachmentBackfillResponse.AttachmentDataList - (*ContactDetails_Avatar)(nil), // 114: signalservice.ContactDetails.Avatar - (*PaymentAddress_MobileCoin)(nil), // 115: signalservice.PaymentAddress.MobileCoin +var file_SignalService_proto_enumTypes = make([]protoimpl.EnumInfo, 26) +var file_SignalService_proto_msgTypes = make([]protoimpl.MessageInfo, 74) +var file_SignalService_proto_goTypes = []interface{}{ + (Envelope_Type)(0), // 0: signalservice.Envelope.Type + (CallMessage_Offer_Type)(0), // 1: signalservice.CallMessage.Offer.Type + (CallMessage_Hangup_Type)(0), // 2: signalservice.CallMessage.Hangup.Type + (CallMessage_Opaque_Urgency)(0), // 3: signalservice.CallMessage.Opaque.Urgency + (BodyRange_Style)(0), // 4: signalservice.BodyRange.Style + (DataMessage_Flags)(0), // 5: signalservice.DataMessage.Flags + (DataMessage_ProtocolVersion)(0), // 6: signalservice.DataMessage.ProtocolVersion + (DataMessage_Quote_Type)(0), // 7: signalservice.DataMessage.Quote.Type + (DataMessage_Contact_Phone_Type)(0), // 8: signalservice.DataMessage.Contact.Phone.Type + (DataMessage_Contact_Email_Type)(0), // 9: signalservice.DataMessage.Contact.Email.Type + (DataMessage_Contact_PostalAddress_Type)(0), // 10: signalservice.DataMessage.Contact.PostalAddress.Type + (DataMessage_Payment_Activation_Type)(0), // 11: signalservice.DataMessage.Payment.Activation.Type + (ReceiptMessage_Type)(0), // 12: signalservice.ReceiptMessage.Type + (TypingMessage_Action)(0), // 13: signalservice.TypingMessage.Action + (TextAttachment_Style)(0), // 14: signalservice.TextAttachment.Style + (Verified_State)(0), // 15: signalservice.Verified.State + (SyncMessage_Request_Type)(0), // 16: signalservice.SyncMessage.Request.Type + (SyncMessage_StickerPackOperation_Type)(0), // 17: signalservice.SyncMessage.StickerPackOperation.Type + (SyncMessage_FetchLatest_Type)(0), // 18: signalservice.SyncMessage.FetchLatest.Type + (SyncMessage_MessageRequestResponse_Type)(0), // 19: signalservice.SyncMessage.MessageRequestResponse.Type + (SyncMessage_CallEvent_Type)(0), // 20: signalservice.SyncMessage.CallEvent.Type + (SyncMessage_CallEvent_Direction)(0), // 21: signalservice.SyncMessage.CallEvent.Direction + (SyncMessage_CallEvent_Event)(0), // 22: signalservice.SyncMessage.CallEvent.Event + (SyncMessage_CallLogEvent_Type)(0), // 23: signalservice.SyncMessage.CallLogEvent.Type + (AttachmentPointer_Flags)(0), // 24: signalservice.AttachmentPointer.Flags + (GroupContext_Type)(0), // 25: signalservice.GroupContext.Type + (*Envelope)(nil), // 26: signalservice.Envelope + (*Content)(nil), // 27: signalservice.Content + (*CallMessage)(nil), // 28: signalservice.CallMessage + (*BodyRange)(nil), // 29: signalservice.BodyRange + (*DataMessage)(nil), // 30: signalservice.DataMessage + (*NullMessage)(nil), // 31: signalservice.NullMessage + (*ReceiptMessage)(nil), // 32: signalservice.ReceiptMessage + (*TypingMessage)(nil), // 33: signalservice.TypingMessage + (*StoryMessage)(nil), // 34: signalservice.StoryMessage + (*Preview)(nil), // 35: signalservice.Preview + (*TextAttachment)(nil), // 36: signalservice.TextAttachment + (*Verified)(nil), // 37: signalservice.Verified + (*SyncMessage)(nil), // 38: signalservice.SyncMessage + (*AttachmentPointer)(nil), // 39: signalservice.AttachmentPointer + (*GroupContext)(nil), // 40: signalservice.GroupContext + (*GroupContextV2)(nil), // 41: signalservice.GroupContextV2 + (*ContactDetails)(nil), // 42: signalservice.ContactDetails + (*GroupDetails)(nil), // 43: signalservice.GroupDetails + (*PaymentAddress)(nil), // 44: signalservice.PaymentAddress + (*DecryptionErrorMessage)(nil), // 45: signalservice.DecryptionErrorMessage + (*PniSignatureMessage)(nil), // 46: signalservice.PniSignatureMessage + (*EditMessage)(nil), // 47: signalservice.EditMessage + (*CallMessage_Offer)(nil), // 48: signalservice.CallMessage.Offer + (*CallMessage_Answer)(nil), // 49: signalservice.CallMessage.Answer + (*CallMessage_IceUpdate)(nil), // 50: signalservice.CallMessage.IceUpdate + (*CallMessage_Busy)(nil), // 51: signalservice.CallMessage.Busy + (*CallMessage_Hangup)(nil), // 52: signalservice.CallMessage.Hangup + (*CallMessage_Opaque)(nil), // 53: signalservice.CallMessage.Opaque + (*DataMessage_Quote)(nil), // 54: signalservice.DataMessage.Quote + (*DataMessage_Contact)(nil), // 55: signalservice.DataMessage.Contact + (*DataMessage_Sticker)(nil), // 56: signalservice.DataMessage.Sticker + (*DataMessage_Reaction)(nil), // 57: signalservice.DataMessage.Reaction + (*DataMessage_Delete)(nil), // 58: signalservice.DataMessage.Delete + (*DataMessage_GroupCallUpdate)(nil), // 59: signalservice.DataMessage.GroupCallUpdate + (*DataMessage_StoryContext)(nil), // 60: signalservice.DataMessage.StoryContext + (*DataMessage_Payment)(nil), // 61: signalservice.DataMessage.Payment + (*DataMessage_GiftBadge)(nil), // 62: signalservice.DataMessage.GiftBadge + (*DataMessage_Quote_QuotedAttachment)(nil), // 63: signalservice.DataMessage.Quote.QuotedAttachment + (*DataMessage_Contact_Name)(nil), // 64: signalservice.DataMessage.Contact.Name + (*DataMessage_Contact_Phone)(nil), // 65: signalservice.DataMessage.Contact.Phone + (*DataMessage_Contact_Email)(nil), // 66: signalservice.DataMessage.Contact.Email + (*DataMessage_Contact_PostalAddress)(nil), // 67: signalservice.DataMessage.Contact.PostalAddress + (*DataMessage_Contact_Avatar)(nil), // 68: signalservice.DataMessage.Contact.Avatar + (*DataMessage_Payment_Amount)(nil), // 69: signalservice.DataMessage.Payment.Amount + (*DataMessage_Payment_Notification)(nil), // 70: signalservice.DataMessage.Payment.Notification + (*DataMessage_Payment_Activation)(nil), // 71: signalservice.DataMessage.Payment.Activation + (*DataMessage_Payment_Amount_MobileCoin)(nil), // 72: signalservice.DataMessage.Payment.Amount.MobileCoin + (*DataMessage_Payment_Notification_MobileCoin)(nil), // 73: signalservice.DataMessage.Payment.Notification.MobileCoin + (*TextAttachment_Gradient)(nil), // 74: signalservice.TextAttachment.Gradient + (*SyncMessage_Sent)(nil), // 75: signalservice.SyncMessage.Sent + (*SyncMessage_Contacts)(nil), // 76: signalservice.SyncMessage.Contacts + (*SyncMessage_Blocked)(nil), // 77: signalservice.SyncMessage.Blocked + (*SyncMessage_Request)(nil), // 78: signalservice.SyncMessage.Request + (*SyncMessage_Read)(nil), // 79: signalservice.SyncMessage.Read + (*SyncMessage_Viewed)(nil), // 80: signalservice.SyncMessage.Viewed + (*SyncMessage_Configuration)(nil), // 81: signalservice.SyncMessage.Configuration + (*SyncMessage_StickerPackOperation)(nil), // 82: signalservice.SyncMessage.StickerPackOperation + (*SyncMessage_ViewOnceOpen)(nil), // 83: signalservice.SyncMessage.ViewOnceOpen + (*SyncMessage_FetchLatest)(nil), // 84: signalservice.SyncMessage.FetchLatest + (*SyncMessage_Keys)(nil), // 85: signalservice.SyncMessage.Keys + (*SyncMessage_MessageRequestResponse)(nil), // 86: signalservice.SyncMessage.MessageRequestResponse + (*SyncMessage_OutgoingPayment)(nil), // 87: signalservice.SyncMessage.OutgoingPayment + (*SyncMessage_PniChangeNumber)(nil), // 88: signalservice.SyncMessage.PniChangeNumber + (*SyncMessage_CallEvent)(nil), // 89: signalservice.SyncMessage.CallEvent + (*SyncMessage_CallLinkUpdate)(nil), // 90: signalservice.SyncMessage.CallLinkUpdate + (*SyncMessage_CallLogEvent)(nil), // 91: signalservice.SyncMessage.CallLogEvent + (*SyncMessage_Sent_UnidentifiedDeliveryStatus)(nil), // 92: signalservice.SyncMessage.Sent.UnidentifiedDeliveryStatus + (*SyncMessage_Sent_StoryMessageRecipient)(nil), // 93: signalservice.SyncMessage.Sent.StoryMessageRecipient + (*SyncMessage_OutgoingPayment_MobileCoin)(nil), // 94: signalservice.SyncMessage.OutgoingPayment.MobileCoin + (*GroupContext_Member)(nil), // 95: signalservice.GroupContext.Member + (*ContactDetails_Avatar)(nil), // 96: signalservice.ContactDetails.Avatar + (*GroupDetails_Avatar)(nil), // 97: signalservice.GroupDetails.Avatar + (*GroupDetails_Member)(nil), // 98: signalservice.GroupDetails.Member + (*PaymentAddress_MobileCoinAddress)(nil), // 99: signalservice.PaymentAddress.MobileCoinAddress } var file_SignalService_proto_depIdxs = []int32{ 0, // 0: signalservice.Envelope.type:type_name -> signalservice.Envelope.Type - 31, // 1: signalservice.Content.dataMessage:type_name -> signalservice.DataMessage - 39, // 2: signalservice.Content.syncMessage:type_name -> signalservice.SyncMessage - 30, // 3: signalservice.Content.callMessage:type_name -> signalservice.CallMessage - 32, // 4: signalservice.Content.nullMessage:type_name -> signalservice.NullMessage - 33, // 5: signalservice.Content.receiptMessage:type_name -> signalservice.ReceiptMessage - 34, // 6: signalservice.Content.typingMessage:type_name -> signalservice.TypingMessage - 35, // 7: signalservice.Content.storyMessage:type_name -> signalservice.StoryMessage - 46, // 8: signalservice.Content.editMessage:type_name -> signalservice.EditMessage - 45, // 9: signalservice.Content.pniSignatureMessage:type_name -> signalservice.PniSignatureMessage - 50, // 10: signalservice.CallMessage.offer:type_name -> signalservice.CallMessage.Offer - 51, // 11: signalservice.CallMessage.answer:type_name -> signalservice.CallMessage.Answer - 52, // 12: signalservice.CallMessage.iceUpdate:type_name -> signalservice.CallMessage.IceUpdate - 53, // 13: signalservice.CallMessage.busy:type_name -> signalservice.CallMessage.Busy - 54, // 14: signalservice.CallMessage.hangup:type_name -> signalservice.CallMessage.Hangup - 55, // 15: signalservice.CallMessage.opaque:type_name -> signalservice.CallMessage.Opaque - 40, // 16: signalservice.DataMessage.attachments:type_name -> signalservice.AttachmentPointer - 41, // 17: signalservice.DataMessage.groupV2:type_name -> signalservice.GroupContextV2 - 57, // 18: signalservice.DataMessage.quote:type_name -> signalservice.DataMessage.Quote - 58, // 19: signalservice.DataMessage.contact:type_name -> signalservice.DataMessage.Contact - 36, // 20: signalservice.DataMessage.preview:type_name -> signalservice.Preview - 59, // 21: signalservice.DataMessage.sticker:type_name -> signalservice.DataMessage.Sticker - 60, // 22: signalservice.DataMessage.reaction:type_name -> signalservice.DataMessage.Reaction - 61, // 23: signalservice.DataMessage.delete:type_name -> signalservice.DataMessage.Delete - 47, // 24: signalservice.DataMessage.bodyRanges:type_name -> signalservice.BodyRange - 62, // 25: signalservice.DataMessage.groupCallUpdate:type_name -> signalservice.DataMessage.GroupCallUpdate - 56, // 26: signalservice.DataMessage.payment:type_name -> signalservice.DataMessage.Payment - 63, // 27: signalservice.DataMessage.storyContext:type_name -> signalservice.DataMessage.StoryContext - 64, // 28: signalservice.DataMessage.giftBadge:type_name -> signalservice.DataMessage.GiftBadge - 65, // 29: signalservice.DataMessage.pollCreate:type_name -> signalservice.DataMessage.PollCreate - 66, // 30: signalservice.DataMessage.pollTerminate:type_name -> signalservice.DataMessage.PollTerminate - 67, // 31: signalservice.DataMessage.pollVote:type_name -> signalservice.DataMessage.PollVote - 68, // 32: signalservice.DataMessage.pinMessage:type_name -> signalservice.DataMessage.PinMessage - 69, // 33: signalservice.DataMessage.unpinMessage:type_name -> signalservice.DataMessage.UnpinMessage - 70, // 34: signalservice.DataMessage.adminDelete:type_name -> signalservice.DataMessage.AdminDelete - 11, // 35: signalservice.ReceiptMessage.type:type_name -> signalservice.ReceiptMessage.Type - 12, // 36: signalservice.TypingMessage.action:type_name -> signalservice.TypingMessage.Action - 41, // 37: signalservice.StoryMessage.group:type_name -> signalservice.GroupContextV2 - 40, // 38: signalservice.StoryMessage.fileAttachment:type_name -> signalservice.AttachmentPointer - 37, // 39: signalservice.StoryMessage.textAttachment:type_name -> signalservice.TextAttachment - 47, // 40: signalservice.StoryMessage.bodyRanges:type_name -> signalservice.BodyRange - 40, // 41: signalservice.Preview.image:type_name -> signalservice.AttachmentPointer - 13, // 42: signalservice.TextAttachment.textStyle:type_name -> signalservice.TextAttachment.Style - 36, // 43: signalservice.TextAttachment.preview:type_name -> signalservice.Preview - 82, // 44: signalservice.TextAttachment.gradient:type_name -> signalservice.TextAttachment.Gradient - 14, // 45: signalservice.Verified.state:type_name -> signalservice.Verified.State - 83, // 46: signalservice.SyncMessage.sent:type_name -> signalservice.SyncMessage.Sent - 84, // 47: signalservice.SyncMessage.contacts:type_name -> signalservice.SyncMessage.Contacts - 86, // 48: signalservice.SyncMessage.request:type_name -> signalservice.SyncMessage.Request - 85, // 49: signalservice.SyncMessage.blocked:type_name -> signalservice.SyncMessage.Blocked - 38, // 50: signalservice.SyncMessage.verified:type_name -> signalservice.Verified - 89, // 51: signalservice.SyncMessage.configuration:type_name -> signalservice.SyncMessage.Configuration - 91, // 52: signalservice.SyncMessage.viewOnceOpen:type_name -> signalservice.SyncMessage.ViewOnceOpen - 92, // 53: signalservice.SyncMessage.fetchLatest:type_name -> signalservice.SyncMessage.FetchLatest - 93, // 54: signalservice.SyncMessage.keys:type_name -> signalservice.SyncMessage.Keys - 95, // 55: signalservice.SyncMessage.messageRequestResponse:type_name -> signalservice.SyncMessage.MessageRequestResponse - 96, // 56: signalservice.SyncMessage.outgoingPayment:type_name -> signalservice.SyncMessage.OutgoingPayment - 97, // 57: signalservice.SyncMessage.pniChangeNumber:type_name -> signalservice.SyncMessage.PniChangeNumber - 98, // 58: signalservice.SyncMessage.callEvent:type_name -> signalservice.SyncMessage.CallEvent - 99, // 59: signalservice.SyncMessage.callLinkUpdate:type_name -> signalservice.SyncMessage.CallLinkUpdate - 100, // 60: signalservice.SyncMessage.callLogEvent:type_name -> signalservice.SyncMessage.CallLogEvent - 101, // 61: signalservice.SyncMessage.deleteForMe:type_name -> signalservice.SyncMessage.DeleteForMe - 102, // 62: signalservice.SyncMessage.deviceNameChange:type_name -> signalservice.SyncMessage.DeviceNameChange - 103, // 63: signalservice.SyncMessage.attachmentBackfillRequest:type_name -> signalservice.SyncMessage.AttachmentBackfillRequest - 104, // 64: signalservice.SyncMessage.attachmentBackfillResponse:type_name -> signalservice.SyncMessage.AttachmentBackfillResponse - 87, // 65: signalservice.SyncMessage.read:type_name -> signalservice.SyncMessage.Read - 90, // 66: signalservice.SyncMessage.stickerPackOperation:type_name -> signalservice.SyncMessage.StickerPackOperation - 88, // 67: signalservice.SyncMessage.viewed:type_name -> signalservice.SyncMessage.Viewed - 114, // 68: signalservice.ContactDetails.avatar:type_name -> signalservice.ContactDetails.Avatar - 115, // 69: signalservice.PaymentAddress.mobileCoin:type_name -> signalservice.PaymentAddress.MobileCoin - 31, // 70: signalservice.EditMessage.dataMessage:type_name -> signalservice.DataMessage - 27, // 71: signalservice.BodyRange.style:type_name -> signalservice.BodyRange.Style - 1, // 72: signalservice.CallMessage.Offer.type:type_name -> signalservice.CallMessage.Offer.Type - 2, // 73: signalservice.CallMessage.Hangup.type:type_name -> signalservice.CallMessage.Hangup.Type - 3, // 74: signalservice.CallMessage.Opaque.urgency:type_name -> signalservice.CallMessage.Opaque.Urgency - 72, // 75: signalservice.DataMessage.Payment.notification:type_name -> signalservice.DataMessage.Payment.Notification - 73, // 76: signalservice.DataMessage.Payment.activation:type_name -> signalservice.DataMessage.Payment.Activation - 76, // 77: signalservice.DataMessage.Quote.attachments:type_name -> signalservice.DataMessage.Quote.QuotedAttachment - 47, // 78: signalservice.DataMessage.Quote.bodyRanges:type_name -> signalservice.BodyRange - 7, // 79: signalservice.DataMessage.Quote.type:type_name -> signalservice.DataMessage.Quote.Type - 77, // 80: signalservice.DataMessage.Contact.name:type_name -> signalservice.DataMessage.Contact.Name - 78, // 81: signalservice.DataMessage.Contact.number:type_name -> signalservice.DataMessage.Contact.Phone - 79, // 82: signalservice.DataMessage.Contact.email:type_name -> signalservice.DataMessage.Contact.Email - 80, // 83: signalservice.DataMessage.Contact.address:type_name -> signalservice.DataMessage.Contact.PostalAddress - 81, // 84: signalservice.DataMessage.Contact.avatar:type_name -> signalservice.DataMessage.Contact.Avatar - 40, // 85: signalservice.DataMessage.Sticker.data:type_name -> signalservice.AttachmentPointer - 74, // 86: signalservice.DataMessage.Payment.Amount.mobileCoin:type_name -> signalservice.DataMessage.Payment.Amount.MobileCoin - 75, // 87: signalservice.DataMessage.Payment.Notification.mobileCoin:type_name -> signalservice.DataMessage.Payment.Notification.MobileCoin - 6, // 88: signalservice.DataMessage.Payment.Activation.type:type_name -> signalservice.DataMessage.Payment.Activation.Type - 40, // 89: signalservice.DataMessage.Quote.QuotedAttachment.thumbnail:type_name -> signalservice.AttachmentPointer - 8, // 90: signalservice.DataMessage.Contact.Phone.type:type_name -> signalservice.DataMessage.Contact.Phone.Type - 9, // 91: signalservice.DataMessage.Contact.Email.type:type_name -> signalservice.DataMessage.Contact.Email.Type - 10, // 92: signalservice.DataMessage.Contact.PostalAddress.type:type_name -> signalservice.DataMessage.Contact.PostalAddress.Type - 40, // 93: signalservice.DataMessage.Contact.Avatar.avatar:type_name -> signalservice.AttachmentPointer - 31, // 94: signalservice.SyncMessage.Sent.message:type_name -> signalservice.DataMessage - 105, // 95: signalservice.SyncMessage.Sent.unidentifiedStatus:type_name -> signalservice.SyncMessage.Sent.UnidentifiedDeliveryStatus - 35, // 96: signalservice.SyncMessage.Sent.storyMessage:type_name -> signalservice.StoryMessage - 106, // 97: signalservice.SyncMessage.Sent.storyMessageRecipients:type_name -> signalservice.SyncMessage.Sent.StoryMessageRecipient - 46, // 98: signalservice.SyncMessage.Sent.editMessage:type_name -> signalservice.EditMessage - 40, // 99: signalservice.SyncMessage.Contacts.blob:type_name -> signalservice.AttachmentPointer - 15, // 100: signalservice.SyncMessage.Request.type:type_name -> signalservice.SyncMessage.Request.Type - 16, // 101: signalservice.SyncMessage.StickerPackOperation.type:type_name -> signalservice.SyncMessage.StickerPackOperation.Type - 17, // 102: signalservice.SyncMessage.FetchLatest.type:type_name -> signalservice.SyncMessage.FetchLatest.Type - 18, // 103: signalservice.SyncMessage.MessageRequestResponse.type:type_name -> signalservice.SyncMessage.MessageRequestResponse.Type - 107, // 104: signalservice.SyncMessage.OutgoingPayment.mobileCoin:type_name -> signalservice.SyncMessage.OutgoingPayment.MobileCoin - 19, // 105: signalservice.SyncMessage.CallEvent.type:type_name -> signalservice.SyncMessage.CallEvent.Type - 20, // 106: signalservice.SyncMessage.CallEvent.direction:type_name -> signalservice.SyncMessage.CallEvent.Direction - 21, // 107: signalservice.SyncMessage.CallEvent.event:type_name -> signalservice.SyncMessage.CallEvent.Event - 22, // 108: signalservice.SyncMessage.CallLinkUpdate.type:type_name -> signalservice.SyncMessage.CallLinkUpdate.Type - 23, // 109: signalservice.SyncMessage.CallLogEvent.type:type_name -> signalservice.SyncMessage.CallLogEvent.Type - 108, // 110: signalservice.SyncMessage.DeleteForMe.messageDeletes:type_name -> signalservice.SyncMessage.DeleteForMe.MessageDeletes - 110, // 111: signalservice.SyncMessage.DeleteForMe.conversationDeletes:type_name -> signalservice.SyncMessage.DeleteForMe.ConversationDelete - 111, // 112: signalservice.SyncMessage.DeleteForMe.localOnlyConversationDeletes:type_name -> signalservice.SyncMessage.DeleteForMe.LocalOnlyConversationDelete - 109, // 113: signalservice.SyncMessage.DeleteForMe.attachmentDeletes:type_name -> signalservice.SyncMessage.DeleteForMe.AttachmentDelete - 48, // 114: signalservice.SyncMessage.AttachmentBackfillRequest.targetMessage:type_name -> signalservice.AddressableMessage - 49, // 115: signalservice.SyncMessage.AttachmentBackfillRequest.targetConversation:type_name -> signalservice.ConversationIdentifier - 48, // 116: signalservice.SyncMessage.AttachmentBackfillResponse.targetMessage:type_name -> signalservice.AddressableMessage - 49, // 117: signalservice.SyncMessage.AttachmentBackfillResponse.targetConversation:type_name -> signalservice.ConversationIdentifier - 113, // 118: signalservice.SyncMessage.AttachmentBackfillResponse.attachments:type_name -> signalservice.SyncMessage.AttachmentBackfillResponse.AttachmentDataList - 24, // 119: signalservice.SyncMessage.AttachmentBackfillResponse.error:type_name -> signalservice.SyncMessage.AttachmentBackfillResponse.Error - 49, // 120: signalservice.SyncMessage.DeleteForMe.MessageDeletes.conversation:type_name -> signalservice.ConversationIdentifier - 48, // 121: signalservice.SyncMessage.DeleteForMe.MessageDeletes.messages:type_name -> signalservice.AddressableMessage - 49, // 122: signalservice.SyncMessage.DeleteForMe.AttachmentDelete.conversation:type_name -> signalservice.ConversationIdentifier - 48, // 123: signalservice.SyncMessage.DeleteForMe.AttachmentDelete.targetMessage:type_name -> signalservice.AddressableMessage - 49, // 124: signalservice.SyncMessage.DeleteForMe.ConversationDelete.conversation:type_name -> signalservice.ConversationIdentifier - 48, // 125: signalservice.SyncMessage.DeleteForMe.ConversationDelete.mostRecentMessages:type_name -> signalservice.AddressableMessage - 48, // 126: signalservice.SyncMessage.DeleteForMe.ConversationDelete.mostRecentNonExpiringMessages:type_name -> signalservice.AddressableMessage - 49, // 127: signalservice.SyncMessage.DeleteForMe.LocalOnlyConversationDelete.conversation:type_name -> signalservice.ConversationIdentifier - 40, // 128: signalservice.SyncMessage.AttachmentBackfillResponse.AttachmentData.attachment:type_name -> signalservice.AttachmentPointer - 25, // 129: signalservice.SyncMessage.AttachmentBackfillResponse.AttachmentData.status:type_name -> signalservice.SyncMessage.AttachmentBackfillResponse.AttachmentData.Status - 112, // 130: signalservice.SyncMessage.AttachmentBackfillResponse.AttachmentDataList.attachments:type_name -> signalservice.SyncMessage.AttachmentBackfillResponse.AttachmentData - 112, // 131: signalservice.SyncMessage.AttachmentBackfillResponse.AttachmentDataList.longText:type_name -> signalservice.SyncMessage.AttachmentBackfillResponse.AttachmentData - 132, // [132:132] is the sub-list for method output_type - 132, // [132:132] is the sub-list for method input_type - 132, // [132:132] is the sub-list for extension type_name - 132, // [132:132] is the sub-list for extension extendee - 0, // [0:132] is the sub-list for field type_name + 30, // 1: signalservice.Content.dataMessage:type_name -> signalservice.DataMessage + 38, // 2: signalservice.Content.syncMessage:type_name -> signalservice.SyncMessage + 28, // 3: signalservice.Content.callMessage:type_name -> signalservice.CallMessage + 31, // 4: signalservice.Content.nullMessage:type_name -> signalservice.NullMessage + 32, // 5: signalservice.Content.receiptMessage:type_name -> signalservice.ReceiptMessage + 33, // 6: signalservice.Content.typingMessage:type_name -> signalservice.TypingMessage + 34, // 7: signalservice.Content.storyMessage:type_name -> signalservice.StoryMessage + 46, // 8: signalservice.Content.pniSignatureMessage:type_name -> signalservice.PniSignatureMessage + 47, // 9: signalservice.Content.editMessage:type_name -> signalservice.EditMessage + 48, // 10: signalservice.CallMessage.offer:type_name -> signalservice.CallMessage.Offer + 49, // 11: signalservice.CallMessage.answer:type_name -> signalservice.CallMessage.Answer + 50, // 12: signalservice.CallMessage.iceUpdate:type_name -> signalservice.CallMessage.IceUpdate + 52, // 13: signalservice.CallMessage.legacyHangup:type_name -> signalservice.CallMessage.Hangup + 51, // 14: signalservice.CallMessage.busy:type_name -> signalservice.CallMessage.Busy + 52, // 15: signalservice.CallMessage.hangup:type_name -> signalservice.CallMessage.Hangup + 53, // 16: signalservice.CallMessage.opaque:type_name -> signalservice.CallMessage.Opaque + 4, // 17: signalservice.BodyRange.style:type_name -> signalservice.BodyRange.Style + 39, // 18: signalservice.DataMessage.attachments:type_name -> signalservice.AttachmentPointer + 41, // 19: signalservice.DataMessage.groupV2:type_name -> signalservice.GroupContextV2 + 54, // 20: signalservice.DataMessage.quote:type_name -> signalservice.DataMessage.Quote + 55, // 21: signalservice.DataMessage.contact:type_name -> signalservice.DataMessage.Contact + 35, // 22: signalservice.DataMessage.preview:type_name -> signalservice.Preview + 56, // 23: signalservice.DataMessage.sticker:type_name -> signalservice.DataMessage.Sticker + 57, // 24: signalservice.DataMessage.reaction:type_name -> signalservice.DataMessage.Reaction + 58, // 25: signalservice.DataMessage.delete:type_name -> signalservice.DataMessage.Delete + 29, // 26: signalservice.DataMessage.bodyRanges:type_name -> signalservice.BodyRange + 59, // 27: signalservice.DataMessage.groupCallUpdate:type_name -> signalservice.DataMessage.GroupCallUpdate + 61, // 28: signalservice.DataMessage.payment:type_name -> signalservice.DataMessage.Payment + 60, // 29: signalservice.DataMessage.storyContext:type_name -> signalservice.DataMessage.StoryContext + 62, // 30: signalservice.DataMessage.giftBadge:type_name -> signalservice.DataMessage.GiftBadge + 12, // 31: signalservice.ReceiptMessage.type:type_name -> signalservice.ReceiptMessage.Type + 13, // 32: signalservice.TypingMessage.action:type_name -> signalservice.TypingMessage.Action + 41, // 33: signalservice.StoryMessage.group:type_name -> signalservice.GroupContextV2 + 39, // 34: signalservice.StoryMessage.fileAttachment:type_name -> signalservice.AttachmentPointer + 36, // 35: signalservice.StoryMessage.textAttachment:type_name -> signalservice.TextAttachment + 29, // 36: signalservice.StoryMessage.bodyRanges:type_name -> signalservice.BodyRange + 39, // 37: signalservice.Preview.image:type_name -> signalservice.AttachmentPointer + 14, // 38: signalservice.TextAttachment.textStyle:type_name -> signalservice.TextAttachment.Style + 35, // 39: signalservice.TextAttachment.preview:type_name -> signalservice.Preview + 74, // 40: signalservice.TextAttachment.gradient:type_name -> signalservice.TextAttachment.Gradient + 15, // 41: signalservice.Verified.state:type_name -> signalservice.Verified.State + 75, // 42: signalservice.SyncMessage.sent:type_name -> signalservice.SyncMessage.Sent + 76, // 43: signalservice.SyncMessage.contacts:type_name -> signalservice.SyncMessage.Contacts + 78, // 44: signalservice.SyncMessage.request:type_name -> signalservice.SyncMessage.Request + 79, // 45: signalservice.SyncMessage.read:type_name -> signalservice.SyncMessage.Read + 77, // 46: signalservice.SyncMessage.blocked:type_name -> signalservice.SyncMessage.Blocked + 37, // 47: signalservice.SyncMessage.verified:type_name -> signalservice.Verified + 81, // 48: signalservice.SyncMessage.configuration:type_name -> signalservice.SyncMessage.Configuration + 82, // 49: signalservice.SyncMessage.stickerPackOperation:type_name -> signalservice.SyncMessage.StickerPackOperation + 83, // 50: signalservice.SyncMessage.viewOnceOpen:type_name -> signalservice.SyncMessage.ViewOnceOpen + 84, // 51: signalservice.SyncMessage.fetchLatest:type_name -> signalservice.SyncMessage.FetchLatest + 85, // 52: signalservice.SyncMessage.keys:type_name -> signalservice.SyncMessage.Keys + 86, // 53: signalservice.SyncMessage.messageRequestResponse:type_name -> signalservice.SyncMessage.MessageRequestResponse + 87, // 54: signalservice.SyncMessage.outgoingPayment:type_name -> signalservice.SyncMessage.OutgoingPayment + 80, // 55: signalservice.SyncMessage.viewed:type_name -> signalservice.SyncMessage.Viewed + 88, // 56: signalservice.SyncMessage.pniChangeNumber:type_name -> signalservice.SyncMessage.PniChangeNumber + 89, // 57: signalservice.SyncMessage.callEvent:type_name -> signalservice.SyncMessage.CallEvent + 90, // 58: signalservice.SyncMessage.callLinkUpdate:type_name -> signalservice.SyncMessage.CallLinkUpdate + 91, // 59: signalservice.SyncMessage.callLogEvent:type_name -> signalservice.SyncMessage.CallLogEvent + 25, // 60: signalservice.GroupContext.type:type_name -> signalservice.GroupContext.Type + 95, // 61: signalservice.GroupContext.members:type_name -> signalservice.GroupContext.Member + 39, // 62: signalservice.GroupContext.avatar:type_name -> signalservice.AttachmentPointer + 96, // 63: signalservice.ContactDetails.avatar:type_name -> signalservice.ContactDetails.Avatar + 37, // 64: signalservice.ContactDetails.verified:type_name -> signalservice.Verified + 98, // 65: signalservice.GroupDetails.members:type_name -> signalservice.GroupDetails.Member + 97, // 66: signalservice.GroupDetails.avatar:type_name -> signalservice.GroupDetails.Avatar + 99, // 67: signalservice.PaymentAddress.mobileCoinAddress:type_name -> signalservice.PaymentAddress.MobileCoinAddress + 30, // 68: signalservice.EditMessage.dataMessage:type_name -> signalservice.DataMessage + 1, // 69: signalservice.CallMessage.Offer.type:type_name -> signalservice.CallMessage.Offer.Type + 2, // 70: signalservice.CallMessage.Hangup.type:type_name -> signalservice.CallMessage.Hangup.Type + 3, // 71: signalservice.CallMessage.Opaque.urgency:type_name -> signalservice.CallMessage.Opaque.Urgency + 63, // 72: signalservice.DataMessage.Quote.attachments:type_name -> signalservice.DataMessage.Quote.QuotedAttachment + 29, // 73: signalservice.DataMessage.Quote.bodyRanges:type_name -> signalservice.BodyRange + 7, // 74: signalservice.DataMessage.Quote.type:type_name -> signalservice.DataMessage.Quote.Type + 64, // 75: signalservice.DataMessage.Contact.name:type_name -> signalservice.DataMessage.Contact.Name + 65, // 76: signalservice.DataMessage.Contact.number:type_name -> signalservice.DataMessage.Contact.Phone + 66, // 77: signalservice.DataMessage.Contact.email:type_name -> signalservice.DataMessage.Contact.Email + 67, // 78: signalservice.DataMessage.Contact.address:type_name -> signalservice.DataMessage.Contact.PostalAddress + 68, // 79: signalservice.DataMessage.Contact.avatar:type_name -> signalservice.DataMessage.Contact.Avatar + 39, // 80: signalservice.DataMessage.Sticker.data:type_name -> signalservice.AttachmentPointer + 70, // 81: signalservice.DataMessage.Payment.notification:type_name -> signalservice.DataMessage.Payment.Notification + 71, // 82: signalservice.DataMessage.Payment.activation:type_name -> signalservice.DataMessage.Payment.Activation + 39, // 83: signalservice.DataMessage.Quote.QuotedAttachment.thumbnail:type_name -> signalservice.AttachmentPointer + 8, // 84: signalservice.DataMessage.Contact.Phone.type:type_name -> signalservice.DataMessage.Contact.Phone.Type + 9, // 85: signalservice.DataMessage.Contact.Email.type:type_name -> signalservice.DataMessage.Contact.Email.Type + 10, // 86: signalservice.DataMessage.Contact.PostalAddress.type:type_name -> signalservice.DataMessage.Contact.PostalAddress.Type + 39, // 87: signalservice.DataMessage.Contact.Avatar.avatar:type_name -> signalservice.AttachmentPointer + 72, // 88: signalservice.DataMessage.Payment.Amount.mobileCoin:type_name -> signalservice.DataMessage.Payment.Amount.MobileCoin + 73, // 89: signalservice.DataMessage.Payment.Notification.mobileCoin:type_name -> signalservice.DataMessage.Payment.Notification.MobileCoin + 11, // 90: signalservice.DataMessage.Payment.Activation.type:type_name -> signalservice.DataMessage.Payment.Activation.Type + 30, // 91: signalservice.SyncMessage.Sent.message:type_name -> signalservice.DataMessage + 92, // 92: signalservice.SyncMessage.Sent.unidentifiedStatus:type_name -> signalservice.SyncMessage.Sent.UnidentifiedDeliveryStatus + 34, // 93: signalservice.SyncMessage.Sent.storyMessage:type_name -> signalservice.StoryMessage + 93, // 94: signalservice.SyncMessage.Sent.storyMessageRecipients:type_name -> signalservice.SyncMessage.Sent.StoryMessageRecipient + 47, // 95: signalservice.SyncMessage.Sent.editMessage:type_name -> signalservice.EditMessage + 39, // 96: signalservice.SyncMessage.Contacts.blob:type_name -> signalservice.AttachmentPointer + 16, // 97: signalservice.SyncMessage.Request.type:type_name -> signalservice.SyncMessage.Request.Type + 17, // 98: signalservice.SyncMessage.StickerPackOperation.type:type_name -> signalservice.SyncMessage.StickerPackOperation.Type + 18, // 99: signalservice.SyncMessage.FetchLatest.type:type_name -> signalservice.SyncMessage.FetchLatest.Type + 19, // 100: signalservice.SyncMessage.MessageRequestResponse.type:type_name -> signalservice.SyncMessage.MessageRequestResponse.Type + 94, // 101: signalservice.SyncMessage.OutgoingPayment.mobileCoin:type_name -> signalservice.SyncMessage.OutgoingPayment.MobileCoin + 20, // 102: signalservice.SyncMessage.CallEvent.type:type_name -> signalservice.SyncMessage.CallEvent.Type + 21, // 103: signalservice.SyncMessage.CallEvent.direction:type_name -> signalservice.SyncMessage.CallEvent.Direction + 22, // 104: signalservice.SyncMessage.CallEvent.event:type_name -> signalservice.SyncMessage.CallEvent.Event + 23, // 105: signalservice.SyncMessage.CallLogEvent.type:type_name -> signalservice.SyncMessage.CallLogEvent.Type + 106, // [106:106] is the sub-list for method output_type + 106, // [106:106] is the sub-list for method input_type + 106, // [106:106] is the sub-list for extension type_name + 106, // [106:106] is the sub-list for extension extendee + 0, // [0:106] is the sub-list for field type_name } func init() { file_SignalService_proto_init() } @@ -9635,101 +8573,935 @@ func file_SignalService_proto_init() { if File_SignalService_proto != nil { return } - file_SignalService_proto_msgTypes[1].OneofWrappers = []any{ - (*Content_DataMessage)(nil), - (*Content_SyncMessage)(nil), - (*Content_CallMessage)(nil), - (*Content_NullMessage)(nil), - (*Content_ReceiptMessage)(nil), - (*Content_TypingMessage)(nil), - (*Content_DecryptionErrorMessage)(nil), - (*Content_StoryMessage)(nil), - (*Content_EditMessage)(nil), + if !protoimpl.UnsafeEnabled { + file_SignalService_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Envelope); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Content); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CallMessage); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BodyRange); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DataMessage); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*NullMessage); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReceiptMessage); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TypingMessage); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StoryMessage); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Preview); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TextAttachment); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Verified); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SyncMessage); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AttachmentPointer); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupContext); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupContextV2); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ContactDetails); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupDetails); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PaymentAddress); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DecryptionErrorMessage); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PniSignatureMessage); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*EditMessage); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CallMessage_Offer); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CallMessage_Answer); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CallMessage_IceUpdate); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CallMessage_Busy); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[26].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CallMessage_Hangup); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[27].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CallMessage_Opaque); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[28].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DataMessage_Quote); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[29].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DataMessage_Contact); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[30].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DataMessage_Sticker); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[31].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DataMessage_Reaction); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[32].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DataMessage_Delete); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[33].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DataMessage_GroupCallUpdate); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[34].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DataMessage_StoryContext); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[35].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DataMessage_Payment); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[36].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DataMessage_GiftBadge); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[37].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DataMessage_Quote_QuotedAttachment); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[38].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DataMessage_Contact_Name); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[39].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DataMessage_Contact_Phone); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[40].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DataMessage_Contact_Email); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[41].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DataMessage_Contact_PostalAddress); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[42].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DataMessage_Contact_Avatar); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[43].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DataMessage_Payment_Amount); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[44].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DataMessage_Payment_Notification); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[45].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DataMessage_Payment_Activation); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[46].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DataMessage_Payment_Amount_MobileCoin); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[47].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DataMessage_Payment_Notification_MobileCoin); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[48].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TextAttachment_Gradient); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[49].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SyncMessage_Sent); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[50].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SyncMessage_Contacts); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[51].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SyncMessage_Blocked); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[52].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SyncMessage_Request); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[53].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SyncMessage_Read); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[54].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SyncMessage_Viewed); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[55].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SyncMessage_Configuration); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[56].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SyncMessage_StickerPackOperation); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[57].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SyncMessage_ViewOnceOpen); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[58].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SyncMessage_FetchLatest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[59].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SyncMessage_Keys); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[60].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SyncMessage_MessageRequestResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[61].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SyncMessage_OutgoingPayment); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[62].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SyncMessage_PniChangeNumber); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[63].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SyncMessage_CallEvent); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[64].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SyncMessage_CallLinkUpdate); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[65].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SyncMessage_CallLogEvent); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[66].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SyncMessage_Sent_UnidentifiedDeliveryStatus); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[67].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SyncMessage_Sent_StoryMessageRecipient); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[68].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SyncMessage_OutgoingPayment_MobileCoin); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[69].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupContext_Member); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[70].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ContactDetails_Avatar); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[71].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupDetails_Avatar); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[72].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GroupDetails_Member); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_SignalService_proto_msgTypes[73].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PaymentAddress_MobileCoinAddress); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } - file_SignalService_proto_msgTypes[7].OneofWrappers = []any{ + file_SignalService_proto_msgTypes[3].OneofWrappers = []interface{}{ + (*BodyRange_MentionAci)(nil), + (*BodyRange_Style_)(nil), + } + file_SignalService_proto_msgTypes[8].OneofWrappers = []interface{}{ (*StoryMessage_FileAttachment)(nil), (*StoryMessage_TextAttachment)(nil), } - file_SignalService_proto_msgTypes[9].OneofWrappers = []any{ + file_SignalService_proto_msgTypes[10].OneofWrappers = []interface{}{ (*TextAttachment_Gradient_)(nil), (*TextAttachment_Color)(nil), } - file_SignalService_proto_msgTypes[11].OneofWrappers = []any{ - (*SyncMessage_Sent_)(nil), - (*SyncMessage_Contacts_)(nil), - (*SyncMessage_Request_)(nil), - (*SyncMessage_Blocked_)(nil), - (*SyncMessage_Verified)(nil), - (*SyncMessage_Configuration_)(nil), - (*SyncMessage_ViewOnceOpen_)(nil), - (*SyncMessage_FetchLatest_)(nil), - (*SyncMessage_Keys_)(nil), - (*SyncMessage_MessageRequestResponse_)(nil), - (*SyncMessage_OutgoingPayment_)(nil), - (*SyncMessage_PniChangeNumber_)(nil), - (*SyncMessage_CallEvent_)(nil), - (*SyncMessage_CallLinkUpdate_)(nil), - (*SyncMessage_CallLogEvent_)(nil), - (*SyncMessage_DeleteForMe_)(nil), - (*SyncMessage_DeviceNameChange_)(nil), - (*SyncMessage_AttachmentBackfillRequest_)(nil), - (*SyncMessage_AttachmentBackfillResponse_)(nil), - } - file_SignalService_proto_msgTypes[12].OneofWrappers = []any{ + file_SignalService_proto_msgTypes[13].OneofWrappers = []interface{}{ (*AttachmentPointer_CdnId)(nil), (*AttachmentPointer_CdnKey)(nil), } - file_SignalService_proto_msgTypes[15].OneofWrappers = []any{ - (*PaymentAddress_MobileCoin_)(nil), + file_SignalService_proto_msgTypes[18].OneofWrappers = []interface{}{ + (*PaymentAddress_MobileCoinAddress_)(nil), } - file_SignalService_proto_msgTypes[19].OneofWrappers = []any{ - (*BodyRange_MentionAci)(nil), - (*BodyRange_Style_)(nil), - (*BodyRange_MentionAciBinary)(nil), - } - file_SignalService_proto_msgTypes[20].OneofWrappers = []any{ - (*AddressableMessage_AuthorServiceId)(nil), - (*AddressableMessage_AuthorE164)(nil), - (*AddressableMessage_AuthorServiceIdBinary)(nil), - } - file_SignalService_proto_msgTypes[21].OneofWrappers = []any{ - (*ConversationIdentifier_ThreadServiceId)(nil), - (*ConversationIdentifier_ThreadGroupId)(nil), - (*ConversationIdentifier_ThreadE164)(nil), - (*ConversationIdentifier_ThreadServiceIdBinary)(nil), - } - file_SignalService_proto_msgTypes[28].OneofWrappers = []any{ + file_SignalService_proto_msgTypes[35].OneofWrappers = []interface{}{ (*DataMessage_Payment_Notification_)(nil), (*DataMessage_Payment_Activation_)(nil), } - file_SignalService_proto_msgTypes[40].OneofWrappers = []any{ - (*DataMessage_PinMessage_PinDurationSeconds)(nil), - (*DataMessage_PinMessage_PinDurationForever)(nil), - } - file_SignalService_proto_msgTypes[43].OneofWrappers = []any{ + file_SignalService_proto_msgTypes[43].OneofWrappers = []interface{}{ (*DataMessage_Payment_Amount_MobileCoin_)(nil), } - file_SignalService_proto_msgTypes[44].OneofWrappers = []any{ + file_SignalService_proto_msgTypes[44].OneofWrappers = []interface{}{ (*DataMessage_Payment_Notification_MobileCoin_)(nil), } - file_SignalService_proto_msgTypes[68].OneofWrappers = []any{ + file_SignalService_proto_msgTypes[61].OneofWrappers = []interface{}{ (*SyncMessage_OutgoingPayment_MobileCoin_)(nil), } - file_SignalService_proto_msgTypes[76].OneofWrappers = []any{ - (*SyncMessage_AttachmentBackfillResponse_Attachments)(nil), - (*SyncMessage_AttachmentBackfillResponse_Error_)(nil), - } - file_SignalService_proto_msgTypes[84].OneofWrappers = []any{ - (*SyncMessage_AttachmentBackfillResponse_AttachmentData_Attachment)(nil), - (*SyncMessage_AttachmentBackfillResponse_AttachmentData_Status_)(nil), - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_SignalService_proto_rawDesc), len(file_SignalService_proto_rawDesc)), - NumEnums: 28, - NumMessages: 88, + RawDescriptor: file_SignalService_proto_rawDesc, + NumEnums: 26, + NumMessages: 74, NumExtensions: 0, NumServices: 0, }, @@ -9739,6 +9511,7 @@ func file_SignalService_proto_init() { MessageInfos: file_SignalService_proto_msgTypes, }.Build() File_SignalService_proto = out.File + file_SignalService_proto_rawDesc = nil file_SignalService_proto_goTypes = nil file_SignalService_proto_depIdxs = nil } diff --git a/pkg/signalmeow/protobuf/SignalService.proto b/pkg/signalmeow/protobuf/SignalService.proto index 0089a16..3fccc00 100644 --- a/pkg/signalmeow/protobuf/SignalService.proto +++ b/pkg/signalmeow/protobuf/SignalService.proto @@ -1,150 +1,90 @@ -/* - * Copyright 2020-2022 Signal Messenger, LLC - * SPDX-License-Identifier: AGPL-3.0-only +/** + * Copyright (C) 2014-2016 Open Whisper Systems + * + * Licensed according to the LICENSE file in this repository. */ - syntax = "proto2"; package signalservice; -option java_package = "org.whispersystems.signalservice.internal.push"; +option java_package = "org.whispersystems.signalservice.internal.push"; option java_outer_classname = "SignalServiceProtos"; message Envelope { enum Type { - UNKNOWN = 0; - - /** - * A double-ratchet message represents a "normal," "unsealed-sender" message - * encrypted using the Double Ratchet within an established Signal session. - * Double-ratchet messages include sender information in the plaintext - * portion of the `Envelope`. - */ - DOUBLE_RATCHET = 1; // content => (version byte | SignalMessage{Content}) - - reserved 2; - reserved "KEY_EXCHANGE"; - - /** - * A prekey message begins a new Signal session. The `content` of a prekey - * message is a superset of a double-ratchet message's `content` and - * contains the sender's identity public key and information identifying the - * pre-keys used in the message's ciphertext. Like double-ratchet messages, - * prekey messages contain sender information in the plaintext portion of - * the `Envelope`. - */ - PREKEY_MESSAGE = 3; // content => (version byte | PreKeySignalMessage{Content}) - - /** - * Server delivery receipts are generated by the server when - * "unsealed-sender" messages are delivered to and acknowledged by the - * destination device. Server delivery receipts identify the sender in the - * plaintext portion of the `Envelope` and have no `content`. Note that - * receipts for sealed-sender messages are generated by clients as - * `UNIDENTIFIED_SENDER` messages. - * - * Note that, with server delivery receipts, the "client timestamp" on - * the envelope refers to the timestamp of the original message (i.e. the - * message the server just delivered) and not to the time of delivery. The - * "server timestamp" refers to the time of delivery. - */ - SERVER_DELIVERY_RECEIPT = 5; // content => [] - - /** - * An unidentified sender message represents a message with no sender - * information in the plaintext portion of the `Envelope`. Unidentified - * sender messages always contain an additional `subtype` in their - * `content`. They may or may not be part of an existing Signal session - * (i.e. an unidentified sender message may have a "prekey message" - * subtype or may indicate an encryption error). - */ - UNIDENTIFIED_SENDER = 6; // content => ((version byte | UnidentifiedSenderMessage) OR (version byte | Multi-Recipient Sealed Sender Format)) - - reserved 7; - reserved "SENDERKEY_MESSAGE"; - - /** - * A plaintext message is used solely to convey encryption error receipts - * and never contains encrypted message content. Encryption error receipts - * must be delivered in plaintext because, encryption/decryption of a prior - * message failed and there is no reason to believe that - * encryption/decryption of subsequent messages with the same key material - * would succeed. - * - * Critically, plaintext messages never have "real" message content - * generated by users. Plaintext messages include sender information. - */ - PLAINTEXT_CONTENT = 8; // content => (marker byte | Content) - - // next: 9 + UNKNOWN = 0; + CIPHERTEXT = 1; + KEY_EXCHANGE = 2; + PREKEY_BUNDLE = 3; + RECEIPT = 5; + UNIDENTIFIED_SENDER = 6; + reserved 7; // SENDERKEY_MESSAGE + PLAINTEXT_CONTENT = 8; } - optional Type type = 1; - reserved 2; // formerly optional string sourceE164 = 2; - optional string sourceServiceId = 11; - optional uint32 sourceDeviceId = 7; + optional Type type = 1; + reserved /*sourceE164*/ 2; + optional string sourceServiceId = 11; + optional uint32 sourceDevice = 7; optional string destinationServiceId = 13; - reserved 3; // formerly optional string relay = 3; - optional uint64 clientTimestamp = 5; - reserved 6; // formerly optional bytes legacyMessage = 6; // Contains an encrypted DataMessage; this field could have been set historically for type 1 or 3 messages; no longer in use - optional bytes content = 8; // Contains an encrypted Content - optional string serverGuid = 9; - optional uint64 serverTimestamp = 10; - optional bool ephemeral = 12; // indicates that the message should not be persisted if the recipient is offline - optional bool urgent = 14 [default = true]; // indicates that the content is considered timely by the sender; defaults to true so senders have to opt-out to say something isn't time critical - optional string updatedPni = 15; // for number-change synchronization messages, provides the new server-assigned phone number identifier associated with the changed number - optional bool story = 16; // indicates that the content is a story. - optional bytes report_spam_token = 17; // token sent when reporting spam - reserved 18; // internal server use - optional bytes sourceServiceIdBinary = 19; // service ID binary (i.e. 16 byte UUID for ACI, 1 byte prefix + 16 byte UUID for PNI) - optional bytes destinationServiceIdBinary = 20; // service ID binary (i.e. 16 byte UUID for ACI, 1 byte prefix + 16 byte UUID for PNI) - optional bytes serverGuidBinary = 21; // 16-byte UUID - optional bytes updatedPniBinary = 22; // 16-byte UUID - // next: 22 + reserved /*relay*/ 3; + optional uint64 timestamp = 5; + reserved /*legacyMessage*/ 6; + optional bytes content = 8; // Contains an encrypted Content + optional string serverGuid = 9; + optional uint64 serverTimestamp = 10; + optional bool urgent = 14 [default = true]; + reserved /*updatedPni*/ 15; // Not used presently, may be used in the future + optional bool story = 16; + optional bytes reportingToken = 17; + // NEXT ID: 18 } message Content { - oneof content { - DataMessage dataMessage = 1; - SyncMessage syncMessage = 2; - CallMessage callMessage = 3; - NullMessage nullMessage = 4; - ReceiptMessage receiptMessage = 5; - TypingMessage typingMessage = 6; - bytes /* DecryptionErrorMessage */ decryptionErrorMessage = 8; - StoryMessage storyMessage = 9; - EditMessage editMessage = 11; - } - - optional bytes /* SenderKeyDistributionMessage */ senderKeyDistributionMessage = 7; - optional PniSignatureMessage pniSignatureMessage = 10; + optional DataMessage dataMessage = 1; + optional SyncMessage syncMessage = 2; + optional CallMessage callMessage = 3; + optional NullMessage nullMessage = 4; + optional ReceiptMessage receiptMessage = 5; + optional TypingMessage typingMessage = 6; + optional bytes senderKeyDistributionMessage = 7; + optional bytes decryptionErrorMessage = 8; + optional StoryMessage storyMessage = 9; + optional PniSignatureMessage pniSignatureMessage = 10; + optional EditMessage editMessage = 11; } message CallMessage { message Offer { enum Type { - OFFER_AUDIO_CALL = 0; - OFFER_VIDEO_CALL = 1; - reserved /* OFFER_NEED_PERMISSION */ 2; // removed + OFFER_AUDIO_CALL = 0; + OFFER_VIDEO_CALL = 1; + reserved /* OFFER_NEED_PERMISSION */ 2; // removed } - optional uint64 id = 1; - reserved /* sdp */ 2; - optional Type type = 3; - optional bytes opaque = 4; + + optional uint64 id = 1; + // Legacy/deprecated; replaced by 'opaque' + optional string sdp = 2; + optional Type type = 3; + optional bytes opaque = 4; } message Answer { - optional uint64 id = 1; - reserved /* sdp */ 2; - optional bytes opaque = 3; + optional uint64 id = 1; + // Legacy/deprecated; replaced by 'opaque' + optional string sdp = 2; + optional bytes opaque = 3; } message IceUpdate { - optional uint64 id = 1; - reserved /* mid */ 2; - reserved /* line */ 3; - reserved /* sdp */ 4; - optional bytes opaque = 5; + optional uint64 id = 1; + // Legacy/deprecated; remove when old clients are gone. + optional string mid = 2; + // Legacy/deprecated; remove when old clients are gone. + optional uint32 line = 3; + // Legacy/deprecated; replaced by 'opaque' + optional string sdp = 4; + optional bytes opaque = 5; } message Busy { @@ -153,50 +93,187 @@ message CallMessage { message Hangup { enum Type { - HANGUP_NORMAL = 0; - HANGUP_ACCEPTED = 1; - HANGUP_DECLINED = 2; - HANGUP_BUSY = 3; + HANGUP_NORMAL = 0; + HANGUP_ACCEPTED = 1; + HANGUP_DECLINED = 2; + HANGUP_BUSY = 3; HANGUP_NEED_PERMISSION = 4; } - optional uint64 id = 1; - optional Type type = 2; + + optional uint64 id = 1; + optional Type type = 2; optional uint32 deviceId = 3; } message Opaque { enum Urgency { - DROPPABLE = 0; + DROPPABLE = 0; HANDLE_IMMEDIATELY = 1; } - optional bytes data = 1; - optional Urgency urgency = 2; // If missing, treat as DROPPABLE. + + optional bytes data = 1; + optional Urgency urgency = 2; } - optional Offer offer = 1; - optional Answer answer = 2; - repeated IceUpdate iceUpdate = 3; - reserved /* legacyHangup */ 4; - optional Busy busy = 5; - reserved /* profileKey */ 6; - optional Hangup hangup = 7; - reserved /* multiRing */ 8; - optional uint32 destinationDeviceId = 9; - optional Opaque opaque = 10; + optional Offer offer = 1; + optional Answer answer = 2; + repeated IceUpdate iceUpdate = 3; + optional Hangup legacyHangup = 4; + optional Busy busy = 5; + reserved /* profileKey */ 6; + optional Hangup hangup = 7; + reserved /* multiRing */ 8; + optional uint32 destinationDeviceId = 9; + optional Opaque opaque = 10; +} + +message BodyRange { + enum Style { + NONE = 0; + BOLD = 1; + ITALIC = 2; + SPOILER = 3; + STRIKETHROUGH = 4; + MONOSPACE = 5; + } + + optional uint32 start = 1; + optional uint32 length = 2; + + oneof associatedValue { + string mentionAci = 3; + Style style = 4; + } } message DataMessage { enum Flags { - END_SESSION = 1; + END_SESSION = 1; EXPIRATION_TIMER_UPDATE = 2; - PROFILE_KEY_UPDATE = 4; - FORWARD = 8; + PROFILE_KEY_UPDATE = 4; + } + + message Quote { + enum Type { + NORMAL = 0; + GIFT_BADGE = 1; + } + + message QuotedAttachment { + optional string contentType = 1; + optional string fileName = 2; + optional AttachmentPointer thumbnail = 3; + } + + optional uint64 id = 1; + reserved /*authorE164*/ 2; + optional string authorAci = 5; + optional string text = 3; + repeated QuotedAttachment attachments = 4; + repeated BodyRange bodyRanges = 6; + optional Type type = 7; + } + + message Contact { + message Name { + optional string givenName = 1; + optional string familyName = 2; + optional string prefix = 3; + optional string suffix = 4; + optional string middleName = 5; + optional string displayName = 6; + } + + message Phone { + enum Type { + HOME = 1; + MOBILE = 2; + WORK = 3; + CUSTOM = 4; + } + + optional string value = 1; + optional Type type = 2; + optional string label = 3; + } + + message Email { + enum Type { + HOME = 1; + MOBILE = 2; + WORK = 3; + CUSTOM = 4; + } + + optional string value = 1; + optional Type type = 2; + optional string label = 3; + } + + message PostalAddress { + enum Type { + HOME = 1; + WORK = 2; + CUSTOM = 3; + } + + optional Type type = 1; + optional string label = 2; + optional string street = 3; + optional string pobox = 4; + optional string neighborhood = 5; + optional string city = 6; + optional string region = 7; + optional string postcode = 8; + optional string country = 9; + } + + message Avatar { + optional AttachmentPointer avatar = 1; + optional bool isProfile = 2; + } + + optional Name name = 1; + repeated Phone number = 3; + repeated Email email = 4; + repeated PostalAddress address = 5; + optional Avatar avatar = 6; + optional string organization = 7; + } + + message Sticker { + optional bytes packId = 1; + optional bytes packKey = 2; + optional uint32 stickerId = 3; + optional AttachmentPointer data = 4; + optional string emoji = 5; + } + + message Reaction { + optional string emoji = 1; + optional bool remove = 2; + reserved /*targetAuthorE164*/ 3; + optional string targetAuthorAci = 4; + optional uint64 targetSentTimestamp = 5; + } + + message Delete { + optional uint64 targetSentTimestamp = 1; + } + + message GroupCallUpdate { + optional string eraId = 1; + } + + message StoryContext { + optional string authorAci = 1; + optional uint64 sentTimestamp = 2; } message Payment { message Amount { message MobileCoin { - optional uint64 picoMob = 1; // 1,000,000,000,000 picoMob per Mob + optional uint64 picoMob = 1; } oneof Amount { @@ -213,14 +290,13 @@ message DataMessage { MobileCoin mobileCoin = 1; } - // Optional, Refers to the PaymentRequest message, if any. optional string note = 2; reserved /*requestId*/ 1003; } message Activation { enum Type { - REQUEST = 0; + REQUEST = 0; ACTIVATED = 1; } @@ -229,219 +305,52 @@ message DataMessage { oneof Item { Notification notification = 1; - Activation activation = 2; + Activation activation = 2; } - reserved /*request*/ 1002; + reserved /*request*/ 1002; reserved /*cancellation*/ 1003; } - message Quote { - enum Type { - NORMAL = 0; - GIFT_BADGE = 1; - POLL = 2; - } - - message QuotedAttachment { - optional string contentType = 1; - optional string fileName = 2; - optional AttachmentPointer thumbnail = 3; - } - - optional uint64 id = 1; - reserved /*authorE164*/ 2; - optional string authorAci = 5; - optional string text = 3; - repeated QuotedAttachment attachments = 4; - repeated BodyRange bodyRanges = 6; - optional Type type = 7; - optional bytes authorAciBinary = 8; // 16-byte UUID - } - - message Contact { - message Name { - optional string givenName = 1; - optional string familyName = 2; - optional string prefix = 3; - optional string suffix = 4; - optional string middleName = 5; - reserved /*displayName*/ 6; - optional string nickname = 7; - } - - message Phone { - enum Type { - HOME = 1; - MOBILE = 2; - WORK = 3; - CUSTOM = 4; - } - - optional string value = 1; - optional Type type = 2; - optional string label = 3; - } - - message Email { - enum Type { - HOME = 1; - MOBILE = 2; - WORK = 3; - CUSTOM = 4; - } - - optional string value = 1; - optional Type type = 2; - optional string label = 3; - } - - message PostalAddress { - enum Type { - HOME = 1; - WORK = 2; - CUSTOM = 3; - } - - optional Type type = 1; - optional string label = 2; - optional string street = 3; - optional string pobox = 4; - optional string neighborhood = 5; - optional string city = 6; - optional string region = 7; - optional string postcode = 8; - optional string country = 9; - } - - message Avatar { - optional AttachmentPointer avatar = 1; - optional bool isProfile = 2; - } - - optional Name name = 1; - repeated Phone number = 3; - repeated Email email = 4; - repeated PostalAddress address = 5; - optional Avatar avatar = 6; - optional string organization = 7; - } - - message Sticker { - optional bytes packId = 1; - optional bytes packKey = 2; - optional uint32 stickerId = 3; - optional AttachmentPointer data = 4; - optional string emoji = 5; - } - - message Reaction { - optional string emoji = 1; - optional bool remove = 2; - reserved /* targetAuthorE164 */ 3; - optional string targetAuthorAci = 4; - optional uint64 targetSentTimestamp = 5; - optional bytes targetAuthorAciBinary = 6; // 16-byte UUID - } - - message Delete { - optional uint64 targetSentTimestamp = 1; - } - - message GroupCallUpdate { - optional string eraId = 1; - } - - message StoryContext { - optional string authorAci = 1; - optional uint64 sentTimestamp = 2; - optional bytes authorAciBinary = 3; // 16-byte UUID - } - - enum ProtocolVersion { - option allow_alias = true; - - INITIAL = 0; - MESSAGE_TIMERS = 1; - VIEW_ONCE = 2; - VIEW_ONCE_VIDEO = 3; - REACTIONS = 4; - CDN_SELECTOR_ATTACHMENTS = 5; - MENTIONS = 6; - PAYMENTS = 7; - POLLS = 8; - CURRENT = 8; - } - message GiftBadge { optional bytes receiptCredentialPresentation = 1; } - message PollCreate { - optional string question = 1; - optional bool allowMultiple = 2; - repeated string options = 3; + enum ProtocolVersion { + option allow_alias = true; + + INITIAL = 0; + MESSAGE_TIMERS = 1; + VIEW_ONCE = 2; + VIEW_ONCE_VIDEO = 3; + REACTIONS = 4; + CDN_SELECTOR_ATTACHMENTS = 5; + MENTIONS = 6; + PAYMENTS = 7; + CURRENT = 7; } - message PollTerminate { - optional uint64 targetSentTimestamp = 1; - } - - message PollVote { - optional bytes targetAuthorAciBinary = 1; - optional uint64 targetSentTimestamp = 2; - repeated uint32 optionIndexes = 3; - optional uint32 voteCount = 4; - } - - message PinMessage { - optional bytes targetAuthorAciBinary = 1; // 16-byte UUID - optional uint64 targetSentTimestamp = 2; - oneof pinDuration { - uint32 pinDurationSeconds = 3; - bool pinDurationForever = 4; - } - } - - message UnpinMessage { - optional bytes targetAuthorAciBinary = 1; // 16-byte UUID - optional uint64 targetSentTimestamp = 2; - } - - message AdminDelete { - optional bytes targetAuthorAciBinary = 1; // 16-byte UUID - optional uint64 targetSentTimestamp = 2; - } - - optional string body = 1; - repeated AttachmentPointer attachments = 2; - reserved /*groupV1*/ 3; - optional GroupContextV2 groupV2 = 15; - optional uint32 flags = 4; - optional uint32 expireTimer = 5; - optional uint32 expireTimerVersion = 23; - optional bytes profileKey = 6; - optional uint64 timestamp = 7; - optional Quote quote = 8; - repeated Contact contact = 9; - repeated Preview preview = 10; - optional Sticker sticker = 11; - optional uint32 requiredProtocolVersion = 12; - optional bool isViewOnce = 14; - optional Reaction reaction = 16; - optional Delete delete = 17; - repeated BodyRange bodyRanges = 18; - optional GroupCallUpdate groupCallUpdate = 19; - optional Payment payment = 20; - optional StoryContext storyContext = 21; - optional GiftBadge giftBadge = 22; - optional PollCreate pollCreate = 24; - optional PollTerminate pollTerminate = 25; - optional PollVote pollVote = 26; - optional PinMessage pinMessage = 27; - optional UnpinMessage unpinMessage = 28; - optional AdminDelete adminDelete = 29; - // NEXT ID: 30 + optional string body = 1; + repeated AttachmentPointer attachments = 2; + reserved /*groupV1*/ 3; + optional GroupContextV2 groupV2 = 15; + optional uint32 flags = 4; + optional uint32 expireTimer = 5; + optional bytes profileKey = 6; + optional uint64 timestamp = 7; + optional Quote quote = 8; + repeated Contact contact = 9; + repeated Preview preview = 10; + optional Sticker sticker = 11; + optional uint32 requiredProtocolVersion = 12; + optional bool isViewOnce = 14; + optional Reaction reaction = 16; + optional Delete delete = 17; + repeated BodyRange bodyRanges = 18; + optional GroupCallUpdate groupCallUpdate = 19; + optional Payment payment = 20; + optional StoryContext storyContext = 21; + optional GiftBadge giftBadge = 22; } message NullMessage { @@ -451,200 +360,181 @@ message NullMessage { message ReceiptMessage { enum Type { DELIVERY = 0; - READ = 1; - VIEWED = 2; + READ = 1; + VIEWED = 2; } - optional Type type = 1; + optional Type type = 1; repeated uint64 timestamp = 2; } message TypingMessage { - enum Action { - STARTED = 0; - STOPPED = 1; - } + enum Action { + STARTED = 0; + STOPPED = 1; + } - optional uint64 timestamp = 1; - optional Action action = 2; - optional bytes groupId = 3; + optional uint64 timestamp = 1; + optional Action action = 2; + optional bytes groupId = 3; } message StoryMessage { - optional bytes profileKey = 1; - optional GroupContextV2 group = 2; + optional bytes profileKey = 1; + optional GroupContextV2 group = 2; oneof attachment { AttachmentPointer fileAttachment = 3; - TextAttachment textAttachment = 4; + TextAttachment textAttachment = 4; } - optional bool allowsReplies = 5; - repeated BodyRange bodyRanges = 6; + optional bool allowsReplies = 5; + repeated BodyRange bodyRanges = 6; } message Preview { - optional string url = 1; - optional string title = 2; - optional AttachmentPointer image = 3; - optional string description = 4; - optional uint64 date = 5; + optional string url = 1; + optional string title = 2; + optional AttachmentPointer image = 3; + optional string description = 4; + optional uint64 date = 5; } message TextAttachment { enum Style { - DEFAULT = 0; - REGULAR = 1; - BOLD = 2; - SERIF = 3; - SCRIPT = 4; + DEFAULT = 0; + REGULAR = 1; + BOLD = 2; + SERIF = 3; + SCRIPT = 4; CONDENSED = 5; } message Gradient { - // Color ordering: - // 0 degrees: bottom-to-top - // 90 degrees: left-to-right - // 180 degrees: top-to-bottom - // 270 degrees: right-to-left - optional uint32 startColor = 1; // deprecated: this field will be removed in a future release. - optional uint32 endColor = 2; // deprecated: this field will be removed in a future release. - optional uint32 angle = 3; // degrees - repeated uint32 colors = 4; - repeated float positions = 5; // percent from 0 to 1 + optional uint32 endColor = 2; // deprecated: this field will be removed in a future release. + optional uint32 angle = 3; // degrees + repeated uint32 colors = 4; + repeated float positions = 5; // percent from 0 to 1 } - optional string text = 1; - optional Style textStyle = 2; - optional uint32 textForegroundColor = 3; // integer representation of hex color - optional uint32 textBackgroundColor = 4; - optional Preview preview = 5; + optional string text = 1; + optional Style textStyle = 2; + optional uint32 textForegroundColor = 3; // integer representation of hex color + optional uint32 textBackgroundColor = 4; + optional Preview preview = 5; oneof background { Gradient gradient = 6; - uint32 color = 7; + uint32 color = 7; } } message Verified { enum State { - DEFAULT = 0; - VERIFIED = 1; + DEFAULT = 0; + VERIFIED = 1; UNVERIFIED = 2; } - reserved /*destinationE164*/ 1; - optional string destinationAci = 5; - optional bytes identityKey = 2; - optional State state = 3; - optional bytes nullMessage = 4; - optional bytes destinationAciBinary = 6; // 16-byte UUID + reserved /*destinationE164*/ 1; + optional string destinationAci = 5; + optional bytes identityKey = 2; + optional State state = 3; + optional bytes nullMessage = 4; } message SyncMessage { message Sent { message UnidentifiedDeliveryStatus { - reserved /*destinationE164*/ 1; + reserved /*destinationE164*/ 1; optional string destinationServiceId = 3; - optional bool unidentified = 2; - reserved /*destinationPni */ 4; - optional bytes destinationPniIdentityKey = 5; // Only set for PNI destinations - optional bytes destinationServiceIdBinary = 6; // service ID binary (i.e. 16 byte UUID for ACI, 1 byte prefix + 16 byte UUID for PNI) + optional bool unidentified = 2; } message StoryMessageRecipient { optional string destinationServiceId = 1; - repeated string distributionListIds = 2; - optional bool isAllowedToReply = 3; - reserved /*destinationPni */ 4; - optional bytes destinationServiceIdBinary = 5; // service ID binary (i.e. 16 byte UUID for ACI, 1 byte prefix + 16 byte UUID for PNI) + repeated string distributionListIds = 2; + optional bool isAllowedToReply = 3; } - optional string destinationE164 = 1; - optional string destinationServiceId = 7; - optional uint64 timestamp = 2; - optional DataMessage message = 3; - optional uint64 expirationStartTimestamp = 4; - repeated UnidentifiedDeliveryStatus unidentifiedStatus = 5; - optional bool isRecipientUpdate = 6 [default = false]; - optional StoryMessage storyMessage = 8; - repeated StoryMessageRecipient storyMessageRecipients = 9; - optional EditMessage editMessage = 10; - reserved /*destinationPni */ 11; - optional bytes destinationServiceIdBinary = 12; // service ID binary (i.e. 16 byte UUID for ACI, 1 byte prefix + 16 byte UUID for PNI) - // Next ID: 13 + optional string destinationE164 = 1; + optional string destinationServiceId = 7; + optional uint64 timestamp = 2; + optional DataMessage message = 3; + optional uint64 expirationStartTimestamp = 4; + repeated UnidentifiedDeliveryStatus unidentifiedStatus = 5; + optional bool isRecipientUpdate = 6 [default = false]; + optional StoryMessage storyMessage = 8; + repeated StoryMessageRecipient storyMessageRecipients = 9; + optional EditMessage editMessage = 10; } message Contacts { - optional AttachmentPointer blob = 1; - optional bool complete = 2 [default = false]; + optional AttachmentPointer blob = 1; + optional bool complete = 2 [default = false]; } message Blocked { - repeated string numbers = 1; - repeated string acis = 3; - repeated bytes groupIds = 2; - repeated bytes acisBinary = 4; // 16-byte UUID + repeated string numbers = 1; + repeated string acis = 3; + repeated bytes groupIds = 2; } message Request { enum Type { - UNKNOWN = 0; - CONTACTS = 1; - reserved /*GROUPS*/ 2; - BLOCKED = 3; + UNKNOWN = 0; + CONTACTS = 1; +// GROUPS = 2; + BLOCKED = 3; CONFIGURATION = 4; - KEYS = 5; - reserved /*PNI_IDENTITY*/ 6; + KEYS = 5; + PNI_IDENTITY = 6; } optional Type type = 1; } message Read { - reserved /*senderE164*/ 1; - optional string senderAci = 3; - optional uint64 timestamp = 2; - optional bytes senderAciBinary = 4; // 16-byte UUID + reserved /*senderE164*/ 1; + optional string senderAci = 3; + optional uint64 timestamp = 2; } message Viewed { - reserved /*senderE164*/ 1; - optional string senderAci = 3; - optional uint64 timestamp = 2; - optional bytes senderAciBinary = 4; // 16-byte UUID + reserved /*senderE164*/ 1; + optional string senderAci = 3; + optional uint64 timestamp = 2; } message Configuration { - optional bool readReceipts = 1; - optional bool unidentifiedDeliveryIndicators = 2; - optional bool typingIndicators = 3; - reserved /* linkPreviews */ 4; - reserved /* provisioningVersion */ 5; - optional bool linkPreviews = 6; + optional bool readReceipts = 1; + optional bool unidentifiedDeliveryIndicators = 2; + optional bool typingIndicators = 3; + reserved /* linkPreviews */ 4; + optional uint32 provisioningVersion = 5; + optional bool linkPreviews = 6; } message StickerPackOperation { enum Type { INSTALL = 0; - REMOVE = 1; + REMOVE = 1; } - optional bytes packId = 1; + optional bytes packId = 1; optional bytes packKey = 2; - optional Type type = 3; + optional Type type = 3; } message ViewOnceOpen { - reserved /*senderE164*/ 1; - optional string senderAci = 3; - optional uint64 timestamp = 2; - optional bytes senderAciBinary = 4; // 16-byte UUID + reserved /*senderE164*/ 1; + optional string senderAci = 3; + optional uint64 timestamp = 2; } message FetchLatest { enum Type { - UNKNOWN = 0; - LOCAL_PROFILE = 1; - STORAGE_MANIFEST = 2; + UNKNOWN = 0; + LOCAL_PROFILE = 1; + STORAGE_MANIFEST = 2; SUBSCRIPTION_STATUS = 3; } @@ -652,365 +542,249 @@ message SyncMessage { } message Keys { - reserved /* storageService */ 1; - reserved /* master */ 2; - optional string accountEntropyPool = 3; - optional bytes mediaRootBackupKey = 4; - } - - message PniIdentity { - optional bytes publicKey = 1; - optional bytes privateKey = 2; + // @deprecated + optional bytes storageService = 1; + optional bytes master = 2; } message MessageRequestResponse { enum Type { - UNKNOWN = 0; - ACCEPT = 1; - DELETE = 2; - BLOCK = 3; + UNKNOWN = 0; + ACCEPT = 1; + DELETE = 2; + BLOCK = 3; BLOCK_AND_DELETE = 4; - SPAM = 5; - BLOCK_AND_SPAM = 6; } - reserved /*threadE164*/ 1; - optional string threadAci = 2; - optional bytes groupId = 3; - optional Type type = 4; - optional bytes threadAciBinary = 5; // 16-byte UUID + reserved /*threadE164*/ 1; + optional string threadAci = 2; + optional bytes groupId = 3; + optional Type type = 4; } message OutgoingPayment { message MobileCoin { - optional bytes recipientAddress = 1; - optional uint64 amountPicoMob = 2; - optional uint64 feePicoMob = 3; - optional bytes receipt = 4; + optional bytes recipientAddress = 1; + // @required + optional uint64 amountPicoMob = 2; + // @required + optional uint64 feePicoMob = 3; + optional bytes receipt = 4; optional uint64 ledgerBlockTimestamp = 5; - optional uint64 ledgerBlockIndex = 6; - repeated bytes spentKeyImages = 7; - repeated bytes outputPublicKeys = 8; + // @required + optional uint64 ledgerBlockIndex = 6; + repeated bytes spentKeyImages = 7; + repeated bytes outputPublicKeys = 8; } optional string recipientServiceId = 1; - optional string note = 2; - oneof attachment_identifier { + optional string note = 2; + + oneof paymentDetail { MobileCoin mobileCoin = 3; } } message PniChangeNumber { - optional bytes identityKeyPair = 1; // Serialized libsignal-client IdentityKeyPair - optional bytes signedPreKey = 2; // Serialized libsignal-client SignedPreKeyRecord - optional bytes lastResortKyberPreKey = 5; // Serialized libsignal-client KyberPreKeyRecord - optional uint32 registrationId = 3; - optional string newE164 = 4; // The e164 we have changed our number to + optional bytes identityKeyPair = 1; // Serialized libsignal-client IdentityKeyPair + optional bytes signedPreKey = 2; // Serialized libsignal-client SignedPreKeyRecord + optional bytes lastResortKyberPreKey = 5; // Serialized libsignal-client KyberPreKeyRecord + optional uint32 registrationId = 3; + optional string newE164 = 4; // The e164 we have changed our number to // Next ID: 6 } message CallEvent { enum Type { UNKNOWN_TYPE = 0; - AUDIO_CALL = 1; - VIDEO_CALL = 2; - GROUP_CALL = 3; - AD_HOC_CALL = 4; + AUDIO_CALL = 1; + VIDEO_CALL = 2; + GROUP_CALL = 3; + AD_HOC_CALL = 4; } enum Direction { UNKNOWN_DIRECTION = 0; - INCOMING = 1; - OUTGOING = 2; + INCOMING = 1; + OUTGOING = 2; } enum Event { - UNKNOWN_EVENT = 0; - ACCEPTED = 1; - NOT_ACCEPTED = 2; - DELETE = 3; - OBSERVED = 4; + UNKNOWN_ACTION = 0; + ACCEPTED = 1; + NOT_ACCEPTED = 2; + DELETE = 3; } - /* Data identifying a conversation. The service ID for 1:1, the group ID for - * group, or the room ID for an ad-hoc call. See also - * `CallLogEvent/conversationId`. */ - optional bytes conversationId = 1; - /* An identifier for a call. Generated directly for 1:1, or derived from - * the era ID for group and ad-hoc calls. See also `CallLogEvent/callId`. */ - optional uint64 callId = 2; - optional uint64 timestamp = 3; - optional Type type = 4; - optional Direction direction = 5; - optional Event event = 6; + optional bytes conversationId = 1; + optional uint64 id = 2; + optional uint64 timestamp = 3; + optional Type type = 4; + optional Direction direction = 5; + optional Event event = 6; } message CallLinkUpdate { - enum Type { - UPDATE = 0; - reserved 1; // was DELETE, superseded by storage service - } - - optional bytes rootKey = 1; - optional bytes adminPasskey = 2; - optional Type type = 3; // defaults to UPDATE - reserved /*epoch*/ 4; + optional bytes rootKey = 1; + optional bytes adminPassKey = 2; } message CallLogEvent { enum Type { CLEAR = 0; - MARKED_AS_READ = 1; - MARKED_AS_READ_IN_CONVERSATION = 2; - CLEAR_IN_CONVERSATION = 3; } - optional Type type = 1; + optional Type type = 1; optional uint64 timestamp = 2; - /* Data identifying a conversation. The service ID for 1:1, the group ID for - * group, or the room ID for an ad-hoc call. See also - * `CallEvent/conversationId`. */ - optional bytes conversationId = 3; - /* An identifier for a call. Generated directly for 1:1, or derived from - * the era ID for group and ad-hoc calls. See also `CallEvent/callId`. */ - optional uint64 callId = 4; } - message DeleteForMe { - message MessageDeletes { - optional ConversationIdentifier conversation = 1; - repeated AddressableMessage messages = 2; - } - - message AttachmentDelete { - optional ConversationIdentifier conversation = 1; - optional AddressableMessage targetMessage = 2; - // The `clientUuid` from `AttachmentPointer`. - optional bytes clientUuid = 3; - // SHA256 hash of the (encrypted, padded, etc.) attachment blob on the CDN. - optional bytes fallbackDigest = 4; - // SHA256 hash of the plaintext content of the attachment. - optional bytes fallbackPlaintextHash = 5; - } - - message ConversationDelete { - optional ConversationIdentifier conversation = 1; - repeated AddressableMessage mostRecentMessages = 2; - optional bool isFullDelete = 3; - repeated AddressableMessage mostRecentNonExpiringMessages = 4; - } - - message LocalOnlyConversationDelete { - optional ConversationIdentifier conversation = 1; - } - - repeated MessageDeletes messageDeletes = 1; - repeated ConversationDelete conversationDeletes = 2; - repeated LocalOnlyConversationDelete localOnlyConversationDeletes = 3; - repeated AttachmentDelete attachmentDeletes = 4; - } - - message DeviceNameChange { - reserved /*name*/ 1; - optional uint32 deviceId = 2; - } - - message AttachmentBackfillRequest { - optional AddressableMessage targetMessage = 1; - optional ConversationIdentifier targetConversation = 2; - } - - message AttachmentBackfillResponse { - message AttachmentData { - enum Status { - PENDING = 0; - TERMINAL_ERROR = 1; - } - - oneof data { - AttachmentPointer attachment = 1; - Status status = 2; - } - } - - enum Error { - MESSAGE_NOT_FOUND = 0; - } - - message AttachmentDataList { - repeated AttachmentData attachments = 1; - optional AttachmentData longText = 2; - } - - optional AddressableMessage targetMessage = 1; - optional ConversationIdentifier targetConversation = 2; - - oneof data { - AttachmentDataList attachments = 3; - Error error = 4; - } - } - - oneof content { - Sent sent = 1; - Contacts contacts = 2; - Request request = 4; - Blocked blocked = 6; - Verified verified = 7; - Configuration configuration = 9; - ViewOnceOpen viewOnceOpen = 11; - FetchLatest fetchLatest = 12; - Keys keys = 13; - MessageRequestResponse messageRequestResponse = 14; - OutgoingPayment outgoingPayment = 15; - PniChangeNumber pniChangeNumber = 18; - CallEvent callEvent = 19; - CallLinkUpdate callLinkUpdate = 20; - CallLogEvent callLogEvent = 21; - DeleteForMe deleteForMe = 22; - DeviceNameChange deviceNameChange = 23; - AttachmentBackfillRequest attachmentBackfillRequest = 24; - AttachmentBackfillResponse attachmentBackfillResponse = 25; - } - - reserved /*groups*/ 3; - - // Protobufs don't allow `repeated` fields to be inside of `oneof` so while - // the fields below are mutually exclusive with the rest of the values above - // we have to place them outside of `oneof`. - repeated Read read = 5; - repeated StickerPackOperation stickerPackOperation = 10; - repeated Viewed viewed = 16; - - reserved /*pniIdentity*/ 17; - - optional bytes padding = 8; + optional Sent sent = 1; + optional Contacts contacts = 2; + reserved /*groups*/ 3; + optional Request request = 4; + repeated Read read = 5; + optional Blocked blocked = 6; + optional Verified verified = 7; + optional Configuration configuration = 9; + optional bytes padding = 8; + repeated StickerPackOperation stickerPackOperation = 10; + optional ViewOnceOpen viewOnceOpen = 11; + optional FetchLatest fetchLatest = 12; + optional Keys keys = 13; + optional MessageRequestResponse messageRequestResponse = 14; + optional OutgoingPayment outgoingPayment = 15; + repeated Viewed viewed = 16; + reserved /*pniIdentity*/ 17; + optional PniChangeNumber pniChangeNumber = 18; + optional CallEvent callEvent = 19; + optional CallLinkUpdate callLinkUpdate = 20; + optional CallLogEvent callLogEvent = 21; } message AttachmentPointer { enum Flags { VOICE_MESSAGE = 1; - BORDERLESS = 2; - reserved 4; - GIF = 8; + BORDERLESS = 2; + reserved 3; + GIF = 4; } oneof attachment_identifier { - fixed64 cdnId = 1; - string cdnKey = 15; + fixed64 cdnId = 1; + string cdnKey = 15; } - // Cross-client identifier for this attachment among all attachments on the - // owning message. - optional bytes clientUuid = 20; - optional string contentType = 2; - optional bytes key = 3; - optional uint32 size = 4; - optional bytes thumbnail = 5; - optional bytes digest = 6; - reserved /* incrementalMac with implicit chunk sizing */ 16; - reserved /* incrementalMac for all attachment types */ 18; - optional bytes incrementalMac = 19; - optional uint32 chunkSize = 17; - optional string fileName = 7; - optional uint32 flags = 8; - optional uint32 width = 9; - optional uint32 height = 10; - optional string caption = 11; - optional string blurHash = 12; - optional uint64 uploadTimestamp = 13; - optional uint32 cdnNumber = 14; - // Next ID: 21 + optional string contentType = 2; + optional bytes key = 3; + optional uint32 size = 4; + optional bytes thumbnail = 5; + optional bytes digest = 6; + reserved 16; + optional bytes incrementalMac = 18; + optional uint32 incrementalMacChunkSize = 17; + optional string fileName = 7; + optional uint32 flags = 8; + optional uint32 width = 9; + optional uint32 height = 10; + optional string caption = 11; + optional string blurHash = 12; + optional uint64 uploadTimestamp = 13; + optional uint32 cdnNumber = 14; + // Next ID: 19 +} + +message GroupContext { + enum Type { + UNKNOWN = 0; + UPDATE = 1; + DELIVER = 2; + QUIT = 3; + REQUEST_INFO = 4; + } + + message Member { + reserved /* uuid */ 1; // removed + optional string e164 = 2; + } + + optional bytes id = 1; + optional Type type = 2; + optional string name = 3; + repeated string membersE164 = 4; + repeated Member members = 6; + optional AttachmentPointer avatar = 5; } message GroupContextV2 { - optional bytes masterKey = 1; - optional uint32 revision = 2; - optional bytes groupChange = 3; + optional bytes masterKey = 1; + optional uint32 revision = 2; + optional bytes groupChange = 3; } message ContactDetails { message Avatar { optional string contentType = 1; - optional uint32 length = 2; + optional uint32 length = 2; } - optional string number = 1; - optional string aci = 9; - optional bytes aciBinary = 13; // 16-byte UUID - optional string name = 2; - optional Avatar avatar = 3; - reserved /* color */ 4; - reserved /* verified */ 5; - reserved /* profileKey */ 6; - reserved /* blocked */ 7; - optional uint32 expireTimer = 8; - optional uint32 expireTimerVersion = 12; + optional string number = 1; + optional string aci = 9; + optional string name = 2; + optional Avatar avatar = 3; + optional string color = 4; + optional Verified verified = 5; + optional bytes profileKey = 6; + optional bool blocked = 7; + optional uint32 expireTimer = 8; + optional uint32 inboxPosition = 10; + optional bool archived = 11; +} + +message GroupDetails { + message Avatar { + optional string contentType = 1; + optional uint32 length = 2; + } + + message Member { + reserved /* uuid */ 1; // removed + optional string e164 = 2; + } + + optional bytes id = 1; + optional string name = 2; + repeated string membersE164 = 3; + repeated Member members = 9; + optional Avatar avatar = 4; + optional bool active = 5 [default = true]; + optional uint32 expireTimer = 6; + optional string color = 7; + optional bool blocked = 8; optional uint32 inboxPosition = 10; - reserved /* archived */ 11; - // NEXT ID: 14 + optional bool archived = 11; } message PaymentAddress { - message MobileCoin { - optional bytes publicAddress = 1; - optional bytes signature = 2; + oneof Address { + MobileCoinAddress mobileCoinAddress = 1; } - oneof Address { - MobileCoin mobileCoin = 1; + message MobileCoinAddress { + optional bytes address = 1; + optional bytes signature = 2; } } message DecryptionErrorMessage { - optional bytes ratchetKey = 1; // set to the public ratchet key from the SignalMessage if a 1-1 payload fails to decrypt - optional uint64 timestamp = 2; - optional uint32 deviceId = 3; + optional bytes ratchetKey = 1; + optional uint64 timestamp = 2; + optional uint32 deviceId = 3; } message PniSignatureMessage { - optional bytes pni = 1; - // Signature *by* the PNI identity key *of* the ACI identity key + optional bytes pni = 1; optional bytes signature = 2; } message EditMessage { - optional uint64 targetSentTimestamp = 1; - optional DataMessage dataMessage = 2; -} - -message BodyRange { - enum Style { - NONE = 0; - BOLD = 1; - ITALIC = 2; - SPOILER = 3; - STRIKETHROUGH = 4; - MONOSPACE = 5; - } - - optional uint32 start = 1; // Starting index in UTF-16 code units/raw string representation - optional uint32 length = 2; // Length of range in UTF-16 code units/raw string representation - - oneof associatedValue { - string mentionAci = 3; - Style style = 4; - bytes mentionAciBinary = 5; // 16-byte UUID - } -} - -message AddressableMessage { - oneof author { - string authorServiceId = 1; - string authorE164 = 2; - bytes authorServiceIdBinary = 4; // service ID binary (i.e. 16 byte UUID for ACI, 1 byte prefix + 16 byte UUID for PNI) - } - optional uint64 sentTimestamp = 3; -} - -message ConversationIdentifier { - oneof identifier { - string threadServiceId = 1; - bytes threadGroupId = 2; - string threadE164 = 3; - bytes threadServiceIdBinary = 4; // service ID binary (i.e. 16 byte UUID for ACI, 1 byte prefix + 16 byte UUID for PNI) - } + optional uint64 targetSentTimestamp = 1; + optional DataMessage dataMessage = 2; } diff --git a/pkg/signalmeow/protobuf/StickerResources.pb.go b/pkg/signalmeow/protobuf/StickerResources.pb.go index f8194aa..34f48be 100644 --- a/pkg/signalmeow/protobuf/StickerResources.pb.go +++ b/pkg/signalmeow/protobuf/StickerResources.pb.go @@ -5,8 +5,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.11 -// protoc v7.34.1 +// protoc-gen-go v1.31.0 +// protoc v3.21.12 // source: StickerResources.proto package signalpb @@ -16,7 +16,6 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" - unsafe "unsafe" ) const ( @@ -27,20 +26,23 @@ const ( ) type Pack struct { - state protoimpl.MessageState `protogen:"open.v1"` - Title *string `protobuf:"bytes,1,opt,name=title" json:"title,omitempty"` - Author *string `protobuf:"bytes,2,opt,name=author" json:"author,omitempty"` - Cover *Pack_Sticker `protobuf:"bytes,3,opt,name=cover" json:"cover,omitempty"` - Stickers []*Pack_Sticker `protobuf:"bytes,4,rep,name=stickers" json:"stickers,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Title *string `protobuf:"bytes,1,opt,name=title" json:"title,omitempty"` + Author *string `protobuf:"bytes,2,opt,name=author" json:"author,omitempty"` + Cover *Pack_Sticker `protobuf:"bytes,3,opt,name=cover" json:"cover,omitempty"` + Stickers []*Pack_Sticker `protobuf:"bytes,4,rep,name=stickers" json:"stickers,omitempty"` } func (x *Pack) Reset() { *x = Pack{} - mi := &file_StickerResources_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_StickerResources_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *Pack) String() string { @@ -51,7 +53,7 @@ func (*Pack) ProtoMessage() {} func (x *Pack) ProtoReflect() protoreflect.Message { mi := &file_StickerResources_proto_msgTypes[0] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -95,19 +97,22 @@ func (x *Pack) GetStickers() []*Pack_Sticker { } type Pack_Sticker struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id *uint32 `protobuf:"varint,1,opt,name=id" json:"id,omitempty"` - Emoji *string `protobuf:"bytes,2,opt,name=emoji" json:"emoji,omitempty"` - ContentType *string `protobuf:"bytes,3,opt,name=contentType" json:"contentType,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id *uint32 `protobuf:"varint,1,opt,name=id" json:"id,omitempty"` + Emoji *string `protobuf:"bytes,2,opt,name=emoji" json:"emoji,omitempty"` + ContentType *string `protobuf:"bytes,3,opt,name=contentType" json:"contentType,omitempty"` } func (x *Pack_Sticker) Reset() { *x = Pack_Sticker{} - mi := &file_StickerResources_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_StickerResources_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *Pack_Sticker) String() string { @@ -118,7 +123,7 @@ func (*Pack_Sticker) ProtoMessage() {} func (x *Pack_Sticker) ProtoReflect() protoreflect.Message { mi := &file_StickerResources_proto_msgTypes[1] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -156,34 +161,46 @@ func (x *Pack_Sticker) GetContentType() string { var File_StickerResources_proto protoreflect.FileDescriptor -const file_StickerResources_proto_rawDesc = "" + - "\n" + - "\x16StickerResources.proto\x12\rsignalservice\"\xf3\x01\n" + - "\x04Pack\x12\x14\n" + - "\x05title\x18\x01 \x01(\tR\x05title\x12\x16\n" + - "\x06author\x18\x02 \x01(\tR\x06author\x121\n" + - "\x05cover\x18\x03 \x01(\v2\x1b.signalservice.Pack.StickerR\x05cover\x127\n" + - "\bstickers\x18\x04 \x03(\v2\x1b.signalservice.Pack.StickerR\bstickers\x1aQ\n" + - "\aSticker\x12\x0e\n" + - "\x02id\x18\x01 \x01(\rR\x02id\x12\x14\n" + - "\x05emoji\x18\x02 \x01(\tR\x05emoji\x12 \n" + - "\vcontentType\x18\x03 \x01(\tR\vcontentTypeBB\n" + - "1org.whispersystems.signalservice.internal.stickerB\rStickerProtos" +var file_StickerResources_proto_rawDesc = []byte{ + 0x0a, 0x16, 0x53, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x72, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0d, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x22, 0xf3, 0x01, 0x0a, 0x04, 0x50, 0x61, 0x63, 0x6b, + 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x12, 0x31, + 0x0a, 0x05, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, + 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x50, 0x61, + 0x63, 0x6b, 0x2e, 0x53, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x72, 0x52, 0x05, 0x63, 0x6f, 0x76, 0x65, + 0x72, 0x12, 0x37, 0x0a, 0x08, 0x73, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x18, 0x04, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x2e, 0x53, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x72, + 0x52, 0x08, 0x73, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x1a, 0x51, 0x0a, 0x07, 0x53, 0x74, + 0x69, 0x63, 0x6b, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0d, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x6f, 0x6a, 0x69, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x6f, 0x6a, 0x69, 0x12, 0x20, 0x0a, 0x0b, 0x63, + 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x42, 0x42, 0x0a, + 0x31, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x68, 0x69, 0x73, 0x70, 0x65, 0x72, 0x73, 0x79, 0x73, 0x74, + 0x65, 0x6d, 0x73, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x73, 0x74, 0x69, 0x63, 0x6b, + 0x65, 0x72, 0x42, 0x0d, 0x53, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x73, +} var ( file_StickerResources_proto_rawDescOnce sync.Once - file_StickerResources_proto_rawDescData []byte + file_StickerResources_proto_rawDescData = file_StickerResources_proto_rawDesc ) func file_StickerResources_proto_rawDescGZIP() []byte { file_StickerResources_proto_rawDescOnce.Do(func() { - file_StickerResources_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_StickerResources_proto_rawDesc), len(file_StickerResources_proto_rawDesc))) + file_StickerResources_proto_rawDescData = protoimpl.X.CompressGZIP(file_StickerResources_proto_rawDescData) }) return file_StickerResources_proto_rawDescData } var file_StickerResources_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_StickerResources_proto_goTypes = []any{ +var file_StickerResources_proto_goTypes = []interface{}{ (*Pack)(nil), // 0: signalservice.Pack (*Pack_Sticker)(nil), // 1: signalservice.Pack.Sticker } @@ -202,11 +219,37 @@ func file_StickerResources_proto_init() { if File_StickerResources_proto != nil { return } + if !protoimpl.UnsafeEnabled { + file_StickerResources_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Pack); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_StickerResources_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Pack_Sticker); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_StickerResources_proto_rawDesc), len(file_StickerResources_proto_rawDesc)), + RawDescriptor: file_StickerResources_proto_rawDesc, NumEnums: 0, NumMessages: 2, NumExtensions: 0, @@ -217,6 +260,7 @@ func file_StickerResources_proto_init() { MessageInfos: file_StickerResources_proto_msgTypes, }.Build() File_StickerResources_proto = out.File + file_StickerResources_proto_rawDesc = nil file_StickerResources_proto_goTypes = nil file_StickerResources_proto_depIdxs = nil } diff --git a/pkg/signalmeow/protobuf/StorageService.pb.go b/pkg/signalmeow/protobuf/StorageService.pb.go deleted file mode 100644 index bbe88ef..0000000 --- a/pkg/signalmeow/protobuf/StorageService.pb.go +++ /dev/null @@ -1,3580 +0,0 @@ -//* -// Copyright (C) 2019 Open Whisper Systems -// -// Licensed according to the LICENSE file in this repository. - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.11 -// protoc v7.34.1 -// source: StorageService.proto - -package signalpb - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type OptionalBool int32 - -const ( - OptionalBool_UNSET OptionalBool = 0 - OptionalBool_ENABLED OptionalBool = 1 - OptionalBool_DISABLED OptionalBool = 2 -) - -// Enum value maps for OptionalBool. -var ( - OptionalBool_name = map[int32]string{ - 0: "UNSET", - 1: "ENABLED", - 2: "DISABLED", - } - OptionalBool_value = map[string]int32{ - "UNSET": 0, - "ENABLED": 1, - "DISABLED": 2, - } -) - -func (x OptionalBool) Enum() *OptionalBool { - p := new(OptionalBool) - *p = x - return p -} - -func (x OptionalBool) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (OptionalBool) Descriptor() protoreflect.EnumDescriptor { - return file_StorageService_proto_enumTypes[0].Descriptor() -} - -func (OptionalBool) Type() protoreflect.EnumType { - return &file_StorageService_proto_enumTypes[0] -} - -func (x OptionalBool) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use OptionalBool.Descriptor instead. -func (OptionalBool) EnumDescriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{0} -} - -// If unset - computed as the value of the first byte of SHA-256(msg=CONTACT_ID) -// modulo the count of colors. Once set the avatar color for a recipient is -// never recomputed or changed. -// -// `CONTACT_ID` is the first available identifier from the list: -// - ServiceIdToBinary(ACI) -// - E164 -// - ServiceIdToBinary(PNI) -// - Group Id -type AvatarColor int32 - -const ( - AvatarColor_A100 AvatarColor = 0 - AvatarColor_A110 AvatarColor = 1 - AvatarColor_A120 AvatarColor = 2 - AvatarColor_A130 AvatarColor = 3 - AvatarColor_A140 AvatarColor = 4 - AvatarColor_A150 AvatarColor = 5 - AvatarColor_A160 AvatarColor = 6 - AvatarColor_A170 AvatarColor = 7 - AvatarColor_A180 AvatarColor = 8 - AvatarColor_A190 AvatarColor = 9 - AvatarColor_A200 AvatarColor = 10 - AvatarColor_A210 AvatarColor = 11 -) - -// Enum value maps for AvatarColor. -var ( - AvatarColor_name = map[int32]string{ - 0: "A100", - 1: "A110", - 2: "A120", - 3: "A130", - 4: "A140", - 5: "A150", - 6: "A160", - 7: "A170", - 8: "A180", - 9: "A190", - 10: "A200", - 11: "A210", - } - AvatarColor_value = map[string]int32{ - "A100": 0, - "A110": 1, - "A120": 2, - "A130": 3, - "A140": 4, - "A150": 5, - "A160": 6, - "A170": 7, - "A180": 8, - "A190": 9, - "A200": 10, - "A210": 11, - } -) - -func (x AvatarColor) Enum() *AvatarColor { - p := new(AvatarColor) - *p = x - return p -} - -func (x AvatarColor) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (AvatarColor) Descriptor() protoreflect.EnumDescriptor { - return file_StorageService_proto_enumTypes[1].Descriptor() -} - -func (AvatarColor) Type() protoreflect.EnumType { - return &file_StorageService_proto_enumTypes[1] -} - -func (x AvatarColor) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use AvatarColor.Descriptor instead. -func (AvatarColor) EnumDescriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{1} -} - -type ManifestRecord_Identifier_Type int32 - -const ( - ManifestRecord_Identifier_UNKNOWN ManifestRecord_Identifier_Type = 0 - ManifestRecord_Identifier_CONTACT ManifestRecord_Identifier_Type = 1 - ManifestRecord_Identifier_GROUPV1 ManifestRecord_Identifier_Type = 2 - ManifestRecord_Identifier_GROUPV2 ManifestRecord_Identifier_Type = 3 - ManifestRecord_Identifier_ACCOUNT ManifestRecord_Identifier_Type = 4 - ManifestRecord_Identifier_STORY_DISTRIBUTION_LIST ManifestRecord_Identifier_Type = 5 - ManifestRecord_Identifier_CALL_LINK ManifestRecord_Identifier_Type = 7 - ManifestRecord_Identifier_CHAT_FOLDER ManifestRecord_Identifier_Type = 8 - ManifestRecord_Identifier_NOTIFICATION_PROFILE ManifestRecord_Identifier_Type = 9 -) - -// Enum value maps for ManifestRecord_Identifier_Type. -var ( - ManifestRecord_Identifier_Type_name = map[int32]string{ - 0: "UNKNOWN", - 1: "CONTACT", - 2: "GROUPV1", - 3: "GROUPV2", - 4: "ACCOUNT", - 5: "STORY_DISTRIBUTION_LIST", - 7: "CALL_LINK", - 8: "CHAT_FOLDER", - 9: "NOTIFICATION_PROFILE", - } - ManifestRecord_Identifier_Type_value = map[string]int32{ - "UNKNOWN": 0, - "CONTACT": 1, - "GROUPV1": 2, - "GROUPV2": 3, - "ACCOUNT": 4, - "STORY_DISTRIBUTION_LIST": 5, - "CALL_LINK": 7, - "CHAT_FOLDER": 8, - "NOTIFICATION_PROFILE": 9, - } -) - -func (x ManifestRecord_Identifier_Type) Enum() *ManifestRecord_Identifier_Type { - p := new(ManifestRecord_Identifier_Type) - *p = x - return p -} - -func (x ManifestRecord_Identifier_Type) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (ManifestRecord_Identifier_Type) Descriptor() protoreflect.EnumDescriptor { - return file_StorageService_proto_enumTypes[2].Descriptor() -} - -func (ManifestRecord_Identifier_Type) Type() protoreflect.EnumType { - return &file_StorageService_proto_enumTypes[2] -} - -func (x ManifestRecord_Identifier_Type) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use ManifestRecord_Identifier_Type.Descriptor instead. -func (ManifestRecord_Identifier_Type) EnumDescriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{5, 0, 0} -} - -type ContactRecord_IdentityState int32 - -const ( - ContactRecord_DEFAULT ContactRecord_IdentityState = 0 - ContactRecord_VERIFIED ContactRecord_IdentityState = 1 - ContactRecord_UNVERIFIED ContactRecord_IdentityState = 2 -) - -// Enum value maps for ContactRecord_IdentityState. -var ( - ContactRecord_IdentityState_name = map[int32]string{ - 0: "DEFAULT", - 1: "VERIFIED", - 2: "UNVERIFIED", - } - ContactRecord_IdentityState_value = map[string]int32{ - "DEFAULT": 0, - "VERIFIED": 1, - "UNVERIFIED": 2, - } -) - -func (x ContactRecord_IdentityState) Enum() *ContactRecord_IdentityState { - p := new(ContactRecord_IdentityState) - *p = x - return p -} - -func (x ContactRecord_IdentityState) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (ContactRecord_IdentityState) Descriptor() protoreflect.EnumDescriptor { - return file_StorageService_proto_enumTypes[3].Descriptor() -} - -func (ContactRecord_IdentityState) Type() protoreflect.EnumType { - return &file_StorageService_proto_enumTypes[3] -} - -func (x ContactRecord_IdentityState) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use ContactRecord_IdentityState.Descriptor instead. -func (ContactRecord_IdentityState) EnumDescriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{7, 0} -} - -type GroupV2Record_StorySendMode int32 - -const ( - GroupV2Record_DEFAULT GroupV2Record_StorySendMode = 0 - GroupV2Record_DISABLED GroupV2Record_StorySendMode = 1 - GroupV2Record_ENABLED GroupV2Record_StorySendMode = 2 -) - -// Enum value maps for GroupV2Record_StorySendMode. -var ( - GroupV2Record_StorySendMode_name = map[int32]string{ - 0: "DEFAULT", - 1: "DISABLED", - 2: "ENABLED", - } - GroupV2Record_StorySendMode_value = map[string]int32{ - "DEFAULT": 0, - "DISABLED": 1, - "ENABLED": 2, - } -) - -func (x GroupV2Record_StorySendMode) Enum() *GroupV2Record_StorySendMode { - p := new(GroupV2Record_StorySendMode) - *p = x - return p -} - -func (x GroupV2Record_StorySendMode) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (GroupV2Record_StorySendMode) Descriptor() protoreflect.EnumDescriptor { - return file_StorageService_proto_enumTypes[4].Descriptor() -} - -func (GroupV2Record_StorySendMode) Type() protoreflect.EnumType { - return &file_StorageService_proto_enumTypes[4] -} - -func (x GroupV2Record_StorySendMode) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use GroupV2Record_StorySendMode.Descriptor instead. -func (GroupV2Record_StorySendMode) EnumDescriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{9, 0} -} - -type AccountRecord_PhoneNumberSharingMode int32 - -const ( - AccountRecord_UNKNOWN AccountRecord_PhoneNumberSharingMode = 0 - AccountRecord_EVERYBODY AccountRecord_PhoneNumberSharingMode = 1 - AccountRecord_NOBODY AccountRecord_PhoneNumberSharingMode = 2 -) - -// Enum value maps for AccountRecord_PhoneNumberSharingMode. -var ( - AccountRecord_PhoneNumberSharingMode_name = map[int32]string{ - 0: "UNKNOWN", - 1: "EVERYBODY", - 2: "NOBODY", - } - AccountRecord_PhoneNumberSharingMode_value = map[string]int32{ - "UNKNOWN": 0, - "EVERYBODY": 1, - "NOBODY": 2, - } -) - -func (x AccountRecord_PhoneNumberSharingMode) Enum() *AccountRecord_PhoneNumberSharingMode { - p := new(AccountRecord_PhoneNumberSharingMode) - *p = x - return p -} - -func (x AccountRecord_PhoneNumberSharingMode) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (AccountRecord_PhoneNumberSharingMode) Descriptor() protoreflect.EnumDescriptor { - return file_StorageService_proto_enumTypes[5].Descriptor() -} - -func (AccountRecord_PhoneNumberSharingMode) Type() protoreflect.EnumType { - return &file_StorageService_proto_enumTypes[5] -} - -func (x AccountRecord_PhoneNumberSharingMode) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use AccountRecord_PhoneNumberSharingMode.Descriptor instead. -func (AccountRecord_PhoneNumberSharingMode) EnumDescriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{11, 0} -} - -type AccountRecord_UsernameLink_Color int32 - -const ( - AccountRecord_UsernameLink_UNKNOWN AccountRecord_UsernameLink_Color = 0 - AccountRecord_UsernameLink_BLUE AccountRecord_UsernameLink_Color = 1 - AccountRecord_UsernameLink_WHITE AccountRecord_UsernameLink_Color = 2 - AccountRecord_UsernameLink_GREY AccountRecord_UsernameLink_Color = 3 - AccountRecord_UsernameLink_OLIVE AccountRecord_UsernameLink_Color = 4 - AccountRecord_UsernameLink_GREEN AccountRecord_UsernameLink_Color = 5 - AccountRecord_UsernameLink_ORANGE AccountRecord_UsernameLink_Color = 6 - AccountRecord_UsernameLink_PINK AccountRecord_UsernameLink_Color = 7 - AccountRecord_UsernameLink_PURPLE AccountRecord_UsernameLink_Color = 8 -) - -// Enum value maps for AccountRecord_UsernameLink_Color. -var ( - AccountRecord_UsernameLink_Color_name = map[int32]string{ - 0: "UNKNOWN", - 1: "BLUE", - 2: "WHITE", - 3: "GREY", - 4: "OLIVE", - 5: "GREEN", - 6: "ORANGE", - 7: "PINK", - 8: "PURPLE", - } - AccountRecord_UsernameLink_Color_value = map[string]int32{ - "UNKNOWN": 0, - "BLUE": 1, - "WHITE": 2, - "GREY": 3, - "OLIVE": 4, - "GREEN": 5, - "ORANGE": 6, - "PINK": 7, - "PURPLE": 8, - } -) - -func (x AccountRecord_UsernameLink_Color) Enum() *AccountRecord_UsernameLink_Color { - p := new(AccountRecord_UsernameLink_Color) - *p = x - return p -} - -func (x AccountRecord_UsernameLink_Color) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (AccountRecord_UsernameLink_Color) Descriptor() protoreflect.EnumDescriptor { - return file_StorageService_proto_enumTypes[6].Descriptor() -} - -func (AccountRecord_UsernameLink_Color) Type() protoreflect.EnumType { - return &file_StorageService_proto_enumTypes[6] -} - -func (x AccountRecord_UsernameLink_Color) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use AccountRecord_UsernameLink_Color.Descriptor instead. -func (AccountRecord_UsernameLink_Color) EnumDescriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{11, 1, 0} -} - -// Represents the default "All chats" folder record vs all other custom folders -type ChatFolderRecord_FolderType int32 - -const ( - ChatFolderRecord_UNKNOWN ChatFolderRecord_FolderType = 0 - ChatFolderRecord_ALL ChatFolderRecord_FolderType = 1 - ChatFolderRecord_CUSTOM ChatFolderRecord_FolderType = 2 -) - -// Enum value maps for ChatFolderRecord_FolderType. -var ( - ChatFolderRecord_FolderType_name = map[int32]string{ - 0: "UNKNOWN", - 1: "ALL", - 2: "CUSTOM", - } - ChatFolderRecord_FolderType_value = map[string]int32{ - "UNKNOWN": 0, - "ALL": 1, - "CUSTOM": 2, - } -) - -func (x ChatFolderRecord_FolderType) Enum() *ChatFolderRecord_FolderType { - p := new(ChatFolderRecord_FolderType) - *p = x - return p -} - -func (x ChatFolderRecord_FolderType) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (ChatFolderRecord_FolderType) Descriptor() protoreflect.EnumDescriptor { - return file_StorageService_proto_enumTypes[7].Descriptor() -} - -func (ChatFolderRecord_FolderType) Type() protoreflect.EnumType { - return &file_StorageService_proto_enumTypes[7] -} - -func (x ChatFolderRecord_FolderType) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use ChatFolderRecord_FolderType.Descriptor instead. -func (ChatFolderRecord_FolderType) EnumDescriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{15, 0} -} - -type NotificationProfile_DayOfWeek int32 - -const ( - NotificationProfile_UNKNOWN NotificationProfile_DayOfWeek = 0 // Interpret as "Monday" - NotificationProfile_MONDAY NotificationProfile_DayOfWeek = 1 - NotificationProfile_TUESDAY NotificationProfile_DayOfWeek = 2 - NotificationProfile_WEDNESDAY NotificationProfile_DayOfWeek = 3 - NotificationProfile_THURSDAY NotificationProfile_DayOfWeek = 4 - NotificationProfile_FRIDAY NotificationProfile_DayOfWeek = 5 - NotificationProfile_SATURDAY NotificationProfile_DayOfWeek = 6 - NotificationProfile_SUNDAY NotificationProfile_DayOfWeek = 7 -) - -// Enum value maps for NotificationProfile_DayOfWeek. -var ( - NotificationProfile_DayOfWeek_name = map[int32]string{ - 0: "UNKNOWN", - 1: "MONDAY", - 2: "TUESDAY", - 3: "WEDNESDAY", - 4: "THURSDAY", - 5: "FRIDAY", - 6: "SATURDAY", - 7: "SUNDAY", - } - NotificationProfile_DayOfWeek_value = map[string]int32{ - "UNKNOWN": 0, - "MONDAY": 1, - "TUESDAY": 2, - "WEDNESDAY": 3, - "THURSDAY": 4, - "FRIDAY": 5, - "SATURDAY": 6, - "SUNDAY": 7, - } -) - -func (x NotificationProfile_DayOfWeek) Enum() *NotificationProfile_DayOfWeek { - p := new(NotificationProfile_DayOfWeek) - *p = x - return p -} - -func (x NotificationProfile_DayOfWeek) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (NotificationProfile_DayOfWeek) Descriptor() protoreflect.EnumDescriptor { - return file_StorageService_proto_enumTypes[8].Descriptor() -} - -func (NotificationProfile_DayOfWeek) Type() protoreflect.EnumType { - return &file_StorageService_proto_enumTypes[8] -} - -func (x NotificationProfile_DayOfWeek) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use NotificationProfile_DayOfWeek.Descriptor instead. -func (NotificationProfile_DayOfWeek) EnumDescriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{16, 0} -} - -type StorageManifest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Version uint64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` - Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *StorageManifest) Reset() { - *x = StorageManifest{} - mi := &file_StorageService_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *StorageManifest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*StorageManifest) ProtoMessage() {} - -func (x *StorageManifest) ProtoReflect() protoreflect.Message { - mi := &file_StorageService_proto_msgTypes[0] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use StorageManifest.ProtoReflect.Descriptor instead. -func (*StorageManifest) Descriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{0} -} - -func (x *StorageManifest) GetVersion() uint64 { - if x != nil { - return x.Version - } - return 0 -} - -func (x *StorageManifest) GetValue() []byte { - if x != nil { - return x.Value - } - return nil -} - -type StorageItem struct { - state protoimpl.MessageState `protogen:"open.v1"` - Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *StorageItem) Reset() { - *x = StorageItem{} - mi := &file_StorageService_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *StorageItem) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*StorageItem) ProtoMessage() {} - -func (x *StorageItem) ProtoReflect() protoreflect.Message { - mi := &file_StorageService_proto_msgTypes[1] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use StorageItem.ProtoReflect.Descriptor instead. -func (*StorageItem) Descriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{1} -} - -func (x *StorageItem) GetKey() []byte { - if x != nil { - return x.Key - } - return nil -} - -func (x *StorageItem) GetValue() []byte { - if x != nil { - return x.Value - } - return nil -} - -type StorageItems struct { - state protoimpl.MessageState `protogen:"open.v1"` - Items []*StorageItem `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *StorageItems) Reset() { - *x = StorageItems{} - mi := &file_StorageService_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *StorageItems) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*StorageItems) ProtoMessage() {} - -func (x *StorageItems) ProtoReflect() protoreflect.Message { - mi := &file_StorageService_proto_msgTypes[2] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use StorageItems.ProtoReflect.Descriptor instead. -func (*StorageItems) Descriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{2} -} - -func (x *StorageItems) GetItems() []*StorageItem { - if x != nil { - return x.Items - } - return nil -} - -type ReadOperation struct { - state protoimpl.MessageState `protogen:"open.v1"` - ReadKey [][]byte `protobuf:"bytes,1,rep,name=readKey,proto3" json:"readKey,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ReadOperation) Reset() { - *x = ReadOperation{} - mi := &file_StorageService_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ReadOperation) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ReadOperation) ProtoMessage() {} - -func (x *ReadOperation) ProtoReflect() protoreflect.Message { - mi := &file_StorageService_proto_msgTypes[3] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ReadOperation.ProtoReflect.Descriptor instead. -func (*ReadOperation) Descriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{3} -} - -func (x *ReadOperation) GetReadKey() [][]byte { - if x != nil { - return x.ReadKey - } - return nil -} - -type WriteOperation struct { - state protoimpl.MessageState `protogen:"open.v1"` - Manifest *StorageManifest `protobuf:"bytes,1,opt,name=manifest,proto3" json:"manifest,omitempty"` - InsertItem []*StorageItem `protobuf:"bytes,2,rep,name=insertItem,proto3" json:"insertItem,omitempty"` - DeleteKey [][]byte `protobuf:"bytes,3,rep,name=deleteKey,proto3" json:"deleteKey,omitempty"` - ClearAll bool `protobuf:"varint,4,opt,name=clearAll,proto3" json:"clearAll,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *WriteOperation) Reset() { - *x = WriteOperation{} - mi := &file_StorageService_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *WriteOperation) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*WriteOperation) ProtoMessage() {} - -func (x *WriteOperation) ProtoReflect() protoreflect.Message { - mi := &file_StorageService_proto_msgTypes[4] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use WriteOperation.ProtoReflect.Descriptor instead. -func (*WriteOperation) Descriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{4} -} - -func (x *WriteOperation) GetManifest() *StorageManifest { - if x != nil { - return x.Manifest - } - return nil -} - -func (x *WriteOperation) GetInsertItem() []*StorageItem { - if x != nil { - return x.InsertItem - } - return nil -} - -func (x *WriteOperation) GetDeleteKey() [][]byte { - if x != nil { - return x.DeleteKey - } - return nil -} - -func (x *WriteOperation) GetClearAll() bool { - if x != nil { - return x.ClearAll - } - return false -} - -type ManifestRecord struct { - state protoimpl.MessageState `protogen:"open.v1"` - Version uint64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` - SourceDevice uint32 `protobuf:"varint,3,opt,name=sourceDevice,proto3" json:"sourceDevice,omitempty"` - Identifiers []*ManifestRecord_Identifier `protobuf:"bytes,2,rep,name=identifiers,proto3" json:"identifiers,omitempty"` - RecordIkm []byte `protobuf:"bytes,4,opt,name=recordIkm,proto3" json:"recordIkm,omitempty"` // Next ID: 5 - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ManifestRecord) Reset() { - *x = ManifestRecord{} - mi := &file_StorageService_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ManifestRecord) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ManifestRecord) ProtoMessage() {} - -func (x *ManifestRecord) ProtoReflect() protoreflect.Message { - mi := &file_StorageService_proto_msgTypes[5] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ManifestRecord.ProtoReflect.Descriptor instead. -func (*ManifestRecord) Descriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{5} -} - -func (x *ManifestRecord) GetVersion() uint64 { - if x != nil { - return x.Version - } - return 0 -} - -func (x *ManifestRecord) GetSourceDevice() uint32 { - if x != nil { - return x.SourceDevice - } - return 0 -} - -func (x *ManifestRecord) GetIdentifiers() []*ManifestRecord_Identifier { - if x != nil { - return x.Identifiers - } - return nil -} - -func (x *ManifestRecord) GetRecordIkm() []byte { - if x != nil { - return x.RecordIkm - } - return nil -} - -type StorageRecord struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Types that are valid to be assigned to Record: - // - // *StorageRecord_Contact - // *StorageRecord_GroupV1 - // *StorageRecord_GroupV2 - // *StorageRecord_Account - // *StorageRecord_StoryDistributionList - // *StorageRecord_CallLink - // *StorageRecord_ChatFolder - // *StorageRecord_NotificationProfile - Record isStorageRecord_Record `protobuf_oneof:"record"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *StorageRecord) Reset() { - *x = StorageRecord{} - mi := &file_StorageService_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *StorageRecord) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*StorageRecord) ProtoMessage() {} - -func (x *StorageRecord) ProtoReflect() protoreflect.Message { - mi := &file_StorageService_proto_msgTypes[6] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use StorageRecord.ProtoReflect.Descriptor instead. -func (*StorageRecord) Descriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{6} -} - -func (x *StorageRecord) GetRecord() isStorageRecord_Record { - if x != nil { - return x.Record - } - return nil -} - -func (x *StorageRecord) GetContact() *ContactRecord { - if x != nil { - if x, ok := x.Record.(*StorageRecord_Contact); ok { - return x.Contact - } - } - return nil -} - -func (x *StorageRecord) GetGroupV1() *GroupV1Record { - if x != nil { - if x, ok := x.Record.(*StorageRecord_GroupV1); ok { - return x.GroupV1 - } - } - return nil -} - -func (x *StorageRecord) GetGroupV2() *GroupV2Record { - if x != nil { - if x, ok := x.Record.(*StorageRecord_GroupV2); ok { - return x.GroupV2 - } - } - return nil -} - -func (x *StorageRecord) GetAccount() *AccountRecord { - if x != nil { - if x, ok := x.Record.(*StorageRecord_Account); ok { - return x.Account - } - } - return nil -} - -func (x *StorageRecord) GetStoryDistributionList() *StoryDistributionListRecord { - if x != nil { - if x, ok := x.Record.(*StorageRecord_StoryDistributionList); ok { - return x.StoryDistributionList - } - } - return nil -} - -func (x *StorageRecord) GetCallLink() *CallLinkRecord { - if x != nil { - if x, ok := x.Record.(*StorageRecord_CallLink); ok { - return x.CallLink - } - } - return nil -} - -func (x *StorageRecord) GetChatFolder() *ChatFolderRecord { - if x != nil { - if x, ok := x.Record.(*StorageRecord_ChatFolder); ok { - return x.ChatFolder - } - } - return nil -} - -func (x *StorageRecord) GetNotificationProfile() *NotificationProfile { - if x != nil { - if x, ok := x.Record.(*StorageRecord_NotificationProfile); ok { - return x.NotificationProfile - } - } - return nil -} - -type isStorageRecord_Record interface { - isStorageRecord_Record() -} - -type StorageRecord_Contact struct { - Contact *ContactRecord `protobuf:"bytes,1,opt,name=contact,proto3,oneof"` -} - -type StorageRecord_GroupV1 struct { - GroupV1 *GroupV1Record `protobuf:"bytes,2,opt,name=groupV1,proto3,oneof"` -} - -type StorageRecord_GroupV2 struct { - GroupV2 *GroupV2Record `protobuf:"bytes,3,opt,name=groupV2,proto3,oneof"` -} - -type StorageRecord_Account struct { - Account *AccountRecord `protobuf:"bytes,4,opt,name=account,proto3,oneof"` -} - -type StorageRecord_StoryDistributionList struct { - StoryDistributionList *StoryDistributionListRecord `protobuf:"bytes,5,opt,name=storyDistributionList,proto3,oneof"` -} - -type StorageRecord_CallLink struct { - CallLink *CallLinkRecord `protobuf:"bytes,7,opt,name=callLink,proto3,oneof"` -} - -type StorageRecord_ChatFolder struct { - ChatFolder *ChatFolderRecord `protobuf:"bytes,8,opt,name=chatFolder,proto3,oneof"` -} - -type StorageRecord_NotificationProfile struct { - NotificationProfile *NotificationProfile `protobuf:"bytes,9,opt,name=notificationProfile,proto3,oneof"` -} - -func (*StorageRecord_Contact) isStorageRecord_Record() {} - -func (*StorageRecord_GroupV1) isStorageRecord_Record() {} - -func (*StorageRecord_GroupV2) isStorageRecord_Record() {} - -func (*StorageRecord_Account) isStorageRecord_Record() {} - -func (*StorageRecord_StoryDistributionList) isStorageRecord_Record() {} - -func (*StorageRecord_CallLink) isStorageRecord_Record() {} - -func (*StorageRecord_ChatFolder) isStorageRecord_Record() {} - -func (*StorageRecord_NotificationProfile) isStorageRecord_Record() {} - -type ContactRecord struct { - state protoimpl.MessageState `protogen:"open.v1"` - Aci string `protobuf:"bytes,1,opt,name=aci,proto3" json:"aci,omitempty"` - E164 string `protobuf:"bytes,2,opt,name=e164,proto3" json:"e164,omitempty"` - Pni string `protobuf:"bytes,15,opt,name=pni,proto3" json:"pni,omitempty"` - ProfileKey []byte `protobuf:"bytes,3,opt,name=profileKey,proto3" json:"profileKey,omitempty"` - IdentityKey []byte `protobuf:"bytes,4,opt,name=identityKey,proto3" json:"identityKey,omitempty"` - IdentityState ContactRecord_IdentityState `protobuf:"varint,5,opt,name=identityState,proto3,enum=signalservice.ContactRecord_IdentityState" json:"identityState,omitempty"` - GivenName string `protobuf:"bytes,6,opt,name=givenName,proto3" json:"givenName,omitempty"` - FamilyName string `protobuf:"bytes,7,opt,name=familyName,proto3" json:"familyName,omitempty"` - Username string `protobuf:"bytes,8,opt,name=username,proto3" json:"username,omitempty"` - Blocked bool `protobuf:"varint,9,opt,name=blocked,proto3" json:"blocked,omitempty"` - Whitelisted bool `protobuf:"varint,10,opt,name=whitelisted,proto3" json:"whitelisted,omitempty"` - Archived bool `protobuf:"varint,11,opt,name=archived,proto3" json:"archived,omitempty"` - MarkedUnread bool `protobuf:"varint,12,opt,name=markedUnread,proto3" json:"markedUnread,omitempty"` - MutedUntilTimestamp uint64 `protobuf:"varint,13,opt,name=mutedUntilTimestamp,proto3" json:"mutedUntilTimestamp,omitempty"` - HideStory bool `protobuf:"varint,14,opt,name=hideStory,proto3" json:"hideStory,omitempty"` - UnregisteredAtTimestamp uint64 `protobuf:"varint,16,opt,name=unregisteredAtTimestamp,proto3" json:"unregisteredAtTimestamp,omitempty"` - SystemGivenName string `protobuf:"bytes,17,opt,name=systemGivenName,proto3" json:"systemGivenName,omitempty"` - SystemFamilyName string `protobuf:"bytes,18,opt,name=systemFamilyName,proto3" json:"systemFamilyName,omitempty"` - SystemNickname string `protobuf:"bytes,19,opt,name=systemNickname,proto3" json:"systemNickname,omitempty"` - Hidden bool `protobuf:"varint,20,opt,name=hidden,proto3" json:"hidden,omitempty"` - PniSignatureVerified bool `protobuf:"varint,21,opt,name=pniSignatureVerified,proto3" json:"pniSignatureVerified,omitempty"` - Nickname *ContactRecord_Name `protobuf:"bytes,22,opt,name=nickname,proto3" json:"nickname,omitempty"` - Note string `protobuf:"bytes,23,opt,name=note,proto3" json:"note,omitempty"` - AvatarColor *AvatarColor `protobuf:"varint,24,opt,name=avatarColor,proto3,enum=signalservice.AvatarColor,oneof" json:"avatarColor,omitempty"` - AciBinary []byte `protobuf:"bytes,25,opt,name=aciBinary,proto3" json:"aciBinary,omitempty"` // 16-byte UUID - PniBinary []byte `protobuf:"bytes,26,opt,name=pniBinary,proto3" json:"pniBinary,omitempty"` // 16-byte UUID - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ContactRecord) Reset() { - *x = ContactRecord{} - mi := &file_StorageService_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ContactRecord) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ContactRecord) ProtoMessage() {} - -func (x *ContactRecord) ProtoReflect() protoreflect.Message { - mi := &file_StorageService_proto_msgTypes[7] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ContactRecord.ProtoReflect.Descriptor instead. -func (*ContactRecord) Descriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{7} -} - -func (x *ContactRecord) GetAci() string { - if x != nil { - return x.Aci - } - return "" -} - -func (x *ContactRecord) GetE164() string { - if x != nil { - return x.E164 - } - return "" -} - -func (x *ContactRecord) GetPni() string { - if x != nil { - return x.Pni - } - return "" -} - -func (x *ContactRecord) GetProfileKey() []byte { - if x != nil { - return x.ProfileKey - } - return nil -} - -func (x *ContactRecord) GetIdentityKey() []byte { - if x != nil { - return x.IdentityKey - } - return nil -} - -func (x *ContactRecord) GetIdentityState() ContactRecord_IdentityState { - if x != nil { - return x.IdentityState - } - return ContactRecord_DEFAULT -} - -func (x *ContactRecord) GetGivenName() string { - if x != nil { - return x.GivenName - } - return "" -} - -func (x *ContactRecord) GetFamilyName() string { - if x != nil { - return x.FamilyName - } - return "" -} - -func (x *ContactRecord) GetUsername() string { - if x != nil { - return x.Username - } - return "" -} - -func (x *ContactRecord) GetBlocked() bool { - if x != nil { - return x.Blocked - } - return false -} - -func (x *ContactRecord) GetWhitelisted() bool { - if x != nil { - return x.Whitelisted - } - return false -} - -func (x *ContactRecord) GetArchived() bool { - if x != nil { - return x.Archived - } - return false -} - -func (x *ContactRecord) GetMarkedUnread() bool { - if x != nil { - return x.MarkedUnread - } - return false -} - -func (x *ContactRecord) GetMutedUntilTimestamp() uint64 { - if x != nil { - return x.MutedUntilTimestamp - } - return 0 -} - -func (x *ContactRecord) GetHideStory() bool { - if x != nil { - return x.HideStory - } - return false -} - -func (x *ContactRecord) GetUnregisteredAtTimestamp() uint64 { - if x != nil { - return x.UnregisteredAtTimestamp - } - return 0 -} - -func (x *ContactRecord) GetSystemGivenName() string { - if x != nil { - return x.SystemGivenName - } - return "" -} - -func (x *ContactRecord) GetSystemFamilyName() string { - if x != nil { - return x.SystemFamilyName - } - return "" -} - -func (x *ContactRecord) GetSystemNickname() string { - if x != nil { - return x.SystemNickname - } - return "" -} - -func (x *ContactRecord) GetHidden() bool { - if x != nil { - return x.Hidden - } - return false -} - -func (x *ContactRecord) GetPniSignatureVerified() bool { - if x != nil { - return x.PniSignatureVerified - } - return false -} - -func (x *ContactRecord) GetNickname() *ContactRecord_Name { - if x != nil { - return x.Nickname - } - return nil -} - -func (x *ContactRecord) GetNote() string { - if x != nil { - return x.Note - } - return "" -} - -func (x *ContactRecord) GetAvatarColor() AvatarColor { - if x != nil && x.AvatarColor != nil { - return *x.AvatarColor - } - return AvatarColor_A100 -} - -func (x *ContactRecord) GetAciBinary() []byte { - if x != nil { - return x.AciBinary - } - return nil -} - -func (x *ContactRecord) GetPniBinary() []byte { - if x != nil { - return x.PniBinary - } - return nil -} - -type GroupV1Record struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id []byte `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Blocked bool `protobuf:"varint,2,opt,name=blocked,proto3" json:"blocked,omitempty"` - Whitelisted bool `protobuf:"varint,3,opt,name=whitelisted,proto3" json:"whitelisted,omitempty"` - Archived bool `protobuf:"varint,4,opt,name=archived,proto3" json:"archived,omitempty"` - MarkedUnread bool `protobuf:"varint,5,opt,name=markedUnread,proto3" json:"markedUnread,omitempty"` - MutedUntilTimestamp uint64 `protobuf:"varint,6,opt,name=mutedUntilTimestamp,proto3" json:"mutedUntilTimestamp,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupV1Record) Reset() { - *x = GroupV1Record{} - mi := &file_StorageService_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupV1Record) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupV1Record) ProtoMessage() {} - -func (x *GroupV1Record) ProtoReflect() protoreflect.Message { - mi := &file_StorageService_proto_msgTypes[8] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupV1Record.ProtoReflect.Descriptor instead. -func (*GroupV1Record) Descriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{8} -} - -func (x *GroupV1Record) GetId() []byte { - if x != nil { - return x.Id - } - return nil -} - -func (x *GroupV1Record) GetBlocked() bool { - if x != nil { - return x.Blocked - } - return false -} - -func (x *GroupV1Record) GetWhitelisted() bool { - if x != nil { - return x.Whitelisted - } - return false -} - -func (x *GroupV1Record) GetArchived() bool { - if x != nil { - return x.Archived - } - return false -} - -func (x *GroupV1Record) GetMarkedUnread() bool { - if x != nil { - return x.MarkedUnread - } - return false -} - -func (x *GroupV1Record) GetMutedUntilTimestamp() uint64 { - if x != nil { - return x.MutedUntilTimestamp - } - return 0 -} - -type GroupV2Record struct { - state protoimpl.MessageState `protogen:"open.v1"` - MasterKey []byte `protobuf:"bytes,1,opt,name=masterKey,proto3" json:"masterKey,omitempty"` - Blocked bool `protobuf:"varint,2,opt,name=blocked,proto3" json:"blocked,omitempty"` - Whitelisted bool `protobuf:"varint,3,opt,name=whitelisted,proto3" json:"whitelisted,omitempty"` - Archived bool `protobuf:"varint,4,opt,name=archived,proto3" json:"archived,omitempty"` - MarkedUnread bool `protobuf:"varint,5,opt,name=markedUnread,proto3" json:"markedUnread,omitempty"` - MutedUntilTimestamp uint64 `protobuf:"varint,6,opt,name=mutedUntilTimestamp,proto3" json:"mutedUntilTimestamp,omitempty"` - DontNotifyForMentionsIfMuted bool `protobuf:"varint,7,opt,name=dontNotifyForMentionsIfMuted,proto3" json:"dontNotifyForMentionsIfMuted,omitempty"` - HideStory bool `protobuf:"varint,8,opt,name=hideStory,proto3" json:"hideStory,omitempty"` - StorySendMode GroupV2Record_StorySendMode `protobuf:"varint,10,opt,name=storySendMode,proto3,enum=signalservice.GroupV2Record_StorySendMode" json:"storySendMode,omitempty"` - AvatarColor *AvatarColor `protobuf:"varint,11,opt,name=avatarColor,proto3,enum=signalservice.AvatarColor,oneof" json:"avatarColor,omitempty"` - VerifiedNameHash []byte `protobuf:"bytes,12,opt,name=verifiedNameHash,proto3" json:"verifiedNameHash,omitempty"` // SHA-256 of UTF-8 encoded decrypted group title that was last verified - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupV2Record) Reset() { - *x = GroupV2Record{} - mi := &file_StorageService_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupV2Record) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupV2Record) ProtoMessage() {} - -func (x *GroupV2Record) ProtoReflect() protoreflect.Message { - mi := &file_StorageService_proto_msgTypes[9] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupV2Record.ProtoReflect.Descriptor instead. -func (*GroupV2Record) Descriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{9} -} - -func (x *GroupV2Record) GetMasterKey() []byte { - if x != nil { - return x.MasterKey - } - return nil -} - -func (x *GroupV2Record) GetBlocked() bool { - if x != nil { - return x.Blocked - } - return false -} - -func (x *GroupV2Record) GetWhitelisted() bool { - if x != nil { - return x.Whitelisted - } - return false -} - -func (x *GroupV2Record) GetArchived() bool { - if x != nil { - return x.Archived - } - return false -} - -func (x *GroupV2Record) GetMarkedUnread() bool { - if x != nil { - return x.MarkedUnread - } - return false -} - -func (x *GroupV2Record) GetMutedUntilTimestamp() uint64 { - if x != nil { - return x.MutedUntilTimestamp - } - return 0 -} - -func (x *GroupV2Record) GetDontNotifyForMentionsIfMuted() bool { - if x != nil { - return x.DontNotifyForMentionsIfMuted - } - return false -} - -func (x *GroupV2Record) GetHideStory() bool { - if x != nil { - return x.HideStory - } - return false -} - -func (x *GroupV2Record) GetStorySendMode() GroupV2Record_StorySendMode { - if x != nil { - return x.StorySendMode - } - return GroupV2Record_DEFAULT -} - -func (x *GroupV2Record) GetAvatarColor() AvatarColor { - if x != nil && x.AvatarColor != nil { - return *x.AvatarColor - } - return AvatarColor_A100 -} - -func (x *GroupV2Record) GetVerifiedNameHash() []byte { - if x != nil { - return x.VerifiedNameHash - } - return nil -} - -type Payments struct { - state protoimpl.MessageState `protogen:"open.v1"` - Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` - Entropy []byte `protobuf:"bytes,2,opt,name=entropy,proto3" json:"entropy,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Payments) Reset() { - *x = Payments{} - mi := &file_StorageService_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Payments) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Payments) ProtoMessage() {} - -func (x *Payments) ProtoReflect() protoreflect.Message { - mi := &file_StorageService_proto_msgTypes[10] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Payments.ProtoReflect.Descriptor instead. -func (*Payments) Descriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{10} -} - -func (x *Payments) GetEnabled() bool { - if x != nil { - return x.Enabled - } - return false -} - -func (x *Payments) GetEntropy() []byte { - if x != nil { - return x.Entropy - } - return nil -} - -type AccountRecord struct { - state protoimpl.MessageState `protogen:"open.v1"` - ProfileKey []byte `protobuf:"bytes,1,opt,name=profileKey,proto3" json:"profileKey,omitempty"` - GivenName string `protobuf:"bytes,2,opt,name=givenName,proto3" json:"givenName,omitempty"` - FamilyName string `protobuf:"bytes,3,opt,name=familyName,proto3" json:"familyName,omitempty"` - AvatarUrlPath string `protobuf:"bytes,4,opt,name=avatarUrlPath,proto3" json:"avatarUrlPath,omitempty"` - NoteToSelfArchived bool `protobuf:"varint,5,opt,name=noteToSelfArchived,proto3" json:"noteToSelfArchived,omitempty"` - ReadReceipts bool `protobuf:"varint,6,opt,name=readReceipts,proto3" json:"readReceipts,omitempty"` - SealedSenderIndicators bool `protobuf:"varint,7,opt,name=sealedSenderIndicators,proto3" json:"sealedSenderIndicators,omitempty"` - TypingIndicators bool `protobuf:"varint,8,opt,name=typingIndicators,proto3" json:"typingIndicators,omitempty"` - NoteToSelfMarkedUnread bool `protobuf:"varint,10,opt,name=noteToSelfMarkedUnread,proto3" json:"noteToSelfMarkedUnread,omitempty"` - LinkPreviews bool `protobuf:"varint,11,opt,name=linkPreviews,proto3" json:"linkPreviews,omitempty"` - PhoneNumberSharingMode AccountRecord_PhoneNumberSharingMode `protobuf:"varint,12,opt,name=phoneNumberSharingMode,proto3,enum=signalservice.AccountRecord_PhoneNumberSharingMode" json:"phoneNumberSharingMode,omitempty"` - UnlistedPhoneNumber bool `protobuf:"varint,13,opt,name=unlistedPhoneNumber,proto3" json:"unlistedPhoneNumber,omitempty"` - PinnedConversations []*AccountRecord_PinnedConversation `protobuf:"bytes,14,rep,name=pinnedConversations,proto3" json:"pinnedConversations,omitempty"` - PreferContactAvatars bool `protobuf:"varint,15,opt,name=preferContactAvatars,proto3" json:"preferContactAvatars,omitempty"` - Payments *Payments `protobuf:"bytes,16,opt,name=payments,proto3" json:"payments,omitempty"` - UniversalExpireTimer uint32 `protobuf:"varint,17,opt,name=universalExpireTimer,proto3" json:"universalExpireTimer,omitempty"` - PrimarySendsSms bool `protobuf:"varint,18,opt,name=primarySendsSms,proto3" json:"primarySendsSms,omitempty"` - PreferredReactionEmoji []string `protobuf:"bytes,20,rep,name=preferredReactionEmoji,proto3" json:"preferredReactionEmoji,omitempty"` - SubscriberId []byte `protobuf:"bytes,21,opt,name=subscriberId,proto3" json:"subscriberId,omitempty"` - SubscriberCurrencyCode string `protobuf:"bytes,22,opt,name=subscriberCurrencyCode,proto3" json:"subscriberCurrencyCode,omitempty"` - DisplayBadgesOnProfile bool `protobuf:"varint,23,opt,name=displayBadgesOnProfile,proto3" json:"displayBadgesOnProfile,omitempty"` - SubscriptionManuallyCancelled bool `protobuf:"varint,24,opt,name=subscriptionManuallyCancelled,proto3" json:"subscriptionManuallyCancelled,omitempty"` - KeepMutedChatsArchived bool `protobuf:"varint,25,opt,name=keepMutedChatsArchived,proto3" json:"keepMutedChatsArchived,omitempty"` - HasSetMyStoriesPrivacy bool `protobuf:"varint,26,opt,name=hasSetMyStoriesPrivacy,proto3" json:"hasSetMyStoriesPrivacy,omitempty"` - HasViewedOnboardingStory bool `protobuf:"varint,27,opt,name=hasViewedOnboardingStory,proto3" json:"hasViewedOnboardingStory,omitempty"` - StoriesDisabled bool `protobuf:"varint,29,opt,name=storiesDisabled,proto3" json:"storiesDisabled,omitempty"` - StoryViewReceiptsEnabled OptionalBool `protobuf:"varint,30,opt,name=storyViewReceiptsEnabled,proto3,enum=signalservice.OptionalBool" json:"storyViewReceiptsEnabled,omitempty"` - HasSeenGroupStoryEducationSheet bool `protobuf:"varint,32,opt,name=hasSeenGroupStoryEducationSheet,proto3" json:"hasSeenGroupStoryEducationSheet,omitempty"` - Username string `protobuf:"bytes,33,opt,name=username,proto3" json:"username,omitempty"` - HasCompletedUsernameOnboarding bool `protobuf:"varint,34,opt,name=hasCompletedUsernameOnboarding,proto3" json:"hasCompletedUsernameOnboarding,omitempty"` - UsernameLink *AccountRecord_UsernameLink `protobuf:"bytes,35,opt,name=usernameLink,proto3" json:"usernameLink,omitempty"` - HasBackup *bool `protobuf:"varint,39,opt,name=hasBackup,proto3,oneof" json:"hasBackup,omitempty"` // Set to true after backups are enabled and one is uploaded. - BackupTier *uint64 `protobuf:"varint,40,opt,name=backupTier,proto3,oneof" json:"backupTier,omitempty"` // See zkgroup for integer particular values. Unset if backups are not enabled. - BackupSubscriberData *AccountRecord_IAPSubscriberData `protobuf:"bytes,41,opt,name=backupSubscriberData,proto3" json:"backupSubscriberData,omitempty"` - AvatarColor *AvatarColor `protobuf:"varint,42,opt,name=avatarColor,proto3,enum=signalservice.AvatarColor,oneof" json:"avatarColor,omitempty"` - BackupTierHistory *AccountRecord_BackupTierHistory `protobuf:"bytes,43,opt,name=backupTierHistory,proto3" json:"backupTierHistory,omitempty"` - NotificationProfileManualOverride *AccountRecord_NotificationProfileManualOverride `protobuf:"bytes,44,opt,name=notificationProfileManualOverride,proto3" json:"notificationProfileManualOverride,omitempty"` - NotificationProfileSyncDisabled bool `protobuf:"varint,45,opt,name=notificationProfileSyncDisabled,proto3" json:"notificationProfileSyncDisabled,omitempty"` - AutomaticKeyVerificationDisabled bool `protobuf:"varint,46,opt,name=automaticKeyVerificationDisabled,proto3" json:"automaticKeyVerificationDisabled,omitempty"` - HasSeenAdminDeleteEducationDialog bool `protobuf:"varint,47,opt,name=hasSeenAdminDeleteEducationDialog,proto3" json:"hasSeenAdminDeleteEducationDialog,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AccountRecord) Reset() { - *x = AccountRecord{} - mi := &file_StorageService_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AccountRecord) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AccountRecord) ProtoMessage() {} - -func (x *AccountRecord) ProtoReflect() protoreflect.Message { - mi := &file_StorageService_proto_msgTypes[11] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AccountRecord.ProtoReflect.Descriptor instead. -func (*AccountRecord) Descriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{11} -} - -func (x *AccountRecord) GetProfileKey() []byte { - if x != nil { - return x.ProfileKey - } - return nil -} - -func (x *AccountRecord) GetGivenName() string { - if x != nil { - return x.GivenName - } - return "" -} - -func (x *AccountRecord) GetFamilyName() string { - if x != nil { - return x.FamilyName - } - return "" -} - -func (x *AccountRecord) GetAvatarUrlPath() string { - if x != nil { - return x.AvatarUrlPath - } - return "" -} - -func (x *AccountRecord) GetNoteToSelfArchived() bool { - if x != nil { - return x.NoteToSelfArchived - } - return false -} - -func (x *AccountRecord) GetReadReceipts() bool { - if x != nil { - return x.ReadReceipts - } - return false -} - -func (x *AccountRecord) GetSealedSenderIndicators() bool { - if x != nil { - return x.SealedSenderIndicators - } - return false -} - -func (x *AccountRecord) GetTypingIndicators() bool { - if x != nil { - return x.TypingIndicators - } - return false -} - -func (x *AccountRecord) GetNoteToSelfMarkedUnread() bool { - if x != nil { - return x.NoteToSelfMarkedUnread - } - return false -} - -func (x *AccountRecord) GetLinkPreviews() bool { - if x != nil { - return x.LinkPreviews - } - return false -} - -func (x *AccountRecord) GetPhoneNumberSharingMode() AccountRecord_PhoneNumberSharingMode { - if x != nil { - return x.PhoneNumberSharingMode - } - return AccountRecord_UNKNOWN -} - -func (x *AccountRecord) GetUnlistedPhoneNumber() bool { - if x != nil { - return x.UnlistedPhoneNumber - } - return false -} - -func (x *AccountRecord) GetPinnedConversations() []*AccountRecord_PinnedConversation { - if x != nil { - return x.PinnedConversations - } - return nil -} - -func (x *AccountRecord) GetPreferContactAvatars() bool { - if x != nil { - return x.PreferContactAvatars - } - return false -} - -func (x *AccountRecord) GetPayments() *Payments { - if x != nil { - return x.Payments - } - return nil -} - -func (x *AccountRecord) GetUniversalExpireTimer() uint32 { - if x != nil { - return x.UniversalExpireTimer - } - return 0 -} - -func (x *AccountRecord) GetPrimarySendsSms() bool { - if x != nil { - return x.PrimarySendsSms - } - return false -} - -func (x *AccountRecord) GetPreferredReactionEmoji() []string { - if x != nil { - return x.PreferredReactionEmoji - } - return nil -} - -func (x *AccountRecord) GetSubscriberId() []byte { - if x != nil { - return x.SubscriberId - } - return nil -} - -func (x *AccountRecord) GetSubscriberCurrencyCode() string { - if x != nil { - return x.SubscriberCurrencyCode - } - return "" -} - -func (x *AccountRecord) GetDisplayBadgesOnProfile() bool { - if x != nil { - return x.DisplayBadgesOnProfile - } - return false -} - -func (x *AccountRecord) GetSubscriptionManuallyCancelled() bool { - if x != nil { - return x.SubscriptionManuallyCancelled - } - return false -} - -func (x *AccountRecord) GetKeepMutedChatsArchived() bool { - if x != nil { - return x.KeepMutedChatsArchived - } - return false -} - -func (x *AccountRecord) GetHasSetMyStoriesPrivacy() bool { - if x != nil { - return x.HasSetMyStoriesPrivacy - } - return false -} - -func (x *AccountRecord) GetHasViewedOnboardingStory() bool { - if x != nil { - return x.HasViewedOnboardingStory - } - return false -} - -func (x *AccountRecord) GetStoriesDisabled() bool { - if x != nil { - return x.StoriesDisabled - } - return false -} - -func (x *AccountRecord) GetStoryViewReceiptsEnabled() OptionalBool { - if x != nil { - return x.StoryViewReceiptsEnabled - } - return OptionalBool_UNSET -} - -func (x *AccountRecord) GetHasSeenGroupStoryEducationSheet() bool { - if x != nil { - return x.HasSeenGroupStoryEducationSheet - } - return false -} - -func (x *AccountRecord) GetUsername() string { - if x != nil { - return x.Username - } - return "" -} - -func (x *AccountRecord) GetHasCompletedUsernameOnboarding() bool { - if x != nil { - return x.HasCompletedUsernameOnboarding - } - return false -} - -func (x *AccountRecord) GetUsernameLink() *AccountRecord_UsernameLink { - if x != nil { - return x.UsernameLink - } - return nil -} - -func (x *AccountRecord) GetHasBackup() bool { - if x != nil && x.HasBackup != nil { - return *x.HasBackup - } - return false -} - -func (x *AccountRecord) GetBackupTier() uint64 { - if x != nil && x.BackupTier != nil { - return *x.BackupTier - } - return 0 -} - -func (x *AccountRecord) GetBackupSubscriberData() *AccountRecord_IAPSubscriberData { - if x != nil { - return x.BackupSubscriberData - } - return nil -} - -func (x *AccountRecord) GetAvatarColor() AvatarColor { - if x != nil && x.AvatarColor != nil { - return *x.AvatarColor - } - return AvatarColor_A100 -} - -func (x *AccountRecord) GetBackupTierHistory() *AccountRecord_BackupTierHistory { - if x != nil { - return x.BackupTierHistory - } - return nil -} - -func (x *AccountRecord) GetNotificationProfileManualOverride() *AccountRecord_NotificationProfileManualOverride { - if x != nil { - return x.NotificationProfileManualOverride - } - return nil -} - -func (x *AccountRecord) GetNotificationProfileSyncDisabled() bool { - if x != nil { - return x.NotificationProfileSyncDisabled - } - return false -} - -func (x *AccountRecord) GetAutomaticKeyVerificationDisabled() bool { - if x != nil { - return x.AutomaticKeyVerificationDisabled - } - return false -} - -func (x *AccountRecord) GetHasSeenAdminDeleteEducationDialog() bool { - if x != nil { - return x.HasSeenAdminDeleteEducationDialog - } - return false -} - -type StoryDistributionListRecord struct { - state protoimpl.MessageState `protogen:"open.v1"` - Identifier []byte `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - RecipientServiceIds []string `protobuf:"bytes,3,rep,name=recipientServiceIds,proto3" json:"recipientServiceIds,omitempty"` - DeletedAtTimestamp uint64 `protobuf:"varint,4,opt,name=deletedAtTimestamp,proto3" json:"deletedAtTimestamp,omitempty"` - AllowsReplies bool `protobuf:"varint,5,opt,name=allowsReplies,proto3" json:"allowsReplies,omitempty"` - IsBlockList bool `protobuf:"varint,6,opt,name=isBlockList,proto3" json:"isBlockList,omitempty"` - RecipientServiceIdsBinary [][]byte `protobuf:"bytes,7,rep,name=recipientServiceIdsBinary,proto3" json:"recipientServiceIdsBinary,omitempty"` // service ID binary (i.e. 16 byte UUID for ACI, 1 byte prefix + 16 byte UUID for PNI) - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *StoryDistributionListRecord) Reset() { - *x = StoryDistributionListRecord{} - mi := &file_StorageService_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *StoryDistributionListRecord) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*StoryDistributionListRecord) ProtoMessage() {} - -func (x *StoryDistributionListRecord) ProtoReflect() protoreflect.Message { - mi := &file_StorageService_proto_msgTypes[12] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use StoryDistributionListRecord.ProtoReflect.Descriptor instead. -func (*StoryDistributionListRecord) Descriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{12} -} - -func (x *StoryDistributionListRecord) GetIdentifier() []byte { - if x != nil { - return x.Identifier - } - return nil -} - -func (x *StoryDistributionListRecord) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *StoryDistributionListRecord) GetRecipientServiceIds() []string { - if x != nil { - return x.RecipientServiceIds - } - return nil -} - -func (x *StoryDistributionListRecord) GetDeletedAtTimestamp() uint64 { - if x != nil { - return x.DeletedAtTimestamp - } - return 0 -} - -func (x *StoryDistributionListRecord) GetAllowsReplies() bool { - if x != nil { - return x.AllowsReplies - } - return false -} - -func (x *StoryDistributionListRecord) GetIsBlockList() bool { - if x != nil { - return x.IsBlockList - } - return false -} - -func (x *StoryDistributionListRecord) GetRecipientServiceIdsBinary() [][]byte { - if x != nil { - return x.RecipientServiceIdsBinary - } - return nil -} - -type CallLinkRecord struct { - state protoimpl.MessageState `protogen:"open.v1"` - RootKey []byte `protobuf:"bytes,1,opt,name=rootKey,proto3" json:"rootKey,omitempty"` - AdminPasskey []byte `protobuf:"bytes,2,opt,name=adminPasskey,proto3" json:"adminPasskey,omitempty"` - DeletedAtTimestampMs uint64 `protobuf:"varint,3,opt,name=deletedAtTimestampMs,proto3" json:"deletedAtTimestampMs,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CallLinkRecord) Reset() { - *x = CallLinkRecord{} - mi := &file_StorageService_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CallLinkRecord) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CallLinkRecord) ProtoMessage() {} - -func (x *CallLinkRecord) ProtoReflect() protoreflect.Message { - mi := &file_StorageService_proto_msgTypes[13] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CallLinkRecord.ProtoReflect.Descriptor instead. -func (*CallLinkRecord) Descriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{13} -} - -func (x *CallLinkRecord) GetRootKey() []byte { - if x != nil { - return x.RootKey - } - return nil -} - -func (x *CallLinkRecord) GetAdminPasskey() []byte { - if x != nil { - return x.AdminPasskey - } - return nil -} - -func (x *CallLinkRecord) GetDeletedAtTimestampMs() uint64 { - if x != nil { - return x.DeletedAtTimestampMs - } - return 0 -} - -type Recipient struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Types that are valid to be assigned to Identifier: - // - // *Recipient_Contact_ - // *Recipient_LegacyGroupId - // *Recipient_GroupMasterKey - Identifier isRecipient_Identifier `protobuf_oneof:"identifier"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Recipient) Reset() { - *x = Recipient{} - mi := &file_StorageService_proto_msgTypes[14] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Recipient) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Recipient) ProtoMessage() {} - -func (x *Recipient) ProtoReflect() protoreflect.Message { - mi := &file_StorageService_proto_msgTypes[14] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Recipient.ProtoReflect.Descriptor instead. -func (*Recipient) Descriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{14} -} - -func (x *Recipient) GetIdentifier() isRecipient_Identifier { - if x != nil { - return x.Identifier - } - return nil -} - -func (x *Recipient) GetContact() *Recipient_Contact { - if x != nil { - if x, ok := x.Identifier.(*Recipient_Contact_); ok { - return x.Contact - } - } - return nil -} - -func (x *Recipient) GetLegacyGroupId() []byte { - if x != nil { - if x, ok := x.Identifier.(*Recipient_LegacyGroupId); ok { - return x.LegacyGroupId - } - } - return nil -} - -func (x *Recipient) GetGroupMasterKey() []byte { - if x != nil { - if x, ok := x.Identifier.(*Recipient_GroupMasterKey); ok { - return x.GroupMasterKey - } - } - return nil -} - -type isRecipient_Identifier interface { - isRecipient_Identifier() -} - -type Recipient_Contact_ struct { - Contact *Recipient_Contact `protobuf:"bytes,1,opt,name=contact,proto3,oneof"` -} - -type Recipient_LegacyGroupId struct { - LegacyGroupId []byte `protobuf:"bytes,2,opt,name=legacyGroupId,proto3,oneof"` -} - -type Recipient_GroupMasterKey struct { - GroupMasterKey []byte `protobuf:"bytes,3,opt,name=groupMasterKey,proto3,oneof"` -} - -func (*Recipient_Contact_) isRecipient_Identifier() {} - -func (*Recipient_LegacyGroupId) isRecipient_Identifier() {} - -func (*Recipient_GroupMasterKey) isRecipient_Identifier() {} - -type ChatFolderRecord struct { - state protoimpl.MessageState `protogen:"open.v1"` - Identifier []byte `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - Position uint32 `protobuf:"varint,3,opt,name=position,proto3" json:"position,omitempty"` - ShowOnlyUnread bool `protobuf:"varint,4,opt,name=showOnlyUnread,proto3" json:"showOnlyUnread,omitempty"` - ShowMutedChats bool `protobuf:"varint,5,opt,name=showMutedChats,proto3" json:"showMutedChats,omitempty"` - IncludeAllIndividualChats bool `protobuf:"varint,6,opt,name=includeAllIndividualChats,proto3" json:"includeAllIndividualChats,omitempty"` // Folder includes all 1:1 chats, unless excluded - IncludeAllGroupChats bool `protobuf:"varint,7,opt,name=includeAllGroupChats,proto3" json:"includeAllGroupChats,omitempty"` // Folder includes all group chats, unless excluded - FolderType ChatFolderRecord_FolderType `protobuf:"varint,8,opt,name=folderType,proto3,enum=signalservice.ChatFolderRecord_FolderType" json:"folderType,omitempty"` - IncludedRecipients []*Recipient `protobuf:"bytes,9,rep,name=includedRecipients,proto3" json:"includedRecipients,omitempty"` - ExcludedRecipients []*Recipient `protobuf:"bytes,10,rep,name=excludedRecipients,proto3" json:"excludedRecipients,omitempty"` - DeletedAtTimestampMs uint64 `protobuf:"varint,11,opt,name=deletedAtTimestampMs,proto3" json:"deletedAtTimestampMs,omitempty"` // When non-zero, `position` should be set to -1 and includedRecipients should be empty - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ChatFolderRecord) Reset() { - *x = ChatFolderRecord{} - mi := &file_StorageService_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ChatFolderRecord) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ChatFolderRecord) ProtoMessage() {} - -func (x *ChatFolderRecord) ProtoReflect() protoreflect.Message { - mi := &file_StorageService_proto_msgTypes[15] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ChatFolderRecord.ProtoReflect.Descriptor instead. -func (*ChatFolderRecord) Descriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{15} -} - -func (x *ChatFolderRecord) GetIdentifier() []byte { - if x != nil { - return x.Identifier - } - return nil -} - -func (x *ChatFolderRecord) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *ChatFolderRecord) GetPosition() uint32 { - if x != nil { - return x.Position - } - return 0 -} - -func (x *ChatFolderRecord) GetShowOnlyUnread() bool { - if x != nil { - return x.ShowOnlyUnread - } - return false -} - -func (x *ChatFolderRecord) GetShowMutedChats() bool { - if x != nil { - return x.ShowMutedChats - } - return false -} - -func (x *ChatFolderRecord) GetIncludeAllIndividualChats() bool { - if x != nil { - return x.IncludeAllIndividualChats - } - return false -} - -func (x *ChatFolderRecord) GetIncludeAllGroupChats() bool { - if x != nil { - return x.IncludeAllGroupChats - } - return false -} - -func (x *ChatFolderRecord) GetFolderType() ChatFolderRecord_FolderType { - if x != nil { - return x.FolderType - } - return ChatFolderRecord_UNKNOWN -} - -func (x *ChatFolderRecord) GetIncludedRecipients() []*Recipient { - if x != nil { - return x.IncludedRecipients - } - return nil -} - -func (x *ChatFolderRecord) GetExcludedRecipients() []*Recipient { - if x != nil { - return x.ExcludedRecipients - } - return nil -} - -func (x *ChatFolderRecord) GetDeletedAtTimestampMs() uint64 { - if x != nil { - return x.DeletedAtTimestampMs - } - return 0 -} - -type NotificationProfile struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id []byte `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - Emoji *string `protobuf:"bytes,3,opt,name=emoji,proto3,oneof" json:"emoji,omitempty"` - Color uint32 `protobuf:"fixed32,4,opt,name=color,proto3" json:"color,omitempty"` // 0xAARRGGBB - CreatedAtMs uint64 `protobuf:"varint,5,opt,name=createdAtMs,proto3" json:"createdAtMs,omitempty"` - AllowAllCalls bool `protobuf:"varint,6,opt,name=allowAllCalls,proto3" json:"allowAllCalls,omitempty"` - AllowAllMentions bool `protobuf:"varint,7,opt,name=allowAllMentions,proto3" json:"allowAllMentions,omitempty"` - AllowedMembers []*Recipient `protobuf:"bytes,8,rep,name=allowedMembers,proto3" json:"allowedMembers,omitempty"` - ScheduleEnabled bool `protobuf:"varint,9,opt,name=scheduleEnabled,proto3" json:"scheduleEnabled,omitempty"` - ScheduleStartTime uint32 `protobuf:"varint,10,opt,name=scheduleStartTime,proto3" json:"scheduleStartTime,omitempty"` // 24-hour clock int, 0000-2359 (e.g., 15, 900, 1130, 2345) - ScheduleEndTime uint32 `protobuf:"varint,11,opt,name=scheduleEndTime,proto3" json:"scheduleEndTime,omitempty"` // 24-hour clock int, 0000-2359 (e.g., 15, 900, 1130, 2345) - ScheduleDaysEnabled []NotificationProfile_DayOfWeek `protobuf:"varint,12,rep,packed,name=scheduleDaysEnabled,proto3,enum=signalservice.NotificationProfile_DayOfWeek" json:"scheduleDaysEnabled,omitempty"` - DeletedAtTimestampMs uint64 `protobuf:"varint,13,opt,name=deletedAtTimestampMs,proto3" json:"deletedAtTimestampMs,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *NotificationProfile) Reset() { - *x = NotificationProfile{} - mi := &file_StorageService_proto_msgTypes[16] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *NotificationProfile) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*NotificationProfile) ProtoMessage() {} - -func (x *NotificationProfile) ProtoReflect() protoreflect.Message { - mi := &file_StorageService_proto_msgTypes[16] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use NotificationProfile.ProtoReflect.Descriptor instead. -func (*NotificationProfile) Descriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{16} -} - -func (x *NotificationProfile) GetId() []byte { - if x != nil { - return x.Id - } - return nil -} - -func (x *NotificationProfile) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *NotificationProfile) GetEmoji() string { - if x != nil && x.Emoji != nil { - return *x.Emoji - } - return "" -} - -func (x *NotificationProfile) GetColor() uint32 { - if x != nil { - return x.Color - } - return 0 -} - -func (x *NotificationProfile) GetCreatedAtMs() uint64 { - if x != nil { - return x.CreatedAtMs - } - return 0 -} - -func (x *NotificationProfile) GetAllowAllCalls() bool { - if x != nil { - return x.AllowAllCalls - } - return false -} - -func (x *NotificationProfile) GetAllowAllMentions() bool { - if x != nil { - return x.AllowAllMentions - } - return false -} - -func (x *NotificationProfile) GetAllowedMembers() []*Recipient { - if x != nil { - return x.AllowedMembers - } - return nil -} - -func (x *NotificationProfile) GetScheduleEnabled() bool { - if x != nil { - return x.ScheduleEnabled - } - return false -} - -func (x *NotificationProfile) GetScheduleStartTime() uint32 { - if x != nil { - return x.ScheduleStartTime - } - return 0 -} - -func (x *NotificationProfile) GetScheduleEndTime() uint32 { - if x != nil { - return x.ScheduleEndTime - } - return 0 -} - -func (x *NotificationProfile) GetScheduleDaysEnabled() []NotificationProfile_DayOfWeek { - if x != nil { - return x.ScheduleDaysEnabled - } - return nil -} - -func (x *NotificationProfile) GetDeletedAtTimestampMs() uint64 { - if x != nil { - return x.DeletedAtTimestampMs - } - return 0 -} - -type ManifestRecord_Identifier struct { - state protoimpl.MessageState `protogen:"open.v1"` - Raw []byte `protobuf:"bytes,1,opt,name=raw,proto3" json:"raw,omitempty"` - Type ManifestRecord_Identifier_Type `protobuf:"varint,2,opt,name=type,proto3,enum=signalservice.ManifestRecord_Identifier_Type" json:"type,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ManifestRecord_Identifier) Reset() { - *x = ManifestRecord_Identifier{} - mi := &file_StorageService_proto_msgTypes[17] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ManifestRecord_Identifier) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ManifestRecord_Identifier) ProtoMessage() {} - -func (x *ManifestRecord_Identifier) ProtoReflect() protoreflect.Message { - mi := &file_StorageService_proto_msgTypes[17] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ManifestRecord_Identifier.ProtoReflect.Descriptor instead. -func (*ManifestRecord_Identifier) Descriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{5, 0} -} - -func (x *ManifestRecord_Identifier) GetRaw() []byte { - if x != nil { - return x.Raw - } - return nil -} - -func (x *ManifestRecord_Identifier) GetType() ManifestRecord_Identifier_Type { - if x != nil { - return x.Type - } - return ManifestRecord_Identifier_UNKNOWN -} - -type ContactRecord_Name struct { - state protoimpl.MessageState `protogen:"open.v1"` - Given string `protobuf:"bytes,1,opt,name=given,proto3" json:"given,omitempty"` - Family string `protobuf:"bytes,2,opt,name=family,proto3" json:"family,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ContactRecord_Name) Reset() { - *x = ContactRecord_Name{} - mi := &file_StorageService_proto_msgTypes[18] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ContactRecord_Name) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ContactRecord_Name) ProtoMessage() {} - -func (x *ContactRecord_Name) ProtoReflect() protoreflect.Message { - mi := &file_StorageService_proto_msgTypes[18] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ContactRecord_Name.ProtoReflect.Descriptor instead. -func (*ContactRecord_Name) Descriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{7, 0} -} - -func (x *ContactRecord_Name) GetGiven() string { - if x != nil { - return x.Given - } - return "" -} - -func (x *ContactRecord_Name) GetFamily() string { - if x != nil { - return x.Family - } - return "" -} - -type AccountRecord_PinnedConversation struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Types that are valid to be assigned to Identifier: - // - // *AccountRecord_PinnedConversation_Contact_ - // *AccountRecord_PinnedConversation_LegacyGroupId - // *AccountRecord_PinnedConversation_GroupMasterKey - Identifier isAccountRecord_PinnedConversation_Identifier `protobuf_oneof:"identifier"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AccountRecord_PinnedConversation) Reset() { - *x = AccountRecord_PinnedConversation{} - mi := &file_StorageService_proto_msgTypes[19] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AccountRecord_PinnedConversation) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AccountRecord_PinnedConversation) ProtoMessage() {} - -func (x *AccountRecord_PinnedConversation) ProtoReflect() protoreflect.Message { - mi := &file_StorageService_proto_msgTypes[19] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AccountRecord_PinnedConversation.ProtoReflect.Descriptor instead. -func (*AccountRecord_PinnedConversation) Descriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{11, 0} -} - -func (x *AccountRecord_PinnedConversation) GetIdentifier() isAccountRecord_PinnedConversation_Identifier { - if x != nil { - return x.Identifier - } - return nil -} - -func (x *AccountRecord_PinnedConversation) GetContact() *AccountRecord_PinnedConversation_Contact { - if x != nil { - if x, ok := x.Identifier.(*AccountRecord_PinnedConversation_Contact_); ok { - return x.Contact - } - } - return nil -} - -func (x *AccountRecord_PinnedConversation) GetLegacyGroupId() []byte { - if x != nil { - if x, ok := x.Identifier.(*AccountRecord_PinnedConversation_LegacyGroupId); ok { - return x.LegacyGroupId - } - } - return nil -} - -func (x *AccountRecord_PinnedConversation) GetGroupMasterKey() []byte { - if x != nil { - if x, ok := x.Identifier.(*AccountRecord_PinnedConversation_GroupMasterKey); ok { - return x.GroupMasterKey - } - } - return nil -} - -type isAccountRecord_PinnedConversation_Identifier interface { - isAccountRecord_PinnedConversation_Identifier() -} - -type AccountRecord_PinnedConversation_Contact_ struct { - Contact *AccountRecord_PinnedConversation_Contact `protobuf:"bytes,1,opt,name=contact,proto3,oneof"` -} - -type AccountRecord_PinnedConversation_LegacyGroupId struct { - LegacyGroupId []byte `protobuf:"bytes,3,opt,name=legacyGroupId,proto3,oneof"` -} - -type AccountRecord_PinnedConversation_GroupMasterKey struct { - GroupMasterKey []byte `protobuf:"bytes,4,opt,name=groupMasterKey,proto3,oneof"` -} - -func (*AccountRecord_PinnedConversation_Contact_) isAccountRecord_PinnedConversation_Identifier() {} - -func (*AccountRecord_PinnedConversation_LegacyGroupId) isAccountRecord_PinnedConversation_Identifier() { -} - -func (*AccountRecord_PinnedConversation_GroupMasterKey) isAccountRecord_PinnedConversation_Identifier() { -} - -type AccountRecord_UsernameLink struct { - state protoimpl.MessageState `protogen:"open.v1"` - Entropy []byte `protobuf:"bytes,1,opt,name=entropy,proto3" json:"entropy,omitempty"` // 32 bytes of entropy used for encryption - ServerId []byte `protobuf:"bytes,2,opt,name=serverId,proto3" json:"serverId,omitempty"` // 16 bytes of encoded UUID provided by the server - Color AccountRecord_UsernameLink_Color `protobuf:"varint,3,opt,name=color,proto3,enum=signalservice.AccountRecord_UsernameLink_Color" json:"color,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AccountRecord_UsernameLink) Reset() { - *x = AccountRecord_UsernameLink{} - mi := &file_StorageService_proto_msgTypes[20] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AccountRecord_UsernameLink) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AccountRecord_UsernameLink) ProtoMessage() {} - -func (x *AccountRecord_UsernameLink) ProtoReflect() protoreflect.Message { - mi := &file_StorageService_proto_msgTypes[20] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AccountRecord_UsernameLink.ProtoReflect.Descriptor instead. -func (*AccountRecord_UsernameLink) Descriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{11, 1} -} - -func (x *AccountRecord_UsernameLink) GetEntropy() []byte { - if x != nil { - return x.Entropy - } - return nil -} - -func (x *AccountRecord_UsernameLink) GetServerId() []byte { - if x != nil { - return x.ServerId - } - return nil -} - -func (x *AccountRecord_UsernameLink) GetColor() AccountRecord_UsernameLink_Color { - if x != nil { - return x.Color - } - return AccountRecord_UsernameLink_UNKNOWN -} - -type AccountRecord_IAPSubscriberData struct { - state protoimpl.MessageState `protogen:"open.v1"` - SubscriberId []byte `protobuf:"bytes,1,opt,name=subscriberId,proto3" json:"subscriberId,omitempty"` - // Types that are valid to be assigned to IapSubscriptionId: - // - // *AccountRecord_IAPSubscriberData_PurchaseToken - // *AccountRecord_IAPSubscriberData_OriginalTransactionId - IapSubscriptionId isAccountRecord_IAPSubscriberData_IapSubscriptionId `protobuf_oneof:"iapSubscriptionId"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AccountRecord_IAPSubscriberData) Reset() { - *x = AccountRecord_IAPSubscriberData{} - mi := &file_StorageService_proto_msgTypes[21] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AccountRecord_IAPSubscriberData) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AccountRecord_IAPSubscriberData) ProtoMessage() {} - -func (x *AccountRecord_IAPSubscriberData) ProtoReflect() protoreflect.Message { - mi := &file_StorageService_proto_msgTypes[21] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AccountRecord_IAPSubscriberData.ProtoReflect.Descriptor instead. -func (*AccountRecord_IAPSubscriberData) Descriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{11, 2} -} - -func (x *AccountRecord_IAPSubscriberData) GetSubscriberId() []byte { - if x != nil { - return x.SubscriberId - } - return nil -} - -func (x *AccountRecord_IAPSubscriberData) GetIapSubscriptionId() isAccountRecord_IAPSubscriberData_IapSubscriptionId { - if x != nil { - return x.IapSubscriptionId - } - return nil -} - -func (x *AccountRecord_IAPSubscriberData) GetPurchaseToken() string { - if x != nil { - if x, ok := x.IapSubscriptionId.(*AccountRecord_IAPSubscriberData_PurchaseToken); ok { - return x.PurchaseToken - } - } - return "" -} - -func (x *AccountRecord_IAPSubscriberData) GetOriginalTransactionId() uint64 { - if x != nil { - if x, ok := x.IapSubscriptionId.(*AccountRecord_IAPSubscriberData_OriginalTransactionId); ok { - return x.OriginalTransactionId - } - } - return 0 -} - -type isAccountRecord_IAPSubscriberData_IapSubscriptionId interface { - isAccountRecord_IAPSubscriberData_IapSubscriptionId() -} - -type AccountRecord_IAPSubscriberData_PurchaseToken struct { - // Identifies an Android Play Store IAP subscription. - PurchaseToken string `protobuf:"bytes,2,opt,name=purchaseToken,proto3,oneof"` -} - -type AccountRecord_IAPSubscriberData_OriginalTransactionId struct { - // Identifies an iOS App Store IAP subscription. - OriginalTransactionId uint64 `protobuf:"varint,3,opt,name=originalTransactionId,proto3,oneof"` -} - -func (*AccountRecord_IAPSubscriberData_PurchaseToken) isAccountRecord_IAPSubscriberData_IapSubscriptionId() { -} - -func (*AccountRecord_IAPSubscriberData_OriginalTransactionId) isAccountRecord_IAPSubscriberData_IapSubscriptionId() { -} - -type AccountRecord_BackupTierHistory struct { - state protoimpl.MessageState `protogen:"open.v1"` - // See zkgroup for integer particular values. Unset if backups are not enabled. - BackupTier *uint64 `protobuf:"varint,1,opt,name=backupTier,proto3,oneof" json:"backupTier,omitempty"` - EndedAtTimestamp *uint64 `protobuf:"varint,2,opt,name=endedAtTimestamp,proto3,oneof" json:"endedAtTimestamp,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AccountRecord_BackupTierHistory) Reset() { - *x = AccountRecord_BackupTierHistory{} - mi := &file_StorageService_proto_msgTypes[22] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AccountRecord_BackupTierHistory) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AccountRecord_BackupTierHistory) ProtoMessage() {} - -func (x *AccountRecord_BackupTierHistory) ProtoReflect() protoreflect.Message { - mi := &file_StorageService_proto_msgTypes[22] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AccountRecord_BackupTierHistory.ProtoReflect.Descriptor instead. -func (*AccountRecord_BackupTierHistory) Descriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{11, 3} -} - -func (x *AccountRecord_BackupTierHistory) GetBackupTier() uint64 { - if x != nil && x.BackupTier != nil { - return *x.BackupTier - } - return 0 -} - -func (x *AccountRecord_BackupTierHistory) GetEndedAtTimestamp() uint64 { - if x != nil && x.EndedAtTimestamp != nil { - return *x.EndedAtTimestamp - } - return 0 -} - -type AccountRecord_NotificationProfileManualOverride struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Types that are valid to be assigned to Override: - // - // *AccountRecord_NotificationProfileManualOverride_DisabledAtTimestampMs - // *AccountRecord_NotificationProfileManualOverride_Enabled - Override isAccountRecord_NotificationProfileManualOverride_Override `protobuf_oneof:"override"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AccountRecord_NotificationProfileManualOverride) Reset() { - *x = AccountRecord_NotificationProfileManualOverride{} - mi := &file_StorageService_proto_msgTypes[23] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AccountRecord_NotificationProfileManualOverride) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AccountRecord_NotificationProfileManualOverride) ProtoMessage() {} - -func (x *AccountRecord_NotificationProfileManualOverride) ProtoReflect() protoreflect.Message { - mi := &file_StorageService_proto_msgTypes[23] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AccountRecord_NotificationProfileManualOverride.ProtoReflect.Descriptor instead. -func (*AccountRecord_NotificationProfileManualOverride) Descriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{11, 4} -} - -func (x *AccountRecord_NotificationProfileManualOverride) GetOverride() isAccountRecord_NotificationProfileManualOverride_Override { - if x != nil { - return x.Override - } - return nil -} - -func (x *AccountRecord_NotificationProfileManualOverride) GetDisabledAtTimestampMs() uint64 { - if x != nil { - if x, ok := x.Override.(*AccountRecord_NotificationProfileManualOverride_DisabledAtTimestampMs); ok { - return x.DisabledAtTimestampMs - } - } - return 0 -} - -func (x *AccountRecord_NotificationProfileManualOverride) GetEnabled() *AccountRecord_NotificationProfileManualOverride_ManuallyEnabled { - if x != nil { - if x, ok := x.Override.(*AccountRecord_NotificationProfileManualOverride_Enabled); ok { - return x.Enabled - } - } - return nil -} - -type isAccountRecord_NotificationProfileManualOverride_Override interface { - isAccountRecord_NotificationProfileManualOverride_Override() -} - -type AccountRecord_NotificationProfileManualOverride_DisabledAtTimestampMs struct { - DisabledAtTimestampMs uint64 `protobuf:"varint,1,opt,name=disabledAtTimestampMs,proto3,oneof"` -} - -type AccountRecord_NotificationProfileManualOverride_Enabled struct { - Enabled *AccountRecord_NotificationProfileManualOverride_ManuallyEnabled `protobuf:"bytes,2,opt,name=enabled,proto3,oneof"` -} - -func (*AccountRecord_NotificationProfileManualOverride_DisabledAtTimestampMs) isAccountRecord_NotificationProfileManualOverride_Override() { -} - -func (*AccountRecord_NotificationProfileManualOverride_Enabled) isAccountRecord_NotificationProfileManualOverride_Override() { -} - -type AccountRecord_PinnedConversation_Contact struct { - state protoimpl.MessageState `protogen:"open.v1"` - ServiceId string `protobuf:"bytes,1,opt,name=serviceId,proto3" json:"serviceId,omitempty"` - E164 string `protobuf:"bytes,2,opt,name=e164,proto3" json:"e164,omitempty"` - ServiceIdBinary []byte `protobuf:"bytes,3,opt,name=serviceIdBinary,proto3" json:"serviceIdBinary,omitempty"` // service ID binary (i.e. 16 byte UUID for ACI, 1 byte prefix + 16 byte UUID for PNI) - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AccountRecord_PinnedConversation_Contact) Reset() { - *x = AccountRecord_PinnedConversation_Contact{} - mi := &file_StorageService_proto_msgTypes[24] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AccountRecord_PinnedConversation_Contact) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AccountRecord_PinnedConversation_Contact) ProtoMessage() {} - -func (x *AccountRecord_PinnedConversation_Contact) ProtoReflect() protoreflect.Message { - mi := &file_StorageService_proto_msgTypes[24] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AccountRecord_PinnedConversation_Contact.ProtoReflect.Descriptor instead. -func (*AccountRecord_PinnedConversation_Contact) Descriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{11, 0, 0} -} - -func (x *AccountRecord_PinnedConversation_Contact) GetServiceId() string { - if x != nil { - return x.ServiceId - } - return "" -} - -func (x *AccountRecord_PinnedConversation_Contact) GetE164() string { - if x != nil { - return x.E164 - } - return "" -} - -func (x *AccountRecord_PinnedConversation_Contact) GetServiceIdBinary() []byte { - if x != nil { - return x.ServiceIdBinary - } - return nil -} - -type AccountRecord_NotificationProfileManualOverride_ManuallyEnabled struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id []byte `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - // This will be unset if no timespan was chosen in the UI. - EndAtTimestampMs uint64 `protobuf:"varint,3,opt,name=endAtTimestampMs,proto3" json:"endAtTimestampMs,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AccountRecord_NotificationProfileManualOverride_ManuallyEnabled) Reset() { - *x = AccountRecord_NotificationProfileManualOverride_ManuallyEnabled{} - mi := &file_StorageService_proto_msgTypes[25] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AccountRecord_NotificationProfileManualOverride_ManuallyEnabled) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AccountRecord_NotificationProfileManualOverride_ManuallyEnabled) ProtoMessage() {} - -func (x *AccountRecord_NotificationProfileManualOverride_ManuallyEnabled) ProtoReflect() protoreflect.Message { - mi := &file_StorageService_proto_msgTypes[25] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AccountRecord_NotificationProfileManualOverride_ManuallyEnabled.ProtoReflect.Descriptor instead. -func (*AccountRecord_NotificationProfileManualOverride_ManuallyEnabled) Descriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{11, 4, 0} -} - -func (x *AccountRecord_NotificationProfileManualOverride_ManuallyEnabled) GetId() []byte { - if x != nil { - return x.Id - } - return nil -} - -func (x *AccountRecord_NotificationProfileManualOverride_ManuallyEnabled) GetEndAtTimestampMs() uint64 { - if x != nil { - return x.EndAtTimestampMs - } - return 0 -} - -type Recipient_Contact struct { - state protoimpl.MessageState `protogen:"open.v1"` - ServiceId string `protobuf:"bytes,1,opt,name=serviceId,proto3" json:"serviceId,omitempty"` - E164 string `protobuf:"bytes,2,opt,name=e164,proto3" json:"e164,omitempty"` - ServiceIdBinary []byte `protobuf:"bytes,3,opt,name=serviceIdBinary,proto3" json:"serviceIdBinary,omitempty"` // service ID binary (i.e. 16 byte UUID for ACI, 1 byte prefix + 16 byte UUID for PNI) - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Recipient_Contact) Reset() { - *x = Recipient_Contact{} - mi := &file_StorageService_proto_msgTypes[26] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Recipient_Contact) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Recipient_Contact) ProtoMessage() {} - -func (x *Recipient_Contact) ProtoReflect() protoreflect.Message { - mi := &file_StorageService_proto_msgTypes[26] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Recipient_Contact.ProtoReflect.Descriptor instead. -func (*Recipient_Contact) Descriptor() ([]byte, []int) { - return file_StorageService_proto_rawDescGZIP(), []int{14, 0} -} - -func (x *Recipient_Contact) GetServiceId() string { - if x != nil { - return x.ServiceId - } - return "" -} - -func (x *Recipient_Contact) GetE164() string { - if x != nil { - return x.E164 - } - return "" -} - -func (x *Recipient_Contact) GetServiceIdBinary() []byte { - if x != nil { - return x.ServiceIdBinary - } - return nil -} - -var File_StorageService_proto protoreflect.FileDescriptor - -const file_StorageService_proto_rawDesc = "" + - "\n" + - "\x14StorageService.proto\x12\rsignalservice\"A\n" + - "\x0fStorageManifest\x12\x18\n" + - "\aversion\x18\x01 \x01(\x04R\aversion\x12\x14\n" + - "\x05value\x18\x02 \x01(\fR\x05value\"5\n" + - "\vStorageItem\x12\x10\n" + - "\x03key\x18\x01 \x01(\fR\x03key\x12\x14\n" + - "\x05value\x18\x02 \x01(\fR\x05value\"@\n" + - "\fStorageItems\x120\n" + - "\x05items\x18\x01 \x03(\v2\x1a.signalservice.StorageItemR\x05items\")\n" + - "\rReadOperation\x12\x18\n" + - "\areadKey\x18\x01 \x03(\fR\areadKey\"\xc2\x01\n" + - "\x0eWriteOperation\x12:\n" + - "\bmanifest\x18\x01 \x01(\v2\x1e.signalservice.StorageManifestR\bmanifest\x12:\n" + - "\n" + - "insertItem\x18\x02 \x03(\v2\x1a.signalservice.StorageItemR\n" + - "insertItem\x12\x1c\n" + - "\tdeleteKey\x18\x03 \x03(\fR\tdeleteKey\x12\x1a\n" + - "\bclearAll\x18\x04 \x01(\bR\bclearAll\"\xbd\x03\n" + - "\x0eManifestRecord\x12\x18\n" + - "\aversion\x18\x01 \x01(\x04R\aversion\x12\"\n" + - "\fsourceDevice\x18\x03 \x01(\rR\fsourceDevice\x12J\n" + - "\videntifiers\x18\x02 \x03(\v2(.signalservice.ManifestRecord.IdentifierR\videntifiers\x12\x1c\n" + - "\trecordIkm\x18\x04 \x01(\fR\trecordIkm\x1a\x82\x02\n" + - "\n" + - "Identifier\x12\x10\n" + - "\x03raw\x18\x01 \x01(\fR\x03raw\x12A\n" + - "\x04type\x18\x02 \x01(\x0e2-.signalservice.ManifestRecord.Identifier.TypeR\x04type\"\x9e\x01\n" + - "\x04Type\x12\v\n" + - "\aUNKNOWN\x10\x00\x12\v\n" + - "\aCONTACT\x10\x01\x12\v\n" + - "\aGROUPV1\x10\x02\x12\v\n" + - "\aGROUPV2\x10\x03\x12\v\n" + - "\aACCOUNT\x10\x04\x12\x1b\n" + - "\x17STORY_DISTRIBUTION_LIST\x10\x05\x12\r\n" + - "\tCALL_LINK\x10\a\x12\x0f\n" + - "\vCHAT_FOLDER\x10\b\x12\x18\n" + - "\x14NOTIFICATION_PROFILE\x10\t\"\xbd\x04\n" + - "\rStorageRecord\x128\n" + - "\acontact\x18\x01 \x01(\v2\x1c.signalservice.ContactRecordH\x00R\acontact\x128\n" + - "\agroupV1\x18\x02 \x01(\v2\x1c.signalservice.GroupV1RecordH\x00R\agroupV1\x128\n" + - "\agroupV2\x18\x03 \x01(\v2\x1c.signalservice.GroupV2RecordH\x00R\agroupV2\x128\n" + - "\aaccount\x18\x04 \x01(\v2\x1c.signalservice.AccountRecordH\x00R\aaccount\x12b\n" + - "\x15storyDistributionList\x18\x05 \x01(\v2*.signalservice.StoryDistributionListRecordH\x00R\x15storyDistributionList\x12;\n" + - "\bcallLink\x18\a \x01(\v2\x1d.signalservice.CallLinkRecordH\x00R\bcallLink\x12A\n" + - "\n" + - "chatFolder\x18\b \x01(\v2\x1f.signalservice.ChatFolderRecordH\x00R\n" + - "chatFolder\x12V\n" + - "\x13notificationProfile\x18\t \x01(\v2\".signalservice.NotificationProfileH\x00R\x13notificationProfileB\b\n" + - "\x06record\"\xd9\b\n" + - "\rContactRecord\x12\x10\n" + - "\x03aci\x18\x01 \x01(\tR\x03aci\x12\x12\n" + - "\x04e164\x18\x02 \x01(\tR\x04e164\x12\x10\n" + - "\x03pni\x18\x0f \x01(\tR\x03pni\x12\x1e\n" + - "\n" + - "profileKey\x18\x03 \x01(\fR\n" + - "profileKey\x12 \n" + - "\videntityKey\x18\x04 \x01(\fR\videntityKey\x12P\n" + - "\ridentityState\x18\x05 \x01(\x0e2*.signalservice.ContactRecord.IdentityStateR\ridentityState\x12\x1c\n" + - "\tgivenName\x18\x06 \x01(\tR\tgivenName\x12\x1e\n" + - "\n" + - "familyName\x18\a \x01(\tR\n" + - "familyName\x12\x1a\n" + - "\busername\x18\b \x01(\tR\busername\x12\x18\n" + - "\ablocked\x18\t \x01(\bR\ablocked\x12 \n" + - "\vwhitelisted\x18\n" + - " \x01(\bR\vwhitelisted\x12\x1a\n" + - "\barchived\x18\v \x01(\bR\barchived\x12\"\n" + - "\fmarkedUnread\x18\f \x01(\bR\fmarkedUnread\x120\n" + - "\x13mutedUntilTimestamp\x18\r \x01(\x04R\x13mutedUntilTimestamp\x12\x1c\n" + - "\thideStory\x18\x0e \x01(\bR\thideStory\x128\n" + - "\x17unregisteredAtTimestamp\x18\x10 \x01(\x04R\x17unregisteredAtTimestamp\x12(\n" + - "\x0fsystemGivenName\x18\x11 \x01(\tR\x0fsystemGivenName\x12*\n" + - "\x10systemFamilyName\x18\x12 \x01(\tR\x10systemFamilyName\x12&\n" + - "\x0esystemNickname\x18\x13 \x01(\tR\x0esystemNickname\x12\x16\n" + - "\x06hidden\x18\x14 \x01(\bR\x06hidden\x122\n" + - "\x14pniSignatureVerified\x18\x15 \x01(\bR\x14pniSignatureVerified\x12=\n" + - "\bnickname\x18\x16 \x01(\v2!.signalservice.ContactRecord.NameR\bnickname\x12\x12\n" + - "\x04note\x18\x17 \x01(\tR\x04note\x12A\n" + - "\vavatarColor\x18\x18 \x01(\x0e2\x1a.signalservice.AvatarColorH\x00R\vavatarColor\x88\x01\x01\x12\x1c\n" + - "\taciBinary\x18\x19 \x01(\fR\taciBinary\x12\x1c\n" + - "\tpniBinary\x18\x1a \x01(\fR\tpniBinary\x1a4\n" + - "\x04Name\x12\x14\n" + - "\x05given\x18\x01 \x01(\tR\x05given\x12\x16\n" + - "\x06family\x18\x02 \x01(\tR\x06family\":\n" + - "\rIdentityState\x12\v\n" + - "\aDEFAULT\x10\x00\x12\f\n" + - "\bVERIFIED\x10\x01\x12\x0e\n" + - "\n" + - "UNVERIFIED\x10\x02B\x0e\n" + - "\f_avatarColor\"\xcd\x01\n" + - "\rGroupV1Record\x12\x0e\n" + - "\x02id\x18\x01 \x01(\fR\x02id\x12\x18\n" + - "\ablocked\x18\x02 \x01(\bR\ablocked\x12 \n" + - "\vwhitelisted\x18\x03 \x01(\bR\vwhitelisted\x12\x1a\n" + - "\barchived\x18\x04 \x01(\bR\barchived\x12\"\n" + - "\fmarkedUnread\x18\x05 \x01(\bR\fmarkedUnread\x120\n" + - "\x13mutedUntilTimestamp\x18\x06 \x01(\x04R\x13mutedUntilTimestamp\"\xcd\x04\n" + - "\rGroupV2Record\x12\x1c\n" + - "\tmasterKey\x18\x01 \x01(\fR\tmasterKey\x12\x18\n" + - "\ablocked\x18\x02 \x01(\bR\ablocked\x12 \n" + - "\vwhitelisted\x18\x03 \x01(\bR\vwhitelisted\x12\x1a\n" + - "\barchived\x18\x04 \x01(\bR\barchived\x12\"\n" + - "\fmarkedUnread\x18\x05 \x01(\bR\fmarkedUnread\x120\n" + - "\x13mutedUntilTimestamp\x18\x06 \x01(\x04R\x13mutedUntilTimestamp\x12B\n" + - "\x1cdontNotifyForMentionsIfMuted\x18\a \x01(\bR\x1cdontNotifyForMentionsIfMuted\x12\x1c\n" + - "\thideStory\x18\b \x01(\bR\thideStory\x12P\n" + - "\rstorySendMode\x18\n" + - " \x01(\x0e2*.signalservice.GroupV2Record.StorySendModeR\rstorySendMode\x12A\n" + - "\vavatarColor\x18\v \x01(\x0e2\x1a.signalservice.AvatarColorH\x00R\vavatarColor\x88\x01\x01\x12*\n" + - "\x10verifiedNameHash\x18\f \x01(\fR\x10verifiedNameHash\"7\n" + - "\rStorySendMode\x12\v\n" + - "\aDEFAULT\x10\x00\x12\f\n" + - "\bDISABLED\x10\x01\x12\v\n" + - "\aENABLED\x10\x02B\x0e\n" + - "\f_avatarColorJ\x04\b\t\x10\n" + - "\">\n" + - "\bPayments\x12\x18\n" + - "\aenabled\x18\x01 \x01(\bR\aenabled\x12\x18\n" + - "\aentropy\x18\x02 \x01(\fR\aentropy\"\x99\x1d\n" + - "\rAccountRecord\x12\x1e\n" + - "\n" + - "profileKey\x18\x01 \x01(\fR\n" + - "profileKey\x12\x1c\n" + - "\tgivenName\x18\x02 \x01(\tR\tgivenName\x12\x1e\n" + - "\n" + - "familyName\x18\x03 \x01(\tR\n" + - "familyName\x12$\n" + - "\ravatarUrlPath\x18\x04 \x01(\tR\ravatarUrlPath\x12.\n" + - "\x12noteToSelfArchived\x18\x05 \x01(\bR\x12noteToSelfArchived\x12\"\n" + - "\freadReceipts\x18\x06 \x01(\bR\freadReceipts\x126\n" + - "\x16sealedSenderIndicators\x18\a \x01(\bR\x16sealedSenderIndicators\x12*\n" + - "\x10typingIndicators\x18\b \x01(\bR\x10typingIndicators\x126\n" + - "\x16noteToSelfMarkedUnread\x18\n" + - " \x01(\bR\x16noteToSelfMarkedUnread\x12\"\n" + - "\flinkPreviews\x18\v \x01(\bR\flinkPreviews\x12k\n" + - "\x16phoneNumberSharingMode\x18\f \x01(\x0e23.signalservice.AccountRecord.PhoneNumberSharingModeR\x16phoneNumberSharingMode\x120\n" + - "\x13unlistedPhoneNumber\x18\r \x01(\bR\x13unlistedPhoneNumber\x12a\n" + - "\x13pinnedConversations\x18\x0e \x03(\v2/.signalservice.AccountRecord.PinnedConversationR\x13pinnedConversations\x122\n" + - "\x14preferContactAvatars\x18\x0f \x01(\bR\x14preferContactAvatars\x123\n" + - "\bpayments\x18\x10 \x01(\v2\x17.signalservice.PaymentsR\bpayments\x122\n" + - "\x14universalExpireTimer\x18\x11 \x01(\rR\x14universalExpireTimer\x12(\n" + - "\x0fprimarySendsSms\x18\x12 \x01(\bR\x0fprimarySendsSms\x126\n" + - "\x16preferredReactionEmoji\x18\x14 \x03(\tR\x16preferredReactionEmoji\x12\"\n" + - "\fsubscriberId\x18\x15 \x01(\fR\fsubscriberId\x126\n" + - "\x16subscriberCurrencyCode\x18\x16 \x01(\tR\x16subscriberCurrencyCode\x126\n" + - "\x16displayBadgesOnProfile\x18\x17 \x01(\bR\x16displayBadgesOnProfile\x12D\n" + - "\x1dsubscriptionManuallyCancelled\x18\x18 \x01(\bR\x1dsubscriptionManuallyCancelled\x126\n" + - "\x16keepMutedChatsArchived\x18\x19 \x01(\bR\x16keepMutedChatsArchived\x126\n" + - "\x16hasSetMyStoriesPrivacy\x18\x1a \x01(\bR\x16hasSetMyStoriesPrivacy\x12:\n" + - "\x18hasViewedOnboardingStory\x18\x1b \x01(\bR\x18hasViewedOnboardingStory\x12(\n" + - "\x0fstoriesDisabled\x18\x1d \x01(\bR\x0fstoriesDisabled\x12W\n" + - "\x18storyViewReceiptsEnabled\x18\x1e \x01(\x0e2\x1b.signalservice.OptionalBoolR\x18storyViewReceiptsEnabled\x12H\n" + - "\x1fhasSeenGroupStoryEducationSheet\x18 \x01(\bR\x1fhasSeenGroupStoryEducationSheet\x12\x1a\n" + - "\busername\x18! \x01(\tR\busername\x12F\n" + - "\x1ehasCompletedUsernameOnboarding\x18\" \x01(\bR\x1ehasCompletedUsernameOnboarding\x12M\n" + - "\fusernameLink\x18# \x01(\v2).signalservice.AccountRecord.UsernameLinkR\fusernameLink\x12!\n" + - "\thasBackup\x18' \x01(\bH\x00R\thasBackup\x88\x01\x01\x12#\n" + - "\n" + - "backupTier\x18( \x01(\x04H\x01R\n" + - "backupTier\x88\x01\x01\x12b\n" + - "\x14backupSubscriberData\x18) \x01(\v2..signalservice.AccountRecord.IAPSubscriberDataR\x14backupSubscriberData\x12A\n" + - "\vavatarColor\x18* \x01(\x0e2\x1a.signalservice.AvatarColorH\x02R\vavatarColor\x88\x01\x01\x12\\\n" + - "\x11backupTierHistory\x18+ \x01(\v2..signalservice.AccountRecord.BackupTierHistoryR\x11backupTierHistory\x12\x8c\x01\n" + - "!notificationProfileManualOverride\x18, \x01(\v2>.signalservice.AccountRecord.NotificationProfileManualOverrideR!notificationProfileManualOverride\x12H\n" + - "\x1fnotificationProfileSyncDisabled\x18- \x01(\bR\x1fnotificationProfileSyncDisabled\x12J\n" + - " automaticKeyVerificationDisabled\x18. \x01(\bR automaticKeyVerificationDisabled\x12L\n" + - "!hasSeenAdminDeleteEducationDialog\x18/ \x01(\bR!hasSeenAdminDeleteEducationDialog\x1a\xb0\x02\n" + - "\x12PinnedConversation\x12S\n" + - "\acontact\x18\x01 \x01(\v27.signalservice.AccountRecord.PinnedConversation.ContactH\x00R\acontact\x12&\n" + - "\rlegacyGroupId\x18\x03 \x01(\fH\x00R\rlegacyGroupId\x12(\n" + - "\x0egroupMasterKey\x18\x04 \x01(\fH\x00R\x0egroupMasterKey\x1ae\n" + - "\aContact\x12\x1c\n" + - "\tserviceId\x18\x01 \x01(\tR\tserviceId\x12\x12\n" + - "\x04e164\x18\x02 \x01(\tR\x04e164\x12(\n" + - "\x0fserviceIdBinary\x18\x03 \x01(\fR\x0fserviceIdBinaryB\f\n" + - "\n" + - "identifier\x1a\xf8\x01\n" + - "\fUsernameLink\x12\x18\n" + - "\aentropy\x18\x01 \x01(\fR\aentropy\x12\x1a\n" + - "\bserverId\x18\x02 \x01(\fR\bserverId\x12E\n" + - "\x05color\x18\x03 \x01(\x0e2/.signalservice.AccountRecord.UsernameLink.ColorR\x05color\"k\n" + - "\x05Color\x12\v\n" + - "\aUNKNOWN\x10\x00\x12\b\n" + - "\x04BLUE\x10\x01\x12\t\n" + - "\x05WHITE\x10\x02\x12\b\n" + - "\x04GREY\x10\x03\x12\t\n" + - "\x05OLIVE\x10\x04\x12\t\n" + - "\x05GREEN\x10\x05\x12\n" + - "\n" + - "\x06ORANGE\x10\x06\x12\b\n" + - "\x04PINK\x10\a\x12\n" + - "\n" + - "\x06PURPLE\x10\b\x1a\xac\x01\n" + - "\x11IAPSubscriberData\x12\"\n" + - "\fsubscriberId\x18\x01 \x01(\fR\fsubscriberId\x12&\n" + - "\rpurchaseToken\x18\x02 \x01(\tH\x00R\rpurchaseToken\x126\n" + - "\x15originalTransactionId\x18\x03 \x01(\x04H\x00R\x15originalTransactionIdB\x13\n" + - "\x11iapSubscriptionId\x1a\x8d\x01\n" + - "\x11BackupTierHistory\x12#\n" + - "\n" + - "backupTier\x18\x01 \x01(\x04H\x00R\n" + - "backupTier\x88\x01\x01\x12/\n" + - "\x10endedAtTimestamp\x18\x02 \x01(\x04H\x01R\x10endedAtTimestamp\x88\x01\x01B\r\n" + - "\v_backupTierB\x13\n" + - "\x11_endedAtTimestamp\x1a\xa2\x02\n" + - "!NotificationProfileManualOverride\x126\n" + - "\x15disabledAtTimestampMs\x18\x01 \x01(\x04H\x00R\x15disabledAtTimestampMs\x12j\n" + - "\aenabled\x18\x02 \x01(\v2N.signalservice.AccountRecord.NotificationProfileManualOverride.ManuallyEnabledH\x00R\aenabled\x1aM\n" + - "\x0fManuallyEnabled\x12\x0e\n" + - "\x02id\x18\x01 \x01(\fR\x02id\x12*\n" + - "\x10endAtTimestampMs\x18\x03 \x01(\x04R\x10endAtTimestampMsB\n" + - "\n" + - "\boverride\"@\n" + - "\x16PhoneNumberSharingMode\x12\v\n" + - "\aUNKNOWN\x10\x00\x12\r\n" + - "\tEVERYBODY\x10\x01\x12\n" + - "\n" + - "\x06NOBODY\x10\x02B\f\n" + - "\n" + - "_hasBackupB\r\n" + - "\v_backupTierB\x0e\n" + - "\f_avatarColorJ\x04\b\t\x10\n" + - "J\x04\b\x13\x10\x14J\x04\b\x1c\x10\x1dJ\x04\b\x1f\x10 J\x04\b$\x10%J\x04\b%\x10&J\x04\b&\x10'\"\xb9\x02\n" + - "\x1bStoryDistributionListRecord\x12\x1e\n" + - "\n" + - "identifier\x18\x01 \x01(\fR\n" + - "identifier\x12\x12\n" + - "\x04name\x18\x02 \x01(\tR\x04name\x120\n" + - "\x13recipientServiceIds\x18\x03 \x03(\tR\x13recipientServiceIds\x12.\n" + - "\x12deletedAtTimestamp\x18\x04 \x01(\x04R\x12deletedAtTimestamp\x12$\n" + - "\rallowsReplies\x18\x05 \x01(\bR\rallowsReplies\x12 \n" + - "\visBlockList\x18\x06 \x01(\bR\visBlockList\x12<\n" + - "\x19recipientServiceIdsBinary\x18\a \x03(\fR\x19recipientServiceIdsBinary\"\x88\x01\n" + - "\x0eCallLinkRecord\x12\x18\n" + - "\arootKey\x18\x01 \x01(\fR\arootKey\x12\"\n" + - "\fadminPasskey\x18\x02 \x01(\fR\fadminPasskey\x122\n" + - "\x14deletedAtTimestampMs\x18\x03 \x01(\x04R\x14deletedAtTimestampMsJ\x04\b\x04\x10\x05\"\x90\x02\n" + - "\tRecipient\x12<\n" + - "\acontact\x18\x01 \x01(\v2 .signalservice.Recipient.ContactH\x00R\acontact\x12&\n" + - "\rlegacyGroupId\x18\x02 \x01(\fH\x00R\rlegacyGroupId\x12(\n" + - "\x0egroupMasterKey\x18\x03 \x01(\fH\x00R\x0egroupMasterKey\x1ae\n" + - "\aContact\x12\x1c\n" + - "\tserviceId\x18\x01 \x01(\tR\tserviceId\x12\x12\n" + - "\x04e164\x18\x02 \x01(\tR\x04e164\x12(\n" + - "\x0fserviceIdBinary\x18\x03 \x01(\fR\x0fserviceIdBinaryB\f\n" + - "\n" + - "identifier\"\xe8\x04\n" + - "\x10ChatFolderRecord\x12\x1e\n" + - "\n" + - "identifier\x18\x01 \x01(\fR\n" + - "identifier\x12\x12\n" + - "\x04name\x18\x02 \x01(\tR\x04name\x12\x1a\n" + - "\bposition\x18\x03 \x01(\rR\bposition\x12&\n" + - "\x0eshowOnlyUnread\x18\x04 \x01(\bR\x0eshowOnlyUnread\x12&\n" + - "\x0eshowMutedChats\x18\x05 \x01(\bR\x0eshowMutedChats\x12<\n" + - "\x19includeAllIndividualChats\x18\x06 \x01(\bR\x19includeAllIndividualChats\x122\n" + - "\x14includeAllGroupChats\x18\a \x01(\bR\x14includeAllGroupChats\x12J\n" + - "\n" + - "folderType\x18\b \x01(\x0e2*.signalservice.ChatFolderRecord.FolderTypeR\n" + - "folderType\x12H\n" + - "\x12includedRecipients\x18\t \x03(\v2\x18.signalservice.RecipientR\x12includedRecipients\x12H\n" + - "\x12excludedRecipients\x18\n" + - " \x03(\v2\x18.signalservice.RecipientR\x12excludedRecipients\x122\n" + - "\x14deletedAtTimestampMs\x18\v \x01(\x04R\x14deletedAtTimestampMs\".\n" + - "\n" + - "FolderType\x12\v\n" + - "\aUNKNOWN\x10\x00\x12\a\n" + - "\x03ALL\x10\x01\x12\n" + - "\n" + - "\x06CUSTOM\x10\x02\"\xb6\x05\n" + - "\x13NotificationProfile\x12\x0e\n" + - "\x02id\x18\x01 \x01(\fR\x02id\x12\x12\n" + - "\x04name\x18\x02 \x01(\tR\x04name\x12\x19\n" + - "\x05emoji\x18\x03 \x01(\tH\x00R\x05emoji\x88\x01\x01\x12\x14\n" + - "\x05color\x18\x04 \x01(\aR\x05color\x12 \n" + - "\vcreatedAtMs\x18\x05 \x01(\x04R\vcreatedAtMs\x12$\n" + - "\rallowAllCalls\x18\x06 \x01(\bR\rallowAllCalls\x12*\n" + - "\x10allowAllMentions\x18\a \x01(\bR\x10allowAllMentions\x12@\n" + - "\x0eallowedMembers\x18\b \x03(\v2\x18.signalservice.RecipientR\x0eallowedMembers\x12(\n" + - "\x0fscheduleEnabled\x18\t \x01(\bR\x0fscheduleEnabled\x12,\n" + - "\x11scheduleStartTime\x18\n" + - " \x01(\rR\x11scheduleStartTime\x12(\n" + - "\x0fscheduleEndTime\x18\v \x01(\rR\x0fscheduleEndTime\x12^\n" + - "\x13scheduleDaysEnabled\x18\f \x03(\x0e2,.signalservice.NotificationProfile.DayOfWeekR\x13scheduleDaysEnabled\x122\n" + - "\x14deletedAtTimestampMs\x18\r \x01(\x04R\x14deletedAtTimestampMs\"t\n" + - "\tDayOfWeek\x12\v\n" + - "\aUNKNOWN\x10\x00\x12\n" + - "\n" + - "\x06MONDAY\x10\x01\x12\v\n" + - "\aTUESDAY\x10\x02\x12\r\n" + - "\tWEDNESDAY\x10\x03\x12\f\n" + - "\bTHURSDAY\x10\x04\x12\n" + - "\n" + - "\x06FRIDAY\x10\x05\x12\f\n" + - "\bSATURDAY\x10\x06\x12\n" + - "\n" + - "\x06SUNDAY\x10\aB\b\n" + - "\x06_emoji*4\n" + - "\fOptionalBool\x12\t\n" + - "\x05UNSET\x10\x00\x12\v\n" + - "\aENABLED\x10\x01\x12\f\n" + - "\bDISABLED\x10\x02*\x85\x01\n" + - "\vAvatarColor\x12\b\n" + - "\x04A100\x10\x00\x12\b\n" + - "\x04A110\x10\x01\x12\b\n" + - "\x04A120\x10\x02\x12\b\n" + - "\x04A130\x10\x03\x12\b\n" + - "\x04A140\x10\x04\x12\b\n" + - "\x04A150\x10\x05\x12\b\n" + - "\x04A160\x10\x06\x12\b\n" + - "\x04A170\x10\a\x12\b\n" + - "\x04A180\x10\b\x12\b\n" + - "\x04A190\x10\t\x12\b\n" + - "\x04A200\x10\n" + - "\x12\b\n" + - "\x04A210\x10\vB<\n" + - "8org.whispersystems.signalservice.internal.storage.protosP\x01b\x06proto3" - -var ( - file_StorageService_proto_rawDescOnce sync.Once - file_StorageService_proto_rawDescData []byte -) - -func file_StorageService_proto_rawDescGZIP() []byte { - file_StorageService_proto_rawDescOnce.Do(func() { - file_StorageService_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_StorageService_proto_rawDesc), len(file_StorageService_proto_rawDesc))) - }) - return file_StorageService_proto_rawDescData -} - -var file_StorageService_proto_enumTypes = make([]protoimpl.EnumInfo, 9) -var file_StorageService_proto_msgTypes = make([]protoimpl.MessageInfo, 27) -var file_StorageService_proto_goTypes = []any{ - (OptionalBool)(0), // 0: signalservice.OptionalBool - (AvatarColor)(0), // 1: signalservice.AvatarColor - (ManifestRecord_Identifier_Type)(0), // 2: signalservice.ManifestRecord.Identifier.Type - (ContactRecord_IdentityState)(0), // 3: signalservice.ContactRecord.IdentityState - (GroupV2Record_StorySendMode)(0), // 4: signalservice.GroupV2Record.StorySendMode - (AccountRecord_PhoneNumberSharingMode)(0), // 5: signalservice.AccountRecord.PhoneNumberSharingMode - (AccountRecord_UsernameLink_Color)(0), // 6: signalservice.AccountRecord.UsernameLink.Color - (ChatFolderRecord_FolderType)(0), // 7: signalservice.ChatFolderRecord.FolderType - (NotificationProfile_DayOfWeek)(0), // 8: signalservice.NotificationProfile.DayOfWeek - (*StorageManifest)(nil), // 9: signalservice.StorageManifest - (*StorageItem)(nil), // 10: signalservice.StorageItem - (*StorageItems)(nil), // 11: signalservice.StorageItems - (*ReadOperation)(nil), // 12: signalservice.ReadOperation - (*WriteOperation)(nil), // 13: signalservice.WriteOperation - (*ManifestRecord)(nil), // 14: signalservice.ManifestRecord - (*StorageRecord)(nil), // 15: signalservice.StorageRecord - (*ContactRecord)(nil), // 16: signalservice.ContactRecord - (*GroupV1Record)(nil), // 17: signalservice.GroupV1Record - (*GroupV2Record)(nil), // 18: signalservice.GroupV2Record - (*Payments)(nil), // 19: signalservice.Payments - (*AccountRecord)(nil), // 20: signalservice.AccountRecord - (*StoryDistributionListRecord)(nil), // 21: signalservice.StoryDistributionListRecord - (*CallLinkRecord)(nil), // 22: signalservice.CallLinkRecord - (*Recipient)(nil), // 23: signalservice.Recipient - (*ChatFolderRecord)(nil), // 24: signalservice.ChatFolderRecord - (*NotificationProfile)(nil), // 25: signalservice.NotificationProfile - (*ManifestRecord_Identifier)(nil), // 26: signalservice.ManifestRecord.Identifier - (*ContactRecord_Name)(nil), // 27: signalservice.ContactRecord.Name - (*AccountRecord_PinnedConversation)(nil), // 28: signalservice.AccountRecord.PinnedConversation - (*AccountRecord_UsernameLink)(nil), // 29: signalservice.AccountRecord.UsernameLink - (*AccountRecord_IAPSubscriberData)(nil), // 30: signalservice.AccountRecord.IAPSubscriberData - (*AccountRecord_BackupTierHistory)(nil), // 31: signalservice.AccountRecord.BackupTierHistory - (*AccountRecord_NotificationProfileManualOverride)(nil), // 32: signalservice.AccountRecord.NotificationProfileManualOverride - (*AccountRecord_PinnedConversation_Contact)(nil), // 33: signalservice.AccountRecord.PinnedConversation.Contact - (*AccountRecord_NotificationProfileManualOverride_ManuallyEnabled)(nil), // 34: signalservice.AccountRecord.NotificationProfileManualOverride.ManuallyEnabled - (*Recipient_Contact)(nil), // 35: signalservice.Recipient.Contact -} -var file_StorageService_proto_depIdxs = []int32{ - 10, // 0: signalservice.StorageItems.items:type_name -> signalservice.StorageItem - 9, // 1: signalservice.WriteOperation.manifest:type_name -> signalservice.StorageManifest - 10, // 2: signalservice.WriteOperation.insertItem:type_name -> signalservice.StorageItem - 26, // 3: signalservice.ManifestRecord.identifiers:type_name -> signalservice.ManifestRecord.Identifier - 16, // 4: signalservice.StorageRecord.contact:type_name -> signalservice.ContactRecord - 17, // 5: signalservice.StorageRecord.groupV1:type_name -> signalservice.GroupV1Record - 18, // 6: signalservice.StorageRecord.groupV2:type_name -> signalservice.GroupV2Record - 20, // 7: signalservice.StorageRecord.account:type_name -> signalservice.AccountRecord - 21, // 8: signalservice.StorageRecord.storyDistributionList:type_name -> signalservice.StoryDistributionListRecord - 22, // 9: signalservice.StorageRecord.callLink:type_name -> signalservice.CallLinkRecord - 24, // 10: signalservice.StorageRecord.chatFolder:type_name -> signalservice.ChatFolderRecord - 25, // 11: signalservice.StorageRecord.notificationProfile:type_name -> signalservice.NotificationProfile - 3, // 12: signalservice.ContactRecord.identityState:type_name -> signalservice.ContactRecord.IdentityState - 27, // 13: signalservice.ContactRecord.nickname:type_name -> signalservice.ContactRecord.Name - 1, // 14: signalservice.ContactRecord.avatarColor:type_name -> signalservice.AvatarColor - 4, // 15: signalservice.GroupV2Record.storySendMode:type_name -> signalservice.GroupV2Record.StorySendMode - 1, // 16: signalservice.GroupV2Record.avatarColor:type_name -> signalservice.AvatarColor - 5, // 17: signalservice.AccountRecord.phoneNumberSharingMode:type_name -> signalservice.AccountRecord.PhoneNumberSharingMode - 28, // 18: signalservice.AccountRecord.pinnedConversations:type_name -> signalservice.AccountRecord.PinnedConversation - 19, // 19: signalservice.AccountRecord.payments:type_name -> signalservice.Payments - 0, // 20: signalservice.AccountRecord.storyViewReceiptsEnabled:type_name -> signalservice.OptionalBool - 29, // 21: signalservice.AccountRecord.usernameLink:type_name -> signalservice.AccountRecord.UsernameLink - 30, // 22: signalservice.AccountRecord.backupSubscriberData:type_name -> signalservice.AccountRecord.IAPSubscriberData - 1, // 23: signalservice.AccountRecord.avatarColor:type_name -> signalservice.AvatarColor - 31, // 24: signalservice.AccountRecord.backupTierHistory:type_name -> signalservice.AccountRecord.BackupTierHistory - 32, // 25: signalservice.AccountRecord.notificationProfileManualOverride:type_name -> signalservice.AccountRecord.NotificationProfileManualOverride - 35, // 26: signalservice.Recipient.contact:type_name -> signalservice.Recipient.Contact - 7, // 27: signalservice.ChatFolderRecord.folderType:type_name -> signalservice.ChatFolderRecord.FolderType - 23, // 28: signalservice.ChatFolderRecord.includedRecipients:type_name -> signalservice.Recipient - 23, // 29: signalservice.ChatFolderRecord.excludedRecipients:type_name -> signalservice.Recipient - 23, // 30: signalservice.NotificationProfile.allowedMembers:type_name -> signalservice.Recipient - 8, // 31: signalservice.NotificationProfile.scheduleDaysEnabled:type_name -> signalservice.NotificationProfile.DayOfWeek - 2, // 32: signalservice.ManifestRecord.Identifier.type:type_name -> signalservice.ManifestRecord.Identifier.Type - 33, // 33: signalservice.AccountRecord.PinnedConversation.contact:type_name -> signalservice.AccountRecord.PinnedConversation.Contact - 6, // 34: signalservice.AccountRecord.UsernameLink.color:type_name -> signalservice.AccountRecord.UsernameLink.Color - 34, // 35: signalservice.AccountRecord.NotificationProfileManualOverride.enabled:type_name -> signalservice.AccountRecord.NotificationProfileManualOverride.ManuallyEnabled - 36, // [36:36] is the sub-list for method output_type - 36, // [36:36] is the sub-list for method input_type - 36, // [36:36] is the sub-list for extension type_name - 36, // [36:36] is the sub-list for extension extendee - 0, // [0:36] is the sub-list for field type_name -} - -func init() { file_StorageService_proto_init() } -func file_StorageService_proto_init() { - if File_StorageService_proto != nil { - return - } - file_StorageService_proto_msgTypes[6].OneofWrappers = []any{ - (*StorageRecord_Contact)(nil), - (*StorageRecord_GroupV1)(nil), - (*StorageRecord_GroupV2)(nil), - (*StorageRecord_Account)(nil), - (*StorageRecord_StoryDistributionList)(nil), - (*StorageRecord_CallLink)(nil), - (*StorageRecord_ChatFolder)(nil), - (*StorageRecord_NotificationProfile)(nil), - } - file_StorageService_proto_msgTypes[7].OneofWrappers = []any{} - file_StorageService_proto_msgTypes[9].OneofWrappers = []any{} - file_StorageService_proto_msgTypes[11].OneofWrappers = []any{} - file_StorageService_proto_msgTypes[14].OneofWrappers = []any{ - (*Recipient_Contact_)(nil), - (*Recipient_LegacyGroupId)(nil), - (*Recipient_GroupMasterKey)(nil), - } - file_StorageService_proto_msgTypes[16].OneofWrappers = []any{} - file_StorageService_proto_msgTypes[19].OneofWrappers = []any{ - (*AccountRecord_PinnedConversation_Contact_)(nil), - (*AccountRecord_PinnedConversation_LegacyGroupId)(nil), - (*AccountRecord_PinnedConversation_GroupMasterKey)(nil), - } - file_StorageService_proto_msgTypes[21].OneofWrappers = []any{ - (*AccountRecord_IAPSubscriberData_PurchaseToken)(nil), - (*AccountRecord_IAPSubscriberData_OriginalTransactionId)(nil), - } - file_StorageService_proto_msgTypes[22].OneofWrappers = []any{} - file_StorageService_proto_msgTypes[23].OneofWrappers = []any{ - (*AccountRecord_NotificationProfileManualOverride_DisabledAtTimestampMs)(nil), - (*AccountRecord_NotificationProfileManualOverride_Enabled)(nil), - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_StorageService_proto_rawDesc), len(file_StorageService_proto_rawDesc)), - NumEnums: 9, - NumMessages: 27, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_StorageService_proto_goTypes, - DependencyIndexes: file_StorageService_proto_depIdxs, - EnumInfos: file_StorageService_proto_enumTypes, - MessageInfos: file_StorageService_proto_msgTypes, - }.Build() - File_StorageService_proto = out.File - file_StorageService_proto_goTypes = nil - file_StorageService_proto_depIdxs = nil -} diff --git a/pkg/signalmeow/protobuf/StorageService.proto b/pkg/signalmeow/protobuf/StorageService.proto deleted file mode 100644 index dd232ca..0000000 --- a/pkg/signalmeow/protobuf/StorageService.proto +++ /dev/null @@ -1,380 +0,0 @@ -/** - * Copyright (C) 2019 Open Whisper Systems - * - * Licensed according to the LICENSE file in this repository. - */ -syntax = "proto3"; - -package signalservice; - -option java_package = "org.whispersystems.signalservice.internal.storage.protos"; -option java_multiple_files = true; - -enum OptionalBool { - UNSET = 0; - ENABLED = 1; - DISABLED = 2; -} - -message StorageManifest { - uint64 version = 1; - bytes value = 2; -} - -message StorageItem { - bytes key = 1; - bytes value = 2; -} - -message StorageItems { - repeated StorageItem items = 1; -} - -message ReadOperation { - repeated bytes readKey = 1; -} - -message WriteOperation { - StorageManifest manifest = 1; - repeated StorageItem insertItem = 2; - repeated bytes deleteKey = 3; - bool clearAll = 4; -} - -message ManifestRecord { - message Identifier { - enum Type { - UNKNOWN = 0; - CONTACT = 1; - GROUPV1 = 2; - GROUPV2 = 3; - ACCOUNT = 4; - STORY_DISTRIBUTION_LIST = 5; - CALL_LINK = 7; - CHAT_FOLDER = 8; - NOTIFICATION_PROFILE = 9; - } - - bytes raw = 1; - Type type = 2; - } - - uint64 version = 1; - uint32 sourceDevice = 3; - repeated Identifier identifiers = 2; - bytes recordIkm = 4; - // Next ID: 5 -} - -message StorageRecord { - oneof record { - ContactRecord contact = 1; - GroupV1Record groupV1 = 2; - GroupV2Record groupV2 = 3; - AccountRecord account = 4; - StoryDistributionListRecord storyDistributionList = 5; - CallLinkRecord callLink = 7; - ChatFolderRecord chatFolder = 8; - NotificationProfile notificationProfile = 9; - } -} - - -// If unset - computed as the value of the first byte of SHA-256(msg=CONTACT_ID) -// modulo the count of colors. Once set the avatar color for a recipient is -// never recomputed or changed. -// -// `CONTACT_ID` is the first available identifier from the list: -// - ServiceIdToBinary(ACI) -// - E164 -// - ServiceIdToBinary(PNI) -// - Group Id -enum AvatarColor { - A100 = 0; - A110 = 1; - A120 = 2; - A130 = 3; - A140 = 4; - A150 = 5; - A160 = 6; - A170 = 7; - A180 = 8; - A190 = 9; - A200 = 10; - A210 = 11; -} - -message ContactRecord { - enum IdentityState { - DEFAULT = 0; - VERIFIED = 1; - UNVERIFIED = 2; - } - - message Name { - string given = 1; - string family = 2; - } - - string aci = 1; - string e164 = 2; - string pni = 15; - bytes profileKey = 3; - bytes identityKey = 4; - IdentityState identityState = 5; - string givenName = 6; - string familyName = 7; - string username = 8; - bool blocked = 9; - bool whitelisted = 10; - bool archived = 11; - bool markedUnread = 12; - uint64 mutedUntilTimestamp = 13; - bool hideStory = 14; - uint64 unregisteredAtTimestamp = 16; - string systemGivenName = 17; - string systemFamilyName = 18; - string systemNickname = 19; - bool hidden = 20; - bool pniSignatureVerified = 21; - Name nickname = 22; - string note = 23; - optional AvatarColor avatarColor = 24; - bytes aciBinary = 25; // 16-byte UUID - bytes pniBinary = 26; // 16-byte UUID - // Next ID: 27 -} - -message GroupV1Record { - bytes id = 1; - bool blocked = 2; - bool whitelisted = 3; - bool archived = 4; - bool markedUnread = 5; - uint64 mutedUntilTimestamp = 6; -} - -message GroupV2Record { - enum StorySendMode { - DEFAULT = 0; - DISABLED = 1; - ENABLED = 2; - } - - bytes masterKey = 1; - bool blocked = 2; - bool whitelisted = 3; - bool archived = 4; - bool markedUnread = 5; - uint64 mutedUntilTimestamp = 6; - bool dontNotifyForMentionsIfMuted = 7; - bool hideStory = 8; - reserved /* storySendEnabled */ 9; - StorySendMode storySendMode = 10; - optional AvatarColor avatarColor = 11; - bytes verifiedNameHash = 12; // SHA-256 of UTF-8 encoded decrypted group title that was last verified -} - -message Payments { - bool enabled = 1; - bytes entropy = 2; -} - -message AccountRecord { - - enum PhoneNumberSharingMode { - UNKNOWN = 0; - EVERYBODY = 1; - NOBODY = 2; - } - - message PinnedConversation { - message Contact { - string serviceId = 1; - string e164 = 2; - bytes serviceIdBinary = 3; // service ID binary (i.e. 16 byte UUID for ACI, 1 byte prefix + 16 byte UUID for PNI) - } - - oneof identifier { - Contact contact = 1; - bytes legacyGroupId = 3; - bytes groupMasterKey = 4; - } - } - - message UsernameLink { - enum Color { - UNKNOWN = 0; - BLUE = 1; - WHITE = 2; - GREY = 3; - OLIVE = 4; - GREEN = 5; - ORANGE = 6; - PINK = 7; - PURPLE = 8; - } - - bytes entropy = 1; // 32 bytes of entropy used for encryption - bytes serverId = 2; // 16 bytes of encoded UUID provided by the server - Color color = 3; - } - - message IAPSubscriberData { - bytes subscriberId = 1; - - oneof iapSubscriptionId { - // Identifies an Android Play Store IAP subscription. - string purchaseToken = 2; - // Identifies an iOS App Store IAP subscription. - uint64 originalTransactionId = 3; - } - } - - message BackupTierHistory { - // See zkgroup for integer particular values. Unset if backups are not enabled. - optional uint64 backupTier = 1; - optional uint64 endedAtTimestamp = 2; - } - - message NotificationProfileManualOverride { - message ManuallyEnabled { - bytes id = 1; - - // This will be unset if no timespan was chosen in the UI. - uint64 endAtTimestampMs = 3; - } - - oneof override { - uint64 disabledAtTimestampMs = 1; - ManuallyEnabled enabled = 2; - } - } - - bytes profileKey = 1; - string givenName = 2; - string familyName = 3; - string avatarUrlPath = 4; - bool noteToSelfArchived = 5; - bool readReceipts = 6; - bool sealedSenderIndicators = 7; - bool typingIndicators = 8; - reserved /* proxiedLinkPreviews */ 9; - bool noteToSelfMarkedUnread = 10; - bool linkPreviews = 11; - PhoneNumberSharingMode phoneNumberSharingMode = 12; - bool unlistedPhoneNumber = 13; - repeated PinnedConversation pinnedConversations = 14; - bool preferContactAvatars = 15; - Payments payments = 16; - uint32 universalExpireTimer = 17; - bool primarySendsSms = 18; - reserved /* e164 */ 19; - repeated string preferredReactionEmoji = 20; - bytes subscriberId = 21; - string subscriberCurrencyCode = 22; - bool displayBadgesOnProfile = 23; - bool subscriptionManuallyCancelled = 24; - bool keepMutedChatsArchived = 25; - bool hasSetMyStoriesPrivacy = 26; - bool hasViewedOnboardingStory = 27; - reserved /* storiesDisabled */ 28; - bool storiesDisabled = 29; - OptionalBool storyViewReceiptsEnabled = 30; - reserved /* hasReadOnboardingStory */ 31; - bool hasSeenGroupStoryEducationSheet = 32; - string username = 33; - bool hasCompletedUsernameOnboarding = 34; - UsernameLink usernameLink = 35; - reserved /* backupsSubscriberId */ 36; - reserved /* backupsSubscriberCurrencyCode */ 37; - reserved /* backupsSubscriptionManuallyCancelled */ 38; - optional bool hasBackup = 39; // Set to true after backups are enabled and one is uploaded. - optional uint64 backupTier = 40; // See zkgroup for integer particular values. Unset if backups are not enabled. - IAPSubscriberData backupSubscriberData = 41; - optional AvatarColor avatarColor = 42; - BackupTierHistory backupTierHistory = 43; - NotificationProfileManualOverride notificationProfileManualOverride = 44; - bool notificationProfileSyncDisabled = 45; - bool automaticKeyVerificationDisabled = 46; - bool hasSeenAdminDeleteEducationDialog = 47; -} - -message StoryDistributionListRecord { - bytes identifier = 1; - string name = 2; - repeated string recipientServiceIds = 3; - uint64 deletedAtTimestamp = 4; - bool allowsReplies = 5; - bool isBlockList = 6; - repeated bytes recipientServiceIdsBinary = 7; // service ID binary (i.e. 16 byte UUID for ACI, 1 byte prefix + 16 byte UUID for PNI) -} - -message CallLinkRecord { - bytes rootKey = 1; - bytes adminPasskey = 2; - uint64 deletedAtTimestampMs = 3; - reserved 4; // was epoch field, never used -} - -message Recipient { - message Contact { - string serviceId = 1; - string e164 = 2; - bytes serviceIdBinary = 3; // service ID binary (i.e. 16 byte UUID for ACI, 1 byte prefix + 16 byte UUID for PNI) - } - - oneof identifier { - Contact contact = 1; - bytes legacyGroupId = 2; - bytes groupMasterKey = 3; - } -} - -message ChatFolderRecord { - // Represents the default "All chats" folder record vs all other custom folders - enum FolderType { - UNKNOWN = 0; - ALL = 1; - CUSTOM = 2; - } - - bytes identifier = 1; - string name = 2; - uint32 position = 3; - bool showOnlyUnread = 4; - bool showMutedChats = 5; - bool includeAllIndividualChats = 6; // Folder includes all 1:1 chats, unless excluded - bool includeAllGroupChats = 7; // Folder includes all group chats, unless excluded - FolderType folderType = 8; - repeated Recipient includedRecipients = 9; - repeated Recipient excludedRecipients = 10; - uint64 deletedAtTimestampMs = 11; // When non-zero, `position` should be set to -1 and includedRecipients should be empty -} - -message NotificationProfile { - enum DayOfWeek { - UNKNOWN = 0; // Interpret as "Monday" - MONDAY = 1; - TUESDAY = 2; - WEDNESDAY = 3; - THURSDAY = 4; - FRIDAY = 5; - SATURDAY = 6; - SUNDAY = 7; - } - - bytes id = 1; - string name = 2; - optional string emoji = 3; - fixed32 color = 4; // 0xAARRGGBB - uint64 createdAtMs = 5; - bool allowAllCalls = 6; - bool allowAllMentions = 7; - repeated Recipient allowedMembers = 8; - bool scheduleEnabled = 9; - uint32 scheduleStartTime = 10; // 24-hour clock int, 0000-2359 (e.g., 15, 900, 1130, 2345) - uint32 scheduleEndTime = 11; // 24-hour clock int, 0000-2359 (e.g., 15, 900, 1130, 2345) - repeated DayOfWeek scheduleDaysEnabled = 12; - uint64 deletedAtTimestampMs = 13; -} diff --git a/pkg/signalmeow/protobuf/UnidentifiedDelivery.pb.go b/pkg/signalmeow/protobuf/UnidentifiedDelivery.pb.go index 5979a4c..9f95088 100644 --- a/pkg/signalmeow/protobuf/UnidentifiedDelivery.pb.go +++ b/pkg/signalmeow/protobuf/UnidentifiedDelivery.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.11 -// protoc v7.34.1 +// protoc-gen-go v1.31.0 +// protoc v3.21.12 // source: UnidentifiedDelivery.proto // Copyright 2018 Signal Messenger, LLC @@ -14,7 +14,6 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" - unsafe "unsafe" ) const ( @@ -27,10 +26,8 @@ const ( type UnidentifiedSenderMessage_Message_Type int32 const ( - // Our parser does not handle reserved in enums: DESKTOP-1569 - // reserved 1; - UnidentifiedSenderMessage_Message_MESSAGE UnidentifiedSenderMessage_Message_Type = 2 - UnidentifiedSenderMessage_Message_PREKEY_MESSAGE UnidentifiedSenderMessage_Message_Type = 3 // Further cases should line up with Envelope.Type, even though old cases don't. + UnidentifiedSenderMessage_Message_PREKEY_MESSAGE UnidentifiedSenderMessage_Message_Type = 1 + UnidentifiedSenderMessage_Message_MESSAGE UnidentifiedSenderMessage_Message_Type = 2 // Further cases should line up with Envelope.Type, even though old cases don't. UnidentifiedSenderMessage_Message_SENDERKEY_MESSAGE UnidentifiedSenderMessage_Message_Type = 7 UnidentifiedSenderMessage_Message_PLAINTEXT_CONTENT UnidentifiedSenderMessage_Message_Type = 8 ) @@ -38,14 +35,14 @@ const ( // Enum value maps for UnidentifiedSenderMessage_Message_Type. var ( UnidentifiedSenderMessage_Message_Type_name = map[int32]string{ + 1: "PREKEY_MESSAGE", 2: "MESSAGE", - 3: "PREKEY_MESSAGE", 7: "SENDERKEY_MESSAGE", 8: "PLAINTEXT_CONTENT", } UnidentifiedSenderMessage_Message_Type_value = map[string]int32{ + "PREKEY_MESSAGE": 1, "MESSAGE": 2, - "PREKEY_MESSAGE": 3, "SENDERKEY_MESSAGE": 7, "PLAINTEXT_CONTENT": 8, } @@ -151,18 +148,21 @@ func (UnidentifiedSenderMessage_Message_ContentHint) EnumDescriptor() ([]byte, [ } type ServerCertificate struct { - state protoimpl.MessageState `protogen:"open.v1"` - Certificate []byte `protobuf:"bytes,1,opt,name=certificate" json:"certificate,omitempty"` - Signature []byte `protobuf:"bytes,2,opt,name=signature" json:"signature,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Certificate []byte `protobuf:"bytes,1,opt,name=certificate" json:"certificate,omitempty"` + Signature []byte `protobuf:"bytes,2,opt,name=signature" json:"signature,omitempty"` } func (x *ServerCertificate) Reset() { *x = ServerCertificate{} - mi := &file_UnidentifiedDelivery_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_UnidentifiedDelivery_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *ServerCertificate) String() string { @@ -173,7 +173,7 @@ func (*ServerCertificate) ProtoMessage() {} func (x *ServerCertificate) ProtoReflect() protoreflect.Message { mi := &file_UnidentifiedDelivery_proto_msgTypes[0] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -203,18 +203,21 @@ func (x *ServerCertificate) GetSignature() []byte { } type SenderCertificate struct { - state protoimpl.MessageState `protogen:"open.v1"` - Certificate []byte `protobuf:"bytes,1,opt,name=certificate" json:"certificate,omitempty"` - Signature []byte `protobuf:"bytes,2,opt,name=signature" json:"signature,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Certificate []byte `protobuf:"bytes,1,opt,name=certificate" json:"certificate,omitempty"` + Signature []byte `protobuf:"bytes,2,opt,name=signature" json:"signature,omitempty"` } func (x *SenderCertificate) Reset() { *x = SenderCertificate{} - mi := &file_UnidentifiedDelivery_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_UnidentifiedDelivery_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *SenderCertificate) String() string { @@ -225,7 +228,7 @@ func (*SenderCertificate) ProtoMessage() {} func (x *SenderCertificate) ProtoReflect() protoreflect.Message { mi := &file_UnidentifiedDelivery_proto_msgTypes[1] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -255,19 +258,22 @@ func (x *SenderCertificate) GetSignature() []byte { } type UnidentifiedSenderMessage struct { - state protoimpl.MessageState `protogen:"open.v1"` - EphemeralPublic []byte `protobuf:"bytes,1,opt,name=ephemeralPublic" json:"ephemeralPublic,omitempty"` - EncryptedStatic []byte `protobuf:"bytes,2,opt,name=encryptedStatic" json:"encryptedStatic,omitempty"` - EncryptedMessage []byte `protobuf:"bytes,3,opt,name=encryptedMessage" json:"encryptedMessage,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + EphemeralPublic []byte `protobuf:"bytes,1,opt,name=ephemeralPublic" json:"ephemeralPublic,omitempty"` + EncryptedStatic []byte `protobuf:"bytes,2,opt,name=encryptedStatic" json:"encryptedStatic,omitempty"` + EncryptedMessage []byte `protobuf:"bytes,3,opt,name=encryptedMessage" json:"encryptedMessage,omitempty"` } func (x *UnidentifiedSenderMessage) Reset() { *x = UnidentifiedSenderMessage{} - mi := &file_UnidentifiedDelivery_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_UnidentifiedDelivery_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *UnidentifiedSenderMessage) String() string { @@ -278,7 +284,7 @@ func (*UnidentifiedSenderMessage) ProtoMessage() {} func (x *UnidentifiedSenderMessage) ProtoReflect() protoreflect.Message { mi := &file_UnidentifiedDelivery_proto_msgTypes[2] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -315,18 +321,21 @@ func (x *UnidentifiedSenderMessage) GetEncryptedMessage() []byte { } type ServerCertificate_Certificate struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id *uint32 `protobuf:"varint,1,opt,name=id" json:"id,omitempty"` - Key []byte `protobuf:"bytes,2,opt,name=key" json:"key,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id *uint32 `protobuf:"varint,1,opt,name=id" json:"id,omitempty"` + Key []byte `protobuf:"bytes,2,opt,name=key" json:"key,omitempty"` } func (x *ServerCertificate_Certificate) Reset() { *x = ServerCertificate_Certificate{} - mi := &file_UnidentifiedDelivery_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_UnidentifiedDelivery_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *ServerCertificate_Certificate) String() string { @@ -337,7 +346,7 @@ func (*ServerCertificate_Certificate) ProtoMessage() {} func (x *ServerCertificate_Certificate) ProtoReflect() protoreflect.Message { mi := &file_UnidentifiedDelivery_proto_msgTypes[3] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -367,22 +376,25 @@ func (x *ServerCertificate_Certificate) GetKey() []byte { } type SenderCertificate_Certificate struct { - state protoimpl.MessageState `protogen:"open.v1"` - SenderE164 *string `protobuf:"bytes,1,opt,name=senderE164" json:"senderE164,omitempty"` - SenderUuid *string `protobuf:"bytes,6,opt,name=senderUuid" json:"senderUuid,omitempty"` - SenderDevice *uint32 `protobuf:"varint,2,opt,name=senderDevice" json:"senderDevice,omitempty"` - Expires *uint64 `protobuf:"fixed64,3,opt,name=expires" json:"expires,omitempty"` - IdentityKey []byte `protobuf:"bytes,4,opt,name=identityKey" json:"identityKey,omitempty"` - Signer *ServerCertificate `protobuf:"bytes,5,opt,name=signer" json:"signer,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SenderE164 *string `protobuf:"bytes,1,opt,name=senderE164" json:"senderE164,omitempty"` + SenderUuid *string `protobuf:"bytes,6,opt,name=senderUuid" json:"senderUuid,omitempty"` + SenderDevice *uint32 `protobuf:"varint,2,opt,name=senderDevice" json:"senderDevice,omitempty"` + Expires *uint64 `protobuf:"fixed64,3,opt,name=expires" json:"expires,omitempty"` + IdentityKey []byte `protobuf:"bytes,4,opt,name=identityKey" json:"identityKey,omitempty"` + Signer *ServerCertificate `protobuf:"bytes,5,opt,name=signer" json:"signer,omitempty"` } func (x *SenderCertificate_Certificate) Reset() { *x = SenderCertificate_Certificate{} - mi := &file_UnidentifiedDelivery_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_UnidentifiedDelivery_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *SenderCertificate_Certificate) String() string { @@ -393,7 +405,7 @@ func (*SenderCertificate_Certificate) ProtoMessage() {} func (x *SenderCertificate_Certificate) ProtoReflect() protoreflect.Message { mi := &file_UnidentifiedDelivery_proto_msgTypes[4] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -451,21 +463,24 @@ func (x *SenderCertificate_Certificate) GetSigner() *ServerCertificate { } type UnidentifiedSenderMessage_Message struct { - state protoimpl.MessageState `protogen:"open.v1"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + Type *UnidentifiedSenderMessage_Message_Type `protobuf:"varint,1,opt,name=type,enum=signalservice.UnidentifiedSenderMessage_Message_Type" json:"type,omitempty"` SenderCertificate *SenderCertificate `protobuf:"bytes,2,opt,name=senderCertificate" json:"senderCertificate,omitempty"` Content []byte `protobuf:"bytes,3,opt,name=content" json:"content,omitempty"` ContentHint *UnidentifiedSenderMessage_Message_ContentHint `protobuf:"varint,4,opt,name=contentHint,enum=signalservice.UnidentifiedSenderMessage_Message_ContentHint" json:"contentHint,omitempty"` GroupId []byte `protobuf:"bytes,5,opt,name=groupId" json:"groupId,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache } func (x *UnidentifiedSenderMessage_Message) Reset() { *x = UnidentifiedSenderMessage_Message{} - mi := &file_UnidentifiedDelivery_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_UnidentifiedDelivery_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *UnidentifiedSenderMessage_Message) String() string { @@ -476,7 +491,7 @@ func (*UnidentifiedSenderMessage_Message) ProtoMessage() {} func (x *UnidentifiedSenderMessage_Message) ProtoReflect() protoreflect.Message { mi := &file_UnidentifiedDelivery_proto_msgTypes[5] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -495,7 +510,7 @@ func (x *UnidentifiedSenderMessage_Message) GetType() UnidentifiedSenderMessage_ if x != nil && x.Type != nil { return *x.Type } - return UnidentifiedSenderMessage_Message_MESSAGE + return UnidentifiedSenderMessage_Message_PREKEY_MESSAGE } func (x *UnidentifiedSenderMessage_Message) GetSenderCertificate() *SenderCertificate { @@ -528,66 +543,98 @@ func (x *UnidentifiedSenderMessage_Message) GetGroupId() []byte { var File_UnidentifiedDelivery_proto protoreflect.FileDescriptor -const file_UnidentifiedDelivery_proto_rawDesc = "" + - "\n" + - "\x1aUnidentifiedDelivery.proto\x12\rsignalservice\"\x84\x01\n" + - "\x11ServerCertificate\x12 \n" + - "\vcertificate\x18\x01 \x01(\fR\vcertificate\x12\x1c\n" + - "\tsignature\x18\x02 \x01(\fR\tsignature\x1a/\n" + - "\vCertificate\x12\x0e\n" + - "\x02id\x18\x01 \x01(\rR\x02id\x12\x10\n" + - "\x03key\x18\x02 \x01(\fR\x03key\"\xbd\x02\n" + - "\x11SenderCertificate\x12 \n" + - "\vcertificate\x18\x01 \x01(\fR\vcertificate\x12\x1c\n" + - "\tsignature\x18\x02 \x01(\fR\tsignature\x1a\xe7\x01\n" + - "\vCertificate\x12\x1e\n" + - "\n" + - "senderE164\x18\x01 \x01(\tR\n" + - "senderE164\x12\x1e\n" + - "\n" + - "senderUuid\x18\x06 \x01(\tR\n" + - "senderUuid\x12\"\n" + - "\fsenderDevice\x18\x02 \x01(\rR\fsenderDevice\x12\x18\n" + - "\aexpires\x18\x03 \x01(\x06R\aexpires\x12 \n" + - "\videntityKey\x18\x04 \x01(\fR\videntityKey\x128\n" + - "\x06signer\x18\x05 \x01(\v2 .signalservice.ServerCertificateR\x06signer\"\xe7\x04\n" + - "\x19UnidentifiedSenderMessage\x12(\n" + - "\x0fephemeralPublic\x18\x01 \x01(\fR\x0fephemeralPublic\x12(\n" + - "\x0fencryptedStatic\x18\x02 \x01(\fR\x0fencryptedStatic\x12*\n" + - "\x10encryptedMessage\x18\x03 \x01(\fR\x10encryptedMessage\x1a\xc9\x03\n" + - "\aMessage\x12I\n" + - "\x04type\x18\x01 \x01(\x0e25.signalservice.UnidentifiedSenderMessage.Message.TypeR\x04type\x12N\n" + - "\x11senderCertificate\x18\x02 \x01(\v2 .signalservice.SenderCertificateR\x11senderCertificate\x12\x18\n" + - "\acontent\x18\x03 \x01(\fR\acontent\x12^\n" + - "\vcontentHint\x18\x04 \x01(\x0e2<.signalservice.UnidentifiedSenderMessage.Message.ContentHintR\vcontentHint\x12\x18\n" + - "\agroupId\x18\x05 \x01(\fR\agroupId\"U\n" + - "\x04Type\x12\v\n" + - "\aMESSAGE\x10\x02\x12\x12\n" + - "\x0ePREKEY_MESSAGE\x10\x03\x12\x15\n" + - "\x11SENDERKEY_MESSAGE\x10\a\x12\x15\n" + - "\x11PLAINTEXT_CONTENT\x10\b\"8\n" + - "\vContentHint\x12\v\n" + - "\aDEFAULT\x10\x00\x12\x0e\n" + - "\n" + - "RESENDABLE\x10\x01\x12\f\n" + - "\bIMPLICIT\x10\x02B6\n" + - "%org.whispersystems.libsignal.protocolB\rWhisperProtos" +var file_UnidentifiedDelivery_proto_rawDesc = []byte{ + 0x0a, 0x1a, 0x55, 0x6e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x64, 0x44, 0x65, + 0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0d, 0x73, 0x69, + 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x22, 0x84, 0x01, 0x0a, 0x11, + 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, + 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, + 0x61, 0x74, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, + 0x65, 0x1a, 0x2f, 0x0a, 0x0b, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, + 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, + 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x6b, + 0x65, 0x79, 0x22, 0xbd, 0x02, 0x0a, 0x11, 0x53, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x43, 0x65, 0x72, + 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x65, 0x72, 0x74, + 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x63, + 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x69, + 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, + 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x1a, 0xe7, 0x01, 0x0a, 0x0b, 0x43, 0x65, 0x72, + 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x65, 0x6e, 0x64, + 0x65, 0x72, 0x45, 0x31, 0x36, 0x34, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, + 0x6e, 0x64, 0x65, 0x72, 0x45, 0x31, 0x36, 0x34, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x65, 0x6e, 0x64, + 0x65, 0x72, 0x55, 0x75, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, + 0x6e, 0x64, 0x65, 0x72, 0x55, 0x75, 0x69, 0x64, 0x12, 0x22, 0x0a, 0x0c, 0x73, 0x65, 0x6e, 0x64, + 0x65, 0x72, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, + 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, + 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x06, 0x52, 0x07, 0x65, + 0x78, 0x70, 0x69, 0x72, 0x65, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, + 0x74, 0x79, 0x4b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x69, 0x64, 0x65, + 0x6e, 0x74, 0x69, 0x74, 0x79, 0x4b, 0x65, 0x79, 0x12, 0x38, 0x0a, 0x06, 0x73, 0x69, 0x67, 0x6e, + 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, + 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, + 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x06, 0x73, 0x69, 0x67, 0x6e, + 0x65, 0x72, 0x22, 0xe7, 0x04, 0x0a, 0x19, 0x55, 0x6e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, + 0x69, 0x65, 0x64, 0x53, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x12, 0x28, 0x0a, 0x0f, 0x65, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x50, 0x75, 0x62, + 0x6c, 0x69, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0f, 0x65, 0x70, 0x68, 0x65, 0x6d, + 0x65, 0x72, 0x61, 0x6c, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x12, 0x28, 0x0a, 0x0f, 0x65, 0x6e, + 0x63, 0x72, 0x79, 0x70, 0x74, 0x65, 0x64, 0x53, 0x74, 0x61, 0x74, 0x69, 0x63, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x0f, 0x65, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x65, 0x64, 0x53, 0x74, + 0x61, 0x74, 0x69, 0x63, 0x12, 0x2a, 0x0a, 0x10, 0x65, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x65, + 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x10, + 0x65, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x1a, 0xc9, 0x03, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x49, 0x0a, 0x04, + 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x35, 0x2e, 0x73, 0x69, 0x67, + 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x55, 0x6e, 0x69, 0x64, 0x65, + 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x64, 0x53, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x54, 0x79, 0x70, + 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x4e, 0x0a, 0x11, 0x73, 0x65, 0x6e, 0x64, 0x65, + 0x72, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, + 0x63, 0x61, 0x74, 0x65, 0x52, 0x11, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x43, 0x65, 0x72, 0x74, + 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, + 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, + 0x74, 0x12, 0x5e, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x48, 0x69, 0x6e, 0x74, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x3c, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x55, 0x6e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, + 0x69, 0x65, 0x64, 0x53, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, + 0x48, 0x69, 0x6e, 0x74, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x48, 0x69, 0x6e, + 0x74, 0x12, 0x18, 0x0a, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x22, 0x55, 0x0a, 0x04, 0x54, + 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x0e, 0x50, 0x52, 0x45, 0x4b, 0x45, 0x59, 0x5f, 0x4d, 0x45, + 0x53, 0x53, 0x41, 0x47, 0x45, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x4d, 0x45, 0x53, 0x53, 0x41, + 0x47, 0x45, 0x10, 0x02, 0x12, 0x15, 0x0a, 0x11, 0x53, 0x45, 0x4e, 0x44, 0x45, 0x52, 0x4b, 0x45, + 0x59, 0x5f, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45, 0x10, 0x07, 0x12, 0x15, 0x0a, 0x11, 0x50, + 0x4c, 0x41, 0x49, 0x4e, 0x54, 0x45, 0x58, 0x54, 0x5f, 0x43, 0x4f, 0x4e, 0x54, 0x45, 0x4e, 0x54, + 0x10, 0x08, 0x22, 0x38, 0x0a, 0x0b, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x48, 0x69, 0x6e, + 0x74, 0x12, 0x0b, 0x0a, 0x07, 0x44, 0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, 0x10, 0x00, 0x12, 0x0e, + 0x0a, 0x0a, 0x52, 0x45, 0x53, 0x45, 0x4e, 0x44, 0x41, 0x42, 0x4c, 0x45, 0x10, 0x01, 0x12, 0x0c, + 0x0a, 0x08, 0x49, 0x4d, 0x50, 0x4c, 0x49, 0x43, 0x49, 0x54, 0x10, 0x02, 0x42, 0x36, 0x0a, 0x25, + 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x68, 0x69, 0x73, 0x70, 0x65, 0x72, 0x73, 0x79, 0x73, 0x74, 0x65, + 0x6d, 0x73, 0x2e, 0x6c, 0x69, 0x62, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x42, 0x0d, 0x57, 0x68, 0x69, 0x73, 0x70, 0x65, 0x72, 0x50, 0x72, + 0x6f, 0x74, 0x6f, 0x73, +} var ( file_UnidentifiedDelivery_proto_rawDescOnce sync.Once - file_UnidentifiedDelivery_proto_rawDescData []byte + file_UnidentifiedDelivery_proto_rawDescData = file_UnidentifiedDelivery_proto_rawDesc ) func file_UnidentifiedDelivery_proto_rawDescGZIP() []byte { file_UnidentifiedDelivery_proto_rawDescOnce.Do(func() { - file_UnidentifiedDelivery_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_UnidentifiedDelivery_proto_rawDesc), len(file_UnidentifiedDelivery_proto_rawDesc))) + file_UnidentifiedDelivery_proto_rawDescData = protoimpl.X.CompressGZIP(file_UnidentifiedDelivery_proto_rawDescData) }) return file_UnidentifiedDelivery_proto_rawDescData } var file_UnidentifiedDelivery_proto_enumTypes = make([]protoimpl.EnumInfo, 2) var file_UnidentifiedDelivery_proto_msgTypes = make([]protoimpl.MessageInfo, 6) -var file_UnidentifiedDelivery_proto_goTypes = []any{ +var file_UnidentifiedDelivery_proto_goTypes = []interface{}{ (UnidentifiedSenderMessage_Message_Type)(0), // 0: signalservice.UnidentifiedSenderMessage.Message.Type (UnidentifiedSenderMessage_Message_ContentHint)(0), // 1: signalservice.UnidentifiedSenderMessage.Message.ContentHint (*ServerCertificate)(nil), // 2: signalservice.ServerCertificate @@ -614,11 +661,85 @@ func file_UnidentifiedDelivery_proto_init() { if File_UnidentifiedDelivery_proto != nil { return } + if !protoimpl.UnsafeEnabled { + file_UnidentifiedDelivery_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ServerCertificate); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_UnidentifiedDelivery_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SenderCertificate); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_UnidentifiedDelivery_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UnidentifiedSenderMessage); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_UnidentifiedDelivery_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ServerCertificate_Certificate); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_UnidentifiedDelivery_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SenderCertificate_Certificate); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_UnidentifiedDelivery_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UnidentifiedSenderMessage_Message); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_UnidentifiedDelivery_proto_rawDesc), len(file_UnidentifiedDelivery_proto_rawDesc)), + RawDescriptor: file_UnidentifiedDelivery_proto_rawDesc, NumEnums: 2, NumMessages: 6, NumExtensions: 0, @@ -630,6 +751,7 @@ func file_UnidentifiedDelivery_proto_init() { MessageInfos: file_UnidentifiedDelivery_proto_msgTypes, }.Build() File_UnidentifiedDelivery_proto = out.File + file_UnidentifiedDelivery_proto_rawDesc = nil file_UnidentifiedDelivery_proto_goTypes = nil file_UnidentifiedDelivery_proto_depIdxs = nil } diff --git a/pkg/signalmeow/protobuf/UnidentifiedDelivery.proto b/pkg/signalmeow/protobuf/UnidentifiedDelivery.proto index 255ab6e..fb86b60 100644 --- a/pkg/signalmeow/protobuf/UnidentifiedDelivery.proto +++ b/pkg/signalmeow/protobuf/UnidentifiedDelivery.proto @@ -34,12 +34,11 @@ message UnidentifiedSenderMessage { message Message { enum Type { - // Our parser does not handle reserved in enums: DESKTOP-1569 - // reserved 1; + PREKEY_MESSAGE = 1; MESSAGE = 2; - PREKEY_MESSAGE = 3; // Further cases should line up with Envelope.Type, even though old cases don't. + // Our parser does not handle reserved in enums: DESKTOP-1569 // reserved 3 to 6; SENDERKEY_MESSAGE = 7; diff --git a/pkg/signalmeow/protobuf/WebSocketResources.pb.go b/pkg/signalmeow/protobuf/WebSocketResources.pb.go index 66520eb..c3aed6d 100644 --- a/pkg/signalmeow/protobuf/WebSocketResources.pb.go +++ b/pkg/signalmeow/protobuf/WebSocketResources.pb.go @@ -5,8 +5,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.11 -// protoc v7.34.1 +// protoc-gen-go v1.31.0 +// protoc v3.21.12 // source: WebSocketResources.proto package signalpb @@ -16,7 +16,6 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" - unsafe "unsafe" ) const ( @@ -86,21 +85,24 @@ func (WebSocketMessage_Type) EnumDescriptor() ([]byte, []int) { } type WebSocketRequestMessage struct { - state protoimpl.MessageState `protogen:"open.v1"` - Verb *string `protobuf:"bytes,1,opt,name=verb" json:"verb,omitempty"` - Path *string `protobuf:"bytes,2,opt,name=path" json:"path,omitempty"` - Body []byte `protobuf:"bytes,3,opt,name=body" json:"body,omitempty"` - Headers []string `protobuf:"bytes,5,rep,name=headers" json:"headers,omitempty"` - Id *uint64 `protobuf:"varint,4,opt,name=id" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Verb *string `protobuf:"bytes,1,opt,name=verb" json:"verb,omitempty"` + Path *string `protobuf:"bytes,2,opt,name=path" json:"path,omitempty"` + Body []byte `protobuf:"bytes,3,opt,name=body" json:"body,omitempty"` + Headers []string `protobuf:"bytes,5,rep,name=headers" json:"headers,omitempty"` + Id *uint64 `protobuf:"varint,4,opt,name=id" json:"id,omitempty"` } func (x *WebSocketRequestMessage) Reset() { *x = WebSocketRequestMessage{} - mi := &file_WebSocketResources_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_WebSocketResources_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *WebSocketRequestMessage) String() string { @@ -111,7 +113,7 @@ func (*WebSocketRequestMessage) ProtoMessage() {} func (x *WebSocketRequestMessage) ProtoReflect() protoreflect.Message { mi := &file_WebSocketResources_proto_msgTypes[0] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -162,21 +164,24 @@ func (x *WebSocketRequestMessage) GetId() uint64 { } type WebSocketResponseMessage struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id *uint64 `protobuf:"varint,1,opt,name=id" json:"id,omitempty"` - Status *uint32 `protobuf:"varint,2,opt,name=status" json:"status,omitempty"` - Message *string `protobuf:"bytes,3,opt,name=message" json:"message,omitempty"` - Headers []string `protobuf:"bytes,5,rep,name=headers" json:"headers,omitempty"` - Body []byte `protobuf:"bytes,4,opt,name=body" json:"body,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id *uint64 `protobuf:"varint,1,opt,name=id" json:"id,omitempty"` + Status *uint32 `protobuf:"varint,2,opt,name=status" json:"status,omitempty"` + Message *string `protobuf:"bytes,3,opt,name=message" json:"message,omitempty"` + Headers []string `protobuf:"bytes,5,rep,name=headers" json:"headers,omitempty"` + Body []byte `protobuf:"bytes,4,opt,name=body" json:"body,omitempty"` } func (x *WebSocketResponseMessage) Reset() { *x = WebSocketResponseMessage{} - mi := &file_WebSocketResources_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_WebSocketResources_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *WebSocketResponseMessage) String() string { @@ -187,7 +192,7 @@ func (*WebSocketResponseMessage) ProtoMessage() {} func (x *WebSocketResponseMessage) ProtoReflect() protoreflect.Message { mi := &file_WebSocketResources_proto_msgTypes[1] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -238,19 +243,22 @@ func (x *WebSocketResponseMessage) GetBody() []byte { } type WebSocketMessage struct { - state protoimpl.MessageState `protogen:"open.v1"` - Type *WebSocketMessage_Type `protobuf:"varint,1,opt,name=type,enum=signalservice.WebSocketMessage_Type" json:"type,omitempty"` - Request *WebSocketRequestMessage `protobuf:"bytes,2,opt,name=request" json:"request,omitempty"` - Response *WebSocketResponseMessage `protobuf:"bytes,3,opt,name=response" json:"response,omitempty"` - unknownFields protoimpl.UnknownFields + state protoimpl.MessageState sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Type *WebSocketMessage_Type `protobuf:"varint,1,opt,name=type,enum=signalservice.WebSocketMessage_Type" json:"type,omitempty"` + Request *WebSocketRequestMessage `protobuf:"bytes,2,opt,name=request" json:"request,omitempty"` + Response *WebSocketResponseMessage `protobuf:"bytes,3,opt,name=response" json:"response,omitempty"` } func (x *WebSocketMessage) Reset() { *x = WebSocketMessage{} - mi := &file_WebSocketResources_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_WebSocketResources_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *WebSocketMessage) String() string { @@ -261,7 +269,7 @@ func (*WebSocketMessage) ProtoMessage() {} func (x *WebSocketMessage) ProtoReflect() protoreflect.Message { mi := &file_WebSocketResources_proto_msgTypes[2] - if x != nil { + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -299,46 +307,65 @@ func (x *WebSocketMessage) GetResponse() *WebSocketResponseMessage { var File_WebSocketResources_proto protoreflect.FileDescriptor -const file_WebSocketResources_proto_rawDesc = "" + - "\n" + - "\x18WebSocketResources.proto\x12\rsignalservice\"\x7f\n" + - "\x17WebSocketRequestMessage\x12\x12\n" + - "\x04verb\x18\x01 \x01(\tR\x04verb\x12\x12\n" + - "\x04path\x18\x02 \x01(\tR\x04path\x12\x12\n" + - "\x04body\x18\x03 \x01(\fR\x04body\x12\x18\n" + - "\aheaders\x18\x05 \x03(\tR\aheaders\x12\x0e\n" + - "\x02id\x18\x04 \x01(\x04R\x02id\"\x8a\x01\n" + - "\x18WebSocketResponseMessage\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x04R\x02id\x12\x16\n" + - "\x06status\x18\x02 \x01(\rR\x06status\x12\x18\n" + - "\amessage\x18\x03 \x01(\tR\amessage\x12\x18\n" + - "\aheaders\x18\x05 \x03(\tR\aheaders\x12\x12\n" + - "\x04body\x18\x04 \x01(\fR\x04body\"\x83\x02\n" + - "\x10WebSocketMessage\x128\n" + - "\x04type\x18\x01 \x01(\x0e2$.signalservice.WebSocketMessage.TypeR\x04type\x12@\n" + - "\arequest\x18\x02 \x01(\v2&.signalservice.WebSocketRequestMessageR\arequest\x12C\n" + - "\bresponse\x18\x03 \x01(\v2'.signalservice.WebSocketResponseMessageR\bresponse\".\n" + - "\x04Type\x12\v\n" + - "\aUNKNOWN\x10\x00\x12\v\n" + - "\aREQUEST\x10\x01\x12\f\n" + - "\bRESPONSE\x10\x02BF\n" + - "3org.whispersystems.signalservice.internal.websocketB\x0fWebSocketProtos" +var file_WebSocketResources_proto_rawDesc = []byte{ + 0x0a, 0x18, 0x57, 0x65, 0x62, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0d, 0x73, 0x69, 0x67, 0x6e, + 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x22, 0x7f, 0x0a, 0x17, 0x57, 0x65, 0x62, + 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x76, 0x65, 0x72, 0x62, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x76, 0x65, 0x72, 0x62, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x12, 0x0a, 0x04, + 0x62, 0x6f, 0x64, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, + 0x12, 0x18, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, + 0x09, 0x52, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x22, 0x8a, 0x01, 0x0a, 0x18, 0x57, + 0x65, 0x62, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, + 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x68, 0x65, 0x61, + 0x64, 0x65, 0x72, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x68, 0x65, 0x61, 0x64, + 0x65, 0x72, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x83, 0x02, 0x0a, 0x10, 0x57, 0x65, 0x62, 0x53, + 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x38, 0x0a, 0x04, + 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x24, 0x2e, 0x73, 0x69, 0x67, + 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x57, 0x65, 0x62, 0x53, 0x6f, + 0x63, 0x6b, 0x65, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x54, 0x79, 0x70, 0x65, + 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x40, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x57, 0x65, 0x62, 0x53, 0x6f, 0x63, 0x6b, 0x65, + 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, + 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x43, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x69, 0x67, + 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x57, 0x65, 0x62, 0x53, 0x6f, + 0x63, 0x6b, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2e, 0x0a, + 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, + 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, 0x54, 0x10, 0x01, 0x12, + 0x0c, 0x0a, 0x08, 0x52, 0x45, 0x53, 0x50, 0x4f, 0x4e, 0x53, 0x45, 0x10, 0x02, 0x42, 0x46, 0x0a, + 0x33, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x68, 0x69, 0x73, 0x70, 0x65, 0x72, 0x73, 0x79, 0x73, 0x74, + 0x65, 0x6d, 0x73, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x77, 0x65, 0x62, 0x73, 0x6f, + 0x63, 0x6b, 0x65, 0x74, 0x42, 0x0f, 0x57, 0x65, 0x62, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x50, + 0x72, 0x6f, 0x74, 0x6f, 0x73, +} var ( file_WebSocketResources_proto_rawDescOnce sync.Once - file_WebSocketResources_proto_rawDescData []byte + file_WebSocketResources_proto_rawDescData = file_WebSocketResources_proto_rawDesc ) func file_WebSocketResources_proto_rawDescGZIP() []byte { file_WebSocketResources_proto_rawDescOnce.Do(func() { - file_WebSocketResources_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_WebSocketResources_proto_rawDesc), len(file_WebSocketResources_proto_rawDesc))) + file_WebSocketResources_proto_rawDescData = protoimpl.X.CompressGZIP(file_WebSocketResources_proto_rawDescData) }) return file_WebSocketResources_proto_rawDescData } var file_WebSocketResources_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_WebSocketResources_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_WebSocketResources_proto_goTypes = []any{ +var file_WebSocketResources_proto_goTypes = []interface{}{ (WebSocketMessage_Type)(0), // 0: signalservice.WebSocketMessage.Type (*WebSocketRequestMessage)(nil), // 1: signalservice.WebSocketRequestMessage (*WebSocketResponseMessage)(nil), // 2: signalservice.WebSocketResponseMessage @@ -360,11 +387,49 @@ func file_WebSocketResources_proto_init() { if File_WebSocketResources_proto != nil { return } + if !protoimpl.UnsafeEnabled { + file_WebSocketResources_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*WebSocketRequestMessage); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_WebSocketResources_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*WebSocketResponseMessage); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_WebSocketResources_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*WebSocketMessage); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_WebSocketResources_proto_rawDesc), len(file_WebSocketResources_proto_rawDesc)), + RawDescriptor: file_WebSocketResources_proto_rawDesc, NumEnums: 1, NumMessages: 3, NumExtensions: 0, @@ -376,6 +441,7 @@ func file_WebSocketResources_proto_init() { MessageInfos: file_WebSocketResources_proto_msgTypes, }.Build() File_WebSocketResources_proto = out.File + file_WebSocketResources_proto_rawDesc = nil file_WebSocketResources_proto_goTypes = nil file_WebSocketResources_proto_depIdxs = nil } diff --git a/pkg/signalmeow/protobuf/backuppb/Backup.pb.go b/pkg/signalmeow/protobuf/backuppb/Backup.pb.go deleted file mode 100644 index bc488e7..0000000 --- a/pkg/signalmeow/protobuf/backuppb/Backup.pb.go +++ /dev/null @@ -1,14029 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.11 -// protoc v7.34.1 -// source: backuppb/Backup.proto - -package backuppb - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// If unset - computed as the value of the first byte of SHA-256(msg=CONTACT_ID) -// modulo the count of colors. Once set the avatar color for a recipient is -// never recomputed or changed. -// -// `CONTACT_ID` is the first available identifier from the list: -// - ServiceIdToBinary(ACI) -// - E164 -// - ServiceIdToBinary(PNI) -// - Group Id -type AvatarColor int32 - -const ( - AvatarColor_A100 AvatarColor = 0 - AvatarColor_A110 AvatarColor = 1 - AvatarColor_A120 AvatarColor = 2 - AvatarColor_A130 AvatarColor = 3 - AvatarColor_A140 AvatarColor = 4 - AvatarColor_A150 AvatarColor = 5 - AvatarColor_A160 AvatarColor = 6 - AvatarColor_A170 AvatarColor = 7 - AvatarColor_A180 AvatarColor = 8 - AvatarColor_A190 AvatarColor = 9 - AvatarColor_A200 AvatarColor = 10 - AvatarColor_A210 AvatarColor = 11 -) - -// Enum value maps for AvatarColor. -var ( - AvatarColor_name = map[int32]string{ - 0: "A100", - 1: "A110", - 2: "A120", - 3: "A130", - 4: "A140", - 5: "A150", - 6: "A160", - 7: "A170", - 8: "A180", - 9: "A190", - 10: "A200", - 11: "A210", - } - AvatarColor_value = map[string]int32{ - "A100": 0, - "A110": 1, - "A120": 2, - "A130": 3, - "A140": 4, - "A150": 5, - "A160": 6, - "A170": 7, - "A180": 8, - "A190": 9, - "A200": 10, - "A210": 11, - } -) - -func (x AvatarColor) Enum() *AvatarColor { - p := new(AvatarColor) - *p = x - return p -} - -func (x AvatarColor) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (AvatarColor) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[0].Descriptor() -} - -func (AvatarColor) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[0] -} - -func (x AvatarColor) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use AvatarColor.Descriptor instead. -func (AvatarColor) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{0} -} - -type GroupV2AccessLevel int32 - -const ( - GroupV2AccessLevel_UNKNOWN GroupV2AccessLevel = 0 // Interpret as "Unsatisfiable" - GroupV2AccessLevel_ANY GroupV2AccessLevel = 1 - GroupV2AccessLevel_MEMBER GroupV2AccessLevel = 2 - GroupV2AccessLevel_ADMINISTRATOR GroupV2AccessLevel = 3 - GroupV2AccessLevel_UNSATISFIABLE GroupV2AccessLevel = 4 -) - -// Enum value maps for GroupV2AccessLevel. -var ( - GroupV2AccessLevel_name = map[int32]string{ - 0: "UNKNOWN", - 1: "ANY", - 2: "MEMBER", - 3: "ADMINISTRATOR", - 4: "UNSATISFIABLE", - } - GroupV2AccessLevel_value = map[string]int32{ - "UNKNOWN": 0, - "ANY": 1, - "MEMBER": 2, - "ADMINISTRATOR": 3, - "UNSATISFIABLE": 4, - } -) - -func (x GroupV2AccessLevel) Enum() *GroupV2AccessLevel { - p := new(GroupV2AccessLevel) - *p = x - return p -} - -func (x GroupV2AccessLevel) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (GroupV2AccessLevel) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[1].Descriptor() -} - -func (GroupV2AccessLevel) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[1] -} - -func (x GroupV2AccessLevel) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use GroupV2AccessLevel.Descriptor instead. -func (GroupV2AccessLevel) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{1} -} - -type AccountData_PhoneNumberSharingMode int32 - -const ( - AccountData_UNKNOWN AccountData_PhoneNumberSharingMode = 0 // Interpret as "Nobody" - AccountData_EVERYBODY AccountData_PhoneNumberSharingMode = 1 - AccountData_NOBODY AccountData_PhoneNumberSharingMode = 2 -) - -// Enum value maps for AccountData_PhoneNumberSharingMode. -var ( - AccountData_PhoneNumberSharingMode_name = map[int32]string{ - 0: "UNKNOWN", - 1: "EVERYBODY", - 2: "NOBODY", - } - AccountData_PhoneNumberSharingMode_value = map[string]int32{ - "UNKNOWN": 0, - "EVERYBODY": 1, - "NOBODY": 2, - } -) - -func (x AccountData_PhoneNumberSharingMode) Enum() *AccountData_PhoneNumberSharingMode { - p := new(AccountData_PhoneNumberSharingMode) - *p = x - return p -} - -func (x AccountData_PhoneNumberSharingMode) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (AccountData_PhoneNumberSharingMode) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[2].Descriptor() -} - -func (AccountData_PhoneNumberSharingMode) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[2] -} - -func (x AccountData_PhoneNumberSharingMode) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use AccountData_PhoneNumberSharingMode.Descriptor instead. -func (AccountData_PhoneNumberSharingMode) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{2, 0} -} - -type AccountData_SentMediaQuality int32 - -const ( - AccountData_UNKNOWN_QUALITY AccountData_SentMediaQuality = 0 // Interpret as "Standard" - AccountData_STANDARD AccountData_SentMediaQuality = 1 - AccountData_HIGH AccountData_SentMediaQuality = 2 -) - -// Enum value maps for AccountData_SentMediaQuality. -var ( - AccountData_SentMediaQuality_name = map[int32]string{ - 0: "UNKNOWN_QUALITY", - 1: "STANDARD", - 2: "HIGH", - } - AccountData_SentMediaQuality_value = map[string]int32{ - "UNKNOWN_QUALITY": 0, - "STANDARD": 1, - "HIGH": 2, - } -) - -func (x AccountData_SentMediaQuality) Enum() *AccountData_SentMediaQuality { - p := new(AccountData_SentMediaQuality) - *p = x - return p -} - -func (x AccountData_SentMediaQuality) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (AccountData_SentMediaQuality) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[3].Descriptor() -} - -func (AccountData_SentMediaQuality) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[3] -} - -func (x AccountData_SentMediaQuality) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use AccountData_SentMediaQuality.Descriptor instead. -func (AccountData_SentMediaQuality) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{2, 1} -} - -type AccountData_AppTheme int32 - -const ( - AccountData_UNKNOWN_APP_THEME AccountData_AppTheme = 0 // Interpret as "System" - AccountData_SYSTEM AccountData_AppTheme = 1 - AccountData_LIGHT AccountData_AppTheme = 2 - AccountData_DARK AccountData_AppTheme = 3 -) - -// Enum value maps for AccountData_AppTheme. -var ( - AccountData_AppTheme_name = map[int32]string{ - 0: "UNKNOWN_APP_THEME", - 1: "SYSTEM", - 2: "LIGHT", - 3: "DARK", - } - AccountData_AppTheme_value = map[string]int32{ - "UNKNOWN_APP_THEME": 0, - "SYSTEM": 1, - "LIGHT": 2, - "DARK": 3, - } -) - -func (x AccountData_AppTheme) Enum() *AccountData_AppTheme { - p := new(AccountData_AppTheme) - *p = x - return p -} - -func (x AccountData_AppTheme) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (AccountData_AppTheme) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[4].Descriptor() -} - -func (AccountData_AppTheme) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[4] -} - -func (x AccountData_AppTheme) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use AccountData_AppTheme.Descriptor instead. -func (AccountData_AppTheme) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{2, 2} -} - -type AccountData_CallsUseLessDataSetting int32 - -const ( - AccountData_UNKNOWN_CALL_DATA_SETTING AccountData_CallsUseLessDataSetting = 0 // Interpret as "Never" - AccountData_NEVER AccountData_CallsUseLessDataSetting = 1 - AccountData_MOBILE_DATA_ONLY AccountData_CallsUseLessDataSetting = 2 - AccountData_WIFI_AND_MOBILE_DATA AccountData_CallsUseLessDataSetting = 3 -) - -// Enum value maps for AccountData_CallsUseLessDataSetting. -var ( - AccountData_CallsUseLessDataSetting_name = map[int32]string{ - 0: "UNKNOWN_CALL_DATA_SETTING", - 1: "NEVER", - 2: "MOBILE_DATA_ONLY", - 3: "WIFI_AND_MOBILE_DATA", - } - AccountData_CallsUseLessDataSetting_value = map[string]int32{ - "UNKNOWN_CALL_DATA_SETTING": 0, - "NEVER": 1, - "MOBILE_DATA_ONLY": 2, - "WIFI_AND_MOBILE_DATA": 3, - } -) - -func (x AccountData_CallsUseLessDataSetting) Enum() *AccountData_CallsUseLessDataSetting { - p := new(AccountData_CallsUseLessDataSetting) - *p = x - return p -} - -func (x AccountData_CallsUseLessDataSetting) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (AccountData_CallsUseLessDataSetting) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[5].Descriptor() -} - -func (AccountData_CallsUseLessDataSetting) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[5] -} - -func (x AccountData_CallsUseLessDataSetting) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use AccountData_CallsUseLessDataSetting.Descriptor instead. -func (AccountData_CallsUseLessDataSetting) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{2, 3} -} - -type AccountData_UsernameLink_Color int32 - -const ( - AccountData_UsernameLink_UNKNOWN AccountData_UsernameLink_Color = 0 // Interpret as "Blue" - AccountData_UsernameLink_BLUE AccountData_UsernameLink_Color = 1 - AccountData_UsernameLink_WHITE AccountData_UsernameLink_Color = 2 - AccountData_UsernameLink_GREY AccountData_UsernameLink_Color = 3 - AccountData_UsernameLink_OLIVE AccountData_UsernameLink_Color = 4 - AccountData_UsernameLink_GREEN AccountData_UsernameLink_Color = 5 - AccountData_UsernameLink_ORANGE AccountData_UsernameLink_Color = 6 - AccountData_UsernameLink_PINK AccountData_UsernameLink_Color = 7 - AccountData_UsernameLink_PURPLE AccountData_UsernameLink_Color = 8 -) - -// Enum value maps for AccountData_UsernameLink_Color. -var ( - AccountData_UsernameLink_Color_name = map[int32]string{ - 0: "UNKNOWN", - 1: "BLUE", - 2: "WHITE", - 3: "GREY", - 4: "OLIVE", - 5: "GREEN", - 6: "ORANGE", - 7: "PINK", - 8: "PURPLE", - } - AccountData_UsernameLink_Color_value = map[string]int32{ - "UNKNOWN": 0, - "BLUE": 1, - "WHITE": 2, - "GREY": 3, - "OLIVE": 4, - "GREEN": 5, - "ORANGE": 6, - "PINK": 7, - "PURPLE": 8, - } -) - -func (x AccountData_UsernameLink_Color) Enum() *AccountData_UsernameLink_Color { - p := new(AccountData_UsernameLink_Color) - *p = x - return p -} - -func (x AccountData_UsernameLink_Color) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (AccountData_UsernameLink_Color) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[6].Descriptor() -} - -func (AccountData_UsernameLink_Color) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[6] -} - -func (x AccountData_UsernameLink_Color) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use AccountData_UsernameLink_Color.Descriptor instead. -func (AccountData_UsernameLink_Color) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{2, 0, 0} -} - -type AccountData_AutoDownloadSettings_AutoDownloadOption int32 - -const ( - AccountData_AutoDownloadSettings_UNKNOWN AccountData_AutoDownloadSettings_AutoDownloadOption = 0 // Interpret as "Never" - AccountData_AutoDownloadSettings_NEVER AccountData_AutoDownloadSettings_AutoDownloadOption = 1 - AccountData_AutoDownloadSettings_WIFI AccountData_AutoDownloadSettings_AutoDownloadOption = 2 - AccountData_AutoDownloadSettings_WIFI_AND_CELLULAR AccountData_AutoDownloadSettings_AutoDownloadOption = 3 -) - -// Enum value maps for AccountData_AutoDownloadSettings_AutoDownloadOption. -var ( - AccountData_AutoDownloadSettings_AutoDownloadOption_name = map[int32]string{ - 0: "UNKNOWN", - 1: "NEVER", - 2: "WIFI", - 3: "WIFI_AND_CELLULAR", - } - AccountData_AutoDownloadSettings_AutoDownloadOption_value = map[string]int32{ - "UNKNOWN": 0, - "NEVER": 1, - "WIFI": 2, - "WIFI_AND_CELLULAR": 3, - } -) - -func (x AccountData_AutoDownloadSettings_AutoDownloadOption) Enum() *AccountData_AutoDownloadSettings_AutoDownloadOption { - p := new(AccountData_AutoDownloadSettings_AutoDownloadOption) - *p = x - return p -} - -func (x AccountData_AutoDownloadSettings_AutoDownloadOption) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (AccountData_AutoDownloadSettings_AutoDownloadOption) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[7].Descriptor() -} - -func (AccountData_AutoDownloadSettings_AutoDownloadOption) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[7] -} - -func (x AccountData_AutoDownloadSettings_AutoDownloadOption) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use AccountData_AutoDownloadSettings_AutoDownloadOption.Descriptor instead. -func (AccountData_AutoDownloadSettings_AutoDownloadOption) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{2, 1, 0} -} - -type AccountData_AndroidSpecificSettings_NavigationBarSize int32 - -const ( - AccountData_AndroidSpecificSettings_UNKNOWN_BAR_SIZE AccountData_AndroidSpecificSettings_NavigationBarSize = 0 // Intepret as "Normal" - AccountData_AndroidSpecificSettings_NORMAL AccountData_AndroidSpecificSettings_NavigationBarSize = 1 - AccountData_AndroidSpecificSettings_COMPACT AccountData_AndroidSpecificSettings_NavigationBarSize = 2 -) - -// Enum value maps for AccountData_AndroidSpecificSettings_NavigationBarSize. -var ( - AccountData_AndroidSpecificSettings_NavigationBarSize_name = map[int32]string{ - 0: "UNKNOWN_BAR_SIZE", - 1: "NORMAL", - 2: "COMPACT", - } - AccountData_AndroidSpecificSettings_NavigationBarSize_value = map[string]int32{ - "UNKNOWN_BAR_SIZE": 0, - "NORMAL": 1, - "COMPACT": 2, - } -) - -func (x AccountData_AndroidSpecificSettings_NavigationBarSize) Enum() *AccountData_AndroidSpecificSettings_NavigationBarSize { - p := new(AccountData_AndroidSpecificSettings_NavigationBarSize) - *p = x - return p -} - -func (x AccountData_AndroidSpecificSettings_NavigationBarSize) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (AccountData_AndroidSpecificSettings_NavigationBarSize) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[8].Descriptor() -} - -func (AccountData_AndroidSpecificSettings_NavigationBarSize) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[8] -} - -func (x AccountData_AndroidSpecificSettings_NavigationBarSize) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use AccountData_AndroidSpecificSettings_NavigationBarSize.Descriptor instead. -func (AccountData_AndroidSpecificSettings_NavigationBarSize) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{2, 5, 0} -} - -type Contact_IdentityState int32 - -const ( - Contact_DEFAULT Contact_IdentityState = 0 // A valid value -- indicates unset by the user - Contact_VERIFIED Contact_IdentityState = 1 - Contact_UNVERIFIED Contact_IdentityState = 2 // Was once verified and is now unverified -) - -// Enum value maps for Contact_IdentityState. -var ( - Contact_IdentityState_name = map[int32]string{ - 0: "DEFAULT", - 1: "VERIFIED", - 2: "UNVERIFIED", - } - Contact_IdentityState_value = map[string]int32{ - "DEFAULT": 0, - "VERIFIED": 1, - "UNVERIFIED": 2, - } -) - -func (x Contact_IdentityState) Enum() *Contact_IdentityState { - p := new(Contact_IdentityState) - *p = x - return p -} - -func (x Contact_IdentityState) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (Contact_IdentityState) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[9].Descriptor() -} - -func (Contact_IdentityState) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[9] -} - -func (x Contact_IdentityState) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use Contact_IdentityState.Descriptor instead. -func (Contact_IdentityState) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{4, 0} -} - -type Contact_Visibility int32 - -const ( - Contact_VISIBLE Contact_Visibility = 0 // A valid value -- the contact is not hidden - Contact_HIDDEN Contact_Visibility = 1 - Contact_HIDDEN_MESSAGE_REQUEST Contact_Visibility = 2 -) - -// Enum value maps for Contact_Visibility. -var ( - Contact_Visibility_name = map[int32]string{ - 0: "VISIBLE", - 1: "HIDDEN", - 2: "HIDDEN_MESSAGE_REQUEST", - } - Contact_Visibility_value = map[string]int32{ - "VISIBLE": 0, - "HIDDEN": 1, - "HIDDEN_MESSAGE_REQUEST": 2, - } -) - -func (x Contact_Visibility) Enum() *Contact_Visibility { - p := new(Contact_Visibility) - *p = x - return p -} - -func (x Contact_Visibility) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (Contact_Visibility) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[10].Descriptor() -} - -func (Contact_Visibility) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[10] -} - -func (x Contact_Visibility) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use Contact_Visibility.Descriptor instead. -func (Contact_Visibility) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{4, 1} -} - -type Group_StorySendMode int32 - -const ( - Group_DEFAULT Group_StorySendMode = 0 // A valid value -- indicates unset by the user - Group_DISABLED Group_StorySendMode = 1 - Group_ENABLED Group_StorySendMode = 2 -) - -// Enum value maps for Group_StorySendMode. -var ( - Group_StorySendMode_name = map[int32]string{ - 0: "DEFAULT", - 1: "DISABLED", - 2: "ENABLED", - } - Group_StorySendMode_value = map[string]int32{ - "DEFAULT": 0, - "DISABLED": 1, - "ENABLED": 2, - } -) - -func (x Group_StorySendMode) Enum() *Group_StorySendMode { - p := new(Group_StorySendMode) - *p = x - return p -} - -func (x Group_StorySendMode) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (Group_StorySendMode) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[11].Descriptor() -} - -func (Group_StorySendMode) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[11] -} - -func (x Group_StorySendMode) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use Group_StorySendMode.Descriptor instead. -func (Group_StorySendMode) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{5, 0} -} - -type Group_Member_Role int32 - -const ( - Group_Member_UNKNOWN Group_Member_Role = 0 // Intepret as "Default" - Group_Member_DEFAULT Group_Member_Role = 1 - Group_Member_ADMINISTRATOR Group_Member_Role = 2 -) - -// Enum value maps for Group_Member_Role. -var ( - Group_Member_Role_name = map[int32]string{ - 0: "UNKNOWN", - 1: "DEFAULT", - 2: "ADMINISTRATOR", - } - Group_Member_Role_value = map[string]int32{ - "UNKNOWN": 0, - "DEFAULT": 1, - "ADMINISTRATOR": 2, - } -) - -func (x Group_Member_Role) Enum() *Group_Member_Role { - p := new(Group_Member_Role) - *p = x - return p -} - -func (x Group_Member_Role) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (Group_Member_Role) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[12].Descriptor() -} - -func (Group_Member_Role) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[12] -} - -func (x Group_Member_Role) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use Group_Member_Role.Descriptor instead. -func (Group_Member_Role) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{5, 2, 0} -} - -type Group_AccessControl_AccessRequired int32 - -const ( - Group_AccessControl_UNKNOWN Group_AccessControl_AccessRequired = 0 // Intepret as "Unsatisfiable" - Group_AccessControl_ANY Group_AccessControl_AccessRequired = 1 - Group_AccessControl_MEMBER Group_AccessControl_AccessRequired = 2 - Group_AccessControl_ADMINISTRATOR Group_AccessControl_AccessRequired = 3 - Group_AccessControl_UNSATISFIABLE Group_AccessControl_AccessRequired = 4 -) - -// Enum value maps for Group_AccessControl_AccessRequired. -var ( - Group_AccessControl_AccessRequired_name = map[int32]string{ - 0: "UNKNOWN", - 1: "ANY", - 2: "MEMBER", - 3: "ADMINISTRATOR", - 4: "UNSATISFIABLE", - } - Group_AccessControl_AccessRequired_value = map[string]int32{ - "UNKNOWN": 0, - "ANY": 1, - "MEMBER": 2, - "ADMINISTRATOR": 3, - "UNSATISFIABLE": 4, - } -) - -func (x Group_AccessControl_AccessRequired) Enum() *Group_AccessControl_AccessRequired { - p := new(Group_AccessControl_AccessRequired) - *p = x - return p -} - -func (x Group_AccessControl_AccessRequired) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (Group_AccessControl_AccessRequired) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[13].Descriptor() -} - -func (Group_AccessControl_AccessRequired) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[13] -} - -func (x Group_AccessControl_AccessRequired) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use Group_AccessControl_AccessRequired.Descriptor instead. -func (Group_AccessControl_AccessRequired) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{5, 6, 0} -} - -type CallLink_Restrictions int32 - -const ( - CallLink_UNKNOWN CallLink_Restrictions = 0 // Interpret as "Admin Approval" - CallLink_NONE CallLink_Restrictions = 1 - CallLink_ADMIN_APPROVAL CallLink_Restrictions = 2 -) - -// Enum value maps for CallLink_Restrictions. -var ( - CallLink_Restrictions_name = map[int32]string{ - 0: "UNKNOWN", - 1: "NONE", - 2: "ADMIN_APPROVAL", - } - CallLink_Restrictions_value = map[string]int32{ - "UNKNOWN": 0, - "NONE": 1, - "ADMIN_APPROVAL": 2, - } -) - -func (x CallLink_Restrictions) Enum() *CallLink_Restrictions { - p := new(CallLink_Restrictions) - *p = x - return p -} - -func (x CallLink_Restrictions) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (CallLink_Restrictions) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[14].Descriptor() -} - -func (CallLink_Restrictions) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[14] -} - -func (x CallLink_Restrictions) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use CallLink_Restrictions.Descriptor instead. -func (CallLink_Restrictions) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{9, 0} -} - -type AdHocCall_State int32 - -const ( - AdHocCall_UNKNOWN_STATE AdHocCall_State = 0 // Interpret as "Generic" - AdHocCall_GENERIC AdHocCall_State = 1 -) - -// Enum value maps for AdHocCall_State. -var ( - AdHocCall_State_name = map[int32]string{ - 0: "UNKNOWN_STATE", - 1: "GENERIC", - } - AdHocCall_State_value = map[string]int32{ - "UNKNOWN_STATE": 0, - "GENERIC": 1, - } -) - -func (x AdHocCall_State) Enum() *AdHocCall_State { - p := new(AdHocCall_State) - *p = x - return p -} - -func (x AdHocCall_State) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (AdHocCall_State) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[15].Descriptor() -} - -func (AdHocCall_State) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[15] -} - -func (x AdHocCall_State) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use AdHocCall_State.Descriptor instead. -func (AdHocCall_State) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{10, 0} -} - -type DistributionList_PrivacyMode int32 - -const ( - DistributionList_UNKNOWN DistributionList_PrivacyMode = 0 // Interpret as "Only with" - DistributionList_ONLY_WITH DistributionList_PrivacyMode = 1 - DistributionList_ALL_EXCEPT DistributionList_PrivacyMode = 2 - DistributionList_ALL DistributionList_PrivacyMode = 3 -) - -// Enum value maps for DistributionList_PrivacyMode. -var ( - DistributionList_PrivacyMode_name = map[int32]string{ - 0: "UNKNOWN", - 1: "ONLY_WITH", - 2: "ALL_EXCEPT", - 3: "ALL", - } - DistributionList_PrivacyMode_value = map[string]int32{ - "UNKNOWN": 0, - "ONLY_WITH": 1, - "ALL_EXCEPT": 2, - "ALL": 3, - } -) - -func (x DistributionList_PrivacyMode) Enum() *DistributionList_PrivacyMode { - p := new(DistributionList_PrivacyMode) - *p = x - return p -} - -func (x DistributionList_PrivacyMode) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (DistributionList_PrivacyMode) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[16].Descriptor() -} - -func (DistributionList_PrivacyMode) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[16] -} - -func (x DistributionList_PrivacyMode) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use DistributionList_PrivacyMode.Descriptor instead. -func (DistributionList_PrivacyMode) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{12, 0} -} - -type SendStatus_Failed_FailureReason int32 - -const ( - SendStatus_Failed_UNKNOWN SendStatus_Failed_FailureReason = 0 // A valid value -- could indicate a crash or lack of information - SendStatus_Failed_NETWORK SendStatus_Failed_FailureReason = 1 - SendStatus_Failed_IDENTITY_KEY_MISMATCH SendStatus_Failed_FailureReason = 2 -) - -// Enum value maps for SendStatus_Failed_FailureReason. -var ( - SendStatus_Failed_FailureReason_name = map[int32]string{ - 0: "UNKNOWN", - 1: "NETWORK", - 2: "IDENTITY_KEY_MISMATCH", - } - SendStatus_Failed_FailureReason_value = map[string]int32{ - "UNKNOWN": 0, - "NETWORK": 1, - "IDENTITY_KEY_MISMATCH": 2, - } -) - -func (x SendStatus_Failed_FailureReason) Enum() *SendStatus_Failed_FailureReason { - p := new(SendStatus_Failed_FailureReason) - *p = x - return p -} - -func (x SendStatus_Failed_FailureReason) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (SendStatus_Failed_FailureReason) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[17].Descriptor() -} - -func (SendStatus_Failed_FailureReason) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[17] -} - -func (x SendStatus_Failed_FailureReason) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use SendStatus_Failed_FailureReason.Descriptor instead. -func (SendStatus_Failed_FailureReason) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{14, 6, 0} -} - -type PaymentNotification_TransactionDetails_FailedTransaction_FailureReason int32 - -const ( - PaymentNotification_TransactionDetails_FailedTransaction_GENERIC PaymentNotification_TransactionDetails_FailedTransaction_FailureReason = 0 // A valid value -- reason unknown - PaymentNotification_TransactionDetails_FailedTransaction_NETWORK PaymentNotification_TransactionDetails_FailedTransaction_FailureReason = 1 - PaymentNotification_TransactionDetails_FailedTransaction_INSUFFICIENT_FUNDS PaymentNotification_TransactionDetails_FailedTransaction_FailureReason = 2 -) - -// Enum value maps for PaymentNotification_TransactionDetails_FailedTransaction_FailureReason. -var ( - PaymentNotification_TransactionDetails_FailedTransaction_FailureReason_name = map[int32]string{ - 0: "GENERIC", - 1: "NETWORK", - 2: "INSUFFICIENT_FUNDS", - } - PaymentNotification_TransactionDetails_FailedTransaction_FailureReason_value = map[string]int32{ - "GENERIC": 0, - "NETWORK": 1, - "INSUFFICIENT_FUNDS": 2, - } -) - -func (x PaymentNotification_TransactionDetails_FailedTransaction_FailureReason) Enum() *PaymentNotification_TransactionDetails_FailedTransaction_FailureReason { - p := new(PaymentNotification_TransactionDetails_FailedTransaction_FailureReason) - *p = x - return p -} - -func (x PaymentNotification_TransactionDetails_FailedTransaction_FailureReason) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (PaymentNotification_TransactionDetails_FailedTransaction_FailureReason) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[18].Descriptor() -} - -func (PaymentNotification_TransactionDetails_FailedTransaction_FailureReason) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[18] -} - -func (x PaymentNotification_TransactionDetails_FailedTransaction_FailureReason) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use PaymentNotification_TransactionDetails_FailedTransaction_FailureReason.Descriptor instead. -func (PaymentNotification_TransactionDetails_FailedTransaction_FailureReason) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{19, 0, 1, 0} -} - -type PaymentNotification_TransactionDetails_Transaction_Status int32 - -const ( - PaymentNotification_TransactionDetails_Transaction_INITIAL PaymentNotification_TransactionDetails_Transaction_Status = 0 // A valid value -- state unconfirmed - PaymentNotification_TransactionDetails_Transaction_SUBMITTED PaymentNotification_TransactionDetails_Transaction_Status = 1 - PaymentNotification_TransactionDetails_Transaction_SUCCESSFUL PaymentNotification_TransactionDetails_Transaction_Status = 2 -) - -// Enum value maps for PaymentNotification_TransactionDetails_Transaction_Status. -var ( - PaymentNotification_TransactionDetails_Transaction_Status_name = map[int32]string{ - 0: "INITIAL", - 1: "SUBMITTED", - 2: "SUCCESSFUL", - } - PaymentNotification_TransactionDetails_Transaction_Status_value = map[string]int32{ - "INITIAL": 0, - "SUBMITTED": 1, - "SUCCESSFUL": 2, - } -) - -func (x PaymentNotification_TransactionDetails_Transaction_Status) Enum() *PaymentNotification_TransactionDetails_Transaction_Status { - p := new(PaymentNotification_TransactionDetails_Transaction_Status) - *p = x - return p -} - -func (x PaymentNotification_TransactionDetails_Transaction_Status) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (PaymentNotification_TransactionDetails_Transaction_Status) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[19].Descriptor() -} - -func (PaymentNotification_TransactionDetails_Transaction_Status) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[19] -} - -func (x PaymentNotification_TransactionDetails_Transaction_Status) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use PaymentNotification_TransactionDetails_Transaction_Status.Descriptor instead. -func (PaymentNotification_TransactionDetails_Transaction_Status) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{19, 0, 2, 0} -} - -type GiftBadge_State int32 - -const ( - GiftBadge_UNOPENED GiftBadge_State = 0 // A valid state - GiftBadge_OPENED GiftBadge_State = 1 - GiftBadge_REDEEMED GiftBadge_State = 2 - GiftBadge_FAILED GiftBadge_State = 3 -) - -// Enum value maps for GiftBadge_State. -var ( - GiftBadge_State_name = map[int32]string{ - 0: "UNOPENED", - 1: "OPENED", - 2: "REDEEMED", - 3: "FAILED", - } - GiftBadge_State_value = map[string]int32{ - "UNOPENED": 0, - "OPENED": 1, - "REDEEMED": 2, - "FAILED": 3, - } -) - -func (x GiftBadge_State) Enum() *GiftBadge_State { - p := new(GiftBadge_State) - *p = x - return p -} - -func (x GiftBadge_State) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (GiftBadge_State) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[20].Descriptor() -} - -func (GiftBadge_State) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[20] -} - -func (x GiftBadge_State) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use GiftBadge_State.Descriptor instead. -func (GiftBadge_State) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{20, 0} -} - -type ContactAttachment_Phone_Type int32 - -const ( - ContactAttachment_Phone_UNKNOWN ContactAttachment_Phone_Type = 0 // Interpret as "Home" - ContactAttachment_Phone_HOME ContactAttachment_Phone_Type = 1 - ContactAttachment_Phone_MOBILE ContactAttachment_Phone_Type = 2 - ContactAttachment_Phone_WORK ContactAttachment_Phone_Type = 3 - ContactAttachment_Phone_CUSTOM ContactAttachment_Phone_Type = 4 -) - -// Enum value maps for ContactAttachment_Phone_Type. -var ( - ContactAttachment_Phone_Type_name = map[int32]string{ - 0: "UNKNOWN", - 1: "HOME", - 2: "MOBILE", - 3: "WORK", - 4: "CUSTOM", - } - ContactAttachment_Phone_Type_value = map[string]int32{ - "UNKNOWN": 0, - "HOME": 1, - "MOBILE": 2, - "WORK": 3, - "CUSTOM": 4, - } -) - -func (x ContactAttachment_Phone_Type) Enum() *ContactAttachment_Phone_Type { - p := new(ContactAttachment_Phone_Type) - *p = x - return p -} - -func (x ContactAttachment_Phone_Type) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (ContactAttachment_Phone_Type) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[21].Descriptor() -} - -func (ContactAttachment_Phone_Type) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[21] -} - -func (x ContactAttachment_Phone_Type) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use ContactAttachment_Phone_Type.Descriptor instead. -func (ContactAttachment_Phone_Type) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{22, 1, 0} -} - -type ContactAttachment_Email_Type int32 - -const ( - ContactAttachment_Email_UNKNOWN ContactAttachment_Email_Type = 0 // Intepret as "Home" - ContactAttachment_Email_HOME ContactAttachment_Email_Type = 1 - ContactAttachment_Email_MOBILE ContactAttachment_Email_Type = 2 - ContactAttachment_Email_WORK ContactAttachment_Email_Type = 3 - ContactAttachment_Email_CUSTOM ContactAttachment_Email_Type = 4 -) - -// Enum value maps for ContactAttachment_Email_Type. -var ( - ContactAttachment_Email_Type_name = map[int32]string{ - 0: "UNKNOWN", - 1: "HOME", - 2: "MOBILE", - 3: "WORK", - 4: "CUSTOM", - } - ContactAttachment_Email_Type_value = map[string]int32{ - "UNKNOWN": 0, - "HOME": 1, - "MOBILE": 2, - "WORK": 3, - "CUSTOM": 4, - } -) - -func (x ContactAttachment_Email_Type) Enum() *ContactAttachment_Email_Type { - p := new(ContactAttachment_Email_Type) - *p = x - return p -} - -func (x ContactAttachment_Email_Type) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (ContactAttachment_Email_Type) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[22].Descriptor() -} - -func (ContactAttachment_Email_Type) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[22] -} - -func (x ContactAttachment_Email_Type) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use ContactAttachment_Email_Type.Descriptor instead. -func (ContactAttachment_Email_Type) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{22, 2, 0} -} - -type ContactAttachment_PostalAddress_Type int32 - -const ( - ContactAttachment_PostalAddress_UNKNOWN ContactAttachment_PostalAddress_Type = 0 // Interpret as "Home" - ContactAttachment_PostalAddress_HOME ContactAttachment_PostalAddress_Type = 1 - ContactAttachment_PostalAddress_WORK ContactAttachment_PostalAddress_Type = 2 - ContactAttachment_PostalAddress_CUSTOM ContactAttachment_PostalAddress_Type = 3 -) - -// Enum value maps for ContactAttachment_PostalAddress_Type. -var ( - ContactAttachment_PostalAddress_Type_name = map[int32]string{ - 0: "UNKNOWN", - 1: "HOME", - 2: "WORK", - 3: "CUSTOM", - } - ContactAttachment_PostalAddress_Type_value = map[string]int32{ - "UNKNOWN": 0, - "HOME": 1, - "WORK": 2, - "CUSTOM": 3, - } -) - -func (x ContactAttachment_PostalAddress_Type) Enum() *ContactAttachment_PostalAddress_Type { - p := new(ContactAttachment_PostalAddress_Type) - *p = x - return p -} - -func (x ContactAttachment_PostalAddress_Type) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (ContactAttachment_PostalAddress_Type) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[23].Descriptor() -} - -func (ContactAttachment_PostalAddress_Type) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[23] -} - -func (x ContactAttachment_PostalAddress_Type) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use ContactAttachment_PostalAddress_Type.Descriptor instead. -func (ContactAttachment_PostalAddress_Type) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{22, 3, 0} -} - -// Similar to SignalService.AttachmentPointer.Flags, -// but explicitly mutually exclusive. Note the different raw values -// (non-zero starting values are not supported in proto3.) -type MessageAttachment_Flag int32 - -const ( - MessageAttachment_NONE MessageAttachment_Flag = 0 // A valid value -- no flag applied - MessageAttachment_VOICE_MESSAGE MessageAttachment_Flag = 1 - MessageAttachment_BORDERLESS MessageAttachment_Flag = 2 - MessageAttachment_GIF MessageAttachment_Flag = 3 -) - -// Enum value maps for MessageAttachment_Flag. -var ( - MessageAttachment_Flag_name = map[int32]string{ - 0: "NONE", - 1: "VOICE_MESSAGE", - 2: "BORDERLESS", - 3: "GIF", - } - MessageAttachment_Flag_value = map[string]int32{ - "NONE": 0, - "VOICE_MESSAGE": 1, - "BORDERLESS": 2, - "GIF": 3, - } -) - -func (x MessageAttachment_Flag) Enum() *MessageAttachment_Flag { - p := new(MessageAttachment_Flag) - *p = x - return p -} - -func (x MessageAttachment_Flag) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (MessageAttachment_Flag) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[24].Descriptor() -} - -func (MessageAttachment_Flag) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[24] -} - -func (x MessageAttachment_Flag) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use MessageAttachment_Flag.Descriptor instead. -func (MessageAttachment_Flag) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{27, 0} -} - -type Quote_Type int32 - -const ( - Quote_UNKNOWN Quote_Type = 0 // Interpret as "Normal" - Quote_NORMAL Quote_Type = 1 - Quote_GIFT_BADGE Quote_Type = 2 - Quote_VIEW_ONCE Quote_Type = 3 - Quote_POLL Quote_Type = 4 -) - -// Enum value maps for Quote_Type. -var ( - Quote_Type_name = map[int32]string{ - 0: "UNKNOWN", - 1: "NORMAL", - 2: "GIFT_BADGE", - 3: "VIEW_ONCE", - 4: "POLL", - } - Quote_Type_value = map[string]int32{ - "UNKNOWN": 0, - "NORMAL": 1, - "GIFT_BADGE": 2, - "VIEW_ONCE": 3, - "POLL": 4, - } -) - -func (x Quote_Type) Enum() *Quote_Type { - p := new(Quote_Type) - *p = x - return p -} - -func (x Quote_Type) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (Quote_Type) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[25].Descriptor() -} - -func (Quote_Type) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[25] -} - -func (x Quote_Type) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use Quote_Type.Descriptor instead. -func (Quote_Type) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{29, 0} -} - -type BodyRange_Style int32 - -const ( - BodyRange_NONE BodyRange_Style = 0 // Importers should ignore the body range without throwing an error. - BodyRange_BOLD BodyRange_Style = 1 - BodyRange_ITALIC BodyRange_Style = 2 - BodyRange_SPOILER BodyRange_Style = 3 - BodyRange_STRIKETHROUGH BodyRange_Style = 4 - BodyRange_MONOSPACE BodyRange_Style = 5 -) - -// Enum value maps for BodyRange_Style. -var ( - BodyRange_Style_name = map[int32]string{ - 0: "NONE", - 1: "BOLD", - 2: "ITALIC", - 3: "SPOILER", - 4: "STRIKETHROUGH", - 5: "MONOSPACE", - } - BodyRange_Style_value = map[string]int32{ - "NONE": 0, - "BOLD": 1, - "ITALIC": 2, - "SPOILER": 3, - "STRIKETHROUGH": 4, - "MONOSPACE": 5, - } -) - -func (x BodyRange_Style) Enum() *BodyRange_Style { - p := new(BodyRange_Style) - *p = x - return p -} - -func (x BodyRange_Style) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (BodyRange_Style) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[26].Descriptor() -} - -func (BodyRange_Style) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[26] -} - -func (x BodyRange_Style) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use BodyRange_Style.Descriptor instead. -func (BodyRange_Style) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{30, 0} -} - -type IndividualCall_Type int32 - -const ( - IndividualCall_UNKNOWN_TYPE IndividualCall_Type = 0 // Interpret as "Audio call" - IndividualCall_AUDIO_CALL IndividualCall_Type = 1 - IndividualCall_VIDEO_CALL IndividualCall_Type = 2 -) - -// Enum value maps for IndividualCall_Type. -var ( - IndividualCall_Type_name = map[int32]string{ - 0: "UNKNOWN_TYPE", - 1: "AUDIO_CALL", - 2: "VIDEO_CALL", - } - IndividualCall_Type_value = map[string]int32{ - "UNKNOWN_TYPE": 0, - "AUDIO_CALL": 1, - "VIDEO_CALL": 2, - } -) - -func (x IndividualCall_Type) Enum() *IndividualCall_Type { - p := new(IndividualCall_Type) - *p = x - return p -} - -func (x IndividualCall_Type) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (IndividualCall_Type) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[27].Descriptor() -} - -func (IndividualCall_Type) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[27] -} - -func (x IndividualCall_Type) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use IndividualCall_Type.Descriptor instead. -func (IndividualCall_Type) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{35, 0} -} - -type IndividualCall_Direction int32 - -const ( - IndividualCall_UNKNOWN_DIRECTION IndividualCall_Direction = 0 // Interpret as "Incoming" - IndividualCall_INCOMING IndividualCall_Direction = 1 - IndividualCall_OUTGOING IndividualCall_Direction = 2 -) - -// Enum value maps for IndividualCall_Direction. -var ( - IndividualCall_Direction_name = map[int32]string{ - 0: "UNKNOWN_DIRECTION", - 1: "INCOMING", - 2: "OUTGOING", - } - IndividualCall_Direction_value = map[string]int32{ - "UNKNOWN_DIRECTION": 0, - "INCOMING": 1, - "OUTGOING": 2, - } -) - -func (x IndividualCall_Direction) Enum() *IndividualCall_Direction { - p := new(IndividualCall_Direction) - *p = x - return p -} - -func (x IndividualCall_Direction) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (IndividualCall_Direction) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[28].Descriptor() -} - -func (IndividualCall_Direction) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[28] -} - -func (x IndividualCall_Direction) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use IndividualCall_Direction.Descriptor instead. -func (IndividualCall_Direction) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{35, 1} -} - -type IndividualCall_State int32 - -const ( - IndividualCall_UNKNOWN_STATE IndividualCall_State = 0 // Interpret as "Accepted" - IndividualCall_ACCEPTED IndividualCall_State = 1 - IndividualCall_NOT_ACCEPTED IndividualCall_State = 2 - // An incoming call that is no longer ongoing, which we neither accepted - // not actively declined. For example, it expired, was canceled by the - // sender, or was rejected due to being in another call. - IndividualCall_MISSED IndividualCall_State = 3 - // We auto-declined an incoming call due to a notification profile. - IndividualCall_MISSED_NOTIFICATION_PROFILE IndividualCall_State = 4 -) - -// Enum value maps for IndividualCall_State. -var ( - IndividualCall_State_name = map[int32]string{ - 0: "UNKNOWN_STATE", - 1: "ACCEPTED", - 2: "NOT_ACCEPTED", - 3: "MISSED", - 4: "MISSED_NOTIFICATION_PROFILE", - } - IndividualCall_State_value = map[string]int32{ - "UNKNOWN_STATE": 0, - "ACCEPTED": 1, - "NOT_ACCEPTED": 2, - "MISSED": 3, - "MISSED_NOTIFICATION_PROFILE": 4, - } -) - -func (x IndividualCall_State) Enum() *IndividualCall_State { - p := new(IndividualCall_State) - *p = x - return p -} - -func (x IndividualCall_State) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (IndividualCall_State) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[29].Descriptor() -} - -func (IndividualCall_State) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[29] -} - -func (x IndividualCall_State) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use IndividualCall_State.Descriptor instead. -func (IndividualCall_State) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{35, 2} -} - -type GroupCall_State int32 - -const ( - GroupCall_UNKNOWN_STATE GroupCall_State = 0 // Interpret as "Generic" - // A group call was started without ringing. - GroupCall_GENERIC GroupCall_State = 1 - // We joined a group call that was started without ringing. - GroupCall_JOINED GroupCall_State = 2 - // An incoming group call is actively ringing. - GroupCall_RINGING GroupCall_State = 3 - // We accepted an incoming group ring. - GroupCall_ACCEPTED GroupCall_State = 4 - // We declined an incoming group ring. - GroupCall_DECLINED GroupCall_State = 5 - // We missed an incoming group ring, for example because it expired. - GroupCall_MISSED GroupCall_State = 6 - // We auto-declined an incoming group ring due to a notification profile. - GroupCall_MISSED_NOTIFICATION_PROFILE GroupCall_State = 7 - // An outgoing ring was started. We don't track any state for outgoing rings - // beyond that they started. - GroupCall_OUTGOING_RING GroupCall_State = 8 -) - -// Enum value maps for GroupCall_State. -var ( - GroupCall_State_name = map[int32]string{ - 0: "UNKNOWN_STATE", - 1: "GENERIC", - 2: "JOINED", - 3: "RINGING", - 4: "ACCEPTED", - 5: "DECLINED", - 6: "MISSED", - 7: "MISSED_NOTIFICATION_PROFILE", - 8: "OUTGOING_RING", - } - GroupCall_State_value = map[string]int32{ - "UNKNOWN_STATE": 0, - "GENERIC": 1, - "JOINED": 2, - "RINGING": 3, - "ACCEPTED": 4, - "DECLINED": 5, - "MISSED": 6, - "MISSED_NOTIFICATION_PROFILE": 7, - "OUTGOING_RING": 8, - } -) - -func (x GroupCall_State) Enum() *GroupCall_State { - p := new(GroupCall_State) - *p = x - return p -} - -func (x GroupCall_State) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (GroupCall_State) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[30].Descriptor() -} - -func (GroupCall_State) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[30] -} - -func (x GroupCall_State) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use GroupCall_State.Descriptor instead. -func (GroupCall_State) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{36, 0} -} - -type SimpleChatUpdate_Type int32 - -const ( - SimpleChatUpdate_UNKNOWN SimpleChatUpdate_Type = 0 // Importers should skip the update without throwing an error. - SimpleChatUpdate_JOINED_SIGNAL SimpleChatUpdate_Type = 1 - SimpleChatUpdate_IDENTITY_UPDATE SimpleChatUpdate_Type = 2 - SimpleChatUpdate_IDENTITY_VERIFIED SimpleChatUpdate_Type = 3 - SimpleChatUpdate_IDENTITY_DEFAULT SimpleChatUpdate_Type = 4 // marking as unverified - SimpleChatUpdate_CHANGE_NUMBER SimpleChatUpdate_Type = 5 - SimpleChatUpdate_RELEASE_CHANNEL_DONATION_REQUEST SimpleChatUpdate_Type = 6 - SimpleChatUpdate_END_SESSION SimpleChatUpdate_Type = 7 - SimpleChatUpdate_CHAT_SESSION_REFRESH SimpleChatUpdate_Type = 8 - SimpleChatUpdate_BAD_DECRYPT SimpleChatUpdate_Type = 9 - SimpleChatUpdate_PAYMENTS_ACTIVATED SimpleChatUpdate_Type = 10 - SimpleChatUpdate_PAYMENT_ACTIVATION_REQUEST SimpleChatUpdate_Type = 11 - SimpleChatUpdate_UNSUPPORTED_PROTOCOL_MESSAGE SimpleChatUpdate_Type = 12 - SimpleChatUpdate_REPORTED_SPAM SimpleChatUpdate_Type = 13 - SimpleChatUpdate_BLOCKED SimpleChatUpdate_Type = 14 - SimpleChatUpdate_UNBLOCKED SimpleChatUpdate_Type = 15 - SimpleChatUpdate_MESSAGE_REQUEST_ACCEPTED SimpleChatUpdate_Type = 16 -) - -// Enum value maps for SimpleChatUpdate_Type. -var ( - SimpleChatUpdate_Type_name = map[int32]string{ - 0: "UNKNOWN", - 1: "JOINED_SIGNAL", - 2: "IDENTITY_UPDATE", - 3: "IDENTITY_VERIFIED", - 4: "IDENTITY_DEFAULT", - 5: "CHANGE_NUMBER", - 6: "RELEASE_CHANNEL_DONATION_REQUEST", - 7: "END_SESSION", - 8: "CHAT_SESSION_REFRESH", - 9: "BAD_DECRYPT", - 10: "PAYMENTS_ACTIVATED", - 11: "PAYMENT_ACTIVATION_REQUEST", - 12: "UNSUPPORTED_PROTOCOL_MESSAGE", - 13: "REPORTED_SPAM", - 14: "BLOCKED", - 15: "UNBLOCKED", - 16: "MESSAGE_REQUEST_ACCEPTED", - } - SimpleChatUpdate_Type_value = map[string]int32{ - "UNKNOWN": 0, - "JOINED_SIGNAL": 1, - "IDENTITY_UPDATE": 2, - "IDENTITY_VERIFIED": 3, - "IDENTITY_DEFAULT": 4, - "CHANGE_NUMBER": 5, - "RELEASE_CHANNEL_DONATION_REQUEST": 6, - "END_SESSION": 7, - "CHAT_SESSION_REFRESH": 8, - "BAD_DECRYPT": 9, - "PAYMENTS_ACTIVATED": 10, - "PAYMENT_ACTIVATION_REQUEST": 11, - "UNSUPPORTED_PROTOCOL_MESSAGE": 12, - "REPORTED_SPAM": 13, - "BLOCKED": 14, - "UNBLOCKED": 15, - "MESSAGE_REQUEST_ACCEPTED": 16, - } -) - -func (x SimpleChatUpdate_Type) Enum() *SimpleChatUpdate_Type { - p := new(SimpleChatUpdate_Type) - *p = x - return p -} - -func (x SimpleChatUpdate_Type) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (SimpleChatUpdate_Type) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[31].Descriptor() -} - -func (SimpleChatUpdate_Type) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[31] -} - -func (x SimpleChatUpdate_Type) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use SimpleChatUpdate_Type.Descriptor instead. -func (SimpleChatUpdate_Type) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{37, 0} -} - -type ChatStyle_WallpaperPreset int32 - -const ( - ChatStyle_UNKNOWN_WALLPAPER_PRESET ChatStyle_WallpaperPreset = 0 // Interpret as the wallpaper being unset - ChatStyle_SOLID_BLUSH ChatStyle_WallpaperPreset = 1 - ChatStyle_SOLID_COPPER ChatStyle_WallpaperPreset = 2 - ChatStyle_SOLID_DUST ChatStyle_WallpaperPreset = 3 - ChatStyle_SOLID_CELADON ChatStyle_WallpaperPreset = 4 - ChatStyle_SOLID_RAINFOREST ChatStyle_WallpaperPreset = 5 - ChatStyle_SOLID_PACIFIC ChatStyle_WallpaperPreset = 6 - ChatStyle_SOLID_FROST ChatStyle_WallpaperPreset = 7 - ChatStyle_SOLID_NAVY ChatStyle_WallpaperPreset = 8 - ChatStyle_SOLID_LILAC ChatStyle_WallpaperPreset = 9 - ChatStyle_SOLID_PINK ChatStyle_WallpaperPreset = 10 - ChatStyle_SOLID_EGGPLANT ChatStyle_WallpaperPreset = 11 - ChatStyle_SOLID_SILVER ChatStyle_WallpaperPreset = 12 - ChatStyle_GRADIENT_SUNSET ChatStyle_WallpaperPreset = 13 - ChatStyle_GRADIENT_NOIR ChatStyle_WallpaperPreset = 14 - ChatStyle_GRADIENT_HEATMAP ChatStyle_WallpaperPreset = 15 - ChatStyle_GRADIENT_AQUA ChatStyle_WallpaperPreset = 16 - ChatStyle_GRADIENT_IRIDESCENT ChatStyle_WallpaperPreset = 17 - ChatStyle_GRADIENT_MONSTERA ChatStyle_WallpaperPreset = 18 - ChatStyle_GRADIENT_BLISS ChatStyle_WallpaperPreset = 19 - ChatStyle_GRADIENT_SKY ChatStyle_WallpaperPreset = 20 - ChatStyle_GRADIENT_PEACH ChatStyle_WallpaperPreset = 21 -) - -// Enum value maps for ChatStyle_WallpaperPreset. -var ( - ChatStyle_WallpaperPreset_name = map[int32]string{ - 0: "UNKNOWN_WALLPAPER_PRESET", - 1: "SOLID_BLUSH", - 2: "SOLID_COPPER", - 3: "SOLID_DUST", - 4: "SOLID_CELADON", - 5: "SOLID_RAINFOREST", - 6: "SOLID_PACIFIC", - 7: "SOLID_FROST", - 8: "SOLID_NAVY", - 9: "SOLID_LILAC", - 10: "SOLID_PINK", - 11: "SOLID_EGGPLANT", - 12: "SOLID_SILVER", - 13: "GRADIENT_SUNSET", - 14: "GRADIENT_NOIR", - 15: "GRADIENT_HEATMAP", - 16: "GRADIENT_AQUA", - 17: "GRADIENT_IRIDESCENT", - 18: "GRADIENT_MONSTERA", - 19: "GRADIENT_BLISS", - 20: "GRADIENT_SKY", - 21: "GRADIENT_PEACH", - } - ChatStyle_WallpaperPreset_value = map[string]int32{ - "UNKNOWN_WALLPAPER_PRESET": 0, - "SOLID_BLUSH": 1, - "SOLID_COPPER": 2, - "SOLID_DUST": 3, - "SOLID_CELADON": 4, - "SOLID_RAINFOREST": 5, - "SOLID_PACIFIC": 6, - "SOLID_FROST": 7, - "SOLID_NAVY": 8, - "SOLID_LILAC": 9, - "SOLID_PINK": 10, - "SOLID_EGGPLANT": 11, - "SOLID_SILVER": 12, - "GRADIENT_SUNSET": 13, - "GRADIENT_NOIR": 14, - "GRADIENT_HEATMAP": 15, - "GRADIENT_AQUA": 16, - "GRADIENT_IRIDESCENT": 17, - "GRADIENT_MONSTERA": 18, - "GRADIENT_BLISS": 19, - "GRADIENT_SKY": 20, - "GRADIENT_PEACH": 21, - } -) - -func (x ChatStyle_WallpaperPreset) Enum() *ChatStyle_WallpaperPreset { - p := new(ChatStyle_WallpaperPreset) - *p = x - return p -} - -func (x ChatStyle_WallpaperPreset) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (ChatStyle_WallpaperPreset) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[32].Descriptor() -} - -func (ChatStyle_WallpaperPreset) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[32] -} - -func (x ChatStyle_WallpaperPreset) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use ChatStyle_WallpaperPreset.Descriptor instead. -func (ChatStyle_WallpaperPreset) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{83, 0} -} - -type ChatStyle_BubbleColorPreset int32 - -const ( - ChatStyle_UNKNOWN_BUBBLE_COLOR_PRESET ChatStyle_BubbleColorPreset = 0 // Interpret as the user's default chat bubble color - ChatStyle_SOLID_ULTRAMARINE ChatStyle_BubbleColorPreset = 1 - ChatStyle_SOLID_CRIMSON ChatStyle_BubbleColorPreset = 2 - ChatStyle_SOLID_VERMILION ChatStyle_BubbleColorPreset = 3 - ChatStyle_SOLID_BURLAP ChatStyle_BubbleColorPreset = 4 - ChatStyle_SOLID_FOREST ChatStyle_BubbleColorPreset = 5 - ChatStyle_SOLID_WINTERGREEN ChatStyle_BubbleColorPreset = 6 - ChatStyle_SOLID_TEAL ChatStyle_BubbleColorPreset = 7 - ChatStyle_SOLID_BLUE ChatStyle_BubbleColorPreset = 8 - ChatStyle_SOLID_INDIGO ChatStyle_BubbleColorPreset = 9 - ChatStyle_SOLID_VIOLET ChatStyle_BubbleColorPreset = 10 - ChatStyle_SOLID_PLUM ChatStyle_BubbleColorPreset = 11 - ChatStyle_SOLID_TAUPE ChatStyle_BubbleColorPreset = 12 - ChatStyle_SOLID_STEEL ChatStyle_BubbleColorPreset = 13 - ChatStyle_GRADIENT_EMBER ChatStyle_BubbleColorPreset = 14 - ChatStyle_GRADIENT_MIDNIGHT ChatStyle_BubbleColorPreset = 15 - ChatStyle_GRADIENT_INFRARED ChatStyle_BubbleColorPreset = 16 - ChatStyle_GRADIENT_LAGOON ChatStyle_BubbleColorPreset = 17 - ChatStyle_GRADIENT_FLUORESCENT ChatStyle_BubbleColorPreset = 18 - ChatStyle_GRADIENT_BASIL ChatStyle_BubbleColorPreset = 19 - ChatStyle_GRADIENT_SUBLIME ChatStyle_BubbleColorPreset = 20 - ChatStyle_GRADIENT_SEA ChatStyle_BubbleColorPreset = 21 - ChatStyle_GRADIENT_TANGERINE ChatStyle_BubbleColorPreset = 22 -) - -// Enum value maps for ChatStyle_BubbleColorPreset. -var ( - ChatStyle_BubbleColorPreset_name = map[int32]string{ - 0: "UNKNOWN_BUBBLE_COLOR_PRESET", - 1: "SOLID_ULTRAMARINE", - 2: "SOLID_CRIMSON", - 3: "SOLID_VERMILION", - 4: "SOLID_BURLAP", - 5: "SOLID_FOREST", - 6: "SOLID_WINTERGREEN", - 7: "SOLID_TEAL", - 8: "SOLID_BLUE", - 9: "SOLID_INDIGO", - 10: "SOLID_VIOLET", - 11: "SOLID_PLUM", - 12: "SOLID_TAUPE", - 13: "SOLID_STEEL", - 14: "GRADIENT_EMBER", - 15: "GRADIENT_MIDNIGHT", - 16: "GRADIENT_INFRARED", - 17: "GRADIENT_LAGOON", - 18: "GRADIENT_FLUORESCENT", - 19: "GRADIENT_BASIL", - 20: "GRADIENT_SUBLIME", - 21: "GRADIENT_SEA", - 22: "GRADIENT_TANGERINE", - } - ChatStyle_BubbleColorPreset_value = map[string]int32{ - "UNKNOWN_BUBBLE_COLOR_PRESET": 0, - "SOLID_ULTRAMARINE": 1, - "SOLID_CRIMSON": 2, - "SOLID_VERMILION": 3, - "SOLID_BURLAP": 4, - "SOLID_FOREST": 5, - "SOLID_WINTERGREEN": 6, - "SOLID_TEAL": 7, - "SOLID_BLUE": 8, - "SOLID_INDIGO": 9, - "SOLID_VIOLET": 10, - "SOLID_PLUM": 11, - "SOLID_TAUPE": 12, - "SOLID_STEEL": 13, - "GRADIENT_EMBER": 14, - "GRADIENT_MIDNIGHT": 15, - "GRADIENT_INFRARED": 16, - "GRADIENT_LAGOON": 17, - "GRADIENT_FLUORESCENT": 18, - "GRADIENT_BASIL": 19, - "GRADIENT_SUBLIME": 20, - "GRADIENT_SEA": 21, - "GRADIENT_TANGERINE": 22, - } -) - -func (x ChatStyle_BubbleColorPreset) Enum() *ChatStyle_BubbleColorPreset { - p := new(ChatStyle_BubbleColorPreset) - *p = x - return p -} - -func (x ChatStyle_BubbleColorPreset) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (ChatStyle_BubbleColorPreset) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[33].Descriptor() -} - -func (ChatStyle_BubbleColorPreset) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[33] -} - -func (x ChatStyle_BubbleColorPreset) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use ChatStyle_BubbleColorPreset.Descriptor instead. -func (ChatStyle_BubbleColorPreset) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{83, 1} -} - -type NotificationProfile_DayOfWeek int32 - -const ( - NotificationProfile_UNKNOWN NotificationProfile_DayOfWeek = 0 // Interpret as "Monday" - NotificationProfile_MONDAY NotificationProfile_DayOfWeek = 1 - NotificationProfile_TUESDAY NotificationProfile_DayOfWeek = 2 - NotificationProfile_WEDNESDAY NotificationProfile_DayOfWeek = 3 - NotificationProfile_THURSDAY NotificationProfile_DayOfWeek = 4 - NotificationProfile_FRIDAY NotificationProfile_DayOfWeek = 5 - NotificationProfile_SATURDAY NotificationProfile_DayOfWeek = 6 - NotificationProfile_SUNDAY NotificationProfile_DayOfWeek = 7 -) - -// Enum value maps for NotificationProfile_DayOfWeek. -var ( - NotificationProfile_DayOfWeek_name = map[int32]string{ - 0: "UNKNOWN", - 1: "MONDAY", - 2: "TUESDAY", - 3: "WEDNESDAY", - 4: "THURSDAY", - 5: "FRIDAY", - 6: "SATURDAY", - 7: "SUNDAY", - } - NotificationProfile_DayOfWeek_value = map[string]int32{ - "UNKNOWN": 0, - "MONDAY": 1, - "TUESDAY": 2, - "WEDNESDAY": 3, - "THURSDAY": 4, - "FRIDAY": 5, - "SATURDAY": 6, - "SUNDAY": 7, - } -) - -func (x NotificationProfile_DayOfWeek) Enum() *NotificationProfile_DayOfWeek { - p := new(NotificationProfile_DayOfWeek) - *p = x - return p -} - -func (x NotificationProfile_DayOfWeek) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (NotificationProfile_DayOfWeek) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[34].Descriptor() -} - -func (NotificationProfile_DayOfWeek) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[34] -} - -func (x NotificationProfile_DayOfWeek) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use NotificationProfile_DayOfWeek.Descriptor instead. -func (NotificationProfile_DayOfWeek) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{84, 0} -} - -// Represents the default "All chats" folder record vs all other custom folders -type ChatFolder_FolderType int32 - -const ( - ChatFolder_UNKNOWN ChatFolder_FolderType = 0 // Interpret as "Custom" - ChatFolder_ALL ChatFolder_FolderType = 1 - ChatFolder_CUSTOM ChatFolder_FolderType = 2 -) - -// Enum value maps for ChatFolder_FolderType. -var ( - ChatFolder_FolderType_name = map[int32]string{ - 0: "UNKNOWN", - 1: "ALL", - 2: "CUSTOM", - } - ChatFolder_FolderType_value = map[string]int32{ - "UNKNOWN": 0, - "ALL": 1, - "CUSTOM": 2, - } -) - -func (x ChatFolder_FolderType) Enum() *ChatFolder_FolderType { - p := new(ChatFolder_FolderType) - *p = x - return p -} - -func (x ChatFolder_FolderType) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (ChatFolder_FolderType) Descriptor() protoreflect.EnumDescriptor { - return file_backuppb_Backup_proto_enumTypes[35].Descriptor() -} - -func (ChatFolder_FolderType) Type() protoreflect.EnumType { - return &file_backuppb_Backup_proto_enumTypes[35] -} - -func (x ChatFolder_FolderType) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use ChatFolder_FolderType.Descriptor instead. -func (ChatFolder_FolderType) EnumDescriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{85, 0} -} - -type BackupInfo struct { - state protoimpl.MessageState `protogen:"open.v1"` - Version uint64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` - BackupTimeMs uint64 `protobuf:"varint,2,opt,name=backupTimeMs,proto3" json:"backupTimeMs,omitempty"` - MediaRootBackupKey []byte `protobuf:"bytes,3,opt,name=mediaRootBackupKey,proto3" json:"mediaRootBackupKey,omitempty"` // 32-byte random value generated when the backup is uploaded for the first time. - CurrentAppVersion string `protobuf:"bytes,4,opt,name=currentAppVersion,proto3" json:"currentAppVersion,omitempty"` - FirstAppVersion string `protobuf:"bytes,5,opt,name=firstAppVersion,proto3" json:"firstAppVersion,omitempty"` - DebugInfo []byte `protobuf:"bytes,6,opt,name=debugInfo,proto3" json:"debugInfo,omitempty"` // Client-specific data field for debug info during testing - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *BackupInfo) Reset() { - *x = BackupInfo{} - mi := &file_backuppb_Backup_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *BackupInfo) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*BackupInfo) ProtoMessage() {} - -func (x *BackupInfo) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[0] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use BackupInfo.ProtoReflect.Descriptor instead. -func (*BackupInfo) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{0} -} - -func (x *BackupInfo) GetVersion() uint64 { - if x != nil { - return x.Version - } - return 0 -} - -func (x *BackupInfo) GetBackupTimeMs() uint64 { - if x != nil { - return x.BackupTimeMs - } - return 0 -} - -func (x *BackupInfo) GetMediaRootBackupKey() []byte { - if x != nil { - return x.MediaRootBackupKey - } - return nil -} - -func (x *BackupInfo) GetCurrentAppVersion() string { - if x != nil { - return x.CurrentAppVersion - } - return "" -} - -func (x *BackupInfo) GetFirstAppVersion() string { - if x != nil { - return x.FirstAppVersion - } - return "" -} - -func (x *BackupInfo) GetDebugInfo() []byte { - if x != nil { - return x.DebugInfo - } - return nil -} - -// Frames must follow in the following ordering rules: -// -// 1. There is exactly one AccountData and it is the first frame. -// 2. A frame referenced by ID must come before the referencing frame. -// e.g. a Recipient must come before any Chat referencing it. -// 3. All ChatItems must appear in global Chat rendering order. -// (The order in which they were received by the client.) -// 4. ChatFolders must appear in render order (e.g., left to right for -// LTR locales), but can appear anywhere relative to other frames respecting -// rule 2 (after Recipients and Chats). -// -// Recipients, Chats, StickerPacks, AdHocCalls, and NotificationProfiles -// can be in any order. (But must respect rule 2.) -// -// For example, Chats may all be together at the beginning, -// or may each immediately precede its first ChatItem. -type Frame struct { - state protoimpl.MessageState `protogen:"open.v1"` - // If unset, importers should skip this frame without throwing an error. - // - // Types that are valid to be assigned to Item: - // - // *Frame_Account - // *Frame_Recipient - // *Frame_Chat - // *Frame_ChatItem - // *Frame_StickerPack - // *Frame_AdHocCall - // *Frame_NotificationProfile - // *Frame_ChatFolder - Item isFrame_Item `protobuf_oneof:"item"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Frame) Reset() { - *x = Frame{} - mi := &file_backuppb_Backup_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Frame) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Frame) ProtoMessage() {} - -func (x *Frame) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[1] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Frame.ProtoReflect.Descriptor instead. -func (*Frame) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{1} -} - -func (x *Frame) GetItem() isFrame_Item { - if x != nil { - return x.Item - } - return nil -} - -func (x *Frame) GetAccount() *AccountData { - if x != nil { - if x, ok := x.Item.(*Frame_Account); ok { - return x.Account - } - } - return nil -} - -func (x *Frame) GetRecipient() *Recipient { - if x != nil { - if x, ok := x.Item.(*Frame_Recipient); ok { - return x.Recipient - } - } - return nil -} - -func (x *Frame) GetChat() *Chat { - if x != nil { - if x, ok := x.Item.(*Frame_Chat); ok { - return x.Chat - } - } - return nil -} - -func (x *Frame) GetChatItem() *ChatItem { - if x != nil { - if x, ok := x.Item.(*Frame_ChatItem); ok { - return x.ChatItem - } - } - return nil -} - -func (x *Frame) GetStickerPack() *StickerPack { - if x != nil { - if x, ok := x.Item.(*Frame_StickerPack); ok { - return x.StickerPack - } - } - return nil -} - -func (x *Frame) GetAdHocCall() *AdHocCall { - if x != nil { - if x, ok := x.Item.(*Frame_AdHocCall); ok { - return x.AdHocCall - } - } - return nil -} - -func (x *Frame) GetNotificationProfile() *NotificationProfile { - if x != nil { - if x, ok := x.Item.(*Frame_NotificationProfile); ok { - return x.NotificationProfile - } - } - return nil -} - -func (x *Frame) GetChatFolder() *ChatFolder { - if x != nil { - if x, ok := x.Item.(*Frame_ChatFolder); ok { - return x.ChatFolder - } - } - return nil -} - -type isFrame_Item interface { - isFrame_Item() -} - -type Frame_Account struct { - Account *AccountData `protobuf:"bytes,1,opt,name=account,proto3,oneof"` -} - -type Frame_Recipient struct { - Recipient *Recipient `protobuf:"bytes,2,opt,name=recipient,proto3,oneof"` -} - -type Frame_Chat struct { - Chat *Chat `protobuf:"bytes,3,opt,name=chat,proto3,oneof"` -} - -type Frame_ChatItem struct { - ChatItem *ChatItem `protobuf:"bytes,4,opt,name=chatItem,proto3,oneof"` -} - -type Frame_StickerPack struct { - StickerPack *StickerPack `protobuf:"bytes,5,opt,name=stickerPack,proto3,oneof"` -} - -type Frame_AdHocCall struct { - AdHocCall *AdHocCall `protobuf:"bytes,6,opt,name=adHocCall,proto3,oneof"` -} - -type Frame_NotificationProfile struct { - NotificationProfile *NotificationProfile `protobuf:"bytes,7,opt,name=notificationProfile,proto3,oneof"` -} - -type Frame_ChatFolder struct { - ChatFolder *ChatFolder `protobuf:"bytes,8,opt,name=chatFolder,proto3,oneof"` -} - -func (*Frame_Account) isFrame_Item() {} - -func (*Frame_Recipient) isFrame_Item() {} - -func (*Frame_Chat) isFrame_Item() {} - -func (*Frame_ChatItem) isFrame_Item() {} - -func (*Frame_StickerPack) isFrame_Item() {} - -func (*Frame_AdHocCall) isFrame_Item() {} - -func (*Frame_NotificationProfile) isFrame_Item() {} - -func (*Frame_ChatFolder) isFrame_Item() {} - -type AccountData struct { - state protoimpl.MessageState `protogen:"open.v1"` - ProfileKey []byte `protobuf:"bytes,1,opt,name=profileKey,proto3" json:"profileKey,omitempty"` - Username *string `protobuf:"bytes,2,opt,name=username,proto3,oneof" json:"username,omitempty"` - UsernameLink *AccountData_UsernameLink `protobuf:"bytes,3,opt,name=usernameLink,proto3" json:"usernameLink,omitempty"` - GivenName string `protobuf:"bytes,4,opt,name=givenName,proto3" json:"givenName,omitempty"` - FamilyName string `protobuf:"bytes,5,opt,name=familyName,proto3" json:"familyName,omitempty"` - AvatarUrlPath string `protobuf:"bytes,6,opt,name=avatarUrlPath,proto3" json:"avatarUrlPath,omitempty"` - DonationSubscriberData *AccountData_SubscriberData `protobuf:"bytes,7,opt,name=donationSubscriberData,proto3" json:"donationSubscriberData,omitempty"` - AccountSettings *AccountData_AccountSettings `protobuf:"bytes,9,opt,name=accountSettings,proto3" json:"accountSettings,omitempty"` - BackupsSubscriberData *AccountData_IAPSubscriberData `protobuf:"bytes,10,opt,name=backupsSubscriberData,proto3" json:"backupsSubscriberData,omitempty"` - SvrPin string `protobuf:"bytes,11,opt,name=svrPin,proto3" json:"svrPin,omitempty"` - AndroidSpecificSettings *AccountData_AndroidSpecificSettings `protobuf:"bytes,12,opt,name=androidSpecificSettings,proto3" json:"androidSpecificSettings,omitempty"` - BioText string `protobuf:"bytes,13,opt,name=bioText,proto3" json:"bioText,omitempty"` - BioEmoji string `protobuf:"bytes,14,opt,name=bioEmoji,proto3" json:"bioEmoji,omitempty"` - KeyTransparencyData []byte `protobuf:"bytes,15,opt,name=keyTransparencyData,proto3,oneof" json:"keyTransparencyData,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AccountData) Reset() { - *x = AccountData{} - mi := &file_backuppb_Backup_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AccountData) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AccountData) ProtoMessage() {} - -func (x *AccountData) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[2] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AccountData.ProtoReflect.Descriptor instead. -func (*AccountData) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{2} -} - -func (x *AccountData) GetProfileKey() []byte { - if x != nil { - return x.ProfileKey - } - return nil -} - -func (x *AccountData) GetUsername() string { - if x != nil && x.Username != nil { - return *x.Username - } - return "" -} - -func (x *AccountData) GetUsernameLink() *AccountData_UsernameLink { - if x != nil { - return x.UsernameLink - } - return nil -} - -func (x *AccountData) GetGivenName() string { - if x != nil { - return x.GivenName - } - return "" -} - -func (x *AccountData) GetFamilyName() string { - if x != nil { - return x.FamilyName - } - return "" -} - -func (x *AccountData) GetAvatarUrlPath() string { - if x != nil { - return x.AvatarUrlPath - } - return "" -} - -func (x *AccountData) GetDonationSubscriberData() *AccountData_SubscriberData { - if x != nil { - return x.DonationSubscriberData - } - return nil -} - -func (x *AccountData) GetAccountSettings() *AccountData_AccountSettings { - if x != nil { - return x.AccountSettings - } - return nil -} - -func (x *AccountData) GetBackupsSubscriberData() *AccountData_IAPSubscriberData { - if x != nil { - return x.BackupsSubscriberData - } - return nil -} - -func (x *AccountData) GetSvrPin() string { - if x != nil { - return x.SvrPin - } - return "" -} - -func (x *AccountData) GetAndroidSpecificSettings() *AccountData_AndroidSpecificSettings { - if x != nil { - return x.AndroidSpecificSettings - } - return nil -} - -func (x *AccountData) GetBioText() string { - if x != nil { - return x.BioText - } - return "" -} - -func (x *AccountData) GetBioEmoji() string { - if x != nil { - return x.BioEmoji - } - return "" -} - -func (x *AccountData) GetKeyTransparencyData() []byte { - if x != nil { - return x.KeyTransparencyData - } - return nil -} - -type Recipient struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // generated id for reference only within this file - // If unset, importers should skip this frame without throwing an error. - // - // Types that are valid to be assigned to Destination: - // - // *Recipient_Contact - // *Recipient_Group - // *Recipient_DistributionList - // *Recipient_Self - // *Recipient_ReleaseNotes - // *Recipient_CallLink - Destination isRecipient_Destination `protobuf_oneof:"destination"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Recipient) Reset() { - *x = Recipient{} - mi := &file_backuppb_Backup_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Recipient) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Recipient) ProtoMessage() {} - -func (x *Recipient) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[3] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Recipient.ProtoReflect.Descriptor instead. -func (*Recipient) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{3} -} - -func (x *Recipient) GetId() uint64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *Recipient) GetDestination() isRecipient_Destination { - if x != nil { - return x.Destination - } - return nil -} - -func (x *Recipient) GetContact() *Contact { - if x != nil { - if x, ok := x.Destination.(*Recipient_Contact); ok { - return x.Contact - } - } - return nil -} - -func (x *Recipient) GetGroup() *Group { - if x != nil { - if x, ok := x.Destination.(*Recipient_Group); ok { - return x.Group - } - } - return nil -} - -func (x *Recipient) GetDistributionList() *DistributionListItem { - if x != nil { - if x, ok := x.Destination.(*Recipient_DistributionList); ok { - return x.DistributionList - } - } - return nil -} - -func (x *Recipient) GetSelf() *Self { - if x != nil { - if x, ok := x.Destination.(*Recipient_Self); ok { - return x.Self - } - } - return nil -} - -func (x *Recipient) GetReleaseNotes() *ReleaseNotes { - if x != nil { - if x, ok := x.Destination.(*Recipient_ReleaseNotes); ok { - return x.ReleaseNotes - } - } - return nil -} - -func (x *Recipient) GetCallLink() *CallLink { - if x != nil { - if x, ok := x.Destination.(*Recipient_CallLink); ok { - return x.CallLink - } - } - return nil -} - -type isRecipient_Destination interface { - isRecipient_Destination() -} - -type Recipient_Contact struct { - Contact *Contact `protobuf:"bytes,2,opt,name=contact,proto3,oneof"` -} - -type Recipient_Group struct { - Group *Group `protobuf:"bytes,3,opt,name=group,proto3,oneof"` -} - -type Recipient_DistributionList struct { - DistributionList *DistributionListItem `protobuf:"bytes,4,opt,name=distributionList,proto3,oneof"` -} - -type Recipient_Self struct { - Self *Self `protobuf:"bytes,5,opt,name=self,proto3,oneof"` -} - -type Recipient_ReleaseNotes struct { - ReleaseNotes *ReleaseNotes `protobuf:"bytes,6,opt,name=releaseNotes,proto3,oneof"` -} - -type Recipient_CallLink struct { - CallLink *CallLink `protobuf:"bytes,7,opt,name=callLink,proto3,oneof"` -} - -func (*Recipient_Contact) isRecipient_Destination() {} - -func (*Recipient_Group) isRecipient_Destination() {} - -func (*Recipient_DistributionList) isRecipient_Destination() {} - -func (*Recipient_Self) isRecipient_Destination() {} - -func (*Recipient_ReleaseNotes) isRecipient_Destination() {} - -func (*Recipient_CallLink) isRecipient_Destination() {} - -type Contact struct { - state protoimpl.MessageState `protogen:"open.v1"` - Aci []byte `protobuf:"bytes,1,opt,name=aci,proto3,oneof" json:"aci,omitempty"` // should be 16 bytes - Pni []byte `protobuf:"bytes,2,opt,name=pni,proto3,oneof" json:"pni,omitempty"` // should be 16 bytes - Username *string `protobuf:"bytes,3,opt,name=username,proto3,oneof" json:"username,omitempty"` - E164 *uint64 `protobuf:"varint,4,opt,name=e164,proto3,oneof" json:"e164,omitempty"` - Blocked bool `protobuf:"varint,5,opt,name=blocked,proto3" json:"blocked,omitempty"` - Visibility Contact_Visibility `protobuf:"varint,6,opt,name=visibility,proto3,enum=signal.backup.Contact_Visibility" json:"visibility,omitempty"` - // If unset, consider the user to be registered - // - // Types that are valid to be assigned to Registration: - // - // *Contact_Registered_ - // *Contact_NotRegistered_ - Registration isContact_Registration `protobuf_oneof:"registration"` - ProfileKey []byte `protobuf:"bytes,9,opt,name=profileKey,proto3,oneof" json:"profileKey,omitempty"` - ProfileSharing bool `protobuf:"varint,10,opt,name=profileSharing,proto3" json:"profileSharing,omitempty"` - ProfileGivenName *string `protobuf:"bytes,11,opt,name=profileGivenName,proto3,oneof" json:"profileGivenName,omitempty"` - ProfileFamilyName *string `protobuf:"bytes,12,opt,name=profileFamilyName,proto3,oneof" json:"profileFamilyName,omitempty"` - HideStory bool `protobuf:"varint,13,opt,name=hideStory,proto3" json:"hideStory,omitempty"` - IdentityKey []byte `protobuf:"bytes,14,opt,name=identityKey,proto3,oneof" json:"identityKey,omitempty"` - IdentityState Contact_IdentityState `protobuf:"varint,15,opt,name=identityState,proto3,enum=signal.backup.Contact_IdentityState" json:"identityState,omitempty"` - Nickname *Contact_Name `protobuf:"bytes,16,opt,name=nickname,proto3" json:"nickname,omitempty"` // absent iff both `given` and `family` are empty - Note string `protobuf:"bytes,17,opt,name=note,proto3" json:"note,omitempty"` - SystemGivenName string `protobuf:"bytes,18,opt,name=systemGivenName,proto3" json:"systemGivenName,omitempty"` - SystemFamilyName string `protobuf:"bytes,19,opt,name=systemFamilyName,proto3" json:"systemFamilyName,omitempty"` - SystemNickname string `protobuf:"bytes,20,opt,name=systemNickname,proto3" json:"systemNickname,omitempty"` - AvatarColor *AvatarColor `protobuf:"varint,21,opt,name=avatarColor,proto3,enum=signal.backup.AvatarColor,oneof" json:"avatarColor,omitempty"` - KeyTransparencyData []byte `protobuf:"bytes,22,opt,name=keyTransparencyData,proto3,oneof" json:"keyTransparencyData,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Contact) Reset() { - *x = Contact{} - mi := &file_backuppb_Backup_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Contact) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Contact) ProtoMessage() {} - -func (x *Contact) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[4] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Contact.ProtoReflect.Descriptor instead. -func (*Contact) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{4} -} - -func (x *Contact) GetAci() []byte { - if x != nil { - return x.Aci - } - return nil -} - -func (x *Contact) GetPni() []byte { - if x != nil { - return x.Pni - } - return nil -} - -func (x *Contact) GetUsername() string { - if x != nil && x.Username != nil { - return *x.Username - } - return "" -} - -func (x *Contact) GetE164() uint64 { - if x != nil && x.E164 != nil { - return *x.E164 - } - return 0 -} - -func (x *Contact) GetBlocked() bool { - if x != nil { - return x.Blocked - } - return false -} - -func (x *Contact) GetVisibility() Contact_Visibility { - if x != nil { - return x.Visibility - } - return Contact_VISIBLE -} - -func (x *Contact) GetRegistration() isContact_Registration { - if x != nil { - return x.Registration - } - return nil -} - -func (x *Contact) GetRegistered() *Contact_Registered { - if x != nil { - if x, ok := x.Registration.(*Contact_Registered_); ok { - return x.Registered - } - } - return nil -} - -func (x *Contact) GetNotRegistered() *Contact_NotRegistered { - if x != nil { - if x, ok := x.Registration.(*Contact_NotRegistered_); ok { - return x.NotRegistered - } - } - return nil -} - -func (x *Contact) GetProfileKey() []byte { - if x != nil { - return x.ProfileKey - } - return nil -} - -func (x *Contact) GetProfileSharing() bool { - if x != nil { - return x.ProfileSharing - } - return false -} - -func (x *Contact) GetProfileGivenName() string { - if x != nil && x.ProfileGivenName != nil { - return *x.ProfileGivenName - } - return "" -} - -func (x *Contact) GetProfileFamilyName() string { - if x != nil && x.ProfileFamilyName != nil { - return *x.ProfileFamilyName - } - return "" -} - -func (x *Contact) GetHideStory() bool { - if x != nil { - return x.HideStory - } - return false -} - -func (x *Contact) GetIdentityKey() []byte { - if x != nil { - return x.IdentityKey - } - return nil -} - -func (x *Contact) GetIdentityState() Contact_IdentityState { - if x != nil { - return x.IdentityState - } - return Contact_DEFAULT -} - -func (x *Contact) GetNickname() *Contact_Name { - if x != nil { - return x.Nickname - } - return nil -} - -func (x *Contact) GetNote() string { - if x != nil { - return x.Note - } - return "" -} - -func (x *Contact) GetSystemGivenName() string { - if x != nil { - return x.SystemGivenName - } - return "" -} - -func (x *Contact) GetSystemFamilyName() string { - if x != nil { - return x.SystemFamilyName - } - return "" -} - -func (x *Contact) GetSystemNickname() string { - if x != nil { - return x.SystemNickname - } - return "" -} - -func (x *Contact) GetAvatarColor() AvatarColor { - if x != nil && x.AvatarColor != nil { - return *x.AvatarColor - } - return AvatarColor_A100 -} - -func (x *Contact) GetKeyTransparencyData() []byte { - if x != nil { - return x.KeyTransparencyData - } - return nil -} - -type isContact_Registration interface { - isContact_Registration() -} - -type Contact_Registered_ struct { - Registered *Contact_Registered `protobuf:"bytes,7,opt,name=registered,proto3,oneof"` -} - -type Contact_NotRegistered_ struct { - NotRegistered *Contact_NotRegistered `protobuf:"bytes,8,opt,name=notRegistered,proto3,oneof"` -} - -func (*Contact_Registered_) isContact_Registration() {} - -func (*Contact_NotRegistered_) isContact_Registration() {} - -type Group struct { - state protoimpl.MessageState `protogen:"open.v1"` - MasterKey []byte `protobuf:"bytes,1,opt,name=masterKey,proto3" json:"masterKey,omitempty"` - Whitelisted bool `protobuf:"varint,2,opt,name=whitelisted,proto3" json:"whitelisted,omitempty"` - HideStory bool `protobuf:"varint,3,opt,name=hideStory,proto3" json:"hideStory,omitempty"` - StorySendMode Group_StorySendMode `protobuf:"varint,4,opt,name=storySendMode,proto3,enum=signal.backup.Group_StorySendMode" json:"storySendMode,omitempty"` - Snapshot *Group_GroupSnapshot `protobuf:"bytes,5,opt,name=snapshot,proto3" json:"snapshot,omitempty"` - Blocked bool `protobuf:"varint,6,opt,name=blocked,proto3" json:"blocked,omitempty"` - AvatarColor *AvatarColor `protobuf:"varint,7,opt,name=avatarColor,proto3,enum=signal.backup.AvatarColor,oneof" json:"avatarColor,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Group) Reset() { - *x = Group{} - mi := &file_backuppb_Backup_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Group) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Group) ProtoMessage() {} - -func (x *Group) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[5] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Group.ProtoReflect.Descriptor instead. -func (*Group) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{5} -} - -func (x *Group) GetMasterKey() []byte { - if x != nil { - return x.MasterKey - } - return nil -} - -func (x *Group) GetWhitelisted() bool { - if x != nil { - return x.Whitelisted - } - return false -} - -func (x *Group) GetHideStory() bool { - if x != nil { - return x.HideStory - } - return false -} - -func (x *Group) GetStorySendMode() Group_StorySendMode { - if x != nil { - return x.StorySendMode - } - return Group_DEFAULT -} - -func (x *Group) GetSnapshot() *Group_GroupSnapshot { - if x != nil { - return x.Snapshot - } - return nil -} - -func (x *Group) GetBlocked() bool { - if x != nil { - return x.Blocked - } - return false -} - -func (x *Group) GetAvatarColor() AvatarColor { - if x != nil && x.AvatarColor != nil { - return *x.AvatarColor - } - return AvatarColor_A100 -} - -type Self struct { - state protoimpl.MessageState `protogen:"open.v1"` - AvatarColor *AvatarColor `protobuf:"varint,1,opt,name=avatarColor,proto3,enum=signal.backup.AvatarColor,oneof" json:"avatarColor,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Self) Reset() { - *x = Self{} - mi := &file_backuppb_Backup_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Self) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Self) ProtoMessage() {} - -func (x *Self) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[6] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Self.ProtoReflect.Descriptor instead. -func (*Self) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{6} -} - -func (x *Self) GetAvatarColor() AvatarColor { - if x != nil && x.AvatarColor != nil { - return *x.AvatarColor - } - return AvatarColor_A100 -} - -type ReleaseNotes struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ReleaseNotes) Reset() { - *x = ReleaseNotes{} - mi := &file_backuppb_Backup_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ReleaseNotes) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ReleaseNotes) ProtoMessage() {} - -func (x *ReleaseNotes) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[7] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ReleaseNotes.ProtoReflect.Descriptor instead. -func (*ReleaseNotes) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{7} -} - -type Chat struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // generated id for reference only within this file - RecipientId uint64 `protobuf:"varint,2,opt,name=recipientId,proto3" json:"recipientId,omitempty"` - Archived bool `protobuf:"varint,3,opt,name=archived,proto3" json:"archived,omitempty"` - PinnedOrder *uint32 `protobuf:"varint,4,opt,name=pinnedOrder,proto3,oneof" json:"pinnedOrder,omitempty"` // will be displayed in ascending order - ExpirationTimerMs *uint64 `protobuf:"varint,5,opt,name=expirationTimerMs,proto3,oneof" json:"expirationTimerMs,omitempty"` - MuteUntilMs *uint64 `protobuf:"varint,6,opt,name=muteUntilMs,proto3,oneof" json:"muteUntilMs,omitempty"` // INT64_MAX (2^63 - 1) = "always muted". - MarkedUnread bool `protobuf:"varint,7,opt,name=markedUnread,proto3" json:"markedUnread,omitempty"` - DontNotifyForMentionsIfMuted bool `protobuf:"varint,8,opt,name=dontNotifyForMentionsIfMuted,proto3" json:"dontNotifyForMentionsIfMuted,omitempty"` - Style *ChatStyle `protobuf:"bytes,9,opt,name=style,proto3" json:"style,omitempty"` - ExpireTimerVersion uint32 `protobuf:"varint,10,opt,name=expireTimerVersion,proto3" json:"expireTimerVersion,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Chat) Reset() { - *x = Chat{} - mi := &file_backuppb_Backup_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Chat) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Chat) ProtoMessage() {} - -func (x *Chat) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[8] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Chat.ProtoReflect.Descriptor instead. -func (*Chat) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{8} -} - -func (x *Chat) GetId() uint64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *Chat) GetRecipientId() uint64 { - if x != nil { - return x.RecipientId - } - return 0 -} - -func (x *Chat) GetArchived() bool { - if x != nil { - return x.Archived - } - return false -} - -func (x *Chat) GetPinnedOrder() uint32 { - if x != nil && x.PinnedOrder != nil { - return *x.PinnedOrder - } - return 0 -} - -func (x *Chat) GetExpirationTimerMs() uint64 { - if x != nil && x.ExpirationTimerMs != nil { - return *x.ExpirationTimerMs - } - return 0 -} - -func (x *Chat) GetMuteUntilMs() uint64 { - if x != nil && x.MuteUntilMs != nil { - return *x.MuteUntilMs - } - return 0 -} - -func (x *Chat) GetMarkedUnread() bool { - if x != nil { - return x.MarkedUnread - } - return false -} - -func (x *Chat) GetDontNotifyForMentionsIfMuted() bool { - if x != nil { - return x.DontNotifyForMentionsIfMuted - } - return false -} - -func (x *Chat) GetStyle() *ChatStyle { - if x != nil { - return x.Style - } - return nil -} - -func (x *Chat) GetExpireTimerVersion() uint32 { - if x != nil { - return x.ExpireTimerVersion - } - return 0 -} - -// * -// Call Links have some associated data including a call, but unlike other recipients -// are not tied to threads because they do not have messages associated with them. -// -// note: -// - room id can be derived from the root key -// - the presence of an admin key means this user is a call admin -type CallLink struct { - state protoimpl.MessageState `protogen:"open.v1"` - RootKey []byte `protobuf:"bytes,1,opt,name=rootKey,proto3" json:"rootKey,omitempty"` - AdminKey []byte `protobuf:"bytes,2,opt,name=adminKey,proto3,oneof" json:"adminKey,omitempty"` // Only present if the user is an admin - Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` - Restrictions CallLink_Restrictions `protobuf:"varint,4,opt,name=restrictions,proto3,enum=signal.backup.CallLink_Restrictions" json:"restrictions,omitempty"` - ExpirationMs uint64 `protobuf:"varint,5,opt,name=expirationMs,proto3" json:"expirationMs,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CallLink) Reset() { - *x = CallLink{} - mi := &file_backuppb_Backup_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CallLink) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CallLink) ProtoMessage() {} - -func (x *CallLink) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[9] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CallLink.ProtoReflect.Descriptor instead. -func (*CallLink) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{9} -} - -func (x *CallLink) GetRootKey() []byte { - if x != nil { - return x.RootKey - } - return nil -} - -func (x *CallLink) GetAdminKey() []byte { - if x != nil { - return x.AdminKey - } - return nil -} - -func (x *CallLink) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *CallLink) GetRestrictions() CallLink_Restrictions { - if x != nil { - return x.Restrictions - } - return CallLink_UNKNOWN -} - -func (x *CallLink) GetExpirationMs() uint64 { - if x != nil { - return x.ExpirationMs - } - return 0 -} - -type AdHocCall struct { - state protoimpl.MessageState `protogen:"open.v1"` - CallId uint64 `protobuf:"varint,1,opt,name=callId,proto3" json:"callId,omitempty"` - // Refers to a `CallLink` recipient. - RecipientId uint64 `protobuf:"varint,2,opt,name=recipientId,proto3" json:"recipientId,omitempty"` - State AdHocCall_State `protobuf:"varint,3,opt,name=state,proto3,enum=signal.backup.AdHocCall_State" json:"state,omitempty"` - CallTimestamp uint64 `protobuf:"varint,4,opt,name=callTimestamp,proto3" json:"callTimestamp,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AdHocCall) Reset() { - *x = AdHocCall{} - mi := &file_backuppb_Backup_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AdHocCall) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AdHocCall) ProtoMessage() {} - -func (x *AdHocCall) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[10] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AdHocCall.ProtoReflect.Descriptor instead. -func (*AdHocCall) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{10} -} - -func (x *AdHocCall) GetCallId() uint64 { - if x != nil { - return x.CallId - } - return 0 -} - -func (x *AdHocCall) GetRecipientId() uint64 { - if x != nil { - return x.RecipientId - } - return 0 -} - -func (x *AdHocCall) GetState() AdHocCall_State { - if x != nil { - return x.State - } - return AdHocCall_UNKNOWN_STATE -} - -func (x *AdHocCall) GetCallTimestamp() uint64 { - if x != nil { - return x.CallTimestamp - } - return 0 -} - -type DistributionListItem struct { - state protoimpl.MessageState `protogen:"open.v1"` - // distribution ids are UUIDv4s. "My Story" is represented - // by an all-0 UUID (00000000-0000-0000-0000-000000000000). - DistributionId []byte `protobuf:"bytes,1,opt,name=distributionId,proto3" json:"distributionId,omitempty"` // distribution list ids are uuids - // If unset, importers should skip the item entirely without showing an error. - // - // Types that are valid to be assigned to Item: - // - // *DistributionListItem_DeletionTimestamp - // *DistributionListItem_DistributionList - Item isDistributionListItem_Item `protobuf_oneof:"item"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DistributionListItem) Reset() { - *x = DistributionListItem{} - mi := &file_backuppb_Backup_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DistributionListItem) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DistributionListItem) ProtoMessage() {} - -func (x *DistributionListItem) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[11] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DistributionListItem.ProtoReflect.Descriptor instead. -func (*DistributionListItem) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{11} -} - -func (x *DistributionListItem) GetDistributionId() []byte { - if x != nil { - return x.DistributionId - } - return nil -} - -func (x *DistributionListItem) GetItem() isDistributionListItem_Item { - if x != nil { - return x.Item - } - return nil -} - -func (x *DistributionListItem) GetDeletionTimestamp() uint64 { - if x != nil { - if x, ok := x.Item.(*DistributionListItem_DeletionTimestamp); ok { - return x.DeletionTimestamp - } - } - return 0 -} - -func (x *DistributionListItem) GetDistributionList() *DistributionList { - if x != nil { - if x, ok := x.Item.(*DistributionListItem_DistributionList); ok { - return x.DistributionList - } - } - return nil -} - -type isDistributionListItem_Item interface { - isDistributionListItem_Item() -} - -type DistributionListItem_DeletionTimestamp struct { - DeletionTimestamp uint64 `protobuf:"varint,2,opt,name=deletionTimestamp,proto3,oneof"` -} - -type DistributionListItem_DistributionList struct { - DistributionList *DistributionList `protobuf:"bytes,3,opt,name=distributionList,proto3,oneof"` -} - -func (*DistributionListItem_DeletionTimestamp) isDistributionListItem_Item() {} - -func (*DistributionListItem_DistributionList) isDistributionListItem_Item() {} - -type DistributionList struct { - state protoimpl.MessageState `protogen:"open.v1"` - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - AllowReplies bool `protobuf:"varint,2,opt,name=allowReplies,proto3" json:"allowReplies,omitempty"` - PrivacyMode DistributionList_PrivacyMode `protobuf:"varint,3,opt,name=privacyMode,proto3,enum=signal.backup.DistributionList_PrivacyMode" json:"privacyMode,omitempty"` - MemberRecipientIds []uint64 `protobuf:"varint,4,rep,packed,name=memberRecipientIds,proto3" json:"memberRecipientIds,omitempty"` // generated recipient id - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DistributionList) Reset() { - *x = DistributionList{} - mi := &file_backuppb_Backup_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DistributionList) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DistributionList) ProtoMessage() {} - -func (x *DistributionList) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[12] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DistributionList.ProtoReflect.Descriptor instead. -func (*DistributionList) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{12} -} - -func (x *DistributionList) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *DistributionList) GetAllowReplies() bool { - if x != nil { - return x.AllowReplies - } - return false -} - -func (x *DistributionList) GetPrivacyMode() DistributionList_PrivacyMode { - if x != nil { - return x.PrivacyMode - } - return DistributionList_UNKNOWN -} - -func (x *DistributionList) GetMemberRecipientIds() []uint64 { - if x != nil { - return x.MemberRecipientIds - } - return nil -} - -type ChatItem struct { - state protoimpl.MessageState `protogen:"open.v1"` - ChatId uint64 `protobuf:"varint,1,opt,name=chatId,proto3" json:"chatId,omitempty"` // conversation id - AuthorId uint64 `protobuf:"varint,2,opt,name=authorId,proto3" json:"authorId,omitempty"` // recipient id - DateSent uint64 `protobuf:"varint,3,opt,name=dateSent,proto3" json:"dateSent,omitempty"` - ExpireStartDate *uint64 `protobuf:"varint,4,opt,name=expireStartDate,proto3,oneof" json:"expireStartDate,omitempty"` // timestamp of when expiration timer started ticking down - ExpiresInMs *uint64 `protobuf:"varint,5,opt,name=expiresInMs,proto3,oneof" json:"expiresInMs,omitempty"` // how long timer of message is (ms) - Revisions []*ChatItem `protobuf:"bytes,6,rep,name=revisions,proto3" json:"revisions,omitempty"` // ordered from oldest to newest - Sms bool `protobuf:"varint,7,opt,name=sms,proto3" json:"sms,omitempty"` - // If unset, importers should skip this item without throwing an error. - // - // Types that are valid to be assigned to DirectionalDetails: - // - // *ChatItem_Incoming - // *ChatItem_Outgoing - // *ChatItem_Directionless - DirectionalDetails isChatItem_DirectionalDetails `protobuf_oneof:"directionalDetails"` - // If unset, importers should skip this item without throwing an error. - // - // Types that are valid to be assigned to Item: - // - // *ChatItem_StandardMessage - // *ChatItem_ContactMessage - // *ChatItem_StickerMessage - // *ChatItem_RemoteDeletedMessage - // *ChatItem_UpdateMessage - // *ChatItem_PaymentNotification - // *ChatItem_GiftBadge - // *ChatItem_ViewOnceMessage - // *ChatItem_DirectStoryReplyMessage - // *ChatItem_Poll - // *ChatItem_AdminDeletedMessage - Item isChatItem_Item `protobuf_oneof:"item"` - PinDetails *ChatItem_PinDetails `protobuf:"bytes,21,opt,name=pinDetails,proto3" json:"pinDetails,omitempty"` // only set if message is pinned - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ChatItem) Reset() { - *x = ChatItem{} - mi := &file_backuppb_Backup_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ChatItem) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ChatItem) ProtoMessage() {} - -func (x *ChatItem) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[13] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ChatItem.ProtoReflect.Descriptor instead. -func (*ChatItem) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{13} -} - -func (x *ChatItem) GetChatId() uint64 { - if x != nil { - return x.ChatId - } - return 0 -} - -func (x *ChatItem) GetAuthorId() uint64 { - if x != nil { - return x.AuthorId - } - return 0 -} - -func (x *ChatItem) GetDateSent() uint64 { - if x != nil { - return x.DateSent - } - return 0 -} - -func (x *ChatItem) GetExpireStartDate() uint64 { - if x != nil && x.ExpireStartDate != nil { - return *x.ExpireStartDate - } - return 0 -} - -func (x *ChatItem) GetExpiresInMs() uint64 { - if x != nil && x.ExpiresInMs != nil { - return *x.ExpiresInMs - } - return 0 -} - -func (x *ChatItem) GetRevisions() []*ChatItem { - if x != nil { - return x.Revisions - } - return nil -} - -func (x *ChatItem) GetSms() bool { - if x != nil { - return x.Sms - } - return false -} - -func (x *ChatItem) GetDirectionalDetails() isChatItem_DirectionalDetails { - if x != nil { - return x.DirectionalDetails - } - return nil -} - -func (x *ChatItem) GetIncoming() *ChatItem_IncomingMessageDetails { - if x != nil { - if x, ok := x.DirectionalDetails.(*ChatItem_Incoming); ok { - return x.Incoming - } - } - return nil -} - -func (x *ChatItem) GetOutgoing() *ChatItem_OutgoingMessageDetails { - if x != nil { - if x, ok := x.DirectionalDetails.(*ChatItem_Outgoing); ok { - return x.Outgoing - } - } - return nil -} - -func (x *ChatItem) GetDirectionless() *ChatItem_DirectionlessMessageDetails { - if x != nil { - if x, ok := x.DirectionalDetails.(*ChatItem_Directionless); ok { - return x.Directionless - } - } - return nil -} - -func (x *ChatItem) GetItem() isChatItem_Item { - if x != nil { - return x.Item - } - return nil -} - -func (x *ChatItem) GetStandardMessage() *StandardMessage { - if x != nil { - if x, ok := x.Item.(*ChatItem_StandardMessage); ok { - return x.StandardMessage - } - } - return nil -} - -func (x *ChatItem) GetContactMessage() *ContactMessage { - if x != nil { - if x, ok := x.Item.(*ChatItem_ContactMessage); ok { - return x.ContactMessage - } - } - return nil -} - -func (x *ChatItem) GetStickerMessage() *StickerMessage { - if x != nil { - if x, ok := x.Item.(*ChatItem_StickerMessage); ok { - return x.StickerMessage - } - } - return nil -} - -func (x *ChatItem) GetRemoteDeletedMessage() *RemoteDeletedMessage { - if x != nil { - if x, ok := x.Item.(*ChatItem_RemoteDeletedMessage); ok { - return x.RemoteDeletedMessage - } - } - return nil -} - -func (x *ChatItem) GetUpdateMessage() *ChatUpdateMessage { - if x != nil { - if x, ok := x.Item.(*ChatItem_UpdateMessage); ok { - return x.UpdateMessage - } - } - return nil -} - -func (x *ChatItem) GetPaymentNotification() *PaymentNotification { - if x != nil { - if x, ok := x.Item.(*ChatItem_PaymentNotification); ok { - return x.PaymentNotification - } - } - return nil -} - -func (x *ChatItem) GetGiftBadge() *GiftBadge { - if x != nil { - if x, ok := x.Item.(*ChatItem_GiftBadge); ok { - return x.GiftBadge - } - } - return nil -} - -func (x *ChatItem) GetViewOnceMessage() *ViewOnceMessage { - if x != nil { - if x, ok := x.Item.(*ChatItem_ViewOnceMessage); ok { - return x.ViewOnceMessage - } - } - return nil -} - -func (x *ChatItem) GetDirectStoryReplyMessage() *DirectStoryReplyMessage { - if x != nil { - if x, ok := x.Item.(*ChatItem_DirectStoryReplyMessage); ok { - return x.DirectStoryReplyMessage - } - } - return nil -} - -func (x *ChatItem) GetPoll() *Poll { - if x != nil { - if x, ok := x.Item.(*ChatItem_Poll); ok { - return x.Poll - } - } - return nil -} - -func (x *ChatItem) GetAdminDeletedMessage() *AdminDeletedMessage { - if x != nil { - if x, ok := x.Item.(*ChatItem_AdminDeletedMessage); ok { - return x.AdminDeletedMessage - } - } - return nil -} - -func (x *ChatItem) GetPinDetails() *ChatItem_PinDetails { - if x != nil { - return x.PinDetails - } - return nil -} - -type isChatItem_DirectionalDetails interface { - isChatItem_DirectionalDetails() -} - -type ChatItem_Incoming struct { - Incoming *ChatItem_IncomingMessageDetails `protobuf:"bytes,8,opt,name=incoming,proto3,oneof"` -} - -type ChatItem_Outgoing struct { - Outgoing *ChatItem_OutgoingMessageDetails `protobuf:"bytes,9,opt,name=outgoing,proto3,oneof"` -} - -type ChatItem_Directionless struct { - Directionless *ChatItem_DirectionlessMessageDetails `protobuf:"bytes,10,opt,name=directionless,proto3,oneof"` -} - -func (*ChatItem_Incoming) isChatItem_DirectionalDetails() {} - -func (*ChatItem_Outgoing) isChatItem_DirectionalDetails() {} - -func (*ChatItem_Directionless) isChatItem_DirectionalDetails() {} - -type isChatItem_Item interface { - isChatItem_Item() -} - -type ChatItem_StandardMessage struct { - StandardMessage *StandardMessage `protobuf:"bytes,11,opt,name=standardMessage,proto3,oneof"` -} - -type ChatItem_ContactMessage struct { - ContactMessage *ContactMessage `protobuf:"bytes,12,opt,name=contactMessage,proto3,oneof"` -} - -type ChatItem_StickerMessage struct { - StickerMessage *StickerMessage `protobuf:"bytes,13,opt,name=stickerMessage,proto3,oneof"` -} - -type ChatItem_RemoteDeletedMessage struct { - RemoteDeletedMessage *RemoteDeletedMessage `protobuf:"bytes,14,opt,name=remoteDeletedMessage,proto3,oneof"` -} - -type ChatItem_UpdateMessage struct { - UpdateMessage *ChatUpdateMessage `protobuf:"bytes,15,opt,name=updateMessage,proto3,oneof"` -} - -type ChatItem_PaymentNotification struct { - PaymentNotification *PaymentNotification `protobuf:"bytes,16,opt,name=paymentNotification,proto3,oneof"` -} - -type ChatItem_GiftBadge struct { - GiftBadge *GiftBadge `protobuf:"bytes,17,opt,name=giftBadge,proto3,oneof"` -} - -type ChatItem_ViewOnceMessage struct { - ViewOnceMessage *ViewOnceMessage `protobuf:"bytes,18,opt,name=viewOnceMessage,proto3,oneof"` -} - -type ChatItem_DirectStoryReplyMessage struct { - DirectStoryReplyMessage *DirectStoryReplyMessage `protobuf:"bytes,19,opt,name=directStoryReplyMessage,proto3,oneof"` // group story reply messages are not backed up -} - -type ChatItem_Poll struct { - Poll *Poll `protobuf:"bytes,20,opt,name=poll,proto3,oneof"` -} - -type ChatItem_AdminDeletedMessage struct { - AdminDeletedMessage *AdminDeletedMessage `protobuf:"bytes,22,opt,name=adminDeletedMessage,proto3,oneof"` -} - -func (*ChatItem_StandardMessage) isChatItem_Item() {} - -func (*ChatItem_ContactMessage) isChatItem_Item() {} - -func (*ChatItem_StickerMessage) isChatItem_Item() {} - -func (*ChatItem_RemoteDeletedMessage) isChatItem_Item() {} - -func (*ChatItem_UpdateMessage) isChatItem_Item() {} - -func (*ChatItem_PaymentNotification) isChatItem_Item() {} - -func (*ChatItem_GiftBadge) isChatItem_Item() {} - -func (*ChatItem_ViewOnceMessage) isChatItem_Item() {} - -func (*ChatItem_DirectStoryReplyMessage) isChatItem_Item() {} - -func (*ChatItem_Poll) isChatItem_Item() {} - -func (*ChatItem_AdminDeletedMessage) isChatItem_Item() {} - -type SendStatus struct { - state protoimpl.MessageState `protogen:"open.v1"` - RecipientId uint64 `protobuf:"varint,1,opt,name=recipientId,proto3" json:"recipientId,omitempty"` - Timestamp uint64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // the time the status was last updated -- if from a receipt, it should be the sentTime of the receipt - // If unset, importers should consider the status to be "pending" - // - // Types that are valid to be assigned to DeliveryStatus: - // - // *SendStatus_Pending_ - // *SendStatus_Sent_ - // *SendStatus_Delivered_ - // *SendStatus_Read_ - // *SendStatus_Viewed_ - // *SendStatus_Skipped_ - // *SendStatus_Failed_ - DeliveryStatus isSendStatus_DeliveryStatus `protobuf_oneof:"deliveryStatus"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *SendStatus) Reset() { - *x = SendStatus{} - mi := &file_backuppb_Backup_proto_msgTypes[14] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *SendStatus) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SendStatus) ProtoMessage() {} - -func (x *SendStatus) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[14] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SendStatus.ProtoReflect.Descriptor instead. -func (*SendStatus) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{14} -} - -func (x *SendStatus) GetRecipientId() uint64 { - if x != nil { - return x.RecipientId - } - return 0 -} - -func (x *SendStatus) GetTimestamp() uint64 { - if x != nil { - return x.Timestamp - } - return 0 -} - -func (x *SendStatus) GetDeliveryStatus() isSendStatus_DeliveryStatus { - if x != nil { - return x.DeliveryStatus - } - return nil -} - -func (x *SendStatus) GetPending() *SendStatus_Pending { - if x != nil { - if x, ok := x.DeliveryStatus.(*SendStatus_Pending_); ok { - return x.Pending - } - } - return nil -} - -func (x *SendStatus) GetSent() *SendStatus_Sent { - if x != nil { - if x, ok := x.DeliveryStatus.(*SendStatus_Sent_); ok { - return x.Sent - } - } - return nil -} - -func (x *SendStatus) GetDelivered() *SendStatus_Delivered { - if x != nil { - if x, ok := x.DeliveryStatus.(*SendStatus_Delivered_); ok { - return x.Delivered - } - } - return nil -} - -func (x *SendStatus) GetRead() *SendStatus_Read { - if x != nil { - if x, ok := x.DeliveryStatus.(*SendStatus_Read_); ok { - return x.Read - } - } - return nil -} - -func (x *SendStatus) GetViewed() *SendStatus_Viewed { - if x != nil { - if x, ok := x.DeliveryStatus.(*SendStatus_Viewed_); ok { - return x.Viewed - } - } - return nil -} - -func (x *SendStatus) GetSkipped() *SendStatus_Skipped { - if x != nil { - if x, ok := x.DeliveryStatus.(*SendStatus_Skipped_); ok { - return x.Skipped - } - } - return nil -} - -func (x *SendStatus) GetFailed() *SendStatus_Failed { - if x != nil { - if x, ok := x.DeliveryStatus.(*SendStatus_Failed_); ok { - return x.Failed - } - } - return nil -} - -type isSendStatus_DeliveryStatus interface { - isSendStatus_DeliveryStatus() -} - -type SendStatus_Pending_ struct { - Pending *SendStatus_Pending `protobuf:"bytes,3,opt,name=pending,proto3,oneof"` -} - -type SendStatus_Sent_ struct { - Sent *SendStatus_Sent `protobuf:"bytes,4,opt,name=sent,proto3,oneof"` -} - -type SendStatus_Delivered_ struct { - Delivered *SendStatus_Delivered `protobuf:"bytes,5,opt,name=delivered,proto3,oneof"` -} - -type SendStatus_Read_ struct { - Read *SendStatus_Read `protobuf:"bytes,6,opt,name=read,proto3,oneof"` -} - -type SendStatus_Viewed_ struct { - Viewed *SendStatus_Viewed `protobuf:"bytes,7,opt,name=viewed,proto3,oneof"` -} - -type SendStatus_Skipped_ struct { - Skipped *SendStatus_Skipped `protobuf:"bytes,8,opt,name=skipped,proto3,oneof"` -} - -type SendStatus_Failed_ struct { - Failed *SendStatus_Failed `protobuf:"bytes,9,opt,name=failed,proto3,oneof"` -} - -func (*SendStatus_Pending_) isSendStatus_DeliveryStatus() {} - -func (*SendStatus_Sent_) isSendStatus_DeliveryStatus() {} - -func (*SendStatus_Delivered_) isSendStatus_DeliveryStatus() {} - -func (*SendStatus_Read_) isSendStatus_DeliveryStatus() {} - -func (*SendStatus_Viewed_) isSendStatus_DeliveryStatus() {} - -func (*SendStatus_Skipped_) isSendStatus_DeliveryStatus() {} - -func (*SendStatus_Failed_) isSendStatus_DeliveryStatus() {} - -type Text struct { - state protoimpl.MessageState `protogen:"open.v1"` - Body string `protobuf:"bytes,1,opt,name=body,proto3" json:"body,omitempty"` - BodyRanges []*BodyRange `protobuf:"bytes,2,rep,name=bodyRanges,proto3" json:"bodyRanges,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Text) Reset() { - *x = Text{} - mi := &file_backuppb_Backup_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Text) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Text) ProtoMessage() {} - -func (x *Text) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[15] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Text.ProtoReflect.Descriptor instead. -func (*Text) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{15} -} - -func (x *Text) GetBody() string { - if x != nil { - return x.Body - } - return "" -} - -func (x *Text) GetBodyRanges() []*BodyRange { - if x != nil { - return x.BodyRanges - } - return nil -} - -type StandardMessage struct { - state protoimpl.MessageState `protogen:"open.v1"` - Quote *Quote `protobuf:"bytes,1,opt,name=quote,proto3,oneof" json:"quote,omitempty"` - Text *Text `protobuf:"bytes,2,opt,name=text,proto3,oneof" json:"text,omitempty"` - Attachments []*MessageAttachment `protobuf:"bytes,3,rep,name=attachments,proto3" json:"attachments,omitempty"` - LinkPreview []*LinkPreview `protobuf:"bytes,4,rep,name=linkPreview,proto3" json:"linkPreview,omitempty"` - LongText *FilePointer `protobuf:"bytes,5,opt,name=longText,proto3,oneof" json:"longText,omitempty"` - Reactions []*Reaction `protobuf:"bytes,6,rep,name=reactions,proto3" json:"reactions,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *StandardMessage) Reset() { - *x = StandardMessage{} - mi := &file_backuppb_Backup_proto_msgTypes[16] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *StandardMessage) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*StandardMessage) ProtoMessage() {} - -func (x *StandardMessage) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[16] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use StandardMessage.ProtoReflect.Descriptor instead. -func (*StandardMessage) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{16} -} - -func (x *StandardMessage) GetQuote() *Quote { - if x != nil { - return x.Quote - } - return nil -} - -func (x *StandardMessage) GetText() *Text { - if x != nil { - return x.Text - } - return nil -} - -func (x *StandardMessage) GetAttachments() []*MessageAttachment { - if x != nil { - return x.Attachments - } - return nil -} - -func (x *StandardMessage) GetLinkPreview() []*LinkPreview { - if x != nil { - return x.LinkPreview - } - return nil -} - -func (x *StandardMessage) GetLongText() *FilePointer { - if x != nil { - return x.LongText - } - return nil -} - -func (x *StandardMessage) GetReactions() []*Reaction { - if x != nil { - return x.Reactions - } - return nil -} - -type ContactMessage struct { - state protoimpl.MessageState `protogen:"open.v1"` - Contact *ContactAttachment `protobuf:"bytes,1,opt,name=contact,proto3" json:"contact,omitempty"` - Reactions []*Reaction `protobuf:"bytes,2,rep,name=reactions,proto3" json:"reactions,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ContactMessage) Reset() { - *x = ContactMessage{} - mi := &file_backuppb_Backup_proto_msgTypes[17] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ContactMessage) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ContactMessage) ProtoMessage() {} - -func (x *ContactMessage) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[17] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ContactMessage.ProtoReflect.Descriptor instead. -func (*ContactMessage) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{17} -} - -func (x *ContactMessage) GetContact() *ContactAttachment { - if x != nil { - return x.Contact - } - return nil -} - -func (x *ContactMessage) GetReactions() []*Reaction { - if x != nil { - return x.Reactions - } - return nil -} - -type DirectStoryReplyMessage struct { - state protoimpl.MessageState `protogen:"open.v1"` - // If unset, importers should ignore the message without throwing an error. - // - // Types that are valid to be assigned to Reply: - // - // *DirectStoryReplyMessage_TextReply_ - // *DirectStoryReplyMessage_Emoji - Reply isDirectStoryReplyMessage_Reply `protobuf_oneof:"reply"` - Reactions []*Reaction `protobuf:"bytes,3,rep,name=reactions,proto3" json:"reactions,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DirectStoryReplyMessage) Reset() { - *x = DirectStoryReplyMessage{} - mi := &file_backuppb_Backup_proto_msgTypes[18] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DirectStoryReplyMessage) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DirectStoryReplyMessage) ProtoMessage() {} - -func (x *DirectStoryReplyMessage) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[18] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DirectStoryReplyMessage.ProtoReflect.Descriptor instead. -func (*DirectStoryReplyMessage) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{18} -} - -func (x *DirectStoryReplyMessage) GetReply() isDirectStoryReplyMessage_Reply { - if x != nil { - return x.Reply - } - return nil -} - -func (x *DirectStoryReplyMessage) GetTextReply() *DirectStoryReplyMessage_TextReply { - if x != nil { - if x, ok := x.Reply.(*DirectStoryReplyMessage_TextReply_); ok { - return x.TextReply - } - } - return nil -} - -func (x *DirectStoryReplyMessage) GetEmoji() string { - if x != nil { - if x, ok := x.Reply.(*DirectStoryReplyMessage_Emoji); ok { - return x.Emoji - } - } - return "" -} - -func (x *DirectStoryReplyMessage) GetReactions() []*Reaction { - if x != nil { - return x.Reactions - } - return nil -} - -type isDirectStoryReplyMessage_Reply interface { - isDirectStoryReplyMessage_Reply() -} - -type DirectStoryReplyMessage_TextReply_ struct { - TextReply *DirectStoryReplyMessage_TextReply `protobuf:"bytes,1,opt,name=textReply,proto3,oneof"` -} - -type DirectStoryReplyMessage_Emoji struct { - Emoji string `protobuf:"bytes,2,opt,name=emoji,proto3,oneof"` -} - -func (*DirectStoryReplyMessage_TextReply_) isDirectStoryReplyMessage_Reply() {} - -func (*DirectStoryReplyMessage_Emoji) isDirectStoryReplyMessage_Reply() {} - -type PaymentNotification struct { - state protoimpl.MessageState `protogen:"open.v1"` - AmountMob *string `protobuf:"bytes,1,opt,name=amountMob,proto3,oneof" json:"amountMob,omitempty"` // stored as a decimal string, e.g. 1.00001 - FeeMob *string `protobuf:"bytes,2,opt,name=feeMob,proto3,oneof" json:"feeMob,omitempty"` // stored as a decimal string, e.g. 1.00001 - Note *string `protobuf:"bytes,3,opt,name=note,proto3,oneof" json:"note,omitempty"` - TransactionDetails *PaymentNotification_TransactionDetails `protobuf:"bytes,4,opt,name=transactionDetails,proto3" json:"transactionDetails,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PaymentNotification) Reset() { - *x = PaymentNotification{} - mi := &file_backuppb_Backup_proto_msgTypes[19] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PaymentNotification) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PaymentNotification) ProtoMessage() {} - -func (x *PaymentNotification) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[19] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PaymentNotification.ProtoReflect.Descriptor instead. -func (*PaymentNotification) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{19} -} - -func (x *PaymentNotification) GetAmountMob() string { - if x != nil && x.AmountMob != nil { - return *x.AmountMob - } - return "" -} - -func (x *PaymentNotification) GetFeeMob() string { - if x != nil && x.FeeMob != nil { - return *x.FeeMob - } - return "" -} - -func (x *PaymentNotification) GetNote() string { - if x != nil && x.Note != nil { - return *x.Note - } - return "" -} - -func (x *PaymentNotification) GetTransactionDetails() *PaymentNotification_TransactionDetails { - if x != nil { - return x.TransactionDetails - } - return nil -} - -type GiftBadge struct { - state protoimpl.MessageState `protogen:"open.v1"` - ReceiptCredentialPresentation []byte `protobuf:"bytes,1,opt,name=receiptCredentialPresentation,proto3" json:"receiptCredentialPresentation,omitempty"` - State GiftBadge_State `protobuf:"varint,2,opt,name=state,proto3,enum=signal.backup.GiftBadge_State" json:"state,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GiftBadge) Reset() { - *x = GiftBadge{} - mi := &file_backuppb_Backup_proto_msgTypes[20] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GiftBadge) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GiftBadge) ProtoMessage() {} - -func (x *GiftBadge) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[20] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GiftBadge.ProtoReflect.Descriptor instead. -func (*GiftBadge) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{20} -} - -func (x *GiftBadge) GetReceiptCredentialPresentation() []byte { - if x != nil { - return x.ReceiptCredentialPresentation - } - return nil -} - -func (x *GiftBadge) GetState() GiftBadge_State { - if x != nil { - return x.State - } - return GiftBadge_UNOPENED -} - -type ViewOnceMessage struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Will be null for viewed messages - Attachment *MessageAttachment `protobuf:"bytes,1,opt,name=attachment,proto3" json:"attachment,omitempty"` - Reactions []*Reaction `protobuf:"bytes,2,rep,name=reactions,proto3" json:"reactions,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ViewOnceMessage) Reset() { - *x = ViewOnceMessage{} - mi := &file_backuppb_Backup_proto_msgTypes[21] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ViewOnceMessage) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ViewOnceMessage) ProtoMessage() {} - -func (x *ViewOnceMessage) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[21] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ViewOnceMessage.ProtoReflect.Descriptor instead. -func (*ViewOnceMessage) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{21} -} - -func (x *ViewOnceMessage) GetAttachment() *MessageAttachment { - if x != nil { - return x.Attachment - } - return nil -} - -func (x *ViewOnceMessage) GetReactions() []*Reaction { - if x != nil { - return x.Reactions - } - return nil -} - -type ContactAttachment struct { - state protoimpl.MessageState `protogen:"open.v1"` - Name *ContactAttachment_Name `protobuf:"bytes,1,opt,name=name,proto3,oneof" json:"name,omitempty"` - Number []*ContactAttachment_Phone `protobuf:"bytes,3,rep,name=number,proto3" json:"number,omitempty"` - Email []*ContactAttachment_Email `protobuf:"bytes,4,rep,name=email,proto3" json:"email,omitempty"` - Address []*ContactAttachment_PostalAddress `protobuf:"bytes,5,rep,name=address,proto3" json:"address,omitempty"` - Avatar *FilePointer `protobuf:"bytes,6,opt,name=avatar,proto3,oneof" json:"avatar,omitempty"` - Organization string `protobuf:"bytes,7,opt,name=organization,proto3" json:"organization,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ContactAttachment) Reset() { - *x = ContactAttachment{} - mi := &file_backuppb_Backup_proto_msgTypes[22] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ContactAttachment) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ContactAttachment) ProtoMessage() {} - -func (x *ContactAttachment) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[22] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ContactAttachment.ProtoReflect.Descriptor instead. -func (*ContactAttachment) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{22} -} - -func (x *ContactAttachment) GetName() *ContactAttachment_Name { - if x != nil { - return x.Name - } - return nil -} - -func (x *ContactAttachment) GetNumber() []*ContactAttachment_Phone { - if x != nil { - return x.Number - } - return nil -} - -func (x *ContactAttachment) GetEmail() []*ContactAttachment_Email { - if x != nil { - return x.Email - } - return nil -} - -func (x *ContactAttachment) GetAddress() []*ContactAttachment_PostalAddress { - if x != nil { - return x.Address - } - return nil -} - -func (x *ContactAttachment) GetAvatar() *FilePointer { - if x != nil { - return x.Avatar - } - return nil -} - -func (x *ContactAttachment) GetOrganization() string { - if x != nil { - return x.Organization - } - return "" -} - -type StickerMessage struct { - state protoimpl.MessageState `protogen:"open.v1"` - Sticker *Sticker `protobuf:"bytes,1,opt,name=sticker,proto3" json:"sticker,omitempty"` - Reactions []*Reaction `protobuf:"bytes,2,rep,name=reactions,proto3" json:"reactions,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *StickerMessage) Reset() { - *x = StickerMessage{} - mi := &file_backuppb_Backup_proto_msgTypes[23] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *StickerMessage) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*StickerMessage) ProtoMessage() {} - -func (x *StickerMessage) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[23] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use StickerMessage.ProtoReflect.Descriptor instead. -func (*StickerMessage) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{23} -} - -func (x *StickerMessage) GetSticker() *Sticker { - if x != nil { - return x.Sticker - } - return nil -} - -func (x *StickerMessage) GetReactions() []*Reaction { - if x != nil { - return x.Reactions - } - return nil -} - -// Tombstone for remote delete -type RemoteDeletedMessage struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RemoteDeletedMessage) Reset() { - *x = RemoteDeletedMessage{} - mi := &file_backuppb_Backup_proto_msgTypes[24] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RemoteDeletedMessage) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RemoteDeletedMessage) ProtoMessage() {} - -func (x *RemoteDeletedMessage) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[24] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RemoteDeletedMessage.ProtoReflect.Descriptor instead. -func (*RemoteDeletedMessage) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{24} -} - -type Sticker struct { - state protoimpl.MessageState `protogen:"open.v1"` - PackId []byte `protobuf:"bytes,1,opt,name=packId,proto3" json:"packId,omitempty"` - PackKey []byte `protobuf:"bytes,2,opt,name=packKey,proto3" json:"packKey,omitempty"` - StickerId uint32 `protobuf:"varint,3,opt,name=stickerId,proto3" json:"stickerId,omitempty"` - Emoji *string `protobuf:"bytes,4,opt,name=emoji,proto3,oneof" json:"emoji,omitempty"` - // Stickers are uploaded to be sent as attachments; we also - // back them up as normal attachments when they are in messages. - // DO NOT treat this as the definitive source of a sticker in - // an installed StickerPack that shares the same packId. - Data *FilePointer `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Sticker) Reset() { - *x = Sticker{} - mi := &file_backuppb_Backup_proto_msgTypes[25] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Sticker) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Sticker) ProtoMessage() {} - -func (x *Sticker) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[25] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Sticker.ProtoReflect.Descriptor instead. -func (*Sticker) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{25} -} - -func (x *Sticker) GetPackId() []byte { - if x != nil { - return x.PackId - } - return nil -} - -func (x *Sticker) GetPackKey() []byte { - if x != nil { - return x.PackKey - } - return nil -} - -func (x *Sticker) GetStickerId() uint32 { - if x != nil { - return x.StickerId - } - return 0 -} - -func (x *Sticker) GetEmoji() string { - if x != nil && x.Emoji != nil { - return *x.Emoji - } - return "" -} - -func (x *Sticker) GetData() *FilePointer { - if x != nil { - return x.Data - } - return nil -} - -type LinkPreview struct { - state protoimpl.MessageState `protogen:"open.v1"` - Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` - Title *string `protobuf:"bytes,2,opt,name=title,proto3,oneof" json:"title,omitempty"` - Image *FilePointer `protobuf:"bytes,3,opt,name=image,proto3,oneof" json:"image,omitempty"` - Description *string `protobuf:"bytes,4,opt,name=description,proto3,oneof" json:"description,omitempty"` - Date *uint64 `protobuf:"varint,5,opt,name=date,proto3,oneof" json:"date,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *LinkPreview) Reset() { - *x = LinkPreview{} - mi := &file_backuppb_Backup_proto_msgTypes[26] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *LinkPreview) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*LinkPreview) ProtoMessage() {} - -func (x *LinkPreview) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[26] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use LinkPreview.ProtoReflect.Descriptor instead. -func (*LinkPreview) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{26} -} - -func (x *LinkPreview) GetUrl() string { - if x != nil { - return x.Url - } - return "" -} - -func (x *LinkPreview) GetTitle() string { - if x != nil && x.Title != nil { - return *x.Title - } - return "" -} - -func (x *LinkPreview) GetImage() *FilePointer { - if x != nil { - return x.Image - } - return nil -} - -func (x *LinkPreview) GetDescription() string { - if x != nil && x.Description != nil { - return *x.Description - } - return "" -} - -func (x *LinkPreview) GetDate() uint64 { - if x != nil && x.Date != nil { - return *x.Date - } - return 0 -} - -// A FilePointer on a message that has additional -// metadata that applies only to message attachments. -type MessageAttachment struct { - state protoimpl.MessageState `protogen:"open.v1"` - Pointer *FilePointer `protobuf:"bytes,1,opt,name=pointer,proto3" json:"pointer,omitempty"` - Flag MessageAttachment_Flag `protobuf:"varint,2,opt,name=flag,proto3,enum=signal.backup.MessageAttachment_Flag" json:"flag,omitempty"` - WasDownloaded bool `protobuf:"varint,3,opt,name=wasDownloaded,proto3" json:"wasDownloaded,omitempty"` - // Cross-client identifier for this attachment among all attachments on the - // owning message. See: SignalService.AttachmentPointer.clientUuid. - ClientUuid []byte `protobuf:"bytes,4,opt,name=clientUuid,proto3,oneof" json:"clientUuid,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *MessageAttachment) Reset() { - *x = MessageAttachment{} - mi := &file_backuppb_Backup_proto_msgTypes[27] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *MessageAttachment) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*MessageAttachment) ProtoMessage() {} - -func (x *MessageAttachment) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[27] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use MessageAttachment.ProtoReflect.Descriptor instead. -func (*MessageAttachment) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{27} -} - -func (x *MessageAttachment) GetPointer() *FilePointer { - if x != nil { - return x.Pointer - } - return nil -} - -func (x *MessageAttachment) GetFlag() MessageAttachment_Flag { - if x != nil { - return x.Flag - } - return MessageAttachment_NONE -} - -func (x *MessageAttachment) GetWasDownloaded() bool { - if x != nil { - return x.WasDownloaded - } - return false -} - -func (x *MessageAttachment) GetClientUuid() []byte { - if x != nil { - return x.ClientUuid - } - return nil -} - -type FilePointer struct { - state protoimpl.MessageState `protogen:"open.v1"` - ContentType *string `protobuf:"bytes,4,opt,name=contentType,proto3,oneof" json:"contentType,omitempty"` - IncrementalMac []byte `protobuf:"bytes,5,opt,name=incrementalMac,proto3,oneof" json:"incrementalMac,omitempty"` - IncrementalMacChunkSize *uint32 `protobuf:"varint,6,opt,name=incrementalMacChunkSize,proto3,oneof" json:"incrementalMacChunkSize,omitempty"` - FileName *string `protobuf:"bytes,7,opt,name=fileName,proto3,oneof" json:"fileName,omitempty"` - Width *uint32 `protobuf:"varint,8,opt,name=width,proto3,oneof" json:"width,omitempty"` - Height *uint32 `protobuf:"varint,9,opt,name=height,proto3,oneof" json:"height,omitempty"` - Caption *string `protobuf:"bytes,10,opt,name=caption,proto3,oneof" json:"caption,omitempty"` - BlurHash *string `protobuf:"bytes,11,opt,name=blurHash,proto3,oneof" json:"blurHash,omitempty"` - LocatorInfo *FilePointer_LocatorInfo `protobuf:"bytes,13,opt,name=locatorInfo,proto3" json:"locatorInfo,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *FilePointer) Reset() { - *x = FilePointer{} - mi := &file_backuppb_Backup_proto_msgTypes[28] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *FilePointer) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*FilePointer) ProtoMessage() {} - -func (x *FilePointer) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[28] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use FilePointer.ProtoReflect.Descriptor instead. -func (*FilePointer) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{28} -} - -func (x *FilePointer) GetContentType() string { - if x != nil && x.ContentType != nil { - return *x.ContentType - } - return "" -} - -func (x *FilePointer) GetIncrementalMac() []byte { - if x != nil { - return x.IncrementalMac - } - return nil -} - -func (x *FilePointer) GetIncrementalMacChunkSize() uint32 { - if x != nil && x.IncrementalMacChunkSize != nil { - return *x.IncrementalMacChunkSize - } - return 0 -} - -func (x *FilePointer) GetFileName() string { - if x != nil && x.FileName != nil { - return *x.FileName - } - return "" -} - -func (x *FilePointer) GetWidth() uint32 { - if x != nil && x.Width != nil { - return *x.Width - } - return 0 -} - -func (x *FilePointer) GetHeight() uint32 { - if x != nil && x.Height != nil { - return *x.Height - } - return 0 -} - -func (x *FilePointer) GetCaption() string { - if x != nil && x.Caption != nil { - return *x.Caption - } - return "" -} - -func (x *FilePointer) GetBlurHash() string { - if x != nil && x.BlurHash != nil { - return *x.BlurHash - } - return "" -} - -func (x *FilePointer) GetLocatorInfo() *FilePointer_LocatorInfo { - if x != nil { - return x.LocatorInfo - } - return nil -} - -type Quote struct { - state protoimpl.MessageState `protogen:"open.v1"` - TargetSentTimestamp *uint64 `protobuf:"varint,1,opt,name=targetSentTimestamp,proto3,oneof" json:"targetSentTimestamp,omitempty"` // null if the target message could not be found at time of quote insert - AuthorId uint64 `protobuf:"varint,2,opt,name=authorId,proto3" json:"authorId,omitempty"` - Text *Text `protobuf:"bytes,3,opt,name=text,proto3,oneof" json:"text,omitempty"` - Attachments []*Quote_QuotedAttachment `protobuf:"bytes,4,rep,name=attachments,proto3" json:"attachments,omitempty"` - Type Quote_Type `protobuf:"varint,5,opt,name=type,proto3,enum=signal.backup.Quote_Type" json:"type,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Quote) Reset() { - *x = Quote{} - mi := &file_backuppb_Backup_proto_msgTypes[29] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Quote) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Quote) ProtoMessage() {} - -func (x *Quote) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[29] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Quote.ProtoReflect.Descriptor instead. -func (*Quote) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{29} -} - -func (x *Quote) GetTargetSentTimestamp() uint64 { - if x != nil && x.TargetSentTimestamp != nil { - return *x.TargetSentTimestamp - } - return 0 -} - -func (x *Quote) GetAuthorId() uint64 { - if x != nil { - return x.AuthorId - } - return 0 -} - -func (x *Quote) GetText() *Text { - if x != nil { - return x.Text - } - return nil -} - -func (x *Quote) GetAttachments() []*Quote_QuotedAttachment { - if x != nil { - return x.Attachments - } - return nil -} - -func (x *Quote) GetType() Quote_Type { - if x != nil { - return x.Type - } - return Quote_UNKNOWN -} - -type BodyRange struct { - state protoimpl.MessageState `protogen:"open.v1"` - // 'start' and 'length' are measured in UTF-16 code units. - // They may refer to offsets in a longText attachment. - Start uint32 `protobuf:"varint,1,opt,name=start,proto3" json:"start,omitempty"` - Length uint32 `protobuf:"varint,2,opt,name=length,proto3" json:"length,omitempty"` - // If unset, importers should ignore the body range without throwing an error. - // - // Types that are valid to be assigned to AssociatedValue: - // - // *BodyRange_MentionAci - // *BodyRange_Style_ - AssociatedValue isBodyRange_AssociatedValue `protobuf_oneof:"associatedValue"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *BodyRange) Reset() { - *x = BodyRange{} - mi := &file_backuppb_Backup_proto_msgTypes[30] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *BodyRange) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*BodyRange) ProtoMessage() {} - -func (x *BodyRange) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[30] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use BodyRange.ProtoReflect.Descriptor instead. -func (*BodyRange) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{30} -} - -func (x *BodyRange) GetStart() uint32 { - if x != nil { - return x.Start - } - return 0 -} - -func (x *BodyRange) GetLength() uint32 { - if x != nil { - return x.Length - } - return 0 -} - -func (x *BodyRange) GetAssociatedValue() isBodyRange_AssociatedValue { - if x != nil { - return x.AssociatedValue - } - return nil -} - -func (x *BodyRange) GetMentionAci() []byte { - if x != nil { - if x, ok := x.AssociatedValue.(*BodyRange_MentionAci); ok { - return x.MentionAci - } - } - return nil -} - -func (x *BodyRange) GetStyle() BodyRange_Style { - if x != nil { - if x, ok := x.AssociatedValue.(*BodyRange_Style_); ok { - return x.Style - } - } - return BodyRange_NONE -} - -type isBodyRange_AssociatedValue interface { - isBodyRange_AssociatedValue() -} - -type BodyRange_MentionAci struct { - MentionAci []byte `protobuf:"bytes,3,opt,name=mentionAci,proto3,oneof"` -} - -type BodyRange_Style_ struct { - Style BodyRange_Style `protobuf:"varint,4,opt,name=style,proto3,enum=signal.backup.BodyRange_Style,oneof"` -} - -func (*BodyRange_MentionAci) isBodyRange_AssociatedValue() {} - -func (*BodyRange_Style_) isBodyRange_AssociatedValue() {} - -type Reaction struct { - state protoimpl.MessageState `protogen:"open.v1"` - Emoji string `protobuf:"bytes,1,opt,name=emoji,proto3" json:"emoji,omitempty"` - AuthorId uint64 `protobuf:"varint,2,opt,name=authorId,proto3" json:"authorId,omitempty"` - SentTimestamp uint64 `protobuf:"varint,3,opt,name=sentTimestamp,proto3" json:"sentTimestamp,omitempty"` - // A higher sort order means that a reaction is more recent. Some clients may export this as - // incrementing numbers (e.g. 1, 2, 3), others as timestamps. - SortOrder uint64 `protobuf:"varint,4,opt,name=sortOrder,proto3" json:"sortOrder,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Reaction) Reset() { - *x = Reaction{} - mi := &file_backuppb_Backup_proto_msgTypes[31] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Reaction) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Reaction) ProtoMessage() {} - -func (x *Reaction) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[31] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Reaction.ProtoReflect.Descriptor instead. -func (*Reaction) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{31} -} - -func (x *Reaction) GetEmoji() string { - if x != nil { - return x.Emoji - } - return "" -} - -func (x *Reaction) GetAuthorId() uint64 { - if x != nil { - return x.AuthorId - } - return 0 -} - -func (x *Reaction) GetSentTimestamp() uint64 { - if x != nil { - return x.SentTimestamp - } - return 0 -} - -func (x *Reaction) GetSortOrder() uint64 { - if x != nil { - return x.SortOrder - } - return 0 -} - -type Poll struct { - state protoimpl.MessageState `protogen:"open.v1"` - Question string `protobuf:"bytes,1,opt,name=question,proto3" json:"question,omitempty"` // Between 1-100 characters - AllowMultiple bool `protobuf:"varint,2,opt,name=allowMultiple,proto3" json:"allowMultiple,omitempty"` - Options []*Poll_PollOption `protobuf:"bytes,3,rep,name=options,proto3" json:"options,omitempty"` // At least two - HasEnded bool `protobuf:"varint,4,opt,name=hasEnded,proto3" json:"hasEnded,omitempty"` - Reactions []*Reaction `protobuf:"bytes,5,rep,name=reactions,proto3" json:"reactions,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Poll) Reset() { - *x = Poll{} - mi := &file_backuppb_Backup_proto_msgTypes[32] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Poll) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Poll) ProtoMessage() {} - -func (x *Poll) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[32] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Poll.ProtoReflect.Descriptor instead. -func (*Poll) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{32} -} - -func (x *Poll) GetQuestion() string { - if x != nil { - return x.Question - } - return "" -} - -func (x *Poll) GetAllowMultiple() bool { - if x != nil { - return x.AllowMultiple - } - return false -} - -func (x *Poll) GetOptions() []*Poll_PollOption { - if x != nil { - return x.Options - } - return nil -} - -func (x *Poll) GetHasEnded() bool { - if x != nil { - return x.HasEnded - } - return false -} - -func (x *Poll) GetReactions() []*Reaction { - if x != nil { - return x.Reactions - } - return nil -} - -type AdminDeletedMessage struct { - state protoimpl.MessageState `protogen:"open.v1"` - AdminId uint64 `protobuf:"varint,1,opt,name=adminId,proto3" json:"adminId,omitempty"` // id of the admin that deleted the message - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AdminDeletedMessage) Reset() { - *x = AdminDeletedMessage{} - mi := &file_backuppb_Backup_proto_msgTypes[33] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AdminDeletedMessage) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AdminDeletedMessage) ProtoMessage() {} - -func (x *AdminDeletedMessage) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[33] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AdminDeletedMessage.ProtoReflect.Descriptor instead. -func (*AdminDeletedMessage) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{33} -} - -func (x *AdminDeletedMessage) GetAdminId() uint64 { - if x != nil { - return x.AdminId - } - return 0 -} - -type ChatUpdateMessage struct { - state protoimpl.MessageState `protogen:"open.v1"` - // If unset, importers should ignore the update message without throwing an error. - // - // Types that are valid to be assigned to Update: - // - // *ChatUpdateMessage_SimpleUpdate - // *ChatUpdateMessage_GroupChange - // *ChatUpdateMessage_ExpirationTimerChange - // *ChatUpdateMessage_ProfileChange - // *ChatUpdateMessage_ThreadMerge - // *ChatUpdateMessage_SessionSwitchover - // *ChatUpdateMessage_IndividualCall - // *ChatUpdateMessage_GroupCall - // *ChatUpdateMessage_LearnedProfileChange - // *ChatUpdateMessage_PollTerminate - // *ChatUpdateMessage_PinMessage - Update isChatUpdateMessage_Update `protobuf_oneof:"update"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ChatUpdateMessage) Reset() { - *x = ChatUpdateMessage{} - mi := &file_backuppb_Backup_proto_msgTypes[34] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ChatUpdateMessage) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ChatUpdateMessage) ProtoMessage() {} - -func (x *ChatUpdateMessage) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[34] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ChatUpdateMessage.ProtoReflect.Descriptor instead. -func (*ChatUpdateMessage) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{34} -} - -func (x *ChatUpdateMessage) GetUpdate() isChatUpdateMessage_Update { - if x != nil { - return x.Update - } - return nil -} - -func (x *ChatUpdateMessage) GetSimpleUpdate() *SimpleChatUpdate { - if x != nil { - if x, ok := x.Update.(*ChatUpdateMessage_SimpleUpdate); ok { - return x.SimpleUpdate - } - } - return nil -} - -func (x *ChatUpdateMessage) GetGroupChange() *GroupChangeChatUpdate { - if x != nil { - if x, ok := x.Update.(*ChatUpdateMessage_GroupChange); ok { - return x.GroupChange - } - } - return nil -} - -func (x *ChatUpdateMessage) GetExpirationTimerChange() *ExpirationTimerChatUpdate { - if x != nil { - if x, ok := x.Update.(*ChatUpdateMessage_ExpirationTimerChange); ok { - return x.ExpirationTimerChange - } - } - return nil -} - -func (x *ChatUpdateMessage) GetProfileChange() *ProfileChangeChatUpdate { - if x != nil { - if x, ok := x.Update.(*ChatUpdateMessage_ProfileChange); ok { - return x.ProfileChange - } - } - return nil -} - -func (x *ChatUpdateMessage) GetThreadMerge() *ThreadMergeChatUpdate { - if x != nil { - if x, ok := x.Update.(*ChatUpdateMessage_ThreadMerge); ok { - return x.ThreadMerge - } - } - return nil -} - -func (x *ChatUpdateMessage) GetSessionSwitchover() *SessionSwitchoverChatUpdate { - if x != nil { - if x, ok := x.Update.(*ChatUpdateMessage_SessionSwitchover); ok { - return x.SessionSwitchover - } - } - return nil -} - -func (x *ChatUpdateMessage) GetIndividualCall() *IndividualCall { - if x != nil { - if x, ok := x.Update.(*ChatUpdateMessage_IndividualCall); ok { - return x.IndividualCall - } - } - return nil -} - -func (x *ChatUpdateMessage) GetGroupCall() *GroupCall { - if x != nil { - if x, ok := x.Update.(*ChatUpdateMessage_GroupCall); ok { - return x.GroupCall - } - } - return nil -} - -func (x *ChatUpdateMessage) GetLearnedProfileChange() *LearnedProfileChatUpdate { - if x != nil { - if x, ok := x.Update.(*ChatUpdateMessage_LearnedProfileChange); ok { - return x.LearnedProfileChange - } - } - return nil -} - -func (x *ChatUpdateMessage) GetPollTerminate() *PollTerminateUpdate { - if x != nil { - if x, ok := x.Update.(*ChatUpdateMessage_PollTerminate); ok { - return x.PollTerminate - } - } - return nil -} - -func (x *ChatUpdateMessage) GetPinMessage() *PinMessageUpdate { - if x != nil { - if x, ok := x.Update.(*ChatUpdateMessage_PinMessage); ok { - return x.PinMessage - } - } - return nil -} - -type isChatUpdateMessage_Update interface { - isChatUpdateMessage_Update() -} - -type ChatUpdateMessage_SimpleUpdate struct { - SimpleUpdate *SimpleChatUpdate `protobuf:"bytes,1,opt,name=simpleUpdate,proto3,oneof"` -} - -type ChatUpdateMessage_GroupChange struct { - GroupChange *GroupChangeChatUpdate `protobuf:"bytes,2,opt,name=groupChange,proto3,oneof"` -} - -type ChatUpdateMessage_ExpirationTimerChange struct { - ExpirationTimerChange *ExpirationTimerChatUpdate `protobuf:"bytes,3,opt,name=expirationTimerChange,proto3,oneof"` -} - -type ChatUpdateMessage_ProfileChange struct { - ProfileChange *ProfileChangeChatUpdate `protobuf:"bytes,4,opt,name=profileChange,proto3,oneof"` -} - -type ChatUpdateMessage_ThreadMerge struct { - ThreadMerge *ThreadMergeChatUpdate `protobuf:"bytes,5,opt,name=threadMerge,proto3,oneof"` -} - -type ChatUpdateMessage_SessionSwitchover struct { - SessionSwitchover *SessionSwitchoverChatUpdate `protobuf:"bytes,6,opt,name=sessionSwitchover,proto3,oneof"` -} - -type ChatUpdateMessage_IndividualCall struct { - IndividualCall *IndividualCall `protobuf:"bytes,7,opt,name=individualCall,proto3,oneof"` -} - -type ChatUpdateMessage_GroupCall struct { - GroupCall *GroupCall `protobuf:"bytes,8,opt,name=groupCall,proto3,oneof"` -} - -type ChatUpdateMessage_LearnedProfileChange struct { - LearnedProfileChange *LearnedProfileChatUpdate `protobuf:"bytes,9,opt,name=learnedProfileChange,proto3,oneof"` -} - -type ChatUpdateMessage_PollTerminate struct { - PollTerminate *PollTerminateUpdate `protobuf:"bytes,10,opt,name=pollTerminate,proto3,oneof"` -} - -type ChatUpdateMessage_PinMessage struct { - PinMessage *PinMessageUpdate `protobuf:"bytes,11,opt,name=pinMessage,proto3,oneof"` -} - -func (*ChatUpdateMessage_SimpleUpdate) isChatUpdateMessage_Update() {} - -func (*ChatUpdateMessage_GroupChange) isChatUpdateMessage_Update() {} - -func (*ChatUpdateMessage_ExpirationTimerChange) isChatUpdateMessage_Update() {} - -func (*ChatUpdateMessage_ProfileChange) isChatUpdateMessage_Update() {} - -func (*ChatUpdateMessage_ThreadMerge) isChatUpdateMessage_Update() {} - -func (*ChatUpdateMessage_SessionSwitchover) isChatUpdateMessage_Update() {} - -func (*ChatUpdateMessage_IndividualCall) isChatUpdateMessage_Update() {} - -func (*ChatUpdateMessage_GroupCall) isChatUpdateMessage_Update() {} - -func (*ChatUpdateMessage_LearnedProfileChange) isChatUpdateMessage_Update() {} - -func (*ChatUpdateMessage_PollTerminate) isChatUpdateMessage_Update() {} - -func (*ChatUpdateMessage_PinMessage) isChatUpdateMessage_Update() {} - -type IndividualCall struct { - state protoimpl.MessageState `protogen:"open.v1"` - CallId *uint64 `protobuf:"varint,1,opt,name=callId,proto3,oneof" json:"callId,omitempty"` - Type IndividualCall_Type `protobuf:"varint,2,opt,name=type,proto3,enum=signal.backup.IndividualCall_Type" json:"type,omitempty"` - Direction IndividualCall_Direction `protobuf:"varint,3,opt,name=direction,proto3,enum=signal.backup.IndividualCall_Direction" json:"direction,omitempty"` - State IndividualCall_State `protobuf:"varint,4,opt,name=state,proto3,enum=signal.backup.IndividualCall_State" json:"state,omitempty"` - StartedCallTimestamp uint64 `protobuf:"varint,5,opt,name=startedCallTimestamp,proto3" json:"startedCallTimestamp,omitempty"` - Read bool `protobuf:"varint,6,opt,name=read,proto3" json:"read,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *IndividualCall) Reset() { - *x = IndividualCall{} - mi := &file_backuppb_Backup_proto_msgTypes[35] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *IndividualCall) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*IndividualCall) ProtoMessage() {} - -func (x *IndividualCall) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[35] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use IndividualCall.ProtoReflect.Descriptor instead. -func (*IndividualCall) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{35} -} - -func (x *IndividualCall) GetCallId() uint64 { - if x != nil && x.CallId != nil { - return *x.CallId - } - return 0 -} - -func (x *IndividualCall) GetType() IndividualCall_Type { - if x != nil { - return x.Type - } - return IndividualCall_UNKNOWN_TYPE -} - -func (x *IndividualCall) GetDirection() IndividualCall_Direction { - if x != nil { - return x.Direction - } - return IndividualCall_UNKNOWN_DIRECTION -} - -func (x *IndividualCall) GetState() IndividualCall_State { - if x != nil { - return x.State - } - return IndividualCall_UNKNOWN_STATE -} - -func (x *IndividualCall) GetStartedCallTimestamp() uint64 { - if x != nil { - return x.StartedCallTimestamp - } - return 0 -} - -func (x *IndividualCall) GetRead() bool { - if x != nil { - return x.Read - } - return false -} - -type GroupCall struct { - state protoimpl.MessageState `protogen:"open.v1"` - CallId *uint64 `protobuf:"varint,1,opt,name=callId,proto3,oneof" json:"callId,omitempty"` - State GroupCall_State `protobuf:"varint,2,opt,name=state,proto3,enum=signal.backup.GroupCall_State" json:"state,omitempty"` - RingerRecipientId *uint64 `protobuf:"varint,3,opt,name=ringerRecipientId,proto3,oneof" json:"ringerRecipientId,omitempty"` - StartedCallRecipientId *uint64 `protobuf:"varint,4,opt,name=startedCallRecipientId,proto3,oneof" json:"startedCallRecipientId,omitempty"` - StartedCallTimestamp uint64 `protobuf:"varint,5,opt,name=startedCallTimestamp,proto3" json:"startedCallTimestamp,omitempty"` - EndedCallTimestamp *uint64 `protobuf:"varint,6,opt,name=endedCallTimestamp,proto3,oneof" json:"endedCallTimestamp,omitempty"` // The time the call ended. - Read bool `protobuf:"varint,7,opt,name=read,proto3" json:"read,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupCall) Reset() { - *x = GroupCall{} - mi := &file_backuppb_Backup_proto_msgTypes[36] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupCall) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupCall) ProtoMessage() {} - -func (x *GroupCall) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[36] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupCall.ProtoReflect.Descriptor instead. -func (*GroupCall) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{36} -} - -func (x *GroupCall) GetCallId() uint64 { - if x != nil && x.CallId != nil { - return *x.CallId - } - return 0 -} - -func (x *GroupCall) GetState() GroupCall_State { - if x != nil { - return x.State - } - return GroupCall_UNKNOWN_STATE -} - -func (x *GroupCall) GetRingerRecipientId() uint64 { - if x != nil && x.RingerRecipientId != nil { - return *x.RingerRecipientId - } - return 0 -} - -func (x *GroupCall) GetStartedCallRecipientId() uint64 { - if x != nil && x.StartedCallRecipientId != nil { - return *x.StartedCallRecipientId - } - return 0 -} - -func (x *GroupCall) GetStartedCallTimestamp() uint64 { - if x != nil { - return x.StartedCallTimestamp - } - return 0 -} - -func (x *GroupCall) GetEndedCallTimestamp() uint64 { - if x != nil && x.EndedCallTimestamp != nil { - return *x.EndedCallTimestamp - } - return 0 -} - -func (x *GroupCall) GetRead() bool { - if x != nil { - return x.Read - } - return false -} - -type SimpleChatUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - Type SimpleChatUpdate_Type `protobuf:"varint,1,opt,name=type,proto3,enum=signal.backup.SimpleChatUpdate_Type" json:"type,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *SimpleChatUpdate) Reset() { - *x = SimpleChatUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[37] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *SimpleChatUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SimpleChatUpdate) ProtoMessage() {} - -func (x *SimpleChatUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[37] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SimpleChatUpdate.ProtoReflect.Descriptor instead. -func (*SimpleChatUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{37} -} - -func (x *SimpleChatUpdate) GetType() SimpleChatUpdate_Type { - if x != nil { - return x.Type - } - return SimpleChatUpdate_UNKNOWN -} - -// For 1:1 chat updates only. -// For group thread updates use GroupExpirationTimerUpdate. -type ExpirationTimerChatUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - ExpiresInMs uint64 `protobuf:"varint,1,opt,name=expiresInMs,proto3" json:"expiresInMs,omitempty"` // 0 means the expiration timer was disabled - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ExpirationTimerChatUpdate) Reset() { - *x = ExpirationTimerChatUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[38] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ExpirationTimerChatUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ExpirationTimerChatUpdate) ProtoMessage() {} - -func (x *ExpirationTimerChatUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[38] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ExpirationTimerChatUpdate.ProtoReflect.Descriptor instead. -func (*ExpirationTimerChatUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{38} -} - -func (x *ExpirationTimerChatUpdate) GetExpiresInMs() uint64 { - if x != nil { - return x.ExpiresInMs - } - return 0 -} - -type ProfileChangeChatUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - PreviousName string `protobuf:"bytes,1,opt,name=previousName,proto3" json:"previousName,omitempty"` - NewName string `protobuf:"bytes,2,opt,name=newName,proto3" json:"newName,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ProfileChangeChatUpdate) Reset() { - *x = ProfileChangeChatUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[39] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ProfileChangeChatUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ProfileChangeChatUpdate) ProtoMessage() {} - -func (x *ProfileChangeChatUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[39] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ProfileChangeChatUpdate.ProtoReflect.Descriptor instead. -func (*ProfileChangeChatUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{39} -} - -func (x *ProfileChangeChatUpdate) GetPreviousName() string { - if x != nil { - return x.PreviousName - } - return "" -} - -func (x *ProfileChangeChatUpdate) GetNewName() string { - if x != nil { - return x.NewName - } - return "" -} - -type LearnedProfileChatUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - // If unset, importers should consider the previous name to be an empty string. - // - // Types that are valid to be assigned to PreviousName: - // - // *LearnedProfileChatUpdate_E164 - // *LearnedProfileChatUpdate_Username - PreviousName isLearnedProfileChatUpdate_PreviousName `protobuf_oneof:"previousName"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *LearnedProfileChatUpdate) Reset() { - *x = LearnedProfileChatUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[40] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *LearnedProfileChatUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*LearnedProfileChatUpdate) ProtoMessage() {} - -func (x *LearnedProfileChatUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[40] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use LearnedProfileChatUpdate.ProtoReflect.Descriptor instead. -func (*LearnedProfileChatUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{40} -} - -func (x *LearnedProfileChatUpdate) GetPreviousName() isLearnedProfileChatUpdate_PreviousName { - if x != nil { - return x.PreviousName - } - return nil -} - -func (x *LearnedProfileChatUpdate) GetE164() uint64 { - if x != nil { - if x, ok := x.PreviousName.(*LearnedProfileChatUpdate_E164); ok { - return x.E164 - } - } - return 0 -} - -func (x *LearnedProfileChatUpdate) GetUsername() string { - if x != nil { - if x, ok := x.PreviousName.(*LearnedProfileChatUpdate_Username); ok { - return x.Username - } - } - return "" -} - -type isLearnedProfileChatUpdate_PreviousName interface { - isLearnedProfileChatUpdate_PreviousName() -} - -type LearnedProfileChatUpdate_E164 struct { - E164 uint64 `protobuf:"varint,1,opt,name=e164,proto3,oneof"` -} - -type LearnedProfileChatUpdate_Username struct { - Username string `protobuf:"bytes,2,opt,name=username,proto3,oneof"` -} - -func (*LearnedProfileChatUpdate_E164) isLearnedProfileChatUpdate_PreviousName() {} - -func (*LearnedProfileChatUpdate_Username) isLearnedProfileChatUpdate_PreviousName() {} - -type ThreadMergeChatUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - PreviousE164 uint64 `protobuf:"varint,1,opt,name=previousE164,proto3" json:"previousE164,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ThreadMergeChatUpdate) Reset() { - *x = ThreadMergeChatUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[41] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ThreadMergeChatUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ThreadMergeChatUpdate) ProtoMessage() {} - -func (x *ThreadMergeChatUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[41] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ThreadMergeChatUpdate.ProtoReflect.Descriptor instead. -func (*ThreadMergeChatUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{41} -} - -func (x *ThreadMergeChatUpdate) GetPreviousE164() uint64 { - if x != nil { - return x.PreviousE164 - } - return 0 -} - -type SessionSwitchoverChatUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - E164 uint64 `protobuf:"varint,1,opt,name=e164,proto3" json:"e164,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *SessionSwitchoverChatUpdate) Reset() { - *x = SessionSwitchoverChatUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[42] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *SessionSwitchoverChatUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SessionSwitchoverChatUpdate) ProtoMessage() {} - -func (x *SessionSwitchoverChatUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[42] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SessionSwitchoverChatUpdate.ProtoReflect.Descriptor instead. -func (*SessionSwitchoverChatUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{42} -} - -func (x *SessionSwitchoverChatUpdate) GetE164() uint64 { - if x != nil { - return x.E164 - } - return 0 -} - -type GroupChangeChatUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Must be one or more; all updates batched together came from - // a single batched group state update. - Updates []*GroupChangeChatUpdate_Update `protobuf:"bytes,1,rep,name=updates,proto3" json:"updates,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupChangeChatUpdate) Reset() { - *x = GroupChangeChatUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[43] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupChangeChatUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupChangeChatUpdate) ProtoMessage() {} - -func (x *GroupChangeChatUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[43] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupChangeChatUpdate.ProtoReflect.Descriptor instead. -func (*GroupChangeChatUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{43} -} - -func (x *GroupChangeChatUpdate) GetUpdates() []*GroupChangeChatUpdate_Update { - if x != nil { - return x.Updates - } - return nil -} - -type GenericGroupUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - UpdaterAci []byte `protobuf:"bytes,1,opt,name=updaterAci,proto3,oneof" json:"updaterAci,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GenericGroupUpdate) Reset() { - *x = GenericGroupUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[44] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GenericGroupUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GenericGroupUpdate) ProtoMessage() {} - -func (x *GenericGroupUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[44] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GenericGroupUpdate.ProtoReflect.Descriptor instead. -func (*GenericGroupUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{44} -} - -func (x *GenericGroupUpdate) GetUpdaterAci() []byte { - if x != nil { - return x.UpdaterAci - } - return nil -} - -type GroupCreationUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - UpdaterAci []byte `protobuf:"bytes,1,opt,name=updaterAci,proto3,oneof" json:"updaterAci,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupCreationUpdate) Reset() { - *x = GroupCreationUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[45] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupCreationUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupCreationUpdate) ProtoMessage() {} - -func (x *GroupCreationUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[45] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupCreationUpdate.ProtoReflect.Descriptor instead. -func (*GroupCreationUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{45} -} - -func (x *GroupCreationUpdate) GetUpdaterAci() []byte { - if x != nil { - return x.UpdaterAci - } - return nil -} - -type GroupNameUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - UpdaterAci []byte `protobuf:"bytes,1,opt,name=updaterAci,proto3,oneof" json:"updaterAci,omitempty"` - // Null value means the group name was removed. - NewGroupName *string `protobuf:"bytes,2,opt,name=newGroupName,proto3,oneof" json:"newGroupName,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupNameUpdate) Reset() { - *x = GroupNameUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[46] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupNameUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupNameUpdate) ProtoMessage() {} - -func (x *GroupNameUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[46] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupNameUpdate.ProtoReflect.Descriptor instead. -func (*GroupNameUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{46} -} - -func (x *GroupNameUpdate) GetUpdaterAci() []byte { - if x != nil { - return x.UpdaterAci - } - return nil -} - -func (x *GroupNameUpdate) GetNewGroupName() string { - if x != nil && x.NewGroupName != nil { - return *x.NewGroupName - } - return "" -} - -type GroupAvatarUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - UpdaterAci []byte `protobuf:"bytes,1,opt,name=updaterAci,proto3,oneof" json:"updaterAci,omitempty"` - WasRemoved bool `protobuf:"varint,2,opt,name=wasRemoved,proto3" json:"wasRemoved,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupAvatarUpdate) Reset() { - *x = GroupAvatarUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[47] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupAvatarUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupAvatarUpdate) ProtoMessage() {} - -func (x *GroupAvatarUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[47] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupAvatarUpdate.ProtoReflect.Descriptor instead. -func (*GroupAvatarUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{47} -} - -func (x *GroupAvatarUpdate) GetUpdaterAci() []byte { - if x != nil { - return x.UpdaterAci - } - return nil -} - -func (x *GroupAvatarUpdate) GetWasRemoved() bool { - if x != nil { - return x.WasRemoved - } - return false -} - -type GroupDescriptionUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - UpdaterAci []byte `protobuf:"bytes,1,opt,name=updaterAci,proto3,oneof" json:"updaterAci,omitempty"` - // Null value means the group description was removed. - NewDescription *string `protobuf:"bytes,2,opt,name=newDescription,proto3,oneof" json:"newDescription,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupDescriptionUpdate) Reset() { - *x = GroupDescriptionUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[48] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupDescriptionUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupDescriptionUpdate) ProtoMessage() {} - -func (x *GroupDescriptionUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[48] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupDescriptionUpdate.ProtoReflect.Descriptor instead. -func (*GroupDescriptionUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{48} -} - -func (x *GroupDescriptionUpdate) GetUpdaterAci() []byte { - if x != nil { - return x.UpdaterAci - } - return nil -} - -func (x *GroupDescriptionUpdate) GetNewDescription() string { - if x != nil && x.NewDescription != nil { - return *x.NewDescription - } - return "" -} - -type GroupMembershipAccessLevelChangeUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - UpdaterAci []byte `protobuf:"bytes,1,opt,name=updaterAci,proto3,oneof" json:"updaterAci,omitempty"` - AccessLevel GroupV2AccessLevel `protobuf:"varint,2,opt,name=accessLevel,proto3,enum=signal.backup.GroupV2AccessLevel" json:"accessLevel,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupMembershipAccessLevelChangeUpdate) Reset() { - *x = GroupMembershipAccessLevelChangeUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[49] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupMembershipAccessLevelChangeUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupMembershipAccessLevelChangeUpdate) ProtoMessage() {} - -func (x *GroupMembershipAccessLevelChangeUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[49] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupMembershipAccessLevelChangeUpdate.ProtoReflect.Descriptor instead. -func (*GroupMembershipAccessLevelChangeUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{49} -} - -func (x *GroupMembershipAccessLevelChangeUpdate) GetUpdaterAci() []byte { - if x != nil { - return x.UpdaterAci - } - return nil -} - -func (x *GroupMembershipAccessLevelChangeUpdate) GetAccessLevel() GroupV2AccessLevel { - if x != nil { - return x.AccessLevel - } - return GroupV2AccessLevel_UNKNOWN -} - -type GroupAttributesAccessLevelChangeUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - UpdaterAci []byte `protobuf:"bytes,1,opt,name=updaterAci,proto3,oneof" json:"updaterAci,omitempty"` - AccessLevel GroupV2AccessLevel `protobuf:"varint,2,opt,name=accessLevel,proto3,enum=signal.backup.GroupV2AccessLevel" json:"accessLevel,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupAttributesAccessLevelChangeUpdate) Reset() { - *x = GroupAttributesAccessLevelChangeUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[50] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupAttributesAccessLevelChangeUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupAttributesAccessLevelChangeUpdate) ProtoMessage() {} - -func (x *GroupAttributesAccessLevelChangeUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[50] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupAttributesAccessLevelChangeUpdate.ProtoReflect.Descriptor instead. -func (*GroupAttributesAccessLevelChangeUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{50} -} - -func (x *GroupAttributesAccessLevelChangeUpdate) GetUpdaterAci() []byte { - if x != nil { - return x.UpdaterAci - } - return nil -} - -func (x *GroupAttributesAccessLevelChangeUpdate) GetAccessLevel() GroupV2AccessLevel { - if x != nil { - return x.AccessLevel - } - return GroupV2AccessLevel_UNKNOWN -} - -type GroupMemberLabelAccessLevelChangeUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - UpdaterAci []byte `protobuf:"bytes,1,opt,name=updaterAci,proto3,oneof" json:"updaterAci,omitempty"` - AccessLevel GroupV2AccessLevel `protobuf:"varint,2,opt,name=accessLevel,proto3,enum=signal.backup.GroupV2AccessLevel" json:"accessLevel,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupMemberLabelAccessLevelChangeUpdate) Reset() { - *x = GroupMemberLabelAccessLevelChangeUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[51] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupMemberLabelAccessLevelChangeUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupMemberLabelAccessLevelChangeUpdate) ProtoMessage() {} - -func (x *GroupMemberLabelAccessLevelChangeUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[51] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupMemberLabelAccessLevelChangeUpdate.ProtoReflect.Descriptor instead. -func (*GroupMemberLabelAccessLevelChangeUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{51} -} - -func (x *GroupMemberLabelAccessLevelChangeUpdate) GetUpdaterAci() []byte { - if x != nil { - return x.UpdaterAci - } - return nil -} - -func (x *GroupMemberLabelAccessLevelChangeUpdate) GetAccessLevel() GroupV2AccessLevel { - if x != nil { - return x.AccessLevel - } - return GroupV2AccessLevel_UNKNOWN -} - -type GroupTerminateChangeUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - UpdaterAci []byte `protobuf:"bytes,1,opt,name=updaterAci,proto3,oneof" json:"updaterAci,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupTerminateChangeUpdate) Reset() { - *x = GroupTerminateChangeUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[52] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupTerminateChangeUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupTerminateChangeUpdate) ProtoMessage() {} - -func (x *GroupTerminateChangeUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[52] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupTerminateChangeUpdate.ProtoReflect.Descriptor instead. -func (*GroupTerminateChangeUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{52} -} - -func (x *GroupTerminateChangeUpdate) GetUpdaterAci() []byte { - if x != nil { - return x.UpdaterAci - } - return nil -} - -type GroupAnnouncementOnlyChangeUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - UpdaterAci []byte `protobuf:"bytes,1,opt,name=updaterAci,proto3,oneof" json:"updaterAci,omitempty"` - IsAnnouncementOnly bool `protobuf:"varint,2,opt,name=isAnnouncementOnly,proto3" json:"isAnnouncementOnly,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupAnnouncementOnlyChangeUpdate) Reset() { - *x = GroupAnnouncementOnlyChangeUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[53] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupAnnouncementOnlyChangeUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupAnnouncementOnlyChangeUpdate) ProtoMessage() {} - -func (x *GroupAnnouncementOnlyChangeUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[53] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupAnnouncementOnlyChangeUpdate.ProtoReflect.Descriptor instead. -func (*GroupAnnouncementOnlyChangeUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{53} -} - -func (x *GroupAnnouncementOnlyChangeUpdate) GetUpdaterAci() []byte { - if x != nil { - return x.UpdaterAci - } - return nil -} - -func (x *GroupAnnouncementOnlyChangeUpdate) GetIsAnnouncementOnly() bool { - if x != nil { - return x.IsAnnouncementOnly - } - return false -} - -type GroupAdminStatusUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - UpdaterAci []byte `protobuf:"bytes,1,opt,name=updaterAci,proto3,oneof" json:"updaterAci,omitempty"` - // The aci who had admin status granted or revoked. - MemberAci []byte `protobuf:"bytes,2,opt,name=memberAci,proto3" json:"memberAci,omitempty"` - WasAdminStatusGranted bool `protobuf:"varint,3,opt,name=wasAdminStatusGranted,proto3" json:"wasAdminStatusGranted,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupAdminStatusUpdate) Reset() { - *x = GroupAdminStatusUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[54] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupAdminStatusUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupAdminStatusUpdate) ProtoMessage() {} - -func (x *GroupAdminStatusUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[54] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupAdminStatusUpdate.ProtoReflect.Descriptor instead. -func (*GroupAdminStatusUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{54} -} - -func (x *GroupAdminStatusUpdate) GetUpdaterAci() []byte { - if x != nil { - return x.UpdaterAci - } - return nil -} - -func (x *GroupAdminStatusUpdate) GetMemberAci() []byte { - if x != nil { - return x.MemberAci - } - return nil -} - -func (x *GroupAdminStatusUpdate) GetWasAdminStatusGranted() bool { - if x != nil { - return x.WasAdminStatusGranted - } - return false -} - -type GroupMemberLeftUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - Aci []byte `protobuf:"bytes,1,opt,name=aci,proto3" json:"aci,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupMemberLeftUpdate) Reset() { - *x = GroupMemberLeftUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[55] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupMemberLeftUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupMemberLeftUpdate) ProtoMessage() {} - -func (x *GroupMemberLeftUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[55] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupMemberLeftUpdate.ProtoReflect.Descriptor instead. -func (*GroupMemberLeftUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{55} -} - -func (x *GroupMemberLeftUpdate) GetAci() []byte { - if x != nil { - return x.Aci - } - return nil -} - -type GroupMemberRemovedUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - RemoverAci []byte `protobuf:"bytes,1,opt,name=removerAci,proto3,oneof" json:"removerAci,omitempty"` - RemovedAci []byte `protobuf:"bytes,2,opt,name=removedAci,proto3" json:"removedAci,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupMemberRemovedUpdate) Reset() { - *x = GroupMemberRemovedUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[56] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupMemberRemovedUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupMemberRemovedUpdate) ProtoMessage() {} - -func (x *GroupMemberRemovedUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[56] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupMemberRemovedUpdate.ProtoReflect.Descriptor instead. -func (*GroupMemberRemovedUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{56} -} - -func (x *GroupMemberRemovedUpdate) GetRemoverAci() []byte { - if x != nil { - return x.RemoverAci - } - return nil -} - -func (x *GroupMemberRemovedUpdate) GetRemovedAci() []byte { - if x != nil { - return x.RemovedAci - } - return nil -} - -type SelfInvitedToGroupUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - InviterAci []byte `protobuf:"bytes,1,opt,name=inviterAci,proto3,oneof" json:"inviterAci,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *SelfInvitedToGroupUpdate) Reset() { - *x = SelfInvitedToGroupUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[57] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *SelfInvitedToGroupUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SelfInvitedToGroupUpdate) ProtoMessage() {} - -func (x *SelfInvitedToGroupUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[57] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SelfInvitedToGroupUpdate.ProtoReflect.Descriptor instead. -func (*SelfInvitedToGroupUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{57} -} - -func (x *SelfInvitedToGroupUpdate) GetInviterAci() []byte { - if x != nil { - return x.InviterAci - } - return nil -} - -type SelfInvitedOtherUserToGroupUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - // If no invitee id available, use GroupUnknownInviteeUpdate - InviteeServiceId []byte `protobuf:"bytes,1,opt,name=inviteeServiceId,proto3" json:"inviteeServiceId,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *SelfInvitedOtherUserToGroupUpdate) Reset() { - *x = SelfInvitedOtherUserToGroupUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[58] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *SelfInvitedOtherUserToGroupUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SelfInvitedOtherUserToGroupUpdate) ProtoMessage() {} - -func (x *SelfInvitedOtherUserToGroupUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[58] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SelfInvitedOtherUserToGroupUpdate.ProtoReflect.Descriptor instead. -func (*SelfInvitedOtherUserToGroupUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{58} -} - -func (x *SelfInvitedOtherUserToGroupUpdate) GetInviteeServiceId() []byte { - if x != nil { - return x.InviteeServiceId - } - return nil -} - -type GroupUnknownInviteeUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Can be the self user. - InviterAci []byte `protobuf:"bytes,1,opt,name=inviterAci,proto3,oneof" json:"inviterAci,omitempty"` - InviteeCount uint32 `protobuf:"varint,2,opt,name=inviteeCount,proto3" json:"inviteeCount,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupUnknownInviteeUpdate) Reset() { - *x = GroupUnknownInviteeUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[59] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupUnknownInviteeUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupUnknownInviteeUpdate) ProtoMessage() {} - -func (x *GroupUnknownInviteeUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[59] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupUnknownInviteeUpdate.ProtoReflect.Descriptor instead. -func (*GroupUnknownInviteeUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{59} -} - -func (x *GroupUnknownInviteeUpdate) GetInviterAci() []byte { - if x != nil { - return x.InviterAci - } - return nil -} - -func (x *GroupUnknownInviteeUpdate) GetInviteeCount() uint32 { - if x != nil { - return x.InviteeCount - } - return 0 -} - -type GroupInvitationAcceptedUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - InviterAci []byte `protobuf:"bytes,1,opt,name=inviterAci,proto3,oneof" json:"inviterAci,omitempty"` - NewMemberAci []byte `protobuf:"bytes,2,opt,name=newMemberAci,proto3" json:"newMemberAci,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupInvitationAcceptedUpdate) Reset() { - *x = GroupInvitationAcceptedUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[60] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupInvitationAcceptedUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupInvitationAcceptedUpdate) ProtoMessage() {} - -func (x *GroupInvitationAcceptedUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[60] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupInvitationAcceptedUpdate.ProtoReflect.Descriptor instead. -func (*GroupInvitationAcceptedUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{60} -} - -func (x *GroupInvitationAcceptedUpdate) GetInviterAci() []byte { - if x != nil { - return x.InviterAci - } - return nil -} - -func (x *GroupInvitationAcceptedUpdate) GetNewMemberAci() []byte { - if x != nil { - return x.NewMemberAci - } - return nil -} - -type GroupInvitationDeclinedUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - InviterAci []byte `protobuf:"bytes,1,opt,name=inviterAci,proto3,oneof" json:"inviterAci,omitempty"` - // Note: if invited by pni, just set inviteeAci to nil. - InviteeAci []byte `protobuf:"bytes,2,opt,name=inviteeAci,proto3,oneof" json:"inviteeAci,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupInvitationDeclinedUpdate) Reset() { - *x = GroupInvitationDeclinedUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[61] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupInvitationDeclinedUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupInvitationDeclinedUpdate) ProtoMessage() {} - -func (x *GroupInvitationDeclinedUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[61] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupInvitationDeclinedUpdate.ProtoReflect.Descriptor instead. -func (*GroupInvitationDeclinedUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{61} -} - -func (x *GroupInvitationDeclinedUpdate) GetInviterAci() []byte { - if x != nil { - return x.InviterAci - } - return nil -} - -func (x *GroupInvitationDeclinedUpdate) GetInviteeAci() []byte { - if x != nil { - return x.InviteeAci - } - return nil -} - -type GroupMemberJoinedUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - NewMemberAci []byte `protobuf:"bytes,1,opt,name=newMemberAci,proto3" json:"newMemberAci,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupMemberJoinedUpdate) Reset() { - *x = GroupMemberJoinedUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[62] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupMemberJoinedUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupMemberJoinedUpdate) ProtoMessage() {} - -func (x *GroupMemberJoinedUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[62] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupMemberJoinedUpdate.ProtoReflect.Descriptor instead. -func (*GroupMemberJoinedUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{62} -} - -func (x *GroupMemberJoinedUpdate) GetNewMemberAci() []byte { - if x != nil { - return x.NewMemberAci - } - return nil -} - -type GroupMemberAddedUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - UpdaterAci []byte `protobuf:"bytes,1,opt,name=updaterAci,proto3,oneof" json:"updaterAci,omitempty"` - NewMemberAci []byte `protobuf:"bytes,2,opt,name=newMemberAci,proto3" json:"newMemberAci,omitempty"` - HadOpenInvitation bool `protobuf:"varint,3,opt,name=hadOpenInvitation,proto3" json:"hadOpenInvitation,omitempty"` - // If hadOpenInvitation is true, optionally include aci of the inviter. - InviterAci []byte `protobuf:"bytes,4,opt,name=inviterAci,proto3,oneof" json:"inviterAci,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupMemberAddedUpdate) Reset() { - *x = GroupMemberAddedUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[63] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupMemberAddedUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupMemberAddedUpdate) ProtoMessage() {} - -func (x *GroupMemberAddedUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[63] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupMemberAddedUpdate.ProtoReflect.Descriptor instead. -func (*GroupMemberAddedUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{63} -} - -func (x *GroupMemberAddedUpdate) GetUpdaterAci() []byte { - if x != nil { - return x.UpdaterAci - } - return nil -} - -func (x *GroupMemberAddedUpdate) GetNewMemberAci() []byte { - if x != nil { - return x.NewMemberAci - } - return nil -} - -func (x *GroupMemberAddedUpdate) GetHadOpenInvitation() bool { - if x != nil { - return x.HadOpenInvitation - } - return false -} - -func (x *GroupMemberAddedUpdate) GetInviterAci() []byte { - if x != nil { - return x.InviterAci - } - return nil -} - -// An invitation to self was revoked. -type GroupSelfInvitationRevokedUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - RevokerAci []byte `protobuf:"bytes,1,opt,name=revokerAci,proto3,oneof" json:"revokerAci,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupSelfInvitationRevokedUpdate) Reset() { - *x = GroupSelfInvitationRevokedUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[64] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupSelfInvitationRevokedUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupSelfInvitationRevokedUpdate) ProtoMessage() {} - -func (x *GroupSelfInvitationRevokedUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[64] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupSelfInvitationRevokedUpdate.ProtoReflect.Descriptor instead. -func (*GroupSelfInvitationRevokedUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{64} -} - -func (x *GroupSelfInvitationRevokedUpdate) GetRevokerAci() []byte { - if x != nil { - return x.RevokerAci - } - return nil -} - -// These invitees should never be the local user. -// Use GroupSelfInvitationRevokedUpdate in those cases. -// The inviter or updater can be the local user. -type GroupInvitationRevokedUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The member that revoked the invite(s), not the inviter! - // Assumed to be an admin (at the time, may no longer be an - // admin or even a member). - UpdaterAci []byte `protobuf:"bytes,1,opt,name=updaterAci,proto3,oneof" json:"updaterAci,omitempty"` - Invitees []*GroupInvitationRevokedUpdate_Invitee `protobuf:"bytes,2,rep,name=invitees,proto3" json:"invitees,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupInvitationRevokedUpdate) Reset() { - *x = GroupInvitationRevokedUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[65] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupInvitationRevokedUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupInvitationRevokedUpdate) ProtoMessage() {} - -func (x *GroupInvitationRevokedUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[65] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupInvitationRevokedUpdate.ProtoReflect.Descriptor instead. -func (*GroupInvitationRevokedUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{65} -} - -func (x *GroupInvitationRevokedUpdate) GetUpdaterAci() []byte { - if x != nil { - return x.UpdaterAci - } - return nil -} - -func (x *GroupInvitationRevokedUpdate) GetInvitees() []*GroupInvitationRevokedUpdate_Invitee { - if x != nil { - return x.Invitees - } - return nil -} - -type GroupJoinRequestUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - RequestorAci []byte `protobuf:"bytes,1,opt,name=requestorAci,proto3" json:"requestorAci,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupJoinRequestUpdate) Reset() { - *x = GroupJoinRequestUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[66] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupJoinRequestUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupJoinRequestUpdate) ProtoMessage() {} - -func (x *GroupJoinRequestUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[66] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupJoinRequestUpdate.ProtoReflect.Descriptor instead. -func (*GroupJoinRequestUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{66} -} - -func (x *GroupJoinRequestUpdate) GetRequestorAci() []byte { - if x != nil { - return x.RequestorAci - } - return nil -} - -type GroupJoinRequestApprovalUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - RequestorAci []byte `protobuf:"bytes,1,opt,name=requestorAci,proto3" json:"requestorAci,omitempty"` - // The aci that approved or rejected the request. - UpdaterAci []byte `protobuf:"bytes,2,opt,name=updaterAci,proto3,oneof" json:"updaterAci,omitempty"` - WasApproved bool `protobuf:"varint,3,opt,name=wasApproved,proto3" json:"wasApproved,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupJoinRequestApprovalUpdate) Reset() { - *x = GroupJoinRequestApprovalUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[67] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupJoinRequestApprovalUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupJoinRequestApprovalUpdate) ProtoMessage() {} - -func (x *GroupJoinRequestApprovalUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[67] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupJoinRequestApprovalUpdate.ProtoReflect.Descriptor instead. -func (*GroupJoinRequestApprovalUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{67} -} - -func (x *GroupJoinRequestApprovalUpdate) GetRequestorAci() []byte { - if x != nil { - return x.RequestorAci - } - return nil -} - -func (x *GroupJoinRequestApprovalUpdate) GetUpdaterAci() []byte { - if x != nil { - return x.UpdaterAci - } - return nil -} - -func (x *GroupJoinRequestApprovalUpdate) GetWasApproved() bool { - if x != nil { - return x.WasApproved - } - return false -} - -type GroupJoinRequestCanceledUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - RequestorAci []byte `protobuf:"bytes,1,opt,name=requestorAci,proto3" json:"requestorAci,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupJoinRequestCanceledUpdate) Reset() { - *x = GroupJoinRequestCanceledUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[68] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupJoinRequestCanceledUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupJoinRequestCanceledUpdate) ProtoMessage() {} - -func (x *GroupJoinRequestCanceledUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[68] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupJoinRequestCanceledUpdate.ProtoReflect.Descriptor instead. -func (*GroupJoinRequestCanceledUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{68} -} - -func (x *GroupJoinRequestCanceledUpdate) GetRequestorAci() []byte { - if x != nil { - return x.RequestorAci - } - return nil -} - -// A single requestor has requested to join and cancelled -// their request repeatedly with no other updates in between. -// The last action encompassed by this update is always a -// cancellation; if there was another open request immediately -// after, it will be a separate GroupJoinRequestUpdate, either -// in the same frame or in a subsequent frame. -type GroupSequenceOfRequestsAndCancelsUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - RequestorAci []byte `protobuf:"bytes,1,opt,name=requestorAci,proto3" json:"requestorAci,omitempty"` - Count uint32 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupSequenceOfRequestsAndCancelsUpdate) Reset() { - *x = GroupSequenceOfRequestsAndCancelsUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[69] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupSequenceOfRequestsAndCancelsUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupSequenceOfRequestsAndCancelsUpdate) ProtoMessage() {} - -func (x *GroupSequenceOfRequestsAndCancelsUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[69] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupSequenceOfRequestsAndCancelsUpdate.ProtoReflect.Descriptor instead. -func (*GroupSequenceOfRequestsAndCancelsUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{69} -} - -func (x *GroupSequenceOfRequestsAndCancelsUpdate) GetRequestorAci() []byte { - if x != nil { - return x.RequestorAci - } - return nil -} - -func (x *GroupSequenceOfRequestsAndCancelsUpdate) GetCount() uint32 { - if x != nil { - return x.Count - } - return 0 -} - -type GroupInviteLinkResetUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - UpdaterAci []byte `protobuf:"bytes,1,opt,name=updaterAci,proto3,oneof" json:"updaterAci,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupInviteLinkResetUpdate) Reset() { - *x = GroupInviteLinkResetUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[70] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupInviteLinkResetUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupInviteLinkResetUpdate) ProtoMessage() {} - -func (x *GroupInviteLinkResetUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[70] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupInviteLinkResetUpdate.ProtoReflect.Descriptor instead. -func (*GroupInviteLinkResetUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{70} -} - -func (x *GroupInviteLinkResetUpdate) GetUpdaterAci() []byte { - if x != nil { - return x.UpdaterAci - } - return nil -} - -type GroupInviteLinkEnabledUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - UpdaterAci []byte `protobuf:"bytes,1,opt,name=updaterAci,proto3,oneof" json:"updaterAci,omitempty"` - LinkRequiresAdminApproval bool `protobuf:"varint,2,opt,name=linkRequiresAdminApproval,proto3" json:"linkRequiresAdminApproval,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupInviteLinkEnabledUpdate) Reset() { - *x = GroupInviteLinkEnabledUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[71] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupInviteLinkEnabledUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupInviteLinkEnabledUpdate) ProtoMessage() {} - -func (x *GroupInviteLinkEnabledUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[71] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupInviteLinkEnabledUpdate.ProtoReflect.Descriptor instead. -func (*GroupInviteLinkEnabledUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{71} -} - -func (x *GroupInviteLinkEnabledUpdate) GetUpdaterAci() []byte { - if x != nil { - return x.UpdaterAci - } - return nil -} - -func (x *GroupInviteLinkEnabledUpdate) GetLinkRequiresAdminApproval() bool { - if x != nil { - return x.LinkRequiresAdminApproval - } - return false -} - -type GroupInviteLinkAdminApprovalUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - UpdaterAci []byte `protobuf:"bytes,1,opt,name=updaterAci,proto3,oneof" json:"updaterAci,omitempty"` - LinkRequiresAdminApproval bool `protobuf:"varint,2,opt,name=linkRequiresAdminApproval,proto3" json:"linkRequiresAdminApproval,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupInviteLinkAdminApprovalUpdate) Reset() { - *x = GroupInviteLinkAdminApprovalUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[72] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupInviteLinkAdminApprovalUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupInviteLinkAdminApprovalUpdate) ProtoMessage() {} - -func (x *GroupInviteLinkAdminApprovalUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[72] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupInviteLinkAdminApprovalUpdate.ProtoReflect.Descriptor instead. -func (*GroupInviteLinkAdminApprovalUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{72} -} - -func (x *GroupInviteLinkAdminApprovalUpdate) GetUpdaterAci() []byte { - if x != nil { - return x.UpdaterAci - } - return nil -} - -func (x *GroupInviteLinkAdminApprovalUpdate) GetLinkRequiresAdminApproval() bool { - if x != nil { - return x.LinkRequiresAdminApproval - } - return false -} - -type GroupInviteLinkDisabledUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - UpdaterAci []byte `protobuf:"bytes,1,opt,name=updaterAci,proto3,oneof" json:"updaterAci,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupInviteLinkDisabledUpdate) Reset() { - *x = GroupInviteLinkDisabledUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[73] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupInviteLinkDisabledUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupInviteLinkDisabledUpdate) ProtoMessage() {} - -func (x *GroupInviteLinkDisabledUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[73] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupInviteLinkDisabledUpdate.ProtoReflect.Descriptor instead. -func (*GroupInviteLinkDisabledUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{73} -} - -func (x *GroupInviteLinkDisabledUpdate) GetUpdaterAci() []byte { - if x != nil { - return x.UpdaterAci - } - return nil -} - -type GroupMemberJoinedByLinkUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - NewMemberAci []byte `protobuf:"bytes,1,opt,name=newMemberAci,proto3" json:"newMemberAci,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupMemberJoinedByLinkUpdate) Reset() { - *x = GroupMemberJoinedByLinkUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[74] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupMemberJoinedByLinkUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupMemberJoinedByLinkUpdate) ProtoMessage() {} - -func (x *GroupMemberJoinedByLinkUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[74] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupMemberJoinedByLinkUpdate.ProtoReflect.Descriptor instead. -func (*GroupMemberJoinedByLinkUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{74} -} - -func (x *GroupMemberJoinedByLinkUpdate) GetNewMemberAci() []byte { - if x != nil { - return x.NewMemberAci - } - return nil -} - -// A gv1->gv2 migration occurred. -type GroupV2MigrationUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupV2MigrationUpdate) Reset() { - *x = GroupV2MigrationUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[75] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupV2MigrationUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupV2MigrationUpdate) ProtoMessage() {} - -func (x *GroupV2MigrationUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[75] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupV2MigrationUpdate.ProtoReflect.Descriptor instead. -func (*GroupV2MigrationUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{75} -} - -// Another user migrated gv1->gv2 but was unable to add -// the local user and invited them instead. -type GroupV2MigrationSelfInvitedUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupV2MigrationSelfInvitedUpdate) Reset() { - *x = GroupV2MigrationSelfInvitedUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[76] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupV2MigrationSelfInvitedUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupV2MigrationSelfInvitedUpdate) ProtoMessage() {} - -func (x *GroupV2MigrationSelfInvitedUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[76] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupV2MigrationSelfInvitedUpdate.ProtoReflect.Descriptor instead. -func (*GroupV2MigrationSelfInvitedUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{76} -} - -// The local user migrated gv1->gv2 but was unable to -// add some members and invited them instead. -// (Happens if we don't have the invitee's profile key) -type GroupV2MigrationInvitedMembersUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - InvitedMembersCount uint32 `protobuf:"varint,1,opt,name=invitedMembersCount,proto3" json:"invitedMembersCount,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupV2MigrationInvitedMembersUpdate) Reset() { - *x = GroupV2MigrationInvitedMembersUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[77] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupV2MigrationInvitedMembersUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupV2MigrationInvitedMembersUpdate) ProtoMessage() {} - -func (x *GroupV2MigrationInvitedMembersUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[77] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupV2MigrationInvitedMembersUpdate.ProtoReflect.Descriptor instead. -func (*GroupV2MigrationInvitedMembersUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{77} -} - -func (x *GroupV2MigrationInvitedMembersUpdate) GetInvitedMembersCount() uint32 { - if x != nil { - return x.InvitedMembersCount - } - return 0 -} - -// The local user migrated gv1->gv2 but was unable to -// add or invite some members and dropped them instead. -// (Happens for e164 members where we don't have an aci). -type GroupV2MigrationDroppedMembersUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - DroppedMembersCount uint32 `protobuf:"varint,1,opt,name=droppedMembersCount,proto3" json:"droppedMembersCount,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupV2MigrationDroppedMembersUpdate) Reset() { - *x = GroupV2MigrationDroppedMembersUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[78] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupV2MigrationDroppedMembersUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupV2MigrationDroppedMembersUpdate) ProtoMessage() {} - -func (x *GroupV2MigrationDroppedMembersUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[78] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupV2MigrationDroppedMembersUpdate.ProtoReflect.Descriptor instead. -func (*GroupV2MigrationDroppedMembersUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{78} -} - -func (x *GroupV2MigrationDroppedMembersUpdate) GetDroppedMembersCount() uint32 { - if x != nil { - return x.DroppedMembersCount - } - return 0 -} - -// For 1:1 timer updates, use ExpirationTimerChatUpdate. -type GroupExpirationTimerUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - ExpiresInMs uint64 `protobuf:"varint,1,opt,name=expiresInMs,proto3" json:"expiresInMs,omitempty"` // 0 means the expiration timer was disabled - UpdaterAci []byte `protobuf:"bytes,2,opt,name=updaterAci,proto3,oneof" json:"updaterAci,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupExpirationTimerUpdate) Reset() { - *x = GroupExpirationTimerUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[79] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupExpirationTimerUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupExpirationTimerUpdate) ProtoMessage() {} - -func (x *GroupExpirationTimerUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[79] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupExpirationTimerUpdate.ProtoReflect.Descriptor instead. -func (*GroupExpirationTimerUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{79} -} - -func (x *GroupExpirationTimerUpdate) GetExpiresInMs() uint64 { - if x != nil { - return x.ExpiresInMs - } - return 0 -} - -func (x *GroupExpirationTimerUpdate) GetUpdaterAci() []byte { - if x != nil { - return x.UpdaterAci - } - return nil -} - -type PollTerminateUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - TargetSentTimestamp uint64 `protobuf:"varint,1,opt,name=targetSentTimestamp,proto3" json:"targetSentTimestamp,omitempty"` - Question string `protobuf:"bytes,2,opt,name=question,proto3" json:"question,omitempty"` // Between 1-100 characters - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PollTerminateUpdate) Reset() { - *x = PollTerminateUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[80] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PollTerminateUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PollTerminateUpdate) ProtoMessage() {} - -func (x *PollTerminateUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[80] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PollTerminateUpdate.ProtoReflect.Descriptor instead. -func (*PollTerminateUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{80} -} - -func (x *PollTerminateUpdate) GetTargetSentTimestamp() uint64 { - if x != nil { - return x.TargetSentTimestamp - } - return 0 -} - -func (x *PollTerminateUpdate) GetQuestion() string { - if x != nil { - return x.Question - } - return "" -} - -type PinMessageUpdate struct { - state protoimpl.MessageState `protogen:"open.v1"` - TargetSentTimestamp uint64 `protobuf:"varint,1,opt,name=targetSentTimestamp,proto3" json:"targetSentTimestamp,omitempty"` - AuthorId uint64 `protobuf:"varint,2,opt,name=authorId,proto3" json:"authorId,omitempty"` // recipient id - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PinMessageUpdate) Reset() { - *x = PinMessageUpdate{} - mi := &file_backuppb_Backup_proto_msgTypes[81] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PinMessageUpdate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PinMessageUpdate) ProtoMessage() {} - -func (x *PinMessageUpdate) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[81] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PinMessageUpdate.ProtoReflect.Descriptor instead. -func (*PinMessageUpdate) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{81} -} - -func (x *PinMessageUpdate) GetTargetSentTimestamp() uint64 { - if x != nil { - return x.TargetSentTimestamp - } - return 0 -} - -func (x *PinMessageUpdate) GetAuthorId() uint64 { - if x != nil { - return x.AuthorId - } - return 0 -} - -type StickerPack struct { - state protoimpl.MessageState `protogen:"open.v1"` - PackId []byte `protobuf:"bytes,1,opt,name=packId,proto3" json:"packId,omitempty"` - PackKey []byte `protobuf:"bytes,2,opt,name=packKey,proto3" json:"packKey,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *StickerPack) Reset() { - *x = StickerPack{} - mi := &file_backuppb_Backup_proto_msgTypes[82] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *StickerPack) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*StickerPack) ProtoMessage() {} - -func (x *StickerPack) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[82] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use StickerPack.ProtoReflect.Descriptor instead. -func (*StickerPack) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{82} -} - -func (x *StickerPack) GetPackId() []byte { - if x != nil { - return x.PackId - } - return nil -} - -func (x *StickerPack) GetPackKey() []byte { - if x != nil { - return x.PackKey - } - return nil -} - -type ChatStyle struct { - state protoimpl.MessageState `protogen:"open.v1"` - // If unset, importers should consider there to be no wallpaper. - // - // Types that are valid to be assigned to Wallpaper: - // - // *ChatStyle_WallpaperPreset_ - // *ChatStyle_WallpaperPhoto - Wallpaper isChatStyle_Wallpaper `protobuf_oneof:"wallpaper"` - // If unset, importers should consider it to be AutomaticBubbleColor - // - // Types that are valid to be assigned to BubbleColor: - // - // *ChatStyle_AutoBubbleColor - // *ChatStyle_BubbleColorPreset_ - // *ChatStyle_CustomColorId - BubbleColor isChatStyle_BubbleColor `protobuf_oneof:"bubbleColor"` - DimWallpaperInDarkMode bool `protobuf:"varint,7,opt,name=dimWallpaperInDarkMode,proto3" json:"dimWallpaperInDarkMode,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ChatStyle) Reset() { - *x = ChatStyle{} - mi := &file_backuppb_Backup_proto_msgTypes[83] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ChatStyle) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ChatStyle) ProtoMessage() {} - -func (x *ChatStyle) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[83] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ChatStyle.ProtoReflect.Descriptor instead. -func (*ChatStyle) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{83} -} - -func (x *ChatStyle) GetWallpaper() isChatStyle_Wallpaper { - if x != nil { - return x.Wallpaper - } - return nil -} - -func (x *ChatStyle) GetWallpaperPreset() ChatStyle_WallpaperPreset { - if x != nil { - if x, ok := x.Wallpaper.(*ChatStyle_WallpaperPreset_); ok { - return x.WallpaperPreset - } - } - return ChatStyle_UNKNOWN_WALLPAPER_PRESET -} - -func (x *ChatStyle) GetWallpaperPhoto() *FilePointer { - if x != nil { - if x, ok := x.Wallpaper.(*ChatStyle_WallpaperPhoto); ok { - return x.WallpaperPhoto - } - } - return nil -} - -func (x *ChatStyle) GetBubbleColor() isChatStyle_BubbleColor { - if x != nil { - return x.BubbleColor - } - return nil -} - -func (x *ChatStyle) GetAutoBubbleColor() *ChatStyle_AutomaticBubbleColor { - if x != nil { - if x, ok := x.BubbleColor.(*ChatStyle_AutoBubbleColor); ok { - return x.AutoBubbleColor - } - } - return nil -} - -func (x *ChatStyle) GetBubbleColorPreset() ChatStyle_BubbleColorPreset { - if x != nil { - if x, ok := x.BubbleColor.(*ChatStyle_BubbleColorPreset_); ok { - return x.BubbleColorPreset - } - } - return ChatStyle_UNKNOWN_BUBBLE_COLOR_PRESET -} - -func (x *ChatStyle) GetCustomColorId() uint64 { - if x != nil { - if x, ok := x.BubbleColor.(*ChatStyle_CustomColorId); ok { - return x.CustomColorId - } - } - return 0 -} - -func (x *ChatStyle) GetDimWallpaperInDarkMode() bool { - if x != nil { - return x.DimWallpaperInDarkMode - } - return false -} - -type isChatStyle_Wallpaper interface { - isChatStyle_Wallpaper() -} - -type ChatStyle_WallpaperPreset_ struct { - WallpaperPreset ChatStyle_WallpaperPreset `protobuf:"varint,1,opt,name=wallpaperPreset,proto3,enum=signal.backup.ChatStyle_WallpaperPreset,oneof"` -} - -type ChatStyle_WallpaperPhoto struct { - // This `FilePointer` is expected not to contain a `fileName`, `width`, - // `height`, or `caption`. - WallpaperPhoto *FilePointer `protobuf:"bytes,2,opt,name=wallpaperPhoto,proto3,oneof"` -} - -func (*ChatStyle_WallpaperPreset_) isChatStyle_Wallpaper() {} - -func (*ChatStyle_WallpaperPhoto) isChatStyle_Wallpaper() {} - -type isChatStyle_BubbleColor interface { - isChatStyle_BubbleColor() -} - -type ChatStyle_AutoBubbleColor struct { - // Bubble setting is automatically determined based on the wallpaper setting, - // or `SOLID_ULTRAMARINE` for `noWallpaper` - AutoBubbleColor *ChatStyle_AutomaticBubbleColor `protobuf:"bytes,3,opt,name=autoBubbleColor,proto3,oneof"` -} - -type ChatStyle_BubbleColorPreset_ struct { - BubbleColorPreset ChatStyle_BubbleColorPreset `protobuf:"varint,4,opt,name=bubbleColorPreset,proto3,enum=signal.backup.ChatStyle_BubbleColorPreset,oneof"` -} - -type ChatStyle_CustomColorId struct { - // See AccountSettings.customChatColors - CustomColorId uint64 `protobuf:"varint,5,opt,name=customColorId,proto3,oneof"` -} - -func (*ChatStyle_AutoBubbleColor) isChatStyle_BubbleColor() {} - -func (*ChatStyle_BubbleColorPreset_) isChatStyle_BubbleColor() {} - -func (*ChatStyle_CustomColorId) isChatStyle_BubbleColor() {} - -type NotificationProfile struct { - state protoimpl.MessageState `protogen:"open.v1"` - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Emoji *string `protobuf:"bytes,2,opt,name=emoji,proto3,oneof" json:"emoji,omitempty"` - Color uint32 `protobuf:"fixed32,3,opt,name=color,proto3" json:"color,omitempty"` // 0xAARRGGBB - CreatedAtMs uint64 `protobuf:"varint,4,opt,name=createdAtMs,proto3" json:"createdAtMs,omitempty"` - AllowAllCalls bool `protobuf:"varint,5,opt,name=allowAllCalls,proto3" json:"allowAllCalls,omitempty"` - AllowAllMentions bool `protobuf:"varint,6,opt,name=allowAllMentions,proto3" json:"allowAllMentions,omitempty"` - AllowedMembers []uint64 `protobuf:"varint,7,rep,packed,name=allowedMembers,proto3" json:"allowedMembers,omitempty"` // generated recipient id for allowed groups and contacts - ScheduleEnabled bool `protobuf:"varint,8,opt,name=scheduleEnabled,proto3" json:"scheduleEnabled,omitempty"` - ScheduleStartTime uint32 `protobuf:"varint,9,opt,name=scheduleStartTime,proto3" json:"scheduleStartTime,omitempty"` // 24-hour clock int, 0000-2359 (e.g., 15, 900, 1130, 2345) - ScheduleEndTime uint32 `protobuf:"varint,10,opt,name=scheduleEndTime,proto3" json:"scheduleEndTime,omitempty"` // 24-hour clock int, 0000-2359 (e.g., 15, 900, 1130, 2345) - ScheduleDaysEnabled []NotificationProfile_DayOfWeek `protobuf:"varint,11,rep,packed,name=scheduleDaysEnabled,proto3,enum=signal.backup.NotificationProfile_DayOfWeek" json:"scheduleDaysEnabled,omitempty"` - Id []byte `protobuf:"bytes,12,opt,name=id,proto3" json:"id,omitempty"` // should be 16 bytes - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *NotificationProfile) Reset() { - *x = NotificationProfile{} - mi := &file_backuppb_Backup_proto_msgTypes[84] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *NotificationProfile) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*NotificationProfile) ProtoMessage() {} - -func (x *NotificationProfile) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[84] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use NotificationProfile.ProtoReflect.Descriptor instead. -func (*NotificationProfile) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{84} -} - -func (x *NotificationProfile) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *NotificationProfile) GetEmoji() string { - if x != nil && x.Emoji != nil { - return *x.Emoji - } - return "" -} - -func (x *NotificationProfile) GetColor() uint32 { - if x != nil { - return x.Color - } - return 0 -} - -func (x *NotificationProfile) GetCreatedAtMs() uint64 { - if x != nil { - return x.CreatedAtMs - } - return 0 -} - -func (x *NotificationProfile) GetAllowAllCalls() bool { - if x != nil { - return x.AllowAllCalls - } - return false -} - -func (x *NotificationProfile) GetAllowAllMentions() bool { - if x != nil { - return x.AllowAllMentions - } - return false -} - -func (x *NotificationProfile) GetAllowedMembers() []uint64 { - if x != nil { - return x.AllowedMembers - } - return nil -} - -func (x *NotificationProfile) GetScheduleEnabled() bool { - if x != nil { - return x.ScheduleEnabled - } - return false -} - -func (x *NotificationProfile) GetScheduleStartTime() uint32 { - if x != nil { - return x.ScheduleStartTime - } - return 0 -} - -func (x *NotificationProfile) GetScheduleEndTime() uint32 { - if x != nil { - return x.ScheduleEndTime - } - return 0 -} - -func (x *NotificationProfile) GetScheduleDaysEnabled() []NotificationProfile_DayOfWeek { - if x != nil { - return x.ScheduleDaysEnabled - } - return nil -} - -func (x *NotificationProfile) GetId() []byte { - if x != nil { - return x.Id - } - return nil -} - -type ChatFolder struct { - state protoimpl.MessageState `protogen:"open.v1"` - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - ShowOnlyUnread bool `protobuf:"varint,2,opt,name=showOnlyUnread,proto3" json:"showOnlyUnread,omitempty"` - ShowMutedChats bool `protobuf:"varint,3,opt,name=showMutedChats,proto3" json:"showMutedChats,omitempty"` - // Folder includes all 1:1 chats, unless excluded - IncludeAllIndividualChats bool `protobuf:"varint,4,opt,name=includeAllIndividualChats,proto3" json:"includeAllIndividualChats,omitempty"` - // Folder includes all group chats, unless excluded - IncludeAllGroupChats bool `protobuf:"varint,5,opt,name=includeAllGroupChats,proto3" json:"includeAllGroupChats,omitempty"` - FolderType ChatFolder_FolderType `protobuf:"varint,6,opt,name=folderType,proto3,enum=signal.backup.ChatFolder_FolderType" json:"folderType,omitempty"` - IncludedRecipientIds []uint64 `protobuf:"varint,7,rep,packed,name=includedRecipientIds,proto3" json:"includedRecipientIds,omitempty"` // generated recipient id of groups, contacts, and/or note to self - ExcludedRecipientIds []uint64 `protobuf:"varint,8,rep,packed,name=excludedRecipientIds,proto3" json:"excludedRecipientIds,omitempty"` // generated recipient id of groups, contacts, and/or note to self - Id []byte `protobuf:"bytes,9,opt,name=id,proto3" json:"id,omitempty"` // should be 16 bytes - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ChatFolder) Reset() { - *x = ChatFolder{} - mi := &file_backuppb_Backup_proto_msgTypes[85] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ChatFolder) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ChatFolder) ProtoMessage() {} - -func (x *ChatFolder) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[85] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ChatFolder.ProtoReflect.Descriptor instead. -func (*ChatFolder) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{85} -} - -func (x *ChatFolder) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *ChatFolder) GetShowOnlyUnread() bool { - if x != nil { - return x.ShowOnlyUnread - } - return false -} - -func (x *ChatFolder) GetShowMutedChats() bool { - if x != nil { - return x.ShowMutedChats - } - return false -} - -func (x *ChatFolder) GetIncludeAllIndividualChats() bool { - if x != nil { - return x.IncludeAllIndividualChats - } - return false -} - -func (x *ChatFolder) GetIncludeAllGroupChats() bool { - if x != nil { - return x.IncludeAllGroupChats - } - return false -} - -func (x *ChatFolder) GetFolderType() ChatFolder_FolderType { - if x != nil { - return x.FolderType - } - return ChatFolder_UNKNOWN -} - -func (x *ChatFolder) GetIncludedRecipientIds() []uint64 { - if x != nil { - return x.IncludedRecipientIds - } - return nil -} - -func (x *ChatFolder) GetExcludedRecipientIds() []uint64 { - if x != nil { - return x.ExcludedRecipientIds - } - return nil -} - -func (x *ChatFolder) GetId() []byte { - if x != nil { - return x.Id - } - return nil -} - -type AccountData_UsernameLink struct { - state protoimpl.MessageState `protogen:"open.v1"` - Entropy []byte `protobuf:"bytes,1,opt,name=entropy,proto3" json:"entropy,omitempty"` // 32 bytes of entropy used for encryption - ServerId []byte `protobuf:"bytes,2,opt,name=serverId,proto3" json:"serverId,omitempty"` // 16 bytes of encoded UUID provided by the server - Color AccountData_UsernameLink_Color `protobuf:"varint,3,opt,name=color,proto3,enum=signal.backup.AccountData_UsernameLink_Color" json:"color,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AccountData_UsernameLink) Reset() { - *x = AccountData_UsernameLink{} - mi := &file_backuppb_Backup_proto_msgTypes[86] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AccountData_UsernameLink) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AccountData_UsernameLink) ProtoMessage() {} - -func (x *AccountData_UsernameLink) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[86] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AccountData_UsernameLink.ProtoReflect.Descriptor instead. -func (*AccountData_UsernameLink) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{2, 0} -} - -func (x *AccountData_UsernameLink) GetEntropy() []byte { - if x != nil { - return x.Entropy - } - return nil -} - -func (x *AccountData_UsernameLink) GetServerId() []byte { - if x != nil { - return x.ServerId - } - return nil -} - -func (x *AccountData_UsernameLink) GetColor() AccountData_UsernameLink_Color { - if x != nil { - return x.Color - } - return AccountData_UsernameLink_UNKNOWN -} - -type AccountData_AutoDownloadSettings struct { - state protoimpl.MessageState `protogen:"open.v1"` - Images AccountData_AutoDownloadSettings_AutoDownloadOption `protobuf:"varint,1,opt,name=images,proto3,enum=signal.backup.AccountData_AutoDownloadSettings_AutoDownloadOption" json:"images,omitempty"` - Audio AccountData_AutoDownloadSettings_AutoDownloadOption `protobuf:"varint,2,opt,name=audio,proto3,enum=signal.backup.AccountData_AutoDownloadSettings_AutoDownloadOption" json:"audio,omitempty"` - Video AccountData_AutoDownloadSettings_AutoDownloadOption `protobuf:"varint,3,opt,name=video,proto3,enum=signal.backup.AccountData_AutoDownloadSettings_AutoDownloadOption" json:"video,omitempty"` - Documents AccountData_AutoDownloadSettings_AutoDownloadOption `protobuf:"varint,4,opt,name=documents,proto3,enum=signal.backup.AccountData_AutoDownloadSettings_AutoDownloadOption" json:"documents,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AccountData_AutoDownloadSettings) Reset() { - *x = AccountData_AutoDownloadSettings{} - mi := &file_backuppb_Backup_proto_msgTypes[87] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AccountData_AutoDownloadSettings) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AccountData_AutoDownloadSettings) ProtoMessage() {} - -func (x *AccountData_AutoDownloadSettings) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[87] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AccountData_AutoDownloadSettings.ProtoReflect.Descriptor instead. -func (*AccountData_AutoDownloadSettings) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{2, 1} -} - -func (x *AccountData_AutoDownloadSettings) GetImages() AccountData_AutoDownloadSettings_AutoDownloadOption { - if x != nil { - return x.Images - } - return AccountData_AutoDownloadSettings_UNKNOWN -} - -func (x *AccountData_AutoDownloadSettings) GetAudio() AccountData_AutoDownloadSettings_AutoDownloadOption { - if x != nil { - return x.Audio - } - return AccountData_AutoDownloadSettings_UNKNOWN -} - -func (x *AccountData_AutoDownloadSettings) GetVideo() AccountData_AutoDownloadSettings_AutoDownloadOption { - if x != nil { - return x.Video - } - return AccountData_AutoDownloadSettings_UNKNOWN -} - -func (x *AccountData_AutoDownloadSettings) GetDocuments() AccountData_AutoDownloadSettings_AutoDownloadOption { - if x != nil { - return x.Documents - } - return AccountData_AutoDownloadSettings_UNKNOWN -} - -type AccountData_AccountSettings struct { - state protoimpl.MessageState `protogen:"open.v1"` - ReadReceipts bool `protobuf:"varint,1,opt,name=readReceipts,proto3" json:"readReceipts,omitempty"` - SealedSenderIndicators bool `protobuf:"varint,2,opt,name=sealedSenderIndicators,proto3" json:"sealedSenderIndicators,omitempty"` - TypingIndicators bool `protobuf:"varint,3,opt,name=typingIndicators,proto3" json:"typingIndicators,omitempty"` - LinkPreviews bool `protobuf:"varint,4,opt,name=linkPreviews,proto3" json:"linkPreviews,omitempty"` - NotDiscoverableByPhoneNumber bool `protobuf:"varint,5,opt,name=notDiscoverableByPhoneNumber,proto3" json:"notDiscoverableByPhoneNumber,omitempty"` - PreferContactAvatars bool `protobuf:"varint,6,opt,name=preferContactAvatars,proto3" json:"preferContactAvatars,omitempty"` - UniversalExpireTimerSeconds uint32 `protobuf:"varint,7,opt,name=universalExpireTimerSeconds,proto3" json:"universalExpireTimerSeconds,omitempty"` // 0 means no universal expire timer. - PreferredReactionEmoji []string `protobuf:"bytes,8,rep,name=preferredReactionEmoji,proto3" json:"preferredReactionEmoji,omitempty"` - DisplayBadgesOnProfile bool `protobuf:"varint,9,opt,name=displayBadgesOnProfile,proto3" json:"displayBadgesOnProfile,omitempty"` - KeepMutedChatsArchived bool `protobuf:"varint,10,opt,name=keepMutedChatsArchived,proto3" json:"keepMutedChatsArchived,omitempty"` - HasSetMyStoriesPrivacy bool `protobuf:"varint,11,opt,name=hasSetMyStoriesPrivacy,proto3" json:"hasSetMyStoriesPrivacy,omitempty"` - HasViewedOnboardingStory bool `protobuf:"varint,12,opt,name=hasViewedOnboardingStory,proto3" json:"hasViewedOnboardingStory,omitempty"` - StoriesDisabled bool `protobuf:"varint,13,opt,name=storiesDisabled,proto3" json:"storiesDisabled,omitempty"` - StoryViewReceiptsEnabled *bool `protobuf:"varint,14,opt,name=storyViewReceiptsEnabled,proto3,oneof" json:"storyViewReceiptsEnabled,omitempty"` - HasSeenGroupStoryEducationSheet bool `protobuf:"varint,15,opt,name=hasSeenGroupStoryEducationSheet,proto3" json:"hasSeenGroupStoryEducationSheet,omitempty"` - HasCompletedUsernameOnboarding bool `protobuf:"varint,16,opt,name=hasCompletedUsernameOnboarding,proto3" json:"hasCompletedUsernameOnboarding,omitempty"` - PhoneNumberSharingMode AccountData_PhoneNumberSharingMode `protobuf:"varint,17,opt,name=phoneNumberSharingMode,proto3,enum=signal.backup.AccountData_PhoneNumberSharingMode" json:"phoneNumberSharingMode,omitempty"` - DefaultChatStyle *ChatStyle `protobuf:"bytes,18,opt,name=defaultChatStyle,proto3" json:"defaultChatStyle,omitempty"` - CustomChatColors []*ChatStyle_CustomChatColor `protobuf:"bytes,19,rep,name=customChatColors,proto3" json:"customChatColors,omitempty"` - OptimizeOnDeviceStorage bool `protobuf:"varint,20,opt,name=optimizeOnDeviceStorage,proto3" json:"optimizeOnDeviceStorage,omitempty"` - // See zkgroup for integer particular values. Unset if backups are not enabled. - BackupTier *uint64 `protobuf:"varint,21,opt,name=backupTier,proto3,oneof" json:"backupTier,omitempty"` - DefaultSentMediaQuality AccountData_SentMediaQuality `protobuf:"varint,23,opt,name=defaultSentMediaQuality,proto3,enum=signal.backup.AccountData_SentMediaQuality" json:"defaultSentMediaQuality,omitempty"` - AutoDownloadSettings *AccountData_AutoDownloadSettings `protobuf:"bytes,24,opt,name=autoDownloadSettings,proto3" json:"autoDownloadSettings,omitempty"` - ScreenLockTimeoutMinutes *uint32 `protobuf:"varint,26,opt,name=screenLockTimeoutMinutes,proto3,oneof" json:"screenLockTimeoutMinutes,omitempty"` // If unset, consider screen lock to be disabled. - PinReminders *bool `protobuf:"varint,27,opt,name=pinReminders,proto3,oneof" json:"pinReminders,omitempty"` // If unset, consider pin reminders to be enabled. - AppTheme AccountData_AppTheme `protobuf:"varint,28,opt,name=appTheme,proto3,enum=signal.backup.AccountData_AppTheme" json:"appTheme,omitempty"` // If unset, treat the same as "Unknown" case - CallsUseLessDataSetting AccountData_CallsUseLessDataSetting `protobuf:"varint,29,opt,name=callsUseLessDataSetting,proto3,enum=signal.backup.AccountData_CallsUseLessDataSetting" json:"callsUseLessDataSetting,omitempty"` // If unset, treat the same as "Unknown" case - AllowSealedSenderFromAnyone bool `protobuf:"varint,30,opt,name=allowSealedSenderFromAnyone,proto3" json:"allowSealedSenderFromAnyone,omitempty"` - AllowAutomaticKeyVerification bool `protobuf:"varint,31,opt,name=allowAutomaticKeyVerification,proto3" json:"allowAutomaticKeyVerification,omitempty"` - HasSeenAdminDeleteEducationDialog bool `protobuf:"varint,32,opt,name=hasSeenAdminDeleteEducationDialog,proto3" json:"hasSeenAdminDeleteEducationDialog,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AccountData_AccountSettings) Reset() { - *x = AccountData_AccountSettings{} - mi := &file_backuppb_Backup_proto_msgTypes[88] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AccountData_AccountSettings) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AccountData_AccountSettings) ProtoMessage() {} - -func (x *AccountData_AccountSettings) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[88] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AccountData_AccountSettings.ProtoReflect.Descriptor instead. -func (*AccountData_AccountSettings) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{2, 2} -} - -func (x *AccountData_AccountSettings) GetReadReceipts() bool { - if x != nil { - return x.ReadReceipts - } - return false -} - -func (x *AccountData_AccountSettings) GetSealedSenderIndicators() bool { - if x != nil { - return x.SealedSenderIndicators - } - return false -} - -func (x *AccountData_AccountSettings) GetTypingIndicators() bool { - if x != nil { - return x.TypingIndicators - } - return false -} - -func (x *AccountData_AccountSettings) GetLinkPreviews() bool { - if x != nil { - return x.LinkPreviews - } - return false -} - -func (x *AccountData_AccountSettings) GetNotDiscoverableByPhoneNumber() bool { - if x != nil { - return x.NotDiscoverableByPhoneNumber - } - return false -} - -func (x *AccountData_AccountSettings) GetPreferContactAvatars() bool { - if x != nil { - return x.PreferContactAvatars - } - return false -} - -func (x *AccountData_AccountSettings) GetUniversalExpireTimerSeconds() uint32 { - if x != nil { - return x.UniversalExpireTimerSeconds - } - return 0 -} - -func (x *AccountData_AccountSettings) GetPreferredReactionEmoji() []string { - if x != nil { - return x.PreferredReactionEmoji - } - return nil -} - -func (x *AccountData_AccountSettings) GetDisplayBadgesOnProfile() bool { - if x != nil { - return x.DisplayBadgesOnProfile - } - return false -} - -func (x *AccountData_AccountSettings) GetKeepMutedChatsArchived() bool { - if x != nil { - return x.KeepMutedChatsArchived - } - return false -} - -func (x *AccountData_AccountSettings) GetHasSetMyStoriesPrivacy() bool { - if x != nil { - return x.HasSetMyStoriesPrivacy - } - return false -} - -func (x *AccountData_AccountSettings) GetHasViewedOnboardingStory() bool { - if x != nil { - return x.HasViewedOnboardingStory - } - return false -} - -func (x *AccountData_AccountSettings) GetStoriesDisabled() bool { - if x != nil { - return x.StoriesDisabled - } - return false -} - -func (x *AccountData_AccountSettings) GetStoryViewReceiptsEnabled() bool { - if x != nil && x.StoryViewReceiptsEnabled != nil { - return *x.StoryViewReceiptsEnabled - } - return false -} - -func (x *AccountData_AccountSettings) GetHasSeenGroupStoryEducationSheet() bool { - if x != nil { - return x.HasSeenGroupStoryEducationSheet - } - return false -} - -func (x *AccountData_AccountSettings) GetHasCompletedUsernameOnboarding() bool { - if x != nil { - return x.HasCompletedUsernameOnboarding - } - return false -} - -func (x *AccountData_AccountSettings) GetPhoneNumberSharingMode() AccountData_PhoneNumberSharingMode { - if x != nil { - return x.PhoneNumberSharingMode - } - return AccountData_UNKNOWN -} - -func (x *AccountData_AccountSettings) GetDefaultChatStyle() *ChatStyle { - if x != nil { - return x.DefaultChatStyle - } - return nil -} - -func (x *AccountData_AccountSettings) GetCustomChatColors() []*ChatStyle_CustomChatColor { - if x != nil { - return x.CustomChatColors - } - return nil -} - -func (x *AccountData_AccountSettings) GetOptimizeOnDeviceStorage() bool { - if x != nil { - return x.OptimizeOnDeviceStorage - } - return false -} - -func (x *AccountData_AccountSettings) GetBackupTier() uint64 { - if x != nil && x.BackupTier != nil { - return *x.BackupTier - } - return 0 -} - -func (x *AccountData_AccountSettings) GetDefaultSentMediaQuality() AccountData_SentMediaQuality { - if x != nil { - return x.DefaultSentMediaQuality - } - return AccountData_UNKNOWN_QUALITY -} - -func (x *AccountData_AccountSettings) GetAutoDownloadSettings() *AccountData_AutoDownloadSettings { - if x != nil { - return x.AutoDownloadSettings - } - return nil -} - -func (x *AccountData_AccountSettings) GetScreenLockTimeoutMinutes() uint32 { - if x != nil && x.ScreenLockTimeoutMinutes != nil { - return *x.ScreenLockTimeoutMinutes - } - return 0 -} - -func (x *AccountData_AccountSettings) GetPinReminders() bool { - if x != nil && x.PinReminders != nil { - return *x.PinReminders - } - return false -} - -func (x *AccountData_AccountSettings) GetAppTheme() AccountData_AppTheme { - if x != nil { - return x.AppTheme - } - return AccountData_UNKNOWN_APP_THEME -} - -func (x *AccountData_AccountSettings) GetCallsUseLessDataSetting() AccountData_CallsUseLessDataSetting { - if x != nil { - return x.CallsUseLessDataSetting - } - return AccountData_UNKNOWN_CALL_DATA_SETTING -} - -func (x *AccountData_AccountSettings) GetAllowSealedSenderFromAnyone() bool { - if x != nil { - return x.AllowSealedSenderFromAnyone - } - return false -} - -func (x *AccountData_AccountSettings) GetAllowAutomaticKeyVerification() bool { - if x != nil { - return x.AllowAutomaticKeyVerification - } - return false -} - -func (x *AccountData_AccountSettings) GetHasSeenAdminDeleteEducationDialog() bool { - if x != nil { - return x.HasSeenAdminDeleteEducationDialog - } - return false -} - -type AccountData_SubscriberData struct { - state protoimpl.MessageState `protogen:"open.v1"` - SubscriberId []byte `protobuf:"bytes,1,opt,name=subscriberId,proto3" json:"subscriberId,omitempty"` - CurrencyCode string `protobuf:"bytes,2,opt,name=currencyCode,proto3" json:"currencyCode,omitempty"` - ManuallyCancelled bool `protobuf:"varint,3,opt,name=manuallyCancelled,proto3" json:"manuallyCancelled,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AccountData_SubscriberData) Reset() { - *x = AccountData_SubscriberData{} - mi := &file_backuppb_Backup_proto_msgTypes[89] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AccountData_SubscriberData) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AccountData_SubscriberData) ProtoMessage() {} - -func (x *AccountData_SubscriberData) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[89] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AccountData_SubscriberData.ProtoReflect.Descriptor instead. -func (*AccountData_SubscriberData) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{2, 3} -} - -func (x *AccountData_SubscriberData) GetSubscriberId() []byte { - if x != nil { - return x.SubscriberId - } - return nil -} - -func (x *AccountData_SubscriberData) GetCurrencyCode() string { - if x != nil { - return x.CurrencyCode - } - return "" -} - -func (x *AccountData_SubscriberData) GetManuallyCancelled() bool { - if x != nil { - return x.ManuallyCancelled - } - return false -} - -type AccountData_IAPSubscriberData struct { - state protoimpl.MessageState `protogen:"open.v1"` - SubscriberId []byte `protobuf:"bytes,1,opt,name=subscriberId,proto3" json:"subscriberId,omitempty"` - // If unset, importers should ignore the subscriber data without throwing an error. - // - // Types that are valid to be assigned to IapSubscriptionId: - // - // *AccountData_IAPSubscriberData_PurchaseToken - // *AccountData_IAPSubscriberData_OriginalTransactionId - IapSubscriptionId isAccountData_IAPSubscriberData_IapSubscriptionId `protobuf_oneof:"iapSubscriptionId"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AccountData_IAPSubscriberData) Reset() { - *x = AccountData_IAPSubscriberData{} - mi := &file_backuppb_Backup_proto_msgTypes[90] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AccountData_IAPSubscriberData) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AccountData_IAPSubscriberData) ProtoMessage() {} - -func (x *AccountData_IAPSubscriberData) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[90] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AccountData_IAPSubscriberData.ProtoReflect.Descriptor instead. -func (*AccountData_IAPSubscriberData) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{2, 4} -} - -func (x *AccountData_IAPSubscriberData) GetSubscriberId() []byte { - if x != nil { - return x.SubscriberId - } - return nil -} - -func (x *AccountData_IAPSubscriberData) GetIapSubscriptionId() isAccountData_IAPSubscriberData_IapSubscriptionId { - if x != nil { - return x.IapSubscriptionId - } - return nil -} - -func (x *AccountData_IAPSubscriberData) GetPurchaseToken() string { - if x != nil { - if x, ok := x.IapSubscriptionId.(*AccountData_IAPSubscriberData_PurchaseToken); ok { - return x.PurchaseToken - } - } - return "" -} - -func (x *AccountData_IAPSubscriberData) GetOriginalTransactionId() uint64 { - if x != nil { - if x, ok := x.IapSubscriptionId.(*AccountData_IAPSubscriberData_OriginalTransactionId); ok { - return x.OriginalTransactionId - } - } - return 0 -} - -type isAccountData_IAPSubscriberData_IapSubscriptionId interface { - isAccountData_IAPSubscriberData_IapSubscriptionId() -} - -type AccountData_IAPSubscriberData_PurchaseToken struct { - // Identifies an Android Play Store IAP subscription. - PurchaseToken string `protobuf:"bytes,2,opt,name=purchaseToken,proto3,oneof"` -} - -type AccountData_IAPSubscriberData_OriginalTransactionId struct { - // Identifies an iOS App Store IAP subscription. - OriginalTransactionId uint64 `protobuf:"varint,3,opt,name=originalTransactionId,proto3,oneof"` -} - -func (*AccountData_IAPSubscriberData_PurchaseToken) isAccountData_IAPSubscriberData_IapSubscriptionId() { -} - -func (*AccountData_IAPSubscriberData_OriginalTransactionId) isAccountData_IAPSubscriberData_IapSubscriptionId() { -} - -type AccountData_AndroidSpecificSettings struct { - state protoimpl.MessageState `protogen:"open.v1"` - UseSystemEmoji bool `protobuf:"varint,1,opt,name=useSystemEmoji,proto3" json:"useSystemEmoji,omitempty"` - ScreenshotSecurity bool `protobuf:"varint,2,opt,name=screenshotSecurity,proto3" json:"screenshotSecurity,omitempty"` - NavigationBarSize AccountData_AndroidSpecificSettings_NavigationBarSize `protobuf:"varint,3,opt,name=navigationBarSize,proto3,enum=signal.backup.AccountData_AndroidSpecificSettings_NavigationBarSize" json:"navigationBarSize,omitempty"` // If unset, treat the same as "Unknown" case - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AccountData_AndroidSpecificSettings) Reset() { - *x = AccountData_AndroidSpecificSettings{} - mi := &file_backuppb_Backup_proto_msgTypes[91] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AccountData_AndroidSpecificSettings) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AccountData_AndroidSpecificSettings) ProtoMessage() {} - -func (x *AccountData_AndroidSpecificSettings) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[91] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AccountData_AndroidSpecificSettings.ProtoReflect.Descriptor instead. -func (*AccountData_AndroidSpecificSettings) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{2, 5} -} - -func (x *AccountData_AndroidSpecificSettings) GetUseSystemEmoji() bool { - if x != nil { - return x.UseSystemEmoji - } - return false -} - -func (x *AccountData_AndroidSpecificSettings) GetScreenshotSecurity() bool { - if x != nil { - return x.ScreenshotSecurity - } - return false -} - -func (x *AccountData_AndroidSpecificSettings) GetNavigationBarSize() AccountData_AndroidSpecificSettings_NavigationBarSize { - if x != nil { - return x.NavigationBarSize - } - return AccountData_AndroidSpecificSettings_UNKNOWN_BAR_SIZE -} - -type Contact_Registered struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Contact_Registered) Reset() { - *x = Contact_Registered{} - mi := &file_backuppb_Backup_proto_msgTypes[92] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Contact_Registered) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Contact_Registered) ProtoMessage() {} - -func (x *Contact_Registered) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[92] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Contact_Registered.ProtoReflect.Descriptor instead. -func (*Contact_Registered) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{4, 0} -} - -type Contact_NotRegistered struct { - state protoimpl.MessageState `protogen:"open.v1"` - UnregisteredTimestamp uint64 `protobuf:"varint,1,opt,name=unregisteredTimestamp,proto3" json:"unregisteredTimestamp,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Contact_NotRegistered) Reset() { - *x = Contact_NotRegistered{} - mi := &file_backuppb_Backup_proto_msgTypes[93] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Contact_NotRegistered) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Contact_NotRegistered) ProtoMessage() {} - -func (x *Contact_NotRegistered) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[93] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Contact_NotRegistered.ProtoReflect.Descriptor instead. -func (*Contact_NotRegistered) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{4, 1} -} - -func (x *Contact_NotRegistered) GetUnregisteredTimestamp() uint64 { - if x != nil { - return x.UnregisteredTimestamp - } - return 0 -} - -type Contact_Name struct { - state protoimpl.MessageState `protogen:"open.v1"` - Given string `protobuf:"bytes,1,opt,name=given,proto3" json:"given,omitempty"` - Family string `protobuf:"bytes,2,opt,name=family,proto3" json:"family,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Contact_Name) Reset() { - *x = Contact_Name{} - mi := &file_backuppb_Backup_proto_msgTypes[94] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Contact_Name) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Contact_Name) ProtoMessage() {} - -func (x *Contact_Name) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[94] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Contact_Name.ProtoReflect.Descriptor instead. -func (*Contact_Name) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{4, 2} -} - -func (x *Contact_Name) GetGiven() string { - if x != nil { - return x.Given - } - return "" -} - -func (x *Contact_Name) GetFamily() string { - if x != nil { - return x.Family - } - return "" -} - -// These are simply plaintext copies of the groups proto from Groups.proto. -// They should be kept completely in-sync with Groups.proto. -// These exist to allow us to have the latest snapshot of a group during restoration without having to hit the network. -// We would use Groups.proto if we could, but we want a plaintext version to improve export readability. -// For documentation, defer to Groups.proto. The only name change is Group -> GroupSnapshot to avoid the naming conflict. -type Group_GroupSnapshot struct { - state protoimpl.MessageState `protogen:"open.v1"` - Title *Group_GroupAttributeBlob `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"` - Description *Group_GroupAttributeBlob `protobuf:"bytes,11,opt,name=description,proto3" json:"description,omitempty"` - AvatarUrl string `protobuf:"bytes,3,opt,name=avatarUrl,proto3" json:"avatarUrl,omitempty"` - DisappearingMessagesTimer *Group_GroupAttributeBlob `protobuf:"bytes,4,opt,name=disappearingMessagesTimer,proto3" json:"disappearingMessagesTimer,omitempty"` - AccessControl *Group_AccessControl `protobuf:"bytes,5,opt,name=accessControl,proto3" json:"accessControl,omitempty"` - Version uint32 `protobuf:"varint,6,opt,name=version,proto3" json:"version,omitempty"` - Members []*Group_Member `protobuf:"bytes,7,rep,name=members,proto3" json:"members,omitempty"` - MembersPendingProfileKey []*Group_MemberPendingProfileKey `protobuf:"bytes,8,rep,name=membersPendingProfileKey,proto3" json:"membersPendingProfileKey,omitempty"` - MembersPendingAdminApproval []*Group_MemberPendingAdminApproval `protobuf:"bytes,9,rep,name=membersPendingAdminApproval,proto3" json:"membersPendingAdminApproval,omitempty"` - InviteLinkPassword []byte `protobuf:"bytes,10,opt,name=inviteLinkPassword,proto3" json:"inviteLinkPassword,omitempty"` - AnnouncementsOnly bool `protobuf:"varint,12,opt,name=announcements_only,json=announcementsOnly,proto3" json:"announcements_only,omitempty"` - MembersBanned []*Group_MemberBanned `protobuf:"bytes,13,rep,name=members_banned,json=membersBanned,proto3" json:"members_banned,omitempty"` - Terminated bool `protobuf:"varint,14,opt,name=terminated,proto3" json:"terminated,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Group_GroupSnapshot) Reset() { - *x = Group_GroupSnapshot{} - mi := &file_backuppb_Backup_proto_msgTypes[95] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Group_GroupSnapshot) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Group_GroupSnapshot) ProtoMessage() {} - -func (x *Group_GroupSnapshot) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[95] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Group_GroupSnapshot.ProtoReflect.Descriptor instead. -func (*Group_GroupSnapshot) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{5, 0} -} - -func (x *Group_GroupSnapshot) GetTitle() *Group_GroupAttributeBlob { - if x != nil { - return x.Title - } - return nil -} - -func (x *Group_GroupSnapshot) GetDescription() *Group_GroupAttributeBlob { - if x != nil { - return x.Description - } - return nil -} - -func (x *Group_GroupSnapshot) GetAvatarUrl() string { - if x != nil { - return x.AvatarUrl - } - return "" -} - -func (x *Group_GroupSnapshot) GetDisappearingMessagesTimer() *Group_GroupAttributeBlob { - if x != nil { - return x.DisappearingMessagesTimer - } - return nil -} - -func (x *Group_GroupSnapshot) GetAccessControl() *Group_AccessControl { - if x != nil { - return x.AccessControl - } - return nil -} - -func (x *Group_GroupSnapshot) GetVersion() uint32 { - if x != nil { - return x.Version - } - return 0 -} - -func (x *Group_GroupSnapshot) GetMembers() []*Group_Member { - if x != nil { - return x.Members - } - return nil -} - -func (x *Group_GroupSnapshot) GetMembersPendingProfileKey() []*Group_MemberPendingProfileKey { - if x != nil { - return x.MembersPendingProfileKey - } - return nil -} - -func (x *Group_GroupSnapshot) GetMembersPendingAdminApproval() []*Group_MemberPendingAdminApproval { - if x != nil { - return x.MembersPendingAdminApproval - } - return nil -} - -func (x *Group_GroupSnapshot) GetInviteLinkPassword() []byte { - if x != nil { - return x.InviteLinkPassword - } - return nil -} - -func (x *Group_GroupSnapshot) GetAnnouncementsOnly() bool { - if x != nil { - return x.AnnouncementsOnly - } - return false -} - -func (x *Group_GroupSnapshot) GetMembersBanned() []*Group_MemberBanned { - if x != nil { - return x.MembersBanned - } - return nil -} - -func (x *Group_GroupSnapshot) GetTerminated() bool { - if x != nil { - return x.Terminated - } - return false -} - -type Group_GroupAttributeBlob struct { - state protoimpl.MessageState `protogen:"open.v1"` - // If unset, consider the field it represents to not be present - // - // Types that are valid to be assigned to Content: - // - // *Group_GroupAttributeBlob_Title - // *Group_GroupAttributeBlob_Avatar - // *Group_GroupAttributeBlob_DisappearingMessagesDuration - // *Group_GroupAttributeBlob_DescriptionText - Content isGroup_GroupAttributeBlob_Content `protobuf_oneof:"content"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Group_GroupAttributeBlob) Reset() { - *x = Group_GroupAttributeBlob{} - mi := &file_backuppb_Backup_proto_msgTypes[96] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Group_GroupAttributeBlob) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Group_GroupAttributeBlob) ProtoMessage() {} - -func (x *Group_GroupAttributeBlob) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[96] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Group_GroupAttributeBlob.ProtoReflect.Descriptor instead. -func (*Group_GroupAttributeBlob) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{5, 1} -} - -func (x *Group_GroupAttributeBlob) GetContent() isGroup_GroupAttributeBlob_Content { - if x != nil { - return x.Content - } - return nil -} - -func (x *Group_GroupAttributeBlob) GetTitle() string { - if x != nil { - if x, ok := x.Content.(*Group_GroupAttributeBlob_Title); ok { - return x.Title - } - } - return "" -} - -func (x *Group_GroupAttributeBlob) GetAvatar() []byte { - if x != nil { - if x, ok := x.Content.(*Group_GroupAttributeBlob_Avatar); ok { - return x.Avatar - } - } - return nil -} - -func (x *Group_GroupAttributeBlob) GetDisappearingMessagesDuration() uint32 { - if x != nil { - if x, ok := x.Content.(*Group_GroupAttributeBlob_DisappearingMessagesDuration); ok { - return x.DisappearingMessagesDuration - } - } - return 0 -} - -func (x *Group_GroupAttributeBlob) GetDescriptionText() string { - if x != nil { - if x, ok := x.Content.(*Group_GroupAttributeBlob_DescriptionText); ok { - return x.DescriptionText - } - } - return "" -} - -type isGroup_GroupAttributeBlob_Content interface { - isGroup_GroupAttributeBlob_Content() -} - -type Group_GroupAttributeBlob_Title struct { - Title string `protobuf:"bytes,1,opt,name=title,proto3,oneof"` -} - -type Group_GroupAttributeBlob_Avatar struct { - Avatar []byte `protobuf:"bytes,2,opt,name=avatar,proto3,oneof"` -} - -type Group_GroupAttributeBlob_DisappearingMessagesDuration struct { - DisappearingMessagesDuration uint32 `protobuf:"varint,3,opt,name=disappearingMessagesDuration,proto3,oneof"` -} - -type Group_GroupAttributeBlob_DescriptionText struct { - DescriptionText string `protobuf:"bytes,4,opt,name=descriptionText,proto3,oneof"` -} - -func (*Group_GroupAttributeBlob_Title) isGroup_GroupAttributeBlob_Content() {} - -func (*Group_GroupAttributeBlob_Avatar) isGroup_GroupAttributeBlob_Content() {} - -func (*Group_GroupAttributeBlob_DisappearingMessagesDuration) isGroup_GroupAttributeBlob_Content() {} - -func (*Group_GroupAttributeBlob_DescriptionText) isGroup_GroupAttributeBlob_Content() {} - -type Group_Member struct { - state protoimpl.MessageState `protogen:"open.v1"` - UserId []byte `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId,omitempty"` - Role Group_Member_Role `protobuf:"varint,2,opt,name=role,proto3,enum=signal.backup.Group_Member_Role" json:"role,omitempty"` - JoinedAtVersion uint32 `protobuf:"varint,5,opt,name=joinedAtVersion,proto3" json:"joinedAtVersion,omitempty"` - LabelEmoji string `protobuf:"bytes,6,opt,name=labelEmoji,proto3" json:"labelEmoji,omitempty"` - LabelString string `protobuf:"bytes,7,opt,name=labelString,proto3" json:"labelString,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Group_Member) Reset() { - *x = Group_Member{} - mi := &file_backuppb_Backup_proto_msgTypes[97] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Group_Member) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Group_Member) ProtoMessage() {} - -func (x *Group_Member) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[97] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Group_Member.ProtoReflect.Descriptor instead. -func (*Group_Member) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{5, 2} -} - -func (x *Group_Member) GetUserId() []byte { - if x != nil { - return x.UserId - } - return nil -} - -func (x *Group_Member) GetRole() Group_Member_Role { - if x != nil { - return x.Role - } - return Group_Member_UNKNOWN -} - -func (x *Group_Member) GetJoinedAtVersion() uint32 { - if x != nil { - return x.JoinedAtVersion - } - return 0 -} - -func (x *Group_Member) GetLabelEmoji() string { - if x != nil { - return x.LabelEmoji - } - return "" -} - -func (x *Group_Member) GetLabelString() string { - if x != nil { - return x.LabelString - } - return "" -} - -type Group_MemberPendingProfileKey struct { - state protoimpl.MessageState `protogen:"open.v1"` - Member *Group_Member `protobuf:"bytes,1,opt,name=member,proto3" json:"member,omitempty"` - AddedByUserId []byte `protobuf:"bytes,2,opt,name=addedByUserId,proto3" json:"addedByUserId,omitempty"` - Timestamp uint64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Group_MemberPendingProfileKey) Reset() { - *x = Group_MemberPendingProfileKey{} - mi := &file_backuppb_Backup_proto_msgTypes[98] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Group_MemberPendingProfileKey) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Group_MemberPendingProfileKey) ProtoMessage() {} - -func (x *Group_MemberPendingProfileKey) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[98] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Group_MemberPendingProfileKey.ProtoReflect.Descriptor instead. -func (*Group_MemberPendingProfileKey) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{5, 3} -} - -func (x *Group_MemberPendingProfileKey) GetMember() *Group_Member { - if x != nil { - return x.Member - } - return nil -} - -func (x *Group_MemberPendingProfileKey) GetAddedByUserId() []byte { - if x != nil { - return x.AddedByUserId - } - return nil -} - -func (x *Group_MemberPendingProfileKey) GetTimestamp() uint64 { - if x != nil { - return x.Timestamp - } - return 0 -} - -type Group_MemberPendingAdminApproval struct { - state protoimpl.MessageState `protogen:"open.v1"` - UserId []byte `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId,omitempty"` - Timestamp uint64 `protobuf:"varint,4,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Group_MemberPendingAdminApproval) Reset() { - *x = Group_MemberPendingAdminApproval{} - mi := &file_backuppb_Backup_proto_msgTypes[99] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Group_MemberPendingAdminApproval) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Group_MemberPendingAdminApproval) ProtoMessage() {} - -func (x *Group_MemberPendingAdminApproval) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[99] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Group_MemberPendingAdminApproval.ProtoReflect.Descriptor instead. -func (*Group_MemberPendingAdminApproval) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{5, 4} -} - -func (x *Group_MemberPendingAdminApproval) GetUserId() []byte { - if x != nil { - return x.UserId - } - return nil -} - -func (x *Group_MemberPendingAdminApproval) GetTimestamp() uint64 { - if x != nil { - return x.Timestamp - } - return 0 -} - -type Group_MemberBanned struct { - state protoimpl.MessageState `protogen:"open.v1"` - UserId []byte `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId,omitempty"` - Timestamp uint64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Group_MemberBanned) Reset() { - *x = Group_MemberBanned{} - mi := &file_backuppb_Backup_proto_msgTypes[100] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Group_MemberBanned) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Group_MemberBanned) ProtoMessage() {} - -func (x *Group_MemberBanned) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[100] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Group_MemberBanned.ProtoReflect.Descriptor instead. -func (*Group_MemberBanned) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{5, 5} -} - -func (x *Group_MemberBanned) GetUserId() []byte { - if x != nil { - return x.UserId - } - return nil -} - -func (x *Group_MemberBanned) GetTimestamp() uint64 { - if x != nil { - return x.Timestamp - } - return 0 -} - -type Group_AccessControl struct { - state protoimpl.MessageState `protogen:"open.v1"` - Attributes Group_AccessControl_AccessRequired `protobuf:"varint,1,opt,name=attributes,proto3,enum=signal.backup.Group_AccessControl_AccessRequired" json:"attributes,omitempty"` - Members Group_AccessControl_AccessRequired `protobuf:"varint,2,opt,name=members,proto3,enum=signal.backup.Group_AccessControl_AccessRequired" json:"members,omitempty"` - AddFromInviteLink Group_AccessControl_AccessRequired `protobuf:"varint,3,opt,name=addFromInviteLink,proto3,enum=signal.backup.Group_AccessControl_AccessRequired" json:"addFromInviteLink,omitempty"` - MemberLabel Group_AccessControl_AccessRequired `protobuf:"varint,4,opt,name=memberLabel,proto3,enum=signal.backup.Group_AccessControl_AccessRequired" json:"memberLabel,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Group_AccessControl) Reset() { - *x = Group_AccessControl{} - mi := &file_backuppb_Backup_proto_msgTypes[101] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Group_AccessControl) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Group_AccessControl) ProtoMessage() {} - -func (x *Group_AccessControl) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[101] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Group_AccessControl.ProtoReflect.Descriptor instead. -func (*Group_AccessControl) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{5, 6} -} - -func (x *Group_AccessControl) GetAttributes() Group_AccessControl_AccessRequired { - if x != nil { - return x.Attributes - } - return Group_AccessControl_UNKNOWN -} - -func (x *Group_AccessControl) GetMembers() Group_AccessControl_AccessRequired { - if x != nil { - return x.Members - } - return Group_AccessControl_UNKNOWN -} - -func (x *Group_AccessControl) GetAddFromInviteLink() Group_AccessControl_AccessRequired { - if x != nil { - return x.AddFromInviteLink - } - return Group_AccessControl_UNKNOWN -} - -func (x *Group_AccessControl) GetMemberLabel() Group_AccessControl_AccessRequired { - if x != nil { - return x.MemberLabel - } - return Group_AccessControl_UNKNOWN -} - -type ChatItem_IncomingMessageDetails struct { - state protoimpl.MessageState `protogen:"open.v1"` - DateReceived uint64 `protobuf:"varint,1,opt,name=dateReceived,proto3" json:"dateReceived,omitempty"` - DateServerSent *uint64 `protobuf:"varint,2,opt,name=dateServerSent,proto3,oneof" json:"dateServerSent,omitempty"` - Read bool `protobuf:"varint,3,opt,name=read,proto3" json:"read,omitempty"` - SealedSender bool `protobuf:"varint,4,opt,name=sealedSender,proto3" json:"sealedSender,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ChatItem_IncomingMessageDetails) Reset() { - *x = ChatItem_IncomingMessageDetails{} - mi := &file_backuppb_Backup_proto_msgTypes[102] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ChatItem_IncomingMessageDetails) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ChatItem_IncomingMessageDetails) ProtoMessage() {} - -func (x *ChatItem_IncomingMessageDetails) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[102] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ChatItem_IncomingMessageDetails.ProtoReflect.Descriptor instead. -func (*ChatItem_IncomingMessageDetails) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{13, 0} -} - -func (x *ChatItem_IncomingMessageDetails) GetDateReceived() uint64 { - if x != nil { - return x.DateReceived - } - return 0 -} - -func (x *ChatItem_IncomingMessageDetails) GetDateServerSent() uint64 { - if x != nil && x.DateServerSent != nil { - return *x.DateServerSent - } - return 0 -} - -func (x *ChatItem_IncomingMessageDetails) GetRead() bool { - if x != nil { - return x.Read - } - return false -} - -func (x *ChatItem_IncomingMessageDetails) GetSealedSender() bool { - if x != nil { - return x.SealedSender - } - return false -} - -type ChatItem_OutgoingMessageDetails struct { - state protoimpl.MessageState `protogen:"open.v1"` - SendStatus []*SendStatus `protobuf:"bytes,1,rep,name=sendStatus,proto3" json:"sendStatus,omitempty"` - DateReceived uint64 `protobuf:"varint,2,opt,name=dateReceived,proto3" json:"dateReceived,omitempty"` // may be different from dateSent for sync messages - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ChatItem_OutgoingMessageDetails) Reset() { - *x = ChatItem_OutgoingMessageDetails{} - mi := &file_backuppb_Backup_proto_msgTypes[103] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ChatItem_OutgoingMessageDetails) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ChatItem_OutgoingMessageDetails) ProtoMessage() {} - -func (x *ChatItem_OutgoingMessageDetails) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[103] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ChatItem_OutgoingMessageDetails.ProtoReflect.Descriptor instead. -func (*ChatItem_OutgoingMessageDetails) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{13, 1} -} - -func (x *ChatItem_OutgoingMessageDetails) GetSendStatus() []*SendStatus { - if x != nil { - return x.SendStatus - } - return nil -} - -func (x *ChatItem_OutgoingMessageDetails) GetDateReceived() uint64 { - if x != nil { - return x.DateReceived - } - return 0 -} - -type ChatItem_DirectionlessMessageDetails struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ChatItem_DirectionlessMessageDetails) Reset() { - *x = ChatItem_DirectionlessMessageDetails{} - mi := &file_backuppb_Backup_proto_msgTypes[104] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ChatItem_DirectionlessMessageDetails) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ChatItem_DirectionlessMessageDetails) ProtoMessage() {} - -func (x *ChatItem_DirectionlessMessageDetails) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[104] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ChatItem_DirectionlessMessageDetails.ProtoReflect.Descriptor instead. -func (*ChatItem_DirectionlessMessageDetails) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{13, 2} -} - -type ChatItem_PinDetails struct { - state protoimpl.MessageState `protogen:"open.v1"` - PinnedAtTimestamp uint64 `protobuf:"varint,1,opt,name=pinnedAtTimestamp,proto3" json:"pinnedAtTimestamp,omitempty"` - // Types that are valid to be assigned to PinExpiry: - // - // *ChatItem_PinDetails_PinExpiresAtTimestamp - // *ChatItem_PinDetails_PinNeverExpires - PinExpiry isChatItem_PinDetails_PinExpiry `protobuf_oneof:"pinExpiry"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ChatItem_PinDetails) Reset() { - *x = ChatItem_PinDetails{} - mi := &file_backuppb_Backup_proto_msgTypes[105] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ChatItem_PinDetails) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ChatItem_PinDetails) ProtoMessage() {} - -func (x *ChatItem_PinDetails) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[105] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ChatItem_PinDetails.ProtoReflect.Descriptor instead. -func (*ChatItem_PinDetails) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{13, 3} -} - -func (x *ChatItem_PinDetails) GetPinnedAtTimestamp() uint64 { - if x != nil { - return x.PinnedAtTimestamp - } - return 0 -} - -func (x *ChatItem_PinDetails) GetPinExpiry() isChatItem_PinDetails_PinExpiry { - if x != nil { - return x.PinExpiry - } - return nil -} - -func (x *ChatItem_PinDetails) GetPinExpiresAtTimestamp() uint64 { - if x != nil { - if x, ok := x.PinExpiry.(*ChatItem_PinDetails_PinExpiresAtTimestamp); ok { - return x.PinExpiresAtTimestamp - } - } - return 0 -} - -func (x *ChatItem_PinDetails) GetPinNeverExpires() bool { - if x != nil { - if x, ok := x.PinExpiry.(*ChatItem_PinDetails_PinNeverExpires); ok { - return x.PinNeverExpires - } - } - return false -} - -type isChatItem_PinDetails_PinExpiry interface { - isChatItem_PinDetails_PinExpiry() -} - -type ChatItem_PinDetails_PinExpiresAtTimestamp struct { - PinExpiresAtTimestamp uint64 `protobuf:"varint,2,opt,name=pinExpiresAtTimestamp,proto3,oneof"` // timestamp when the pin should expire -} - -type ChatItem_PinDetails_PinNeverExpires struct { - PinNeverExpires bool `protobuf:"varint,3,opt,name=pinNeverExpires,proto3,oneof"` -} - -func (*ChatItem_PinDetails_PinExpiresAtTimestamp) isChatItem_PinDetails_PinExpiry() {} - -func (*ChatItem_PinDetails_PinNeverExpires) isChatItem_PinDetails_PinExpiry() {} - -type SendStatus_Pending struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *SendStatus_Pending) Reset() { - *x = SendStatus_Pending{} - mi := &file_backuppb_Backup_proto_msgTypes[106] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *SendStatus_Pending) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SendStatus_Pending) ProtoMessage() {} - -func (x *SendStatus_Pending) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[106] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SendStatus_Pending.ProtoReflect.Descriptor instead. -func (*SendStatus_Pending) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{14, 0} -} - -type SendStatus_Sent struct { - state protoimpl.MessageState `protogen:"open.v1"` - SealedSender bool `protobuf:"varint,1,opt,name=sealedSender,proto3" json:"sealedSender,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *SendStatus_Sent) Reset() { - *x = SendStatus_Sent{} - mi := &file_backuppb_Backup_proto_msgTypes[107] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *SendStatus_Sent) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SendStatus_Sent) ProtoMessage() {} - -func (x *SendStatus_Sent) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[107] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SendStatus_Sent.ProtoReflect.Descriptor instead. -func (*SendStatus_Sent) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{14, 1} -} - -func (x *SendStatus_Sent) GetSealedSender() bool { - if x != nil { - return x.SealedSender - } - return false -} - -type SendStatus_Delivered struct { - state protoimpl.MessageState `protogen:"open.v1"` - SealedSender bool `protobuf:"varint,1,opt,name=sealedSender,proto3" json:"sealedSender,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *SendStatus_Delivered) Reset() { - *x = SendStatus_Delivered{} - mi := &file_backuppb_Backup_proto_msgTypes[108] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *SendStatus_Delivered) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SendStatus_Delivered) ProtoMessage() {} - -func (x *SendStatus_Delivered) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[108] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SendStatus_Delivered.ProtoReflect.Descriptor instead. -func (*SendStatus_Delivered) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{14, 2} -} - -func (x *SendStatus_Delivered) GetSealedSender() bool { - if x != nil { - return x.SealedSender - } - return false -} - -type SendStatus_Read struct { - state protoimpl.MessageState `protogen:"open.v1"` - SealedSender bool `protobuf:"varint,1,opt,name=sealedSender,proto3" json:"sealedSender,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *SendStatus_Read) Reset() { - *x = SendStatus_Read{} - mi := &file_backuppb_Backup_proto_msgTypes[109] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *SendStatus_Read) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SendStatus_Read) ProtoMessage() {} - -func (x *SendStatus_Read) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[109] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SendStatus_Read.ProtoReflect.Descriptor instead. -func (*SendStatus_Read) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{14, 3} -} - -func (x *SendStatus_Read) GetSealedSender() bool { - if x != nil { - return x.SealedSender - } - return false -} - -type SendStatus_Viewed struct { - state protoimpl.MessageState `protogen:"open.v1"` - SealedSender bool `protobuf:"varint,1,opt,name=sealedSender,proto3" json:"sealedSender,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *SendStatus_Viewed) Reset() { - *x = SendStatus_Viewed{} - mi := &file_backuppb_Backup_proto_msgTypes[110] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *SendStatus_Viewed) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SendStatus_Viewed) ProtoMessage() {} - -func (x *SendStatus_Viewed) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[110] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SendStatus_Viewed.ProtoReflect.Descriptor instead. -func (*SendStatus_Viewed) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{14, 4} -} - -func (x *SendStatus_Viewed) GetSealedSender() bool { - if x != nil { - return x.SealedSender - } - return false -} - -// e.g. user in group was blocked, so we skipped sending to them -type SendStatus_Skipped struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *SendStatus_Skipped) Reset() { - *x = SendStatus_Skipped{} - mi := &file_backuppb_Backup_proto_msgTypes[111] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *SendStatus_Skipped) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SendStatus_Skipped) ProtoMessage() {} - -func (x *SendStatus_Skipped) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[111] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SendStatus_Skipped.ProtoReflect.Descriptor instead. -func (*SendStatus_Skipped) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{14, 5} -} - -type SendStatus_Failed struct { - state protoimpl.MessageState `protogen:"open.v1"` - Reason SendStatus_Failed_FailureReason `protobuf:"varint,1,opt,name=reason,proto3,enum=signal.backup.SendStatus_Failed_FailureReason" json:"reason,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *SendStatus_Failed) Reset() { - *x = SendStatus_Failed{} - mi := &file_backuppb_Backup_proto_msgTypes[112] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *SendStatus_Failed) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SendStatus_Failed) ProtoMessage() {} - -func (x *SendStatus_Failed) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[112] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SendStatus_Failed.ProtoReflect.Descriptor instead. -func (*SendStatus_Failed) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{14, 6} -} - -func (x *SendStatus_Failed) GetReason() SendStatus_Failed_FailureReason { - if x != nil { - return x.Reason - } - return SendStatus_Failed_UNKNOWN -} - -type DirectStoryReplyMessage_TextReply struct { - state protoimpl.MessageState `protogen:"open.v1"` - Text *Text `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"` - LongText *FilePointer `protobuf:"bytes,2,opt,name=longText,proto3" json:"longText,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DirectStoryReplyMessage_TextReply) Reset() { - *x = DirectStoryReplyMessage_TextReply{} - mi := &file_backuppb_Backup_proto_msgTypes[113] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DirectStoryReplyMessage_TextReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DirectStoryReplyMessage_TextReply) ProtoMessage() {} - -func (x *DirectStoryReplyMessage_TextReply) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[113] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DirectStoryReplyMessage_TextReply.ProtoReflect.Descriptor instead. -func (*DirectStoryReplyMessage_TextReply) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{18, 0} -} - -func (x *DirectStoryReplyMessage_TextReply) GetText() *Text { - if x != nil { - return x.Text - } - return nil -} - -func (x *DirectStoryReplyMessage_TextReply) GetLongText() *FilePointer { - if x != nil { - return x.LongText - } - return nil -} - -type PaymentNotification_TransactionDetails struct { - state protoimpl.MessageState `protogen:"open.v1"` - // If unset, importers should treat the transaction as successful with no metadata. - // - // Types that are valid to be assigned to Payment: - // - // *PaymentNotification_TransactionDetails_Transaction_ - // *PaymentNotification_TransactionDetails_FailedTransaction_ - Payment isPaymentNotification_TransactionDetails_Payment `protobuf_oneof:"payment"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PaymentNotification_TransactionDetails) Reset() { - *x = PaymentNotification_TransactionDetails{} - mi := &file_backuppb_Backup_proto_msgTypes[114] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PaymentNotification_TransactionDetails) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PaymentNotification_TransactionDetails) ProtoMessage() {} - -func (x *PaymentNotification_TransactionDetails) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[114] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PaymentNotification_TransactionDetails.ProtoReflect.Descriptor instead. -func (*PaymentNotification_TransactionDetails) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{19, 0} -} - -func (x *PaymentNotification_TransactionDetails) GetPayment() isPaymentNotification_TransactionDetails_Payment { - if x != nil { - return x.Payment - } - return nil -} - -func (x *PaymentNotification_TransactionDetails) GetTransaction() *PaymentNotification_TransactionDetails_Transaction { - if x != nil { - if x, ok := x.Payment.(*PaymentNotification_TransactionDetails_Transaction_); ok { - return x.Transaction - } - } - return nil -} - -func (x *PaymentNotification_TransactionDetails) GetFailedTransaction() *PaymentNotification_TransactionDetails_FailedTransaction { - if x != nil { - if x, ok := x.Payment.(*PaymentNotification_TransactionDetails_FailedTransaction_); ok { - return x.FailedTransaction - } - } - return nil -} - -type isPaymentNotification_TransactionDetails_Payment interface { - isPaymentNotification_TransactionDetails_Payment() -} - -type PaymentNotification_TransactionDetails_Transaction_ struct { - Transaction *PaymentNotification_TransactionDetails_Transaction `protobuf:"bytes,1,opt,name=transaction,proto3,oneof"` -} - -type PaymentNotification_TransactionDetails_FailedTransaction_ struct { - FailedTransaction *PaymentNotification_TransactionDetails_FailedTransaction `protobuf:"bytes,2,opt,name=failedTransaction,proto3,oneof"` -} - -func (*PaymentNotification_TransactionDetails_Transaction_) isPaymentNotification_TransactionDetails_Payment() { -} - -func (*PaymentNotification_TransactionDetails_FailedTransaction_) isPaymentNotification_TransactionDetails_Payment() { -} - -type PaymentNotification_TransactionDetails_MobileCoinTxoIdentification struct { - state protoimpl.MessageState `protogen:"open.v1"` - PublicKey [][]byte `protobuf:"bytes,1,rep,name=publicKey,proto3" json:"publicKey,omitempty"` // for received transactions - KeyImages [][]byte `protobuf:"bytes,2,rep,name=keyImages,proto3" json:"keyImages,omitempty"` // for sent transactions - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PaymentNotification_TransactionDetails_MobileCoinTxoIdentification) Reset() { - *x = PaymentNotification_TransactionDetails_MobileCoinTxoIdentification{} - mi := &file_backuppb_Backup_proto_msgTypes[115] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PaymentNotification_TransactionDetails_MobileCoinTxoIdentification) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PaymentNotification_TransactionDetails_MobileCoinTxoIdentification) ProtoMessage() {} - -func (x *PaymentNotification_TransactionDetails_MobileCoinTxoIdentification) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[115] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PaymentNotification_TransactionDetails_MobileCoinTxoIdentification.ProtoReflect.Descriptor instead. -func (*PaymentNotification_TransactionDetails_MobileCoinTxoIdentification) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{19, 0, 0} -} - -func (x *PaymentNotification_TransactionDetails_MobileCoinTxoIdentification) GetPublicKey() [][]byte { - if x != nil { - return x.PublicKey - } - return nil -} - -func (x *PaymentNotification_TransactionDetails_MobileCoinTxoIdentification) GetKeyImages() [][]byte { - if x != nil { - return x.KeyImages - } - return nil -} - -type PaymentNotification_TransactionDetails_FailedTransaction struct { - state protoimpl.MessageState `protogen:"open.v1"` - Reason PaymentNotification_TransactionDetails_FailedTransaction_FailureReason `protobuf:"varint,1,opt,name=reason,proto3,enum=signal.backup.PaymentNotification_TransactionDetails_FailedTransaction_FailureReason" json:"reason,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PaymentNotification_TransactionDetails_FailedTransaction) Reset() { - *x = PaymentNotification_TransactionDetails_FailedTransaction{} - mi := &file_backuppb_Backup_proto_msgTypes[116] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PaymentNotification_TransactionDetails_FailedTransaction) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PaymentNotification_TransactionDetails_FailedTransaction) ProtoMessage() {} - -func (x *PaymentNotification_TransactionDetails_FailedTransaction) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[116] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PaymentNotification_TransactionDetails_FailedTransaction.ProtoReflect.Descriptor instead. -func (*PaymentNotification_TransactionDetails_FailedTransaction) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{19, 0, 1} -} - -func (x *PaymentNotification_TransactionDetails_FailedTransaction) GetReason() PaymentNotification_TransactionDetails_FailedTransaction_FailureReason { - if x != nil { - return x.Reason - } - return PaymentNotification_TransactionDetails_FailedTransaction_GENERIC -} - -type PaymentNotification_TransactionDetails_Transaction struct { - state protoimpl.MessageState `protogen:"open.v1"` - Status PaymentNotification_TransactionDetails_Transaction_Status `protobuf:"varint,1,opt,name=status,proto3,enum=signal.backup.PaymentNotification_TransactionDetails_Transaction_Status" json:"status,omitempty"` - // This identification is used to map the payment table to the ledger - // and is likely required otherwise we may have issues reconciling with - // the ledger - MobileCoinIdentification *PaymentNotification_TransactionDetails_MobileCoinTxoIdentification `protobuf:"bytes,2,opt,name=mobileCoinIdentification,proto3" json:"mobileCoinIdentification,omitempty"` - Timestamp *uint64 `protobuf:"varint,3,opt,name=timestamp,proto3,oneof" json:"timestamp,omitempty"` - BlockIndex *uint64 `protobuf:"varint,4,opt,name=blockIndex,proto3,oneof" json:"blockIndex,omitempty"` - BlockTimestamp *uint64 `protobuf:"varint,5,opt,name=blockTimestamp,proto3,oneof" json:"blockTimestamp,omitempty"` - Transaction []byte `protobuf:"bytes,6,opt,name=transaction,proto3,oneof" json:"transaction,omitempty"` // mobile coin blobs - Receipt []byte `protobuf:"bytes,7,opt,name=receipt,proto3,oneof" json:"receipt,omitempty"` // mobile coin blobs - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PaymentNotification_TransactionDetails_Transaction) Reset() { - *x = PaymentNotification_TransactionDetails_Transaction{} - mi := &file_backuppb_Backup_proto_msgTypes[117] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PaymentNotification_TransactionDetails_Transaction) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PaymentNotification_TransactionDetails_Transaction) ProtoMessage() {} - -func (x *PaymentNotification_TransactionDetails_Transaction) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[117] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PaymentNotification_TransactionDetails_Transaction.ProtoReflect.Descriptor instead. -func (*PaymentNotification_TransactionDetails_Transaction) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{19, 0, 2} -} - -func (x *PaymentNotification_TransactionDetails_Transaction) GetStatus() PaymentNotification_TransactionDetails_Transaction_Status { - if x != nil { - return x.Status - } - return PaymentNotification_TransactionDetails_Transaction_INITIAL -} - -func (x *PaymentNotification_TransactionDetails_Transaction) GetMobileCoinIdentification() *PaymentNotification_TransactionDetails_MobileCoinTxoIdentification { - if x != nil { - return x.MobileCoinIdentification - } - return nil -} - -func (x *PaymentNotification_TransactionDetails_Transaction) GetTimestamp() uint64 { - if x != nil && x.Timestamp != nil { - return *x.Timestamp - } - return 0 -} - -func (x *PaymentNotification_TransactionDetails_Transaction) GetBlockIndex() uint64 { - if x != nil && x.BlockIndex != nil { - return *x.BlockIndex - } - return 0 -} - -func (x *PaymentNotification_TransactionDetails_Transaction) GetBlockTimestamp() uint64 { - if x != nil && x.BlockTimestamp != nil { - return *x.BlockTimestamp - } - return 0 -} - -func (x *PaymentNotification_TransactionDetails_Transaction) GetTransaction() []byte { - if x != nil { - return x.Transaction - } - return nil -} - -func (x *PaymentNotification_TransactionDetails_Transaction) GetReceipt() []byte { - if x != nil { - return x.Receipt - } - return nil -} - -type ContactAttachment_Name struct { - state protoimpl.MessageState `protogen:"open.v1"` - GivenName string `protobuf:"bytes,1,opt,name=givenName,proto3" json:"givenName,omitempty"` - FamilyName string `protobuf:"bytes,2,opt,name=familyName,proto3" json:"familyName,omitempty"` - Prefix string `protobuf:"bytes,3,opt,name=prefix,proto3" json:"prefix,omitempty"` - Suffix string `protobuf:"bytes,4,opt,name=suffix,proto3" json:"suffix,omitempty"` - MiddleName string `protobuf:"bytes,5,opt,name=middleName,proto3" json:"middleName,omitempty"` - Nickname string `protobuf:"bytes,6,opt,name=nickname,proto3" json:"nickname,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ContactAttachment_Name) Reset() { - *x = ContactAttachment_Name{} - mi := &file_backuppb_Backup_proto_msgTypes[118] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ContactAttachment_Name) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ContactAttachment_Name) ProtoMessage() {} - -func (x *ContactAttachment_Name) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[118] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ContactAttachment_Name.ProtoReflect.Descriptor instead. -func (*ContactAttachment_Name) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{22, 0} -} - -func (x *ContactAttachment_Name) GetGivenName() string { - if x != nil { - return x.GivenName - } - return "" -} - -func (x *ContactAttachment_Name) GetFamilyName() string { - if x != nil { - return x.FamilyName - } - return "" -} - -func (x *ContactAttachment_Name) GetPrefix() string { - if x != nil { - return x.Prefix - } - return "" -} - -func (x *ContactAttachment_Name) GetSuffix() string { - if x != nil { - return x.Suffix - } - return "" -} - -func (x *ContactAttachment_Name) GetMiddleName() string { - if x != nil { - return x.MiddleName - } - return "" -} - -func (x *ContactAttachment_Name) GetNickname() string { - if x != nil { - return x.Nickname - } - return "" -} - -type ContactAttachment_Phone struct { - state protoimpl.MessageState `protogen:"open.v1"` - Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` - Type ContactAttachment_Phone_Type `protobuf:"varint,2,opt,name=type,proto3,enum=signal.backup.ContactAttachment_Phone_Type" json:"type,omitempty"` - Label string `protobuf:"bytes,3,opt,name=label,proto3" json:"label,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ContactAttachment_Phone) Reset() { - *x = ContactAttachment_Phone{} - mi := &file_backuppb_Backup_proto_msgTypes[119] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ContactAttachment_Phone) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ContactAttachment_Phone) ProtoMessage() {} - -func (x *ContactAttachment_Phone) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[119] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ContactAttachment_Phone.ProtoReflect.Descriptor instead. -func (*ContactAttachment_Phone) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{22, 1} -} - -func (x *ContactAttachment_Phone) GetValue() string { - if x != nil { - return x.Value - } - return "" -} - -func (x *ContactAttachment_Phone) GetType() ContactAttachment_Phone_Type { - if x != nil { - return x.Type - } - return ContactAttachment_Phone_UNKNOWN -} - -func (x *ContactAttachment_Phone) GetLabel() string { - if x != nil { - return x.Label - } - return "" -} - -type ContactAttachment_Email struct { - state protoimpl.MessageState `protogen:"open.v1"` - Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` - Type ContactAttachment_Email_Type `protobuf:"varint,2,opt,name=type,proto3,enum=signal.backup.ContactAttachment_Email_Type" json:"type,omitempty"` - Label string `protobuf:"bytes,3,opt,name=label,proto3" json:"label,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ContactAttachment_Email) Reset() { - *x = ContactAttachment_Email{} - mi := &file_backuppb_Backup_proto_msgTypes[120] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ContactAttachment_Email) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ContactAttachment_Email) ProtoMessage() {} - -func (x *ContactAttachment_Email) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[120] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ContactAttachment_Email.ProtoReflect.Descriptor instead. -func (*ContactAttachment_Email) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{22, 2} -} - -func (x *ContactAttachment_Email) GetValue() string { - if x != nil { - return x.Value - } - return "" -} - -func (x *ContactAttachment_Email) GetType() ContactAttachment_Email_Type { - if x != nil { - return x.Type - } - return ContactAttachment_Email_UNKNOWN -} - -func (x *ContactAttachment_Email) GetLabel() string { - if x != nil { - return x.Label - } - return "" -} - -type ContactAttachment_PostalAddress struct { - state protoimpl.MessageState `protogen:"open.v1"` - Type ContactAttachment_PostalAddress_Type `protobuf:"varint,1,opt,name=type,proto3,enum=signal.backup.ContactAttachment_PostalAddress_Type" json:"type,omitempty"` - Label string `protobuf:"bytes,2,opt,name=label,proto3" json:"label,omitempty"` - Street string `protobuf:"bytes,3,opt,name=street,proto3" json:"street,omitempty"` - Pobox string `protobuf:"bytes,4,opt,name=pobox,proto3" json:"pobox,omitempty"` - Neighborhood string `protobuf:"bytes,5,opt,name=neighborhood,proto3" json:"neighborhood,omitempty"` - City string `protobuf:"bytes,6,opt,name=city,proto3" json:"city,omitempty"` - Region string `protobuf:"bytes,7,opt,name=region,proto3" json:"region,omitempty"` - Postcode string `protobuf:"bytes,8,opt,name=postcode,proto3" json:"postcode,omitempty"` - Country string `protobuf:"bytes,9,opt,name=country,proto3" json:"country,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ContactAttachment_PostalAddress) Reset() { - *x = ContactAttachment_PostalAddress{} - mi := &file_backuppb_Backup_proto_msgTypes[121] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ContactAttachment_PostalAddress) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ContactAttachment_PostalAddress) ProtoMessage() {} - -func (x *ContactAttachment_PostalAddress) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[121] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ContactAttachment_PostalAddress.ProtoReflect.Descriptor instead. -func (*ContactAttachment_PostalAddress) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{22, 3} -} - -func (x *ContactAttachment_PostalAddress) GetType() ContactAttachment_PostalAddress_Type { - if x != nil { - return x.Type - } - return ContactAttachment_PostalAddress_UNKNOWN -} - -func (x *ContactAttachment_PostalAddress) GetLabel() string { - if x != nil { - return x.Label - } - return "" -} - -func (x *ContactAttachment_PostalAddress) GetStreet() string { - if x != nil { - return x.Street - } - return "" -} - -func (x *ContactAttachment_PostalAddress) GetPobox() string { - if x != nil { - return x.Pobox - } - return "" -} - -func (x *ContactAttachment_PostalAddress) GetNeighborhood() string { - if x != nil { - return x.Neighborhood - } - return "" -} - -func (x *ContactAttachment_PostalAddress) GetCity() string { - if x != nil { - return x.City - } - return "" -} - -func (x *ContactAttachment_PostalAddress) GetRegion() string { - if x != nil { - return x.Region - } - return "" -} - -func (x *ContactAttachment_PostalAddress) GetPostcode() string { - if x != nil { - return x.Postcode - } - return "" -} - -func (x *ContactAttachment_PostalAddress) GetCountry() string { - if x != nil { - return x.Country - } - return "" -} - -type FilePointer_LocatorInfo struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Must be non-empty if transitCdnKey or plaintextHash are set/nonempty. - // Otherwise must be empty. - Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - // Types that are valid to be assigned to IntegrityCheck: - // - // *FilePointer_LocatorInfo_PlaintextHash - // *FilePointer_LocatorInfo_EncryptedDigest - IntegrityCheck isFilePointer_LocatorInfo_IntegrityCheck `protobuf_oneof:"integrityCheck"` - // NB: This is the plaintext size, and empty content attachments are legal, so this - // may be zero even if transitCdnKey or mediaName are set/nonempty. - Size uint32 `protobuf:"varint,3,opt,name=size,proto3" json:"size,omitempty"` - // Either both transit cdn key and number are set or neither should be set. - // Upload timestamp is optional but should only be set if key/number are set. - TransitCdnKey *string `protobuf:"bytes,4,opt,name=transitCdnKey,proto3,oneof" json:"transitCdnKey,omitempty"` - TransitCdnNumber *uint32 `protobuf:"varint,5,opt,name=transitCdnNumber,proto3,oneof" json:"transitCdnNumber,omitempty"` - TransitTierUploadTimestamp *uint64 `protobuf:"varint,6,opt,name=transitTierUploadTimestamp,proto3,oneof" json:"transitTierUploadTimestamp,omitempty"` - // If present, the cdn number of the succesful upload to media tier. - // If unset, may still have been uploaded, and clients - // can discover the cdn number via the list endpoint. - // Exporting clients should set this as long as their subscription - // has not rotated since last upload; even if currently free tier. - MediaTierCdnNumber *uint32 `protobuf:"varint,7,opt,name=mediaTierCdnNumber,proto3,oneof" json:"mediaTierCdnNumber,omitempty"` - // Separate key used to encrypt this file for the local backup. - // Generally required for local backups. - // Missing field indicates attachment was not available locally - // when the backup was generated, but remote backup or transit - // info was available. - LocalKey []byte `protobuf:"bytes,9,opt,name=localKey,proto3,oneof" json:"localKey,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *FilePointer_LocatorInfo) Reset() { - *x = FilePointer_LocatorInfo{} - mi := &file_backuppb_Backup_proto_msgTypes[122] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *FilePointer_LocatorInfo) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*FilePointer_LocatorInfo) ProtoMessage() {} - -func (x *FilePointer_LocatorInfo) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[122] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use FilePointer_LocatorInfo.ProtoReflect.Descriptor instead. -func (*FilePointer_LocatorInfo) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{28, 0} -} - -func (x *FilePointer_LocatorInfo) GetKey() []byte { - if x != nil { - return x.Key - } - return nil -} - -func (x *FilePointer_LocatorInfo) GetIntegrityCheck() isFilePointer_LocatorInfo_IntegrityCheck { - if x != nil { - return x.IntegrityCheck - } - return nil -} - -func (x *FilePointer_LocatorInfo) GetPlaintextHash() []byte { - if x != nil { - if x, ok := x.IntegrityCheck.(*FilePointer_LocatorInfo_PlaintextHash); ok { - return x.PlaintextHash - } - } - return nil -} - -func (x *FilePointer_LocatorInfo) GetEncryptedDigest() []byte { - if x != nil { - if x, ok := x.IntegrityCheck.(*FilePointer_LocatorInfo_EncryptedDigest); ok { - return x.EncryptedDigest - } - } - return nil -} - -func (x *FilePointer_LocatorInfo) GetSize() uint32 { - if x != nil { - return x.Size - } - return 0 -} - -func (x *FilePointer_LocatorInfo) GetTransitCdnKey() string { - if x != nil && x.TransitCdnKey != nil { - return *x.TransitCdnKey - } - return "" -} - -func (x *FilePointer_LocatorInfo) GetTransitCdnNumber() uint32 { - if x != nil && x.TransitCdnNumber != nil { - return *x.TransitCdnNumber - } - return 0 -} - -func (x *FilePointer_LocatorInfo) GetTransitTierUploadTimestamp() uint64 { - if x != nil && x.TransitTierUploadTimestamp != nil { - return *x.TransitTierUploadTimestamp - } - return 0 -} - -func (x *FilePointer_LocatorInfo) GetMediaTierCdnNumber() uint32 { - if x != nil && x.MediaTierCdnNumber != nil { - return *x.MediaTierCdnNumber - } - return 0 -} - -func (x *FilePointer_LocatorInfo) GetLocalKey() []byte { - if x != nil { - return x.LocalKey - } - return nil -} - -type isFilePointer_LocatorInfo_IntegrityCheck interface { - isFilePointer_LocatorInfo_IntegrityCheck() -} - -type FilePointer_LocatorInfo_PlaintextHash struct { - // Set if file was at one point downloaded and its plaintextHash was calculated - PlaintextHash []byte `protobuf:"bytes,10,opt,name=plaintextHash,proto3,oneof"` -} - -type FilePointer_LocatorInfo_EncryptedDigest struct { - // Set if file has not been downloaded so its integrity has not been verified - // From the sender of the attachment - EncryptedDigest []byte `protobuf:"bytes,11,opt,name=encryptedDigest,proto3,oneof"` -} - -func (*FilePointer_LocatorInfo_PlaintextHash) isFilePointer_LocatorInfo_IntegrityCheck() {} - -func (*FilePointer_LocatorInfo_EncryptedDigest) isFilePointer_LocatorInfo_IntegrityCheck() {} - -type Quote_QuotedAttachment struct { - state protoimpl.MessageState `protogen:"open.v1"` - ContentType *string `protobuf:"bytes,1,opt,name=contentType,proto3,oneof" json:"contentType,omitempty"` - FileName *string `protobuf:"bytes,2,opt,name=fileName,proto3,oneof" json:"fileName,omitempty"` - Thumbnail *MessageAttachment `protobuf:"bytes,3,opt,name=thumbnail,proto3,oneof" json:"thumbnail,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Quote_QuotedAttachment) Reset() { - *x = Quote_QuotedAttachment{} - mi := &file_backuppb_Backup_proto_msgTypes[123] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Quote_QuotedAttachment) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Quote_QuotedAttachment) ProtoMessage() {} - -func (x *Quote_QuotedAttachment) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[123] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Quote_QuotedAttachment.ProtoReflect.Descriptor instead. -func (*Quote_QuotedAttachment) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{29, 0} -} - -func (x *Quote_QuotedAttachment) GetContentType() string { - if x != nil && x.ContentType != nil { - return *x.ContentType - } - return "" -} - -func (x *Quote_QuotedAttachment) GetFileName() string { - if x != nil && x.FileName != nil { - return *x.FileName - } - return "" -} - -func (x *Quote_QuotedAttachment) GetThumbnail() *MessageAttachment { - if x != nil { - return x.Thumbnail - } - return nil -} - -type Poll_PollOption struct { - state protoimpl.MessageState `protogen:"open.v1"` - Option string `protobuf:"bytes,1,opt,name=option,proto3" json:"option,omitempty"` // Between 1-100 characters - Votes []*Poll_PollOption_PollVote `protobuf:"bytes,2,rep,name=votes,proto3" json:"votes,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Poll_PollOption) Reset() { - *x = Poll_PollOption{} - mi := &file_backuppb_Backup_proto_msgTypes[124] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Poll_PollOption) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Poll_PollOption) ProtoMessage() {} - -func (x *Poll_PollOption) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[124] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Poll_PollOption.ProtoReflect.Descriptor instead. -func (*Poll_PollOption) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{32, 0} -} - -func (x *Poll_PollOption) GetOption() string { - if x != nil { - return x.Option - } - return "" -} - -func (x *Poll_PollOption) GetVotes() []*Poll_PollOption_PollVote { - if x != nil { - return x.Votes - } - return nil -} - -type Poll_PollOption_PollVote struct { - state protoimpl.MessageState `protogen:"open.v1"` - VoterId uint64 `protobuf:"varint,1,opt,name=voterId,proto3" json:"voterId,omitempty"` // A direct reference to Recipient proto id. Must be self or contact. - VoteCount uint32 `protobuf:"varint,2,opt,name=voteCount,proto3" json:"voteCount,omitempty"` // Tracks how many times you voted. - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Poll_PollOption_PollVote) Reset() { - *x = Poll_PollOption_PollVote{} - mi := &file_backuppb_Backup_proto_msgTypes[125] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Poll_PollOption_PollVote) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Poll_PollOption_PollVote) ProtoMessage() {} - -func (x *Poll_PollOption_PollVote) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[125] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Poll_PollOption_PollVote.ProtoReflect.Descriptor instead. -func (*Poll_PollOption_PollVote) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{32, 0, 0} -} - -func (x *Poll_PollOption_PollVote) GetVoterId() uint64 { - if x != nil { - return x.VoterId - } - return 0 -} - -func (x *Poll_PollOption_PollVote) GetVoteCount() uint32 { - if x != nil { - return x.VoteCount - } - return 0 -} - -type GroupChangeChatUpdate_Update struct { - state protoimpl.MessageState `protogen:"open.v1"` - // If unset, importers should consider it to be a GenericGroupUpdate with unset updaterAci - // - // Types that are valid to be assigned to Update: - // - // *GroupChangeChatUpdate_Update_GenericGroupUpdate - // *GroupChangeChatUpdate_Update_GroupCreationUpdate - // *GroupChangeChatUpdate_Update_GroupNameUpdate - // *GroupChangeChatUpdate_Update_GroupAvatarUpdate - // *GroupChangeChatUpdate_Update_GroupDescriptionUpdate - // *GroupChangeChatUpdate_Update_GroupMembershipAccessLevelChangeUpdate - // *GroupChangeChatUpdate_Update_GroupAttributesAccessLevelChangeUpdate - // *GroupChangeChatUpdate_Update_GroupAnnouncementOnlyChangeUpdate - // *GroupChangeChatUpdate_Update_GroupAdminStatusUpdate - // *GroupChangeChatUpdate_Update_GroupMemberLeftUpdate - // *GroupChangeChatUpdate_Update_GroupMemberRemovedUpdate - // *GroupChangeChatUpdate_Update_SelfInvitedToGroupUpdate - // *GroupChangeChatUpdate_Update_SelfInvitedOtherUserToGroupUpdate - // *GroupChangeChatUpdate_Update_GroupUnknownInviteeUpdate - // *GroupChangeChatUpdate_Update_GroupInvitationAcceptedUpdate - // *GroupChangeChatUpdate_Update_GroupInvitationDeclinedUpdate - // *GroupChangeChatUpdate_Update_GroupMemberJoinedUpdate - // *GroupChangeChatUpdate_Update_GroupMemberAddedUpdate - // *GroupChangeChatUpdate_Update_GroupSelfInvitationRevokedUpdate - // *GroupChangeChatUpdate_Update_GroupInvitationRevokedUpdate - // *GroupChangeChatUpdate_Update_GroupJoinRequestUpdate - // *GroupChangeChatUpdate_Update_GroupJoinRequestApprovalUpdate - // *GroupChangeChatUpdate_Update_GroupJoinRequestCanceledUpdate - // *GroupChangeChatUpdate_Update_GroupInviteLinkResetUpdate - // *GroupChangeChatUpdate_Update_GroupInviteLinkEnabledUpdate - // *GroupChangeChatUpdate_Update_GroupInviteLinkAdminApprovalUpdate - // *GroupChangeChatUpdate_Update_GroupInviteLinkDisabledUpdate - // *GroupChangeChatUpdate_Update_GroupMemberJoinedByLinkUpdate - // *GroupChangeChatUpdate_Update_GroupV2MigrationUpdate - // *GroupChangeChatUpdate_Update_GroupV2MigrationSelfInvitedUpdate - // *GroupChangeChatUpdate_Update_GroupV2MigrationInvitedMembersUpdate - // *GroupChangeChatUpdate_Update_GroupV2MigrationDroppedMembersUpdate - // *GroupChangeChatUpdate_Update_GroupSequenceOfRequestsAndCancelsUpdate - // *GroupChangeChatUpdate_Update_GroupExpirationTimerUpdate - // *GroupChangeChatUpdate_Update_GroupMemberLabelAccessLevelChangeUpdate - // *GroupChangeChatUpdate_Update_GroupTerminateChangeUpdate - Update isGroupChangeChatUpdate_Update_Update `protobuf_oneof:"update"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupChangeChatUpdate_Update) Reset() { - *x = GroupChangeChatUpdate_Update{} - mi := &file_backuppb_Backup_proto_msgTypes[126] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupChangeChatUpdate_Update) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupChangeChatUpdate_Update) ProtoMessage() {} - -func (x *GroupChangeChatUpdate_Update) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[126] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupChangeChatUpdate_Update.ProtoReflect.Descriptor instead. -func (*GroupChangeChatUpdate_Update) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{43, 0} -} - -func (x *GroupChangeChatUpdate_Update) GetUpdate() isGroupChangeChatUpdate_Update_Update { - if x != nil { - return x.Update - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGenericGroupUpdate() *GenericGroupUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GenericGroupUpdate); ok { - return x.GenericGroupUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupCreationUpdate() *GroupCreationUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupCreationUpdate); ok { - return x.GroupCreationUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupNameUpdate() *GroupNameUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupNameUpdate); ok { - return x.GroupNameUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupAvatarUpdate() *GroupAvatarUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupAvatarUpdate); ok { - return x.GroupAvatarUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupDescriptionUpdate() *GroupDescriptionUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupDescriptionUpdate); ok { - return x.GroupDescriptionUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupMembershipAccessLevelChangeUpdate() *GroupMembershipAccessLevelChangeUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupMembershipAccessLevelChangeUpdate); ok { - return x.GroupMembershipAccessLevelChangeUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupAttributesAccessLevelChangeUpdate() *GroupAttributesAccessLevelChangeUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupAttributesAccessLevelChangeUpdate); ok { - return x.GroupAttributesAccessLevelChangeUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupAnnouncementOnlyChangeUpdate() *GroupAnnouncementOnlyChangeUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupAnnouncementOnlyChangeUpdate); ok { - return x.GroupAnnouncementOnlyChangeUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupAdminStatusUpdate() *GroupAdminStatusUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupAdminStatusUpdate); ok { - return x.GroupAdminStatusUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupMemberLeftUpdate() *GroupMemberLeftUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupMemberLeftUpdate); ok { - return x.GroupMemberLeftUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupMemberRemovedUpdate() *GroupMemberRemovedUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupMemberRemovedUpdate); ok { - return x.GroupMemberRemovedUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetSelfInvitedToGroupUpdate() *SelfInvitedToGroupUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_SelfInvitedToGroupUpdate); ok { - return x.SelfInvitedToGroupUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetSelfInvitedOtherUserToGroupUpdate() *SelfInvitedOtherUserToGroupUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_SelfInvitedOtherUserToGroupUpdate); ok { - return x.SelfInvitedOtherUserToGroupUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupUnknownInviteeUpdate() *GroupUnknownInviteeUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupUnknownInviteeUpdate); ok { - return x.GroupUnknownInviteeUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupInvitationAcceptedUpdate() *GroupInvitationAcceptedUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupInvitationAcceptedUpdate); ok { - return x.GroupInvitationAcceptedUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupInvitationDeclinedUpdate() *GroupInvitationDeclinedUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupInvitationDeclinedUpdate); ok { - return x.GroupInvitationDeclinedUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupMemberJoinedUpdate() *GroupMemberJoinedUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupMemberJoinedUpdate); ok { - return x.GroupMemberJoinedUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupMemberAddedUpdate() *GroupMemberAddedUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupMemberAddedUpdate); ok { - return x.GroupMemberAddedUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupSelfInvitationRevokedUpdate() *GroupSelfInvitationRevokedUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupSelfInvitationRevokedUpdate); ok { - return x.GroupSelfInvitationRevokedUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupInvitationRevokedUpdate() *GroupInvitationRevokedUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupInvitationRevokedUpdate); ok { - return x.GroupInvitationRevokedUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupJoinRequestUpdate() *GroupJoinRequestUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupJoinRequestUpdate); ok { - return x.GroupJoinRequestUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupJoinRequestApprovalUpdate() *GroupJoinRequestApprovalUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupJoinRequestApprovalUpdate); ok { - return x.GroupJoinRequestApprovalUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupJoinRequestCanceledUpdate() *GroupJoinRequestCanceledUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupJoinRequestCanceledUpdate); ok { - return x.GroupJoinRequestCanceledUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupInviteLinkResetUpdate() *GroupInviteLinkResetUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupInviteLinkResetUpdate); ok { - return x.GroupInviteLinkResetUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupInviteLinkEnabledUpdate() *GroupInviteLinkEnabledUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupInviteLinkEnabledUpdate); ok { - return x.GroupInviteLinkEnabledUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupInviteLinkAdminApprovalUpdate() *GroupInviteLinkAdminApprovalUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupInviteLinkAdminApprovalUpdate); ok { - return x.GroupInviteLinkAdminApprovalUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupInviteLinkDisabledUpdate() *GroupInviteLinkDisabledUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupInviteLinkDisabledUpdate); ok { - return x.GroupInviteLinkDisabledUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupMemberJoinedByLinkUpdate() *GroupMemberJoinedByLinkUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupMemberJoinedByLinkUpdate); ok { - return x.GroupMemberJoinedByLinkUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupV2MigrationUpdate() *GroupV2MigrationUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupV2MigrationUpdate); ok { - return x.GroupV2MigrationUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupV2MigrationSelfInvitedUpdate() *GroupV2MigrationSelfInvitedUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupV2MigrationSelfInvitedUpdate); ok { - return x.GroupV2MigrationSelfInvitedUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupV2MigrationInvitedMembersUpdate() *GroupV2MigrationInvitedMembersUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupV2MigrationInvitedMembersUpdate); ok { - return x.GroupV2MigrationInvitedMembersUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupV2MigrationDroppedMembersUpdate() *GroupV2MigrationDroppedMembersUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupV2MigrationDroppedMembersUpdate); ok { - return x.GroupV2MigrationDroppedMembersUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupSequenceOfRequestsAndCancelsUpdate() *GroupSequenceOfRequestsAndCancelsUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupSequenceOfRequestsAndCancelsUpdate); ok { - return x.GroupSequenceOfRequestsAndCancelsUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupExpirationTimerUpdate() *GroupExpirationTimerUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupExpirationTimerUpdate); ok { - return x.GroupExpirationTimerUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupMemberLabelAccessLevelChangeUpdate() *GroupMemberLabelAccessLevelChangeUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupMemberLabelAccessLevelChangeUpdate); ok { - return x.GroupMemberLabelAccessLevelChangeUpdate - } - } - return nil -} - -func (x *GroupChangeChatUpdate_Update) GetGroupTerminateChangeUpdate() *GroupTerminateChangeUpdate { - if x != nil { - if x, ok := x.Update.(*GroupChangeChatUpdate_Update_GroupTerminateChangeUpdate); ok { - return x.GroupTerminateChangeUpdate - } - } - return nil -} - -type isGroupChangeChatUpdate_Update_Update interface { - isGroupChangeChatUpdate_Update_Update() -} - -type GroupChangeChatUpdate_Update_GenericGroupUpdate struct { - GenericGroupUpdate *GenericGroupUpdate `protobuf:"bytes,1,opt,name=genericGroupUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupCreationUpdate struct { - GroupCreationUpdate *GroupCreationUpdate `protobuf:"bytes,2,opt,name=groupCreationUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupNameUpdate struct { - GroupNameUpdate *GroupNameUpdate `protobuf:"bytes,3,opt,name=groupNameUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupAvatarUpdate struct { - GroupAvatarUpdate *GroupAvatarUpdate `protobuf:"bytes,4,opt,name=groupAvatarUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupDescriptionUpdate struct { - GroupDescriptionUpdate *GroupDescriptionUpdate `protobuf:"bytes,5,opt,name=groupDescriptionUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupMembershipAccessLevelChangeUpdate struct { - GroupMembershipAccessLevelChangeUpdate *GroupMembershipAccessLevelChangeUpdate `protobuf:"bytes,6,opt,name=groupMembershipAccessLevelChangeUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupAttributesAccessLevelChangeUpdate struct { - GroupAttributesAccessLevelChangeUpdate *GroupAttributesAccessLevelChangeUpdate `protobuf:"bytes,7,opt,name=groupAttributesAccessLevelChangeUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupAnnouncementOnlyChangeUpdate struct { - GroupAnnouncementOnlyChangeUpdate *GroupAnnouncementOnlyChangeUpdate `protobuf:"bytes,8,opt,name=groupAnnouncementOnlyChangeUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupAdminStatusUpdate struct { - GroupAdminStatusUpdate *GroupAdminStatusUpdate `protobuf:"bytes,9,opt,name=groupAdminStatusUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupMemberLeftUpdate struct { - GroupMemberLeftUpdate *GroupMemberLeftUpdate `protobuf:"bytes,10,opt,name=groupMemberLeftUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupMemberRemovedUpdate struct { - GroupMemberRemovedUpdate *GroupMemberRemovedUpdate `protobuf:"bytes,11,opt,name=groupMemberRemovedUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_SelfInvitedToGroupUpdate struct { - SelfInvitedToGroupUpdate *SelfInvitedToGroupUpdate `protobuf:"bytes,12,opt,name=selfInvitedToGroupUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_SelfInvitedOtherUserToGroupUpdate struct { - SelfInvitedOtherUserToGroupUpdate *SelfInvitedOtherUserToGroupUpdate `protobuf:"bytes,13,opt,name=selfInvitedOtherUserToGroupUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupUnknownInviteeUpdate struct { - GroupUnknownInviteeUpdate *GroupUnknownInviteeUpdate `protobuf:"bytes,14,opt,name=groupUnknownInviteeUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupInvitationAcceptedUpdate struct { - GroupInvitationAcceptedUpdate *GroupInvitationAcceptedUpdate `protobuf:"bytes,15,opt,name=groupInvitationAcceptedUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupInvitationDeclinedUpdate struct { - GroupInvitationDeclinedUpdate *GroupInvitationDeclinedUpdate `protobuf:"bytes,16,opt,name=groupInvitationDeclinedUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupMemberJoinedUpdate struct { - GroupMemberJoinedUpdate *GroupMemberJoinedUpdate `protobuf:"bytes,17,opt,name=groupMemberJoinedUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupMemberAddedUpdate struct { - GroupMemberAddedUpdate *GroupMemberAddedUpdate `protobuf:"bytes,18,opt,name=groupMemberAddedUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupSelfInvitationRevokedUpdate struct { - GroupSelfInvitationRevokedUpdate *GroupSelfInvitationRevokedUpdate `protobuf:"bytes,19,opt,name=groupSelfInvitationRevokedUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupInvitationRevokedUpdate struct { - GroupInvitationRevokedUpdate *GroupInvitationRevokedUpdate `protobuf:"bytes,20,opt,name=groupInvitationRevokedUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupJoinRequestUpdate struct { - GroupJoinRequestUpdate *GroupJoinRequestUpdate `protobuf:"bytes,21,opt,name=groupJoinRequestUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupJoinRequestApprovalUpdate struct { - GroupJoinRequestApprovalUpdate *GroupJoinRequestApprovalUpdate `protobuf:"bytes,22,opt,name=groupJoinRequestApprovalUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupJoinRequestCanceledUpdate struct { - GroupJoinRequestCanceledUpdate *GroupJoinRequestCanceledUpdate `protobuf:"bytes,23,opt,name=groupJoinRequestCanceledUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupInviteLinkResetUpdate struct { - GroupInviteLinkResetUpdate *GroupInviteLinkResetUpdate `protobuf:"bytes,24,opt,name=groupInviteLinkResetUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupInviteLinkEnabledUpdate struct { - GroupInviteLinkEnabledUpdate *GroupInviteLinkEnabledUpdate `protobuf:"bytes,25,opt,name=groupInviteLinkEnabledUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupInviteLinkAdminApprovalUpdate struct { - GroupInviteLinkAdminApprovalUpdate *GroupInviteLinkAdminApprovalUpdate `protobuf:"bytes,26,opt,name=groupInviteLinkAdminApprovalUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupInviteLinkDisabledUpdate struct { - GroupInviteLinkDisabledUpdate *GroupInviteLinkDisabledUpdate `protobuf:"bytes,27,opt,name=groupInviteLinkDisabledUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupMemberJoinedByLinkUpdate struct { - GroupMemberJoinedByLinkUpdate *GroupMemberJoinedByLinkUpdate `protobuf:"bytes,28,opt,name=groupMemberJoinedByLinkUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupV2MigrationUpdate struct { - GroupV2MigrationUpdate *GroupV2MigrationUpdate `protobuf:"bytes,29,opt,name=groupV2MigrationUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupV2MigrationSelfInvitedUpdate struct { - GroupV2MigrationSelfInvitedUpdate *GroupV2MigrationSelfInvitedUpdate `protobuf:"bytes,30,opt,name=groupV2MigrationSelfInvitedUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupV2MigrationInvitedMembersUpdate struct { - GroupV2MigrationInvitedMembersUpdate *GroupV2MigrationInvitedMembersUpdate `protobuf:"bytes,31,opt,name=groupV2MigrationInvitedMembersUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupV2MigrationDroppedMembersUpdate struct { - GroupV2MigrationDroppedMembersUpdate *GroupV2MigrationDroppedMembersUpdate `protobuf:"bytes,32,opt,name=groupV2MigrationDroppedMembersUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupSequenceOfRequestsAndCancelsUpdate struct { - GroupSequenceOfRequestsAndCancelsUpdate *GroupSequenceOfRequestsAndCancelsUpdate `protobuf:"bytes,33,opt,name=groupSequenceOfRequestsAndCancelsUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupExpirationTimerUpdate struct { - GroupExpirationTimerUpdate *GroupExpirationTimerUpdate `protobuf:"bytes,34,opt,name=groupExpirationTimerUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupMemberLabelAccessLevelChangeUpdate struct { - GroupMemberLabelAccessLevelChangeUpdate *GroupMemberLabelAccessLevelChangeUpdate `protobuf:"bytes,35,opt,name=groupMemberLabelAccessLevelChangeUpdate,proto3,oneof"` -} - -type GroupChangeChatUpdate_Update_GroupTerminateChangeUpdate struct { - GroupTerminateChangeUpdate *GroupTerminateChangeUpdate `protobuf:"bytes,36,opt,name=groupTerminateChangeUpdate,proto3,oneof"` -} - -func (*GroupChangeChatUpdate_Update_GenericGroupUpdate) isGroupChangeChatUpdate_Update_Update() {} - -func (*GroupChangeChatUpdate_Update_GroupCreationUpdate) isGroupChangeChatUpdate_Update_Update() {} - -func (*GroupChangeChatUpdate_Update_GroupNameUpdate) isGroupChangeChatUpdate_Update_Update() {} - -func (*GroupChangeChatUpdate_Update_GroupAvatarUpdate) isGroupChangeChatUpdate_Update_Update() {} - -func (*GroupChangeChatUpdate_Update_GroupDescriptionUpdate) isGroupChangeChatUpdate_Update_Update() {} - -func (*GroupChangeChatUpdate_Update_GroupMembershipAccessLevelChangeUpdate) isGroupChangeChatUpdate_Update_Update() { -} - -func (*GroupChangeChatUpdate_Update_GroupAttributesAccessLevelChangeUpdate) isGroupChangeChatUpdate_Update_Update() { -} - -func (*GroupChangeChatUpdate_Update_GroupAnnouncementOnlyChangeUpdate) isGroupChangeChatUpdate_Update_Update() { -} - -func (*GroupChangeChatUpdate_Update_GroupAdminStatusUpdate) isGroupChangeChatUpdate_Update_Update() {} - -func (*GroupChangeChatUpdate_Update_GroupMemberLeftUpdate) isGroupChangeChatUpdate_Update_Update() {} - -func (*GroupChangeChatUpdate_Update_GroupMemberRemovedUpdate) isGroupChangeChatUpdate_Update_Update() { -} - -func (*GroupChangeChatUpdate_Update_SelfInvitedToGroupUpdate) isGroupChangeChatUpdate_Update_Update() { -} - -func (*GroupChangeChatUpdate_Update_SelfInvitedOtherUserToGroupUpdate) isGroupChangeChatUpdate_Update_Update() { -} - -func (*GroupChangeChatUpdate_Update_GroupUnknownInviteeUpdate) isGroupChangeChatUpdate_Update_Update() { -} - -func (*GroupChangeChatUpdate_Update_GroupInvitationAcceptedUpdate) isGroupChangeChatUpdate_Update_Update() { -} - -func (*GroupChangeChatUpdate_Update_GroupInvitationDeclinedUpdate) isGroupChangeChatUpdate_Update_Update() { -} - -func (*GroupChangeChatUpdate_Update_GroupMemberJoinedUpdate) isGroupChangeChatUpdate_Update_Update() { -} - -func (*GroupChangeChatUpdate_Update_GroupMemberAddedUpdate) isGroupChangeChatUpdate_Update_Update() {} - -func (*GroupChangeChatUpdate_Update_GroupSelfInvitationRevokedUpdate) isGroupChangeChatUpdate_Update_Update() { -} - -func (*GroupChangeChatUpdate_Update_GroupInvitationRevokedUpdate) isGroupChangeChatUpdate_Update_Update() { -} - -func (*GroupChangeChatUpdate_Update_GroupJoinRequestUpdate) isGroupChangeChatUpdate_Update_Update() {} - -func (*GroupChangeChatUpdate_Update_GroupJoinRequestApprovalUpdate) isGroupChangeChatUpdate_Update_Update() { -} - -func (*GroupChangeChatUpdate_Update_GroupJoinRequestCanceledUpdate) isGroupChangeChatUpdate_Update_Update() { -} - -func (*GroupChangeChatUpdate_Update_GroupInviteLinkResetUpdate) isGroupChangeChatUpdate_Update_Update() { -} - -func (*GroupChangeChatUpdate_Update_GroupInviteLinkEnabledUpdate) isGroupChangeChatUpdate_Update_Update() { -} - -func (*GroupChangeChatUpdate_Update_GroupInviteLinkAdminApprovalUpdate) isGroupChangeChatUpdate_Update_Update() { -} - -func (*GroupChangeChatUpdate_Update_GroupInviteLinkDisabledUpdate) isGroupChangeChatUpdate_Update_Update() { -} - -func (*GroupChangeChatUpdate_Update_GroupMemberJoinedByLinkUpdate) isGroupChangeChatUpdate_Update_Update() { -} - -func (*GroupChangeChatUpdate_Update_GroupV2MigrationUpdate) isGroupChangeChatUpdate_Update_Update() {} - -func (*GroupChangeChatUpdate_Update_GroupV2MigrationSelfInvitedUpdate) isGroupChangeChatUpdate_Update_Update() { -} - -func (*GroupChangeChatUpdate_Update_GroupV2MigrationInvitedMembersUpdate) isGroupChangeChatUpdate_Update_Update() { -} - -func (*GroupChangeChatUpdate_Update_GroupV2MigrationDroppedMembersUpdate) isGroupChangeChatUpdate_Update_Update() { -} - -func (*GroupChangeChatUpdate_Update_GroupSequenceOfRequestsAndCancelsUpdate) isGroupChangeChatUpdate_Update_Update() { -} - -func (*GroupChangeChatUpdate_Update_GroupExpirationTimerUpdate) isGroupChangeChatUpdate_Update_Update() { -} - -func (*GroupChangeChatUpdate_Update_GroupMemberLabelAccessLevelChangeUpdate) isGroupChangeChatUpdate_Update_Update() { -} - -func (*GroupChangeChatUpdate_Update_GroupTerminateChangeUpdate) isGroupChangeChatUpdate_Update_Update() { -} - -type GroupInvitationRevokedUpdate_Invitee struct { - state protoimpl.MessageState `protogen:"open.v1"` - InviterAci []byte `protobuf:"bytes,1,opt,name=inviterAci,proto3,oneof" json:"inviterAci,omitempty"` - // Prefer to use aci over pni. No need to set - // pni if aci is set. Both can be missing. - InviteeAci []byte `protobuf:"bytes,2,opt,name=inviteeAci,proto3,oneof" json:"inviteeAci,omitempty"` - InviteePni []byte `protobuf:"bytes,3,opt,name=inviteePni,proto3,oneof" json:"inviteePni,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupInvitationRevokedUpdate_Invitee) Reset() { - *x = GroupInvitationRevokedUpdate_Invitee{} - mi := &file_backuppb_Backup_proto_msgTypes[127] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupInvitationRevokedUpdate_Invitee) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupInvitationRevokedUpdate_Invitee) ProtoMessage() {} - -func (x *GroupInvitationRevokedUpdate_Invitee) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[127] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GroupInvitationRevokedUpdate_Invitee.ProtoReflect.Descriptor instead. -func (*GroupInvitationRevokedUpdate_Invitee) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{65, 0} -} - -func (x *GroupInvitationRevokedUpdate_Invitee) GetInviterAci() []byte { - if x != nil { - return x.InviterAci - } - return nil -} - -func (x *GroupInvitationRevokedUpdate_Invitee) GetInviteeAci() []byte { - if x != nil { - return x.InviteeAci - } - return nil -} - -func (x *GroupInvitationRevokedUpdate_Invitee) GetInviteePni() []byte { - if x != nil { - return x.InviteePni - } - return nil -} - -type ChatStyle_Gradient struct { - state protoimpl.MessageState `protogen:"open.v1"` - Angle uint32 `protobuf:"varint,1,opt,name=angle,proto3" json:"angle,omitempty"` // degrees - Colors []uint32 `protobuf:"fixed32,2,rep,packed,name=colors,proto3" json:"colors,omitempty"` // 0xAARRGGBB - Positions []float32 `protobuf:"fixed32,3,rep,packed,name=positions,proto3" json:"positions,omitempty"` // percent from 0 to 1 - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ChatStyle_Gradient) Reset() { - *x = ChatStyle_Gradient{} - mi := &file_backuppb_Backup_proto_msgTypes[128] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ChatStyle_Gradient) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ChatStyle_Gradient) ProtoMessage() {} - -func (x *ChatStyle_Gradient) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[128] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ChatStyle_Gradient.ProtoReflect.Descriptor instead. -func (*ChatStyle_Gradient) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{83, 0} -} - -func (x *ChatStyle_Gradient) GetAngle() uint32 { - if x != nil { - return x.Angle - } - return 0 -} - -func (x *ChatStyle_Gradient) GetColors() []uint32 { - if x != nil { - return x.Colors - } - return nil -} - -func (x *ChatStyle_Gradient) GetPositions() []float32 { - if x != nil { - return x.Positions - } - return nil -} - -type ChatStyle_CustomChatColor struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // If unset, use the default chat color - // - // Types that are valid to be assigned to Color: - // - // *ChatStyle_CustomChatColor_Solid - // *ChatStyle_CustomChatColor_Gradient - Color isChatStyle_CustomChatColor_Color `protobuf_oneof:"color"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ChatStyle_CustomChatColor) Reset() { - *x = ChatStyle_CustomChatColor{} - mi := &file_backuppb_Backup_proto_msgTypes[129] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ChatStyle_CustomChatColor) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ChatStyle_CustomChatColor) ProtoMessage() {} - -func (x *ChatStyle_CustomChatColor) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[129] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ChatStyle_CustomChatColor.ProtoReflect.Descriptor instead. -func (*ChatStyle_CustomChatColor) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{83, 1} -} - -func (x *ChatStyle_CustomChatColor) GetId() uint64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *ChatStyle_CustomChatColor) GetColor() isChatStyle_CustomChatColor_Color { - if x != nil { - return x.Color - } - return nil -} - -func (x *ChatStyle_CustomChatColor) GetSolid() uint32 { - if x != nil { - if x, ok := x.Color.(*ChatStyle_CustomChatColor_Solid); ok { - return x.Solid - } - } - return 0 -} - -func (x *ChatStyle_CustomChatColor) GetGradient() *ChatStyle_Gradient { - if x != nil { - if x, ok := x.Color.(*ChatStyle_CustomChatColor_Gradient); ok { - return x.Gradient - } - } - return nil -} - -type isChatStyle_CustomChatColor_Color interface { - isChatStyle_CustomChatColor_Color() -} - -type ChatStyle_CustomChatColor_Solid struct { - Solid uint32 `protobuf:"fixed32,2,opt,name=solid,proto3,oneof"` // 0xAARRGGBB -} - -type ChatStyle_CustomChatColor_Gradient struct { - Gradient *ChatStyle_Gradient `protobuf:"bytes,3,opt,name=gradient,proto3,oneof"` -} - -func (*ChatStyle_CustomChatColor_Solid) isChatStyle_CustomChatColor_Color() {} - -func (*ChatStyle_CustomChatColor_Gradient) isChatStyle_CustomChatColor_Color() {} - -type ChatStyle_AutomaticBubbleColor struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ChatStyle_AutomaticBubbleColor) Reset() { - *x = ChatStyle_AutomaticBubbleColor{} - mi := &file_backuppb_Backup_proto_msgTypes[130] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ChatStyle_AutomaticBubbleColor) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ChatStyle_AutomaticBubbleColor) ProtoMessage() {} - -func (x *ChatStyle_AutomaticBubbleColor) ProtoReflect() protoreflect.Message { - mi := &file_backuppb_Backup_proto_msgTypes[130] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ChatStyle_AutomaticBubbleColor.ProtoReflect.Descriptor instead. -func (*ChatStyle_AutomaticBubbleColor) Descriptor() ([]byte, []int) { - return file_backuppb_Backup_proto_rawDescGZIP(), []int{83, 2} -} - -var File_backuppb_Backup_proto protoreflect.FileDescriptor - -const file_backuppb_Backup_proto_rawDesc = "" + - "\n" + - "\x15backuppb/Backup.proto\x12\rsignal.backup\"\xf0\x01\n" + - "\n" + - "BackupInfo\x12\x18\n" + - "\aversion\x18\x01 \x01(\x04R\aversion\x12\"\n" + - "\fbackupTimeMs\x18\x02 \x01(\x04R\fbackupTimeMs\x12.\n" + - "\x12mediaRootBackupKey\x18\x03 \x01(\fR\x12mediaRootBackupKey\x12,\n" + - "\x11currentAppVersion\x18\x04 \x01(\tR\x11currentAppVersion\x12(\n" + - "\x0ffirstAppVersion\x18\x05 \x01(\tR\x0ffirstAppVersion\x12\x1c\n" + - "\tdebugInfo\x18\x06 \x01(\fR\tdebugInfo\"\xf2\x03\n" + - "\x05Frame\x126\n" + - "\aaccount\x18\x01 \x01(\v2\x1a.signal.backup.AccountDataH\x00R\aaccount\x128\n" + - "\trecipient\x18\x02 \x01(\v2\x18.signal.backup.RecipientH\x00R\trecipient\x12)\n" + - "\x04chat\x18\x03 \x01(\v2\x13.signal.backup.ChatH\x00R\x04chat\x125\n" + - "\bchatItem\x18\x04 \x01(\v2\x17.signal.backup.ChatItemH\x00R\bchatItem\x12>\n" + - "\vstickerPack\x18\x05 \x01(\v2\x1a.signal.backup.StickerPackH\x00R\vstickerPack\x128\n" + - "\tadHocCall\x18\x06 \x01(\v2\x18.signal.backup.AdHocCallH\x00R\tadHocCall\x12V\n" + - "\x13notificationProfile\x18\a \x01(\v2\".signal.backup.NotificationProfileH\x00R\x13notificationProfile\x12;\n" + - "\n" + - "chatFolder\x18\b \x01(\v2\x19.signal.backup.ChatFolderH\x00R\n" + - "chatFolderB\x06\n" + - "\x04item\"\xc7#\n" + - "\vAccountData\x12\x1e\n" + - "\n" + - "profileKey\x18\x01 \x01(\fR\n" + - "profileKey\x12\x1f\n" + - "\busername\x18\x02 \x01(\tH\x00R\busername\x88\x01\x01\x12K\n" + - "\fusernameLink\x18\x03 \x01(\v2'.signal.backup.AccountData.UsernameLinkR\fusernameLink\x12\x1c\n" + - "\tgivenName\x18\x04 \x01(\tR\tgivenName\x12\x1e\n" + - "\n" + - "familyName\x18\x05 \x01(\tR\n" + - "familyName\x12$\n" + - "\ravatarUrlPath\x18\x06 \x01(\tR\ravatarUrlPath\x12a\n" + - "\x16donationSubscriberData\x18\a \x01(\v2).signal.backup.AccountData.SubscriberDataR\x16donationSubscriberData\x12T\n" + - "\x0faccountSettings\x18\t \x01(\v2*.signal.backup.AccountData.AccountSettingsR\x0faccountSettings\x12b\n" + - "\x15backupsSubscriberData\x18\n" + - " \x01(\v2,.signal.backup.AccountData.IAPSubscriberDataR\x15backupsSubscriberData\x12\x16\n" + - "\x06svrPin\x18\v \x01(\tR\x06svrPin\x12l\n" + - "\x17androidSpecificSettings\x18\f \x01(\v22.signal.backup.AccountData.AndroidSpecificSettingsR\x17androidSpecificSettings\x12\x18\n" + - "\abioText\x18\r \x01(\tR\abioText\x12\x1a\n" + - "\bbioEmoji\x18\x0e \x01(\tR\bbioEmoji\x125\n" + - "\x13keyTransparencyData\x18\x0f \x01(\fH\x01R\x13keyTransparencyData\x88\x01\x01\x1a\xf6\x01\n" + - "\fUsernameLink\x12\x18\n" + - "\aentropy\x18\x01 \x01(\fR\aentropy\x12\x1a\n" + - "\bserverId\x18\x02 \x01(\fR\bserverId\x12C\n" + - "\x05color\x18\x03 \x01(\x0e2-.signal.backup.AccountData.UsernameLink.ColorR\x05color\"k\n" + - "\x05Color\x12\v\n" + - "\aUNKNOWN\x10\x00\x12\b\n" + - "\x04BLUE\x10\x01\x12\t\n" + - "\x05WHITE\x10\x02\x12\b\n" + - "\x04GREY\x10\x03\x12\t\n" + - "\x05OLIVE\x10\x04\x12\t\n" + - "\x05GREEN\x10\x05\x12\n" + - "\n" + - "\x06ORANGE\x10\x06\x12\b\n" + - "\x04PINK\x10\a\x12\n" + - "\n" + - "\x06PURPLE\x10\b\x1a\xd7\x03\n" + - "\x14AutoDownloadSettings\x12Z\n" + - "\x06images\x18\x01 \x01(\x0e2B.signal.backup.AccountData.AutoDownloadSettings.AutoDownloadOptionR\x06images\x12X\n" + - "\x05audio\x18\x02 \x01(\x0e2B.signal.backup.AccountData.AutoDownloadSettings.AutoDownloadOptionR\x05audio\x12X\n" + - "\x05video\x18\x03 \x01(\x0e2B.signal.backup.AccountData.AutoDownloadSettings.AutoDownloadOptionR\x05video\x12`\n" + - "\tdocuments\x18\x04 \x01(\x0e2B.signal.backup.AccountData.AutoDownloadSettings.AutoDownloadOptionR\tdocuments\"M\n" + - "\x12AutoDownloadOption\x12\v\n" + - "\aUNKNOWN\x10\x00\x12\t\n" + - "\x05NEVER\x10\x01\x12\b\n" + - "\x04WIFI\x10\x02\x12\x15\n" + - "\x11WIFI_AND_CELLULAR\x10\x03\x1a\x97\x10\n" + - "\x0fAccountSettings\x12\"\n" + - "\freadReceipts\x18\x01 \x01(\bR\freadReceipts\x126\n" + - "\x16sealedSenderIndicators\x18\x02 \x01(\bR\x16sealedSenderIndicators\x12*\n" + - "\x10typingIndicators\x18\x03 \x01(\bR\x10typingIndicators\x12\"\n" + - "\flinkPreviews\x18\x04 \x01(\bR\flinkPreviews\x12B\n" + - "\x1cnotDiscoverableByPhoneNumber\x18\x05 \x01(\bR\x1cnotDiscoverableByPhoneNumber\x122\n" + - "\x14preferContactAvatars\x18\x06 \x01(\bR\x14preferContactAvatars\x12@\n" + - "\x1buniversalExpireTimerSeconds\x18\a \x01(\rR\x1buniversalExpireTimerSeconds\x126\n" + - "\x16preferredReactionEmoji\x18\b \x03(\tR\x16preferredReactionEmoji\x126\n" + - "\x16displayBadgesOnProfile\x18\t \x01(\bR\x16displayBadgesOnProfile\x126\n" + - "\x16keepMutedChatsArchived\x18\n" + - " \x01(\bR\x16keepMutedChatsArchived\x126\n" + - "\x16hasSetMyStoriesPrivacy\x18\v \x01(\bR\x16hasSetMyStoriesPrivacy\x12:\n" + - "\x18hasViewedOnboardingStory\x18\f \x01(\bR\x18hasViewedOnboardingStory\x12(\n" + - "\x0fstoriesDisabled\x18\r \x01(\bR\x0fstoriesDisabled\x12?\n" + - "\x18storyViewReceiptsEnabled\x18\x0e \x01(\bH\x00R\x18storyViewReceiptsEnabled\x88\x01\x01\x12H\n" + - "\x1fhasSeenGroupStoryEducationSheet\x18\x0f \x01(\bR\x1fhasSeenGroupStoryEducationSheet\x12F\n" + - "\x1ehasCompletedUsernameOnboarding\x18\x10 \x01(\bR\x1ehasCompletedUsernameOnboarding\x12i\n" + - "\x16phoneNumberSharingMode\x18\x11 \x01(\x0e21.signal.backup.AccountData.PhoneNumberSharingModeR\x16phoneNumberSharingMode\x12D\n" + - "\x10defaultChatStyle\x18\x12 \x01(\v2\x18.signal.backup.ChatStyleR\x10defaultChatStyle\x12T\n" + - "\x10customChatColors\x18\x13 \x03(\v2(.signal.backup.ChatStyle.CustomChatColorR\x10customChatColors\x128\n" + - "\x17optimizeOnDeviceStorage\x18\x14 \x01(\bR\x17optimizeOnDeviceStorage\x12#\n" + - "\n" + - "backupTier\x18\x15 \x01(\x04H\x01R\n" + - "backupTier\x88\x01\x01\x12e\n" + - "\x17defaultSentMediaQuality\x18\x17 \x01(\x0e2+.signal.backup.AccountData.SentMediaQualityR\x17defaultSentMediaQuality\x12c\n" + - "\x14autoDownloadSettings\x18\x18 \x01(\v2/.signal.backup.AccountData.AutoDownloadSettingsR\x14autoDownloadSettings\x12?\n" + - "\x18screenLockTimeoutMinutes\x18\x1a \x01(\rH\x02R\x18screenLockTimeoutMinutes\x88\x01\x01\x12'\n" + - "\fpinReminders\x18\x1b \x01(\bH\x03R\fpinReminders\x88\x01\x01\x12?\n" + - "\bappTheme\x18\x1c \x01(\x0e2#.signal.backup.AccountData.AppThemeR\bappTheme\x12l\n" + - "\x17callsUseLessDataSetting\x18\x1d \x01(\x0e22.signal.backup.AccountData.CallsUseLessDataSettingR\x17callsUseLessDataSetting\x12@\n" + - "\x1ballowSealedSenderFromAnyone\x18\x1e \x01(\bR\x1ballowSealedSenderFromAnyone\x12D\n" + - "\x1dallowAutomaticKeyVerification\x18\x1f \x01(\bR\x1dallowAutomaticKeyVerification\x12L\n" + - "!hasSeenAdminDeleteEducationDialog\x18 \x01(\bR!hasSeenAdminDeleteEducationDialogB\x1b\n" + - "\x19_storyViewReceiptsEnabledB\r\n" + - "\v_backupTierB\x1b\n" + - "\x19_screenLockTimeoutMinutesB\x0f\n" + - "\r_pinRemindersJ\x04\b\x16\x10\x17J\x04\b\x19\x10\x1a\x1a\x86\x01\n" + - "\x0eSubscriberData\x12\"\n" + - "\fsubscriberId\x18\x01 \x01(\fR\fsubscriberId\x12\"\n" + - "\fcurrencyCode\x18\x02 \x01(\tR\fcurrencyCode\x12,\n" + - "\x11manuallyCancelled\x18\x03 \x01(\bR\x11manuallyCancelled\x1a\xac\x01\n" + - "\x11IAPSubscriberData\x12\"\n" + - "\fsubscriberId\x18\x01 \x01(\fR\fsubscriberId\x12&\n" + - "\rpurchaseToken\x18\x02 \x01(\tH\x00R\rpurchaseToken\x126\n" + - "\x15originalTransactionId\x18\x03 \x01(\x04H\x00R\x15originalTransactionIdB\x13\n" + - "\x11iapSubscriptionId\x1a\xa9\x02\n" + - "\x17AndroidSpecificSettings\x12&\n" + - "\x0euseSystemEmoji\x18\x01 \x01(\bR\x0euseSystemEmoji\x12.\n" + - "\x12screenshotSecurity\x18\x02 \x01(\bR\x12screenshotSecurity\x12r\n" + - "\x11navigationBarSize\x18\x03 \x01(\x0e2D.signal.backup.AccountData.AndroidSpecificSettings.NavigationBarSizeR\x11navigationBarSize\"B\n" + - "\x11NavigationBarSize\x12\x14\n" + - "\x10UNKNOWN_BAR_SIZE\x10\x00\x12\n" + - "\n" + - "\x06NORMAL\x10\x01\x12\v\n" + - "\aCOMPACT\x10\x02\"@\n" + - "\x16PhoneNumberSharingMode\x12\v\n" + - "\aUNKNOWN\x10\x00\x12\r\n" + - "\tEVERYBODY\x10\x01\x12\n" + - "\n" + - "\x06NOBODY\x10\x02\"?\n" + - "\x10SentMediaQuality\x12\x13\n" + - "\x0fUNKNOWN_QUALITY\x10\x00\x12\f\n" + - "\bSTANDARD\x10\x01\x12\b\n" + - "\x04HIGH\x10\x02\"B\n" + - "\bAppTheme\x12\x15\n" + - "\x11UNKNOWN_APP_THEME\x10\x00\x12\n" + - "\n" + - "\x06SYSTEM\x10\x01\x12\t\n" + - "\x05LIGHT\x10\x02\x12\b\n" + - "\x04DARK\x10\x03\"s\n" + - "\x17CallsUseLessDataSetting\x12\x1d\n" + - "\x19UNKNOWN_CALL_DATA_SETTING\x10\x00\x12\t\n" + - "\x05NEVER\x10\x01\x12\x14\n" + - "\x10MOBILE_DATA_ONLY\x10\x02\x12\x18\n" + - "\x14WIFI_AND_MOBILE_DATA\x10\x03B\v\n" + - "\t_usernameB\x16\n" + - "\x14_keyTransparencyDataJ\x04\b\b\x10\t\"\x84\x03\n" + - "\tRecipient\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x04R\x02id\x122\n" + - "\acontact\x18\x02 \x01(\v2\x16.signal.backup.ContactH\x00R\acontact\x12,\n" + - "\x05group\x18\x03 \x01(\v2\x14.signal.backup.GroupH\x00R\x05group\x12Q\n" + - "\x10distributionList\x18\x04 \x01(\v2#.signal.backup.DistributionListItemH\x00R\x10distributionList\x12)\n" + - "\x04self\x18\x05 \x01(\v2\x13.signal.backup.SelfH\x00R\x04self\x12A\n" + - "\freleaseNotes\x18\x06 \x01(\v2\x1b.signal.backup.ReleaseNotesH\x00R\freleaseNotes\x125\n" + - "\bcallLink\x18\a \x01(\v2\x17.signal.backup.CallLinkH\x00R\bcallLinkB\r\n" + - "\vdestination\"\x9a\v\n" + - "\aContact\x12\x15\n" + - "\x03aci\x18\x01 \x01(\fH\x01R\x03aci\x88\x01\x01\x12\x15\n" + - "\x03pni\x18\x02 \x01(\fH\x02R\x03pni\x88\x01\x01\x12\x1f\n" + - "\busername\x18\x03 \x01(\tH\x03R\busername\x88\x01\x01\x12\x17\n" + - "\x04e164\x18\x04 \x01(\x04H\x04R\x04e164\x88\x01\x01\x12\x18\n" + - "\ablocked\x18\x05 \x01(\bR\ablocked\x12A\n" + - "\n" + - "visibility\x18\x06 \x01(\x0e2!.signal.backup.Contact.VisibilityR\n" + - "visibility\x12C\n" + - "\n" + - "registered\x18\a \x01(\v2!.signal.backup.Contact.RegisteredH\x00R\n" + - "registered\x12L\n" + - "\rnotRegistered\x18\b \x01(\v2$.signal.backup.Contact.NotRegisteredH\x00R\rnotRegistered\x12#\n" + - "\n" + - "profileKey\x18\t \x01(\fH\x05R\n" + - "profileKey\x88\x01\x01\x12&\n" + - "\x0eprofileSharing\x18\n" + - " \x01(\bR\x0eprofileSharing\x12/\n" + - "\x10profileGivenName\x18\v \x01(\tH\x06R\x10profileGivenName\x88\x01\x01\x121\n" + - "\x11profileFamilyName\x18\f \x01(\tH\aR\x11profileFamilyName\x88\x01\x01\x12\x1c\n" + - "\thideStory\x18\r \x01(\bR\thideStory\x12%\n" + - "\videntityKey\x18\x0e \x01(\fH\bR\videntityKey\x88\x01\x01\x12J\n" + - "\ridentityState\x18\x0f \x01(\x0e2$.signal.backup.Contact.IdentityStateR\ridentityState\x127\n" + - "\bnickname\x18\x10 \x01(\v2\x1b.signal.backup.Contact.NameR\bnickname\x12\x12\n" + - "\x04note\x18\x11 \x01(\tR\x04note\x12(\n" + - "\x0fsystemGivenName\x18\x12 \x01(\tR\x0fsystemGivenName\x12*\n" + - "\x10systemFamilyName\x18\x13 \x01(\tR\x10systemFamilyName\x12&\n" + - "\x0esystemNickname\x18\x14 \x01(\tR\x0esystemNickname\x12A\n" + - "\vavatarColor\x18\x15 \x01(\x0e2\x1a.signal.backup.AvatarColorH\tR\vavatarColor\x88\x01\x01\x125\n" + - "\x13keyTransparencyData\x18\x16 \x01(\fH\n" + - "R\x13keyTransparencyData\x88\x01\x01\x1a\f\n" + - "\n" + - "Registered\x1aE\n" + - "\rNotRegistered\x124\n" + - "\x15unregisteredTimestamp\x18\x01 \x01(\x04R\x15unregisteredTimestamp\x1a4\n" + - "\x04Name\x12\x14\n" + - "\x05given\x18\x01 \x01(\tR\x05given\x12\x16\n" + - "\x06family\x18\x02 \x01(\tR\x06family\":\n" + - "\rIdentityState\x12\v\n" + - "\aDEFAULT\x10\x00\x12\f\n" + - "\bVERIFIED\x10\x01\x12\x0e\n" + - "\n" + - "UNVERIFIED\x10\x02\"A\n" + - "\n" + - "Visibility\x12\v\n" + - "\aVISIBLE\x10\x00\x12\n" + - "\n" + - "\x06HIDDEN\x10\x01\x12\x1a\n" + - "\x16HIDDEN_MESSAGE_REQUEST\x10\x02B\x0e\n" + - "\fregistrationB\x06\n" + - "\x04_aciB\x06\n" + - "\x04_pniB\v\n" + - "\t_usernameB\a\n" + - "\x05_e164B\r\n" + - "\v_profileKeyB\x13\n" + - "\x11_profileGivenNameB\x14\n" + - "\x12_profileFamilyNameB\x0e\n" + - "\f_identityKeyB\x0e\n" + - "\f_avatarColorB\x16\n" + - "\x14_keyTransparencyData\"\xc6\x13\n" + - "\x05Group\x12\x1c\n" + - "\tmasterKey\x18\x01 \x01(\fR\tmasterKey\x12 \n" + - "\vwhitelisted\x18\x02 \x01(\bR\vwhitelisted\x12\x1c\n" + - "\thideStory\x18\x03 \x01(\bR\thideStory\x12H\n" + - "\rstorySendMode\x18\x04 \x01(\x0e2\".signal.backup.Group.StorySendModeR\rstorySendMode\x12>\n" + - "\bsnapshot\x18\x05 \x01(\v2\".signal.backup.Group.GroupSnapshotR\bsnapshot\x12\x18\n" + - "\ablocked\x18\x06 \x01(\bR\ablocked\x12A\n" + - "\vavatarColor\x18\a \x01(\x0e2\x1a.signal.backup.AvatarColorH\x00R\vavatarColor\x88\x01\x01\x1a\xe5\x06\n" + - "\rGroupSnapshot\x12=\n" + - "\x05title\x18\x02 \x01(\v2'.signal.backup.Group.GroupAttributeBlobR\x05title\x12I\n" + - "\vdescription\x18\v \x01(\v2'.signal.backup.Group.GroupAttributeBlobR\vdescription\x12\x1c\n" + - "\tavatarUrl\x18\x03 \x01(\tR\tavatarUrl\x12e\n" + - "\x19disappearingMessagesTimer\x18\x04 \x01(\v2'.signal.backup.Group.GroupAttributeBlobR\x19disappearingMessagesTimer\x12H\n" + - "\raccessControl\x18\x05 \x01(\v2\".signal.backup.Group.AccessControlR\raccessControl\x12\x18\n" + - "\aversion\x18\x06 \x01(\rR\aversion\x125\n" + - "\amembers\x18\a \x03(\v2\x1b.signal.backup.Group.MemberR\amembers\x12h\n" + - "\x18membersPendingProfileKey\x18\b \x03(\v2,.signal.backup.Group.MemberPendingProfileKeyR\x18membersPendingProfileKey\x12q\n" + - "\x1bmembersPendingAdminApproval\x18\t \x03(\v2/.signal.backup.Group.MemberPendingAdminApprovalR\x1bmembersPendingAdminApproval\x12.\n" + - "\x12inviteLinkPassword\x18\n" + - " \x01(\fR\x12inviteLinkPassword\x12-\n" + - "\x12announcements_only\x18\f \x01(\bR\x11announcementsOnly\x12H\n" + - "\x0emembers_banned\x18\r \x03(\v2!.signal.backup.Group.MemberBannedR\rmembersBanned\x12\x1e\n" + - "\n" + - "terminated\x18\x0e \x01(\bR\n" + - "terminatedJ\x04\b\x01\x10\x02\x1a\xc3\x01\n" + - "\x12GroupAttributeBlob\x12\x16\n" + - "\x05title\x18\x01 \x01(\tH\x00R\x05title\x12\x18\n" + - "\x06avatar\x18\x02 \x01(\fH\x00R\x06avatar\x12D\n" + - "\x1cdisappearingMessagesDuration\x18\x03 \x01(\rH\x00R\x1cdisappearingMessagesDuration\x12*\n" + - "\x0fdescriptionText\x18\x04 \x01(\tH\x00R\x0fdescriptionTextB\t\n" + - "\acontent\x1a\x83\x02\n" + - "\x06Member\x12\x16\n" + - "\x06userId\x18\x01 \x01(\fR\x06userId\x124\n" + - "\x04role\x18\x02 \x01(\x0e2 .signal.backup.Group.Member.RoleR\x04role\x12(\n" + - "\x0fjoinedAtVersion\x18\x05 \x01(\rR\x0fjoinedAtVersion\x12\x1e\n" + - "\n" + - "labelEmoji\x18\x06 \x01(\tR\n" + - "labelEmoji\x12 \n" + - "\vlabelString\x18\a \x01(\tR\vlabelString\"3\n" + - "\x04Role\x12\v\n" + - "\aUNKNOWN\x10\x00\x12\v\n" + - "\aDEFAULT\x10\x01\x12\x11\n" + - "\rADMINISTRATOR\x10\x02J\x04\b\x03\x10\x04J\x04\b\x04\x10\x05\x1a\x92\x01\n" + - "\x17MemberPendingProfileKey\x123\n" + - "\x06member\x18\x01 \x01(\v2\x1b.signal.backup.Group.MemberR\x06member\x12$\n" + - "\raddedByUserId\x18\x02 \x01(\fR\raddedByUserId\x12\x1c\n" + - "\ttimestamp\x18\x03 \x01(\x04R\ttimestamp\x1a^\n" + - "\x1aMemberPendingAdminApproval\x12\x16\n" + - "\x06userId\x18\x01 \x01(\fR\x06userId\x12\x1c\n" + - "\ttimestamp\x18\x04 \x01(\x04R\ttimestampJ\x04\b\x02\x10\x03J\x04\b\x03\x10\x04\x1aD\n" + - "\fMemberBanned\x12\x16\n" + - "\x06userId\x18\x01 \x01(\fR\x06userId\x12\x1c\n" + - "\ttimestamp\x18\x02 \x01(\x04R\ttimestamp\x1a\xbf\x03\n" + - "\rAccessControl\x12Q\n" + - "\n" + - "attributes\x18\x01 \x01(\x0e21.signal.backup.Group.AccessControl.AccessRequiredR\n" + - "attributes\x12K\n" + - "\amembers\x18\x02 \x01(\x0e21.signal.backup.Group.AccessControl.AccessRequiredR\amembers\x12_\n" + - "\x11addFromInviteLink\x18\x03 \x01(\x0e21.signal.backup.Group.AccessControl.AccessRequiredR\x11addFromInviteLink\x12S\n" + - "\vmemberLabel\x18\x04 \x01(\x0e21.signal.backup.Group.AccessControl.AccessRequiredR\vmemberLabel\"X\n" + - "\x0eAccessRequired\x12\v\n" + - "\aUNKNOWN\x10\x00\x12\a\n" + - "\x03ANY\x10\x01\x12\n" + - "\n" + - "\x06MEMBER\x10\x02\x12\x11\n" + - "\rADMINISTRATOR\x10\x03\x12\x11\n" + - "\rUNSATISFIABLE\x10\x04\"7\n" + - "\rStorySendMode\x12\v\n" + - "\aDEFAULT\x10\x00\x12\f\n" + - "\bDISABLED\x10\x01\x12\v\n" + - "\aENABLED\x10\x02B\x0e\n" + - "\f_avatarColor\"Y\n" + - "\x04Self\x12A\n" + - "\vavatarColor\x18\x01 \x01(\x0e2\x1a.signal.backup.AvatarColorH\x00R\vavatarColor\x88\x01\x01B\x0e\n" + - "\f_avatarColor\"\x0e\n" + - "\fReleaseNotes\"\xd3\x03\n" + - "\x04Chat\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x04R\x02id\x12 \n" + - "\vrecipientId\x18\x02 \x01(\x04R\vrecipientId\x12\x1a\n" + - "\barchived\x18\x03 \x01(\bR\barchived\x12%\n" + - "\vpinnedOrder\x18\x04 \x01(\rH\x00R\vpinnedOrder\x88\x01\x01\x121\n" + - "\x11expirationTimerMs\x18\x05 \x01(\x04H\x01R\x11expirationTimerMs\x88\x01\x01\x12%\n" + - "\vmuteUntilMs\x18\x06 \x01(\x04H\x02R\vmuteUntilMs\x88\x01\x01\x12\"\n" + - "\fmarkedUnread\x18\a \x01(\bR\fmarkedUnread\x12B\n" + - "\x1cdontNotifyForMentionsIfMuted\x18\b \x01(\bR\x1cdontNotifyForMentionsIfMuted\x12.\n" + - "\x05style\x18\t \x01(\v2\x18.signal.backup.ChatStyleR\x05style\x12.\n" + - "\x12expireTimerVersion\x18\n" + - " \x01(\rR\x12expireTimerVersionB\x0e\n" + - "\f_pinnedOrderB\x14\n" + - "\x12_expirationTimerMsB\x0e\n" + - "\f_muteUntilMs\"\x95\x02\n" + - "\bCallLink\x12\x18\n" + - "\arootKey\x18\x01 \x01(\fR\arootKey\x12\x1f\n" + - "\badminKey\x18\x02 \x01(\fH\x00R\badminKey\x88\x01\x01\x12\x12\n" + - "\x04name\x18\x03 \x01(\tR\x04name\x12H\n" + - "\frestrictions\x18\x04 \x01(\x0e2$.signal.backup.CallLink.RestrictionsR\frestrictions\x12\"\n" + - "\fexpirationMs\x18\x05 \x01(\x04R\fexpirationMs\"9\n" + - "\fRestrictions\x12\v\n" + - "\aUNKNOWN\x10\x00\x12\b\n" + - "\x04NONE\x10\x01\x12\x12\n" + - "\x0eADMIN_APPROVAL\x10\x02B\v\n" + - "\t_adminKeyJ\x04\b\x06\x10\a\"\xca\x01\n" + - "\tAdHocCall\x12\x16\n" + - "\x06callId\x18\x01 \x01(\x04R\x06callId\x12 \n" + - "\vrecipientId\x18\x02 \x01(\x04R\vrecipientId\x124\n" + - "\x05state\x18\x03 \x01(\x0e2\x1e.signal.backup.AdHocCall.StateR\x05state\x12$\n" + - "\rcallTimestamp\x18\x04 \x01(\x04R\rcallTimestamp\"'\n" + - "\x05State\x12\x11\n" + - "\rUNKNOWN_STATE\x10\x00\x12\v\n" + - "\aGENERIC\x10\x01\"\xc5\x01\n" + - "\x14DistributionListItem\x12&\n" + - "\x0edistributionId\x18\x01 \x01(\fR\x0edistributionId\x12.\n" + - "\x11deletionTimestamp\x18\x02 \x01(\x04H\x00R\x11deletionTimestamp\x12M\n" + - "\x10distributionList\x18\x03 \x01(\v2\x1f.signal.backup.DistributionListH\x00R\x10distributionListB\x06\n" + - "\x04item\"\x8d\x02\n" + - "\x10DistributionList\x12\x12\n" + - "\x04name\x18\x01 \x01(\tR\x04name\x12\"\n" + - "\fallowReplies\x18\x02 \x01(\bR\fallowReplies\x12M\n" + - "\vprivacyMode\x18\x03 \x01(\x0e2+.signal.backup.DistributionList.PrivacyModeR\vprivacyMode\x12.\n" + - "\x12memberRecipientIds\x18\x04 \x03(\x04R\x12memberRecipientIds\"B\n" + - "\vPrivacyMode\x12\v\n" + - "\aUNKNOWN\x10\x00\x12\r\n" + - "\tONLY_WITH\x10\x01\x12\x0e\n" + - "\n" + - "ALL_EXCEPT\x10\x02\x12\a\n" + - "\x03ALL\x10\x03\"\xbd\x0f\n" + - "\bChatItem\x12\x16\n" + - "\x06chatId\x18\x01 \x01(\x04R\x06chatId\x12\x1a\n" + - "\bauthorId\x18\x02 \x01(\x04R\bauthorId\x12\x1a\n" + - "\bdateSent\x18\x03 \x01(\x04R\bdateSent\x12-\n" + - "\x0fexpireStartDate\x18\x04 \x01(\x04H\x02R\x0fexpireStartDate\x88\x01\x01\x12%\n" + - "\vexpiresInMs\x18\x05 \x01(\x04H\x03R\vexpiresInMs\x88\x01\x01\x125\n" + - "\trevisions\x18\x06 \x03(\v2\x17.signal.backup.ChatItemR\trevisions\x12\x10\n" + - "\x03sms\x18\a \x01(\bR\x03sms\x12L\n" + - "\bincoming\x18\b \x01(\v2..signal.backup.ChatItem.IncomingMessageDetailsH\x00R\bincoming\x12L\n" + - "\boutgoing\x18\t \x01(\v2..signal.backup.ChatItem.OutgoingMessageDetailsH\x00R\boutgoing\x12[\n" + - "\rdirectionless\x18\n" + - " \x01(\v23.signal.backup.ChatItem.DirectionlessMessageDetailsH\x00R\rdirectionless\x12J\n" + - "\x0fstandardMessage\x18\v \x01(\v2\x1e.signal.backup.StandardMessageH\x01R\x0fstandardMessage\x12G\n" + - "\x0econtactMessage\x18\f \x01(\v2\x1d.signal.backup.ContactMessageH\x01R\x0econtactMessage\x12G\n" + - "\x0estickerMessage\x18\r \x01(\v2\x1d.signal.backup.StickerMessageH\x01R\x0estickerMessage\x12Y\n" + - "\x14remoteDeletedMessage\x18\x0e \x01(\v2#.signal.backup.RemoteDeletedMessageH\x01R\x14remoteDeletedMessage\x12H\n" + - "\rupdateMessage\x18\x0f \x01(\v2 .signal.backup.ChatUpdateMessageH\x01R\rupdateMessage\x12V\n" + - "\x13paymentNotification\x18\x10 \x01(\v2\".signal.backup.PaymentNotificationH\x01R\x13paymentNotification\x128\n" + - "\tgiftBadge\x18\x11 \x01(\v2\x18.signal.backup.GiftBadgeH\x01R\tgiftBadge\x12J\n" + - "\x0fviewOnceMessage\x18\x12 \x01(\v2\x1e.signal.backup.ViewOnceMessageH\x01R\x0fviewOnceMessage\x12b\n" + - "\x17directStoryReplyMessage\x18\x13 \x01(\v2&.signal.backup.DirectStoryReplyMessageH\x01R\x17directStoryReplyMessage\x12)\n" + - "\x04poll\x18\x14 \x01(\v2\x13.signal.backup.PollH\x01R\x04poll\x12V\n" + - "\x13adminDeletedMessage\x18\x16 \x01(\v2\".signal.backup.AdminDeletedMessageH\x01R\x13adminDeletedMessage\x12B\n" + - "\n" + - "pinDetails\x18\x15 \x01(\v2\".signal.backup.ChatItem.PinDetailsR\n" + - "pinDetails\x1a\xb4\x01\n" + - "\x16IncomingMessageDetails\x12\"\n" + - "\fdateReceived\x18\x01 \x01(\x04R\fdateReceived\x12+\n" + - "\x0edateServerSent\x18\x02 \x01(\x04H\x00R\x0edateServerSent\x88\x01\x01\x12\x12\n" + - "\x04read\x18\x03 \x01(\bR\x04read\x12\"\n" + - "\fsealedSender\x18\x04 \x01(\bR\fsealedSenderB\x11\n" + - "\x0f_dateServerSent\x1aw\n" + - "\x16OutgoingMessageDetails\x129\n" + - "\n" + - "sendStatus\x18\x01 \x03(\v2\x19.signal.backup.SendStatusR\n" + - "sendStatus\x12\"\n" + - "\fdateReceived\x18\x02 \x01(\x04R\fdateReceived\x1a\x1d\n" + - "\x1bDirectionlessMessageDetails\x1a\xab\x01\n" + - "\n" + - "PinDetails\x12,\n" + - "\x11pinnedAtTimestamp\x18\x01 \x01(\x04R\x11pinnedAtTimestamp\x126\n" + - "\x15pinExpiresAtTimestamp\x18\x02 \x01(\x04H\x00R\x15pinExpiresAtTimestamp\x12*\n" + - "\x0fpinNeverExpires\x18\x03 \x01(\bH\x00R\x0fpinNeverExpiresB\v\n" + - "\tpinExpiryB\x14\n" + - "\x12directionalDetailsB\x06\n" + - "\x04itemB\x12\n" + - "\x10_expireStartDateB\x0e\n" + - "\f_expiresInMs\"\xeb\x06\n" + - "\n" + - "SendStatus\x12 \n" + - "\vrecipientId\x18\x01 \x01(\x04R\vrecipientId\x12\x1c\n" + - "\ttimestamp\x18\x02 \x01(\x04R\ttimestamp\x12=\n" + - "\apending\x18\x03 \x01(\v2!.signal.backup.SendStatus.PendingH\x00R\apending\x124\n" + - "\x04sent\x18\x04 \x01(\v2\x1e.signal.backup.SendStatus.SentH\x00R\x04sent\x12C\n" + - "\tdelivered\x18\x05 \x01(\v2#.signal.backup.SendStatus.DeliveredH\x00R\tdelivered\x124\n" + - "\x04read\x18\x06 \x01(\v2\x1e.signal.backup.SendStatus.ReadH\x00R\x04read\x12:\n" + - "\x06viewed\x18\a \x01(\v2 .signal.backup.SendStatus.ViewedH\x00R\x06viewed\x12=\n" + - "\askipped\x18\b \x01(\v2!.signal.backup.SendStatus.SkippedH\x00R\askipped\x12:\n" + - "\x06failed\x18\t \x01(\v2 .signal.backup.SendStatus.FailedH\x00R\x06failed\x1a\t\n" + - "\aPending\x1a*\n" + - "\x04Sent\x12\"\n" + - "\fsealedSender\x18\x01 \x01(\bR\fsealedSender\x1a/\n" + - "\tDelivered\x12\"\n" + - "\fsealedSender\x18\x01 \x01(\bR\fsealedSender\x1a*\n" + - "\x04Read\x12\"\n" + - "\fsealedSender\x18\x01 \x01(\bR\fsealedSender\x1a,\n" + - "\x06Viewed\x12\"\n" + - "\fsealedSender\x18\x01 \x01(\bR\fsealedSender\x1a\t\n" + - "\aSkipped\x1a\x96\x01\n" + - "\x06Failed\x12F\n" + - "\x06reason\x18\x01 \x01(\x0e2..signal.backup.SendStatus.Failed.FailureReasonR\x06reason\"D\n" + - "\rFailureReason\x12\v\n" + - "\aUNKNOWN\x10\x00\x12\v\n" + - "\aNETWORK\x10\x01\x12\x19\n" + - "\x15IDENTITY_KEY_MISMATCH\x10\x02B\x10\n" + - "\x0edeliveryStatus\"T\n" + - "\x04Text\x12\x12\n" + - "\x04body\x18\x01 \x01(\tR\x04body\x128\n" + - "\n" + - "bodyRanges\x18\x02 \x03(\v2\x18.signal.backup.BodyRangeR\n" + - "bodyRanges\"\x86\x03\n" + - "\x0fStandardMessage\x12/\n" + - "\x05quote\x18\x01 \x01(\v2\x14.signal.backup.QuoteH\x00R\x05quote\x88\x01\x01\x12,\n" + - "\x04text\x18\x02 \x01(\v2\x13.signal.backup.TextH\x01R\x04text\x88\x01\x01\x12B\n" + - "\vattachments\x18\x03 \x03(\v2 .signal.backup.MessageAttachmentR\vattachments\x12<\n" + - "\vlinkPreview\x18\x04 \x03(\v2\x1a.signal.backup.LinkPreviewR\vlinkPreview\x12;\n" + - "\blongText\x18\x05 \x01(\v2\x1a.signal.backup.FilePointerH\x02R\blongText\x88\x01\x01\x125\n" + - "\treactions\x18\x06 \x03(\v2\x17.signal.backup.ReactionR\treactionsB\b\n" + - "\x06_quoteB\a\n" + - "\x05_textB\v\n" + - "\t_longText\"\x83\x01\n" + - "\x0eContactMessage\x12:\n" + - "\acontact\x18\x01 \x01(\v2 .signal.backup.ContactAttachmentR\acontact\x125\n" + - "\treactions\x18\x02 \x03(\v2\x17.signal.backup.ReactionR\treactions\"\xb7\x02\n" + - "\x17DirectStoryReplyMessage\x12P\n" + - "\ttextReply\x18\x01 \x01(\v20.signal.backup.DirectStoryReplyMessage.TextReplyH\x00R\ttextReply\x12\x16\n" + - "\x05emoji\x18\x02 \x01(\tH\x00R\x05emoji\x125\n" + - "\treactions\x18\x03 \x03(\v2\x17.signal.backup.ReactionR\treactions\x1al\n" + - "\tTextReply\x12'\n" + - "\x04text\x18\x01 \x01(\v2\x13.signal.backup.TextR\x04text\x126\n" + - "\blongText\x18\x02 \x01(\v2\x1a.signal.backup.FilePointerR\blongTextB\a\n" + - "\x05replyJ\x04\b\x04\x10\x05\"\xdb\n" + - "\n" + - "\x13PaymentNotification\x12!\n" + - "\tamountMob\x18\x01 \x01(\tH\x00R\tamountMob\x88\x01\x01\x12\x1b\n" + - "\x06feeMob\x18\x02 \x01(\tH\x01R\x06feeMob\x88\x01\x01\x12\x17\n" + - "\x04note\x18\x03 \x01(\tH\x02R\x04note\x88\x01\x01\x12e\n" + - "\x12transactionDetails\x18\x04 \x01(\v25.signal.backup.PaymentNotification.TransactionDetailsR\x12transactionDetails\x1a\xe1\b\n" + - "\x12TransactionDetails\x12e\n" + - "\vtransaction\x18\x01 \x01(\v2A.signal.backup.PaymentNotification.TransactionDetails.TransactionH\x00R\vtransaction\x12w\n" + - "\x11failedTransaction\x18\x02 \x01(\v2G.signal.backup.PaymentNotification.TransactionDetails.FailedTransactionH\x00R\x11failedTransaction\x1aY\n" + - "\x1bMobileCoinTxoIdentification\x12\x1c\n" + - "\tpublicKey\x18\x01 \x03(\fR\tpublicKey\x12\x1c\n" + - "\tkeyImages\x18\x02 \x03(\fR\tkeyImages\x1a\xc5\x01\n" + - "\x11FailedTransaction\x12m\n" + - "\x06reason\x18\x01 \x01(\x0e2U.signal.backup.PaymentNotification.TransactionDetails.FailedTransaction.FailureReasonR\x06reason\"A\n" + - "\rFailureReason\x12\v\n" + - "\aGENERIC\x10\x00\x12\v\n" + - "\aNETWORK\x10\x01\x12\x16\n" + - "\x12INSUFFICIENT_FUNDS\x10\x02\x1a\xbc\x04\n" + - "\vTransaction\x12`\n" + - "\x06status\x18\x01 \x01(\x0e2H.signal.backup.PaymentNotification.TransactionDetails.Transaction.StatusR\x06status\x12\x8d\x01\n" + - "\x18mobileCoinIdentification\x18\x02 \x01(\v2Q.signal.backup.PaymentNotification.TransactionDetails.MobileCoinTxoIdentificationR\x18mobileCoinIdentification\x12!\n" + - "\ttimestamp\x18\x03 \x01(\x04H\x00R\ttimestamp\x88\x01\x01\x12#\n" + - "\n" + - "blockIndex\x18\x04 \x01(\x04H\x01R\n" + - "blockIndex\x88\x01\x01\x12+\n" + - "\x0eblockTimestamp\x18\x05 \x01(\x04H\x02R\x0eblockTimestamp\x88\x01\x01\x12%\n" + - "\vtransaction\x18\x06 \x01(\fH\x03R\vtransaction\x88\x01\x01\x12\x1d\n" + - "\areceipt\x18\a \x01(\fH\x04R\areceipt\x88\x01\x01\"4\n" + - "\x06Status\x12\v\n" + - "\aINITIAL\x10\x00\x12\r\n" + - "\tSUBMITTED\x10\x01\x12\x0e\n" + - "\n" + - "SUCCESSFUL\x10\x02B\f\n" + - "\n" + - "_timestampB\r\n" + - "\v_blockIndexB\x11\n" + - "\x0f_blockTimestampB\x0e\n" + - "\f_transactionB\n" + - "\n" + - "\b_receiptB\t\n" + - "\apaymentB\f\n" + - "\n" + - "_amountMobB\t\n" + - "\a_feeMobB\a\n" + - "\x05_note\"\xc4\x01\n" + - "\tGiftBadge\x12D\n" + - "\x1dreceiptCredentialPresentation\x18\x01 \x01(\fR\x1dreceiptCredentialPresentation\x124\n" + - "\x05state\x18\x02 \x01(\x0e2\x1e.signal.backup.GiftBadge.StateR\x05state\";\n" + - "\x05State\x12\f\n" + - "\bUNOPENED\x10\x00\x12\n" + - "\n" + - "\x06OPENED\x10\x01\x12\f\n" + - "\bREDEEMED\x10\x02\x12\n" + - "\n" + - "\x06FAILED\x10\x03\"\x8a\x01\n" + - "\x0fViewOnceMessage\x12@\n" + - "\n" + - "attachment\x18\x01 \x01(\v2 .signal.backup.MessageAttachmentR\n" + - "attachment\x125\n" + - "\treactions\x18\x02 \x03(\v2\x17.signal.backup.ReactionR\treactions\"\x89\n" + - "\n" + - "\x11ContactAttachment\x12>\n" + - "\x04name\x18\x01 \x01(\v2%.signal.backup.ContactAttachment.NameH\x00R\x04name\x88\x01\x01\x12>\n" + - "\x06number\x18\x03 \x03(\v2&.signal.backup.ContactAttachment.PhoneR\x06number\x12<\n" + - "\x05email\x18\x04 \x03(\v2&.signal.backup.ContactAttachment.EmailR\x05email\x12H\n" + - "\aaddress\x18\x05 \x03(\v2..signal.backup.ContactAttachment.PostalAddressR\aaddress\x127\n" + - "\x06avatar\x18\x06 \x01(\v2\x1a.signal.backup.FilePointerH\x01R\x06avatar\x88\x01\x01\x12\"\n" + - "\forganization\x18\a \x01(\tR\forganization\x1a\xb0\x01\n" + - "\x04Name\x12\x1c\n" + - "\tgivenName\x18\x01 \x01(\tR\tgivenName\x12\x1e\n" + - "\n" + - "familyName\x18\x02 \x01(\tR\n" + - "familyName\x12\x16\n" + - "\x06prefix\x18\x03 \x01(\tR\x06prefix\x12\x16\n" + - "\x06suffix\x18\x04 \x01(\tR\x06suffix\x12\x1e\n" + - "\n" + - "middleName\x18\x05 \x01(\tR\n" + - "middleName\x12\x1a\n" + - "\bnickname\x18\x06 \x01(\tR\bnickname\x1a\xb5\x01\n" + - "\x05Phone\x12\x14\n" + - "\x05value\x18\x01 \x01(\tR\x05value\x12?\n" + - "\x04type\x18\x02 \x01(\x0e2+.signal.backup.ContactAttachment.Phone.TypeR\x04type\x12\x14\n" + - "\x05label\x18\x03 \x01(\tR\x05label\"?\n" + - "\x04Type\x12\v\n" + - "\aUNKNOWN\x10\x00\x12\b\n" + - "\x04HOME\x10\x01\x12\n" + - "\n" + - "\x06MOBILE\x10\x02\x12\b\n" + - "\x04WORK\x10\x03\x12\n" + - "\n" + - "\x06CUSTOM\x10\x04\x1a\xb5\x01\n" + - "\x05Email\x12\x14\n" + - "\x05value\x18\x01 \x01(\tR\x05value\x12?\n" + - "\x04type\x18\x02 \x01(\x0e2+.signal.backup.ContactAttachment.Email.TypeR\x04type\x12\x14\n" + - "\x05label\x18\x03 \x01(\tR\x05label\"?\n" + - "\x04Type\x12\v\n" + - "\aUNKNOWN\x10\x00\x12\b\n" + - "\x04HOME\x10\x01\x12\n" + - "\n" + - "\x06MOBILE\x10\x02\x12\b\n" + - "\x04WORK\x10\x03\x12\n" + - "\n" + - "\x06CUSTOM\x10\x04\x1a\xd7\x02\n" + - "\rPostalAddress\x12G\n" + - "\x04type\x18\x01 \x01(\x0e23.signal.backup.ContactAttachment.PostalAddress.TypeR\x04type\x12\x14\n" + - "\x05label\x18\x02 \x01(\tR\x05label\x12\x16\n" + - "\x06street\x18\x03 \x01(\tR\x06street\x12\x14\n" + - "\x05pobox\x18\x04 \x01(\tR\x05pobox\x12\"\n" + - "\fneighborhood\x18\x05 \x01(\tR\fneighborhood\x12\x12\n" + - "\x04city\x18\x06 \x01(\tR\x04city\x12\x16\n" + - "\x06region\x18\a \x01(\tR\x06region\x12\x1a\n" + - "\bpostcode\x18\b \x01(\tR\bpostcode\x12\x18\n" + - "\acountry\x18\t \x01(\tR\acountry\"3\n" + - "\x04Type\x12\v\n" + - "\aUNKNOWN\x10\x00\x12\b\n" + - "\x04HOME\x10\x01\x12\b\n" + - "\x04WORK\x10\x02\x12\n" + - "\n" + - "\x06CUSTOM\x10\x03B\a\n" + - "\x05_nameB\t\n" + - "\a_avatar\"y\n" + - "\x0eStickerMessage\x120\n" + - "\asticker\x18\x01 \x01(\v2\x16.signal.backup.StickerR\asticker\x125\n" + - "\treactions\x18\x02 \x03(\v2\x17.signal.backup.ReactionR\treactions\"\x16\n" + - "\x14RemoteDeletedMessage\"\xae\x01\n" + - "\aSticker\x12\x16\n" + - "\x06packId\x18\x01 \x01(\fR\x06packId\x12\x18\n" + - "\apackKey\x18\x02 \x01(\fR\apackKey\x12\x1c\n" + - "\tstickerId\x18\x03 \x01(\rR\tstickerId\x12\x19\n" + - "\x05emoji\x18\x04 \x01(\tH\x00R\x05emoji\x88\x01\x01\x12.\n" + - "\x04data\x18\x05 \x01(\v2\x1a.signal.backup.FilePointerR\x04dataB\b\n" + - "\x06_emoji\"\xde\x01\n" + - "\vLinkPreview\x12\x10\n" + - "\x03url\x18\x01 \x01(\tR\x03url\x12\x19\n" + - "\x05title\x18\x02 \x01(\tH\x00R\x05title\x88\x01\x01\x125\n" + - "\x05image\x18\x03 \x01(\v2\x1a.signal.backup.FilePointerH\x01R\x05image\x88\x01\x01\x12%\n" + - "\vdescription\x18\x04 \x01(\tH\x02R\vdescription\x88\x01\x01\x12\x17\n" + - "\x04date\x18\x05 \x01(\x04H\x03R\x04date\x88\x01\x01B\b\n" + - "\x06_titleB\b\n" + - "\x06_imageB\x0e\n" + - "\f_descriptionB\a\n" + - "\x05_date\"\x9c\x02\n" + - "\x11MessageAttachment\x124\n" + - "\apointer\x18\x01 \x01(\v2\x1a.signal.backup.FilePointerR\apointer\x129\n" + - "\x04flag\x18\x02 \x01(\x0e2%.signal.backup.MessageAttachment.FlagR\x04flag\x12$\n" + - "\rwasDownloaded\x18\x03 \x01(\bR\rwasDownloaded\x12#\n" + - "\n" + - "clientUuid\x18\x04 \x01(\fH\x00R\n" + - "clientUuid\x88\x01\x01\"<\n" + - "\x04Flag\x12\b\n" + - "\x04NONE\x10\x00\x12\x11\n" + - "\rVOICE_MESSAGE\x10\x01\x12\x0e\n" + - "\n" + - "BORDERLESS\x10\x02\x12\a\n" + - "\x03GIF\x10\x03B\r\n" + - "\v_clientUuid\"\x9e\b\n" + - "\vFilePointer\x12%\n" + - "\vcontentType\x18\x04 \x01(\tH\x00R\vcontentType\x88\x01\x01\x12+\n" + - "\x0eincrementalMac\x18\x05 \x01(\fH\x01R\x0eincrementalMac\x88\x01\x01\x12=\n" + - "\x17incrementalMacChunkSize\x18\x06 \x01(\rH\x02R\x17incrementalMacChunkSize\x88\x01\x01\x12\x1f\n" + - "\bfileName\x18\a \x01(\tH\x03R\bfileName\x88\x01\x01\x12\x19\n" + - "\x05width\x18\b \x01(\rH\x04R\x05width\x88\x01\x01\x12\x1b\n" + - "\x06height\x18\t \x01(\rH\x05R\x06height\x88\x01\x01\x12\x1d\n" + - "\acaption\x18\n" + - " \x01(\tH\x06R\acaption\x88\x01\x01\x12\x1f\n" + - "\bblurHash\x18\v \x01(\tH\aR\bblurHash\x88\x01\x01\x12H\n" + - "\vlocatorInfo\x18\r \x01(\v2&.signal.backup.FilePointer.LocatorInfoR\vlocatorInfo\x1a\x86\x04\n" + - "\vLocatorInfo\x12\x10\n" + - "\x03key\x18\x01 \x01(\fR\x03key\x12&\n" + - "\rplaintextHash\x18\n" + - " \x01(\fH\x00R\rplaintextHash\x12*\n" + - "\x0fencryptedDigest\x18\v \x01(\fH\x00R\x0fencryptedDigest\x12\x12\n" + - "\x04size\x18\x03 \x01(\rR\x04size\x12)\n" + - "\rtransitCdnKey\x18\x04 \x01(\tH\x01R\rtransitCdnKey\x88\x01\x01\x12/\n" + - "\x10transitCdnNumber\x18\x05 \x01(\rH\x02R\x10transitCdnNumber\x88\x01\x01\x12C\n" + - "\x1atransitTierUploadTimestamp\x18\x06 \x01(\x04H\x03R\x1atransitTierUploadTimestamp\x88\x01\x01\x123\n" + - "\x12mediaTierCdnNumber\x18\a \x01(\rH\x04R\x12mediaTierCdnNumber\x88\x01\x01\x12\x1f\n" + - "\blocalKey\x18\t \x01(\fH\x05R\blocalKey\x88\x01\x01B\x10\n" + - "\x0eintegrityCheckB\x10\n" + - "\x0e_transitCdnKeyB\x13\n" + - "\x11_transitCdnNumberB\x1d\n" + - "\x1b_transitTierUploadTimestampB\x15\n" + - "\x13_mediaTierCdnNumberB\v\n" + - "\t_localKeyJ\x04\b\x02\x10\x03J\x04\b\b\x10\tB\x0e\n" + - "\f_contentTypeB\x11\n" + - "\x0f_incrementalMacB\x1a\n" + - "\x18_incrementalMacChunkSizeB\v\n" + - "\t_fileNameB\b\n" + - "\x06_widthB\t\n" + - "\a_heightB\n" + - "\n" + - "\b_captionB\v\n" + - "\t_blurHashJ\x04\b\x01\x10\x02J\x04\b\x02\x10\x03J\x04\b\x03\x10\x04J\x04\b\f\x10\r\"\xb8\x04\n" + - "\x05Quote\x125\n" + - "\x13targetSentTimestamp\x18\x01 \x01(\x04H\x00R\x13targetSentTimestamp\x88\x01\x01\x12\x1a\n" + - "\bauthorId\x18\x02 \x01(\x04R\bauthorId\x12,\n" + - "\x04text\x18\x03 \x01(\v2\x13.signal.backup.TextH\x01R\x04text\x88\x01\x01\x12G\n" + - "\vattachments\x18\x04 \x03(\v2%.signal.backup.Quote.QuotedAttachmentR\vattachments\x12-\n" + - "\x04type\x18\x05 \x01(\x0e2\x19.signal.backup.Quote.TypeR\x04type\x1a\xca\x01\n" + - "\x10QuotedAttachment\x12%\n" + - "\vcontentType\x18\x01 \x01(\tH\x00R\vcontentType\x88\x01\x01\x12\x1f\n" + - "\bfileName\x18\x02 \x01(\tH\x01R\bfileName\x88\x01\x01\x12C\n" + - "\tthumbnail\x18\x03 \x01(\v2 .signal.backup.MessageAttachmentH\x02R\tthumbnail\x88\x01\x01B\x0e\n" + - "\f_contentTypeB\v\n" + - "\t_fileNameB\f\n" + - "\n" + - "_thumbnail\"H\n" + - "\x04Type\x12\v\n" + - "\aUNKNOWN\x10\x00\x12\n" + - "\n" + - "\x06NORMAL\x10\x01\x12\x0e\n" + - "\n" + - "GIFT_BADGE\x10\x02\x12\r\n" + - "\tVIEW_ONCE\x10\x03\x12\b\n" + - "\x04POLL\x10\x04B\x16\n" + - "\x14_targetSentTimestampB\a\n" + - "\x05_text\"\xfe\x01\n" + - "\tBodyRange\x12\x14\n" + - "\x05start\x18\x01 \x01(\rR\x05start\x12\x16\n" + - "\x06length\x18\x02 \x01(\rR\x06length\x12 \n" + - "\n" + - "mentionAci\x18\x03 \x01(\fH\x00R\n" + - "mentionAci\x126\n" + - "\x05style\x18\x04 \x01(\x0e2\x1e.signal.backup.BodyRange.StyleH\x00R\x05style\"V\n" + - "\x05Style\x12\b\n" + - "\x04NONE\x10\x00\x12\b\n" + - "\x04BOLD\x10\x01\x12\n" + - "\n" + - "\x06ITALIC\x10\x02\x12\v\n" + - "\aSPOILER\x10\x03\x12\x11\n" + - "\rSTRIKETHROUGH\x10\x04\x12\r\n" + - "\tMONOSPACE\x10\x05B\x11\n" + - "\x0fassociatedValue\"\x80\x01\n" + - "\bReaction\x12\x14\n" + - "\x05emoji\x18\x01 \x01(\tR\x05emoji\x12\x1a\n" + - "\bauthorId\x18\x02 \x01(\x04R\bauthorId\x12$\n" + - "\rsentTimestamp\x18\x03 \x01(\x04R\rsentTimestamp\x12\x1c\n" + - "\tsortOrder\x18\x04 \x01(\x04R\tsortOrder\"\xff\x02\n" + - "\x04Poll\x12\x1a\n" + - "\bquestion\x18\x01 \x01(\tR\bquestion\x12$\n" + - "\rallowMultiple\x18\x02 \x01(\bR\rallowMultiple\x128\n" + - "\aoptions\x18\x03 \x03(\v2\x1e.signal.backup.Poll.PollOptionR\aoptions\x12\x1a\n" + - "\bhasEnded\x18\x04 \x01(\bR\bhasEnded\x125\n" + - "\treactions\x18\x05 \x03(\v2\x17.signal.backup.ReactionR\treactions\x1a\xa7\x01\n" + - "\n" + - "PollOption\x12\x16\n" + - "\x06option\x18\x01 \x01(\tR\x06option\x12=\n" + - "\x05votes\x18\x02 \x03(\v2'.signal.backup.Poll.PollOption.PollVoteR\x05votes\x1aB\n" + - "\bPollVote\x12\x18\n" + - "\avoterId\x18\x01 \x01(\x04R\avoterId\x12\x1c\n" + - "\tvoteCount\x18\x02 \x01(\rR\tvoteCount\"/\n" + - "\x13AdminDeletedMessage\x12\x18\n" + - "\aadminId\x18\x01 \x01(\x04R\aadminId\"\xf7\x06\n" + - "\x11ChatUpdateMessage\x12E\n" + - "\fsimpleUpdate\x18\x01 \x01(\v2\x1f.signal.backup.SimpleChatUpdateH\x00R\fsimpleUpdate\x12H\n" + - "\vgroupChange\x18\x02 \x01(\v2$.signal.backup.GroupChangeChatUpdateH\x00R\vgroupChange\x12`\n" + - "\x15expirationTimerChange\x18\x03 \x01(\v2(.signal.backup.ExpirationTimerChatUpdateH\x00R\x15expirationTimerChange\x12N\n" + - "\rprofileChange\x18\x04 \x01(\v2&.signal.backup.ProfileChangeChatUpdateH\x00R\rprofileChange\x12H\n" + - "\vthreadMerge\x18\x05 \x01(\v2$.signal.backup.ThreadMergeChatUpdateH\x00R\vthreadMerge\x12Z\n" + - "\x11sessionSwitchover\x18\x06 \x01(\v2*.signal.backup.SessionSwitchoverChatUpdateH\x00R\x11sessionSwitchover\x12G\n" + - "\x0eindividualCall\x18\a \x01(\v2\x1d.signal.backup.IndividualCallH\x00R\x0eindividualCall\x128\n" + - "\tgroupCall\x18\b \x01(\v2\x18.signal.backup.GroupCallH\x00R\tgroupCall\x12]\n" + - "\x14learnedProfileChange\x18\t \x01(\v2'.signal.backup.LearnedProfileChatUpdateH\x00R\x14learnedProfileChange\x12J\n" + - "\rpollTerminate\x18\n" + - " \x01(\v2\".signal.backup.PollTerminateUpdateH\x00R\rpollTerminate\x12A\n" + - "\n" + - "pinMessage\x18\v \x01(\v2\x1f.signal.backup.PinMessageUpdateH\x00R\n" + - "pinMessageB\b\n" + - "\x06update\"\x9d\x04\n" + - "\x0eIndividualCall\x12\x1b\n" + - "\x06callId\x18\x01 \x01(\x04H\x00R\x06callId\x88\x01\x01\x126\n" + - "\x04type\x18\x02 \x01(\x0e2\".signal.backup.IndividualCall.TypeR\x04type\x12E\n" + - "\tdirection\x18\x03 \x01(\x0e2'.signal.backup.IndividualCall.DirectionR\tdirection\x129\n" + - "\x05state\x18\x04 \x01(\x0e2#.signal.backup.IndividualCall.StateR\x05state\x122\n" + - "\x14startedCallTimestamp\x18\x05 \x01(\x04R\x14startedCallTimestamp\x12\x12\n" + - "\x04read\x18\x06 \x01(\bR\x04read\"8\n" + - "\x04Type\x12\x10\n" + - "\fUNKNOWN_TYPE\x10\x00\x12\x0e\n" + - "\n" + - "AUDIO_CALL\x10\x01\x12\x0e\n" + - "\n" + - "VIDEO_CALL\x10\x02\">\n" + - "\tDirection\x12\x15\n" + - "\x11UNKNOWN_DIRECTION\x10\x00\x12\f\n" + - "\bINCOMING\x10\x01\x12\f\n" + - "\bOUTGOING\x10\x02\"g\n" + - "\x05State\x12\x11\n" + - "\rUNKNOWN_STATE\x10\x00\x12\f\n" + - "\bACCEPTED\x10\x01\x12\x10\n" + - "\fNOT_ACCEPTED\x10\x02\x12\n" + - "\n" + - "\x06MISSED\x10\x03\x12\x1f\n" + - "\x1bMISSED_NOTIFICATION_PROFILE\x10\x04B\t\n" + - "\a_callId\"\xbd\x04\n" + - "\tGroupCall\x12\x1b\n" + - "\x06callId\x18\x01 \x01(\x04H\x00R\x06callId\x88\x01\x01\x124\n" + - "\x05state\x18\x02 \x01(\x0e2\x1e.signal.backup.GroupCall.StateR\x05state\x121\n" + - "\x11ringerRecipientId\x18\x03 \x01(\x04H\x01R\x11ringerRecipientId\x88\x01\x01\x12;\n" + - "\x16startedCallRecipientId\x18\x04 \x01(\x04H\x02R\x16startedCallRecipientId\x88\x01\x01\x122\n" + - "\x14startedCallTimestamp\x18\x05 \x01(\x04R\x14startedCallTimestamp\x123\n" + - "\x12endedCallTimestamp\x18\x06 \x01(\x04H\x03R\x12endedCallTimestamp\x88\x01\x01\x12\x12\n" + - "\x04read\x18\a \x01(\bR\x04read\"\x9c\x01\n" + - "\x05State\x12\x11\n" + - "\rUNKNOWN_STATE\x10\x00\x12\v\n" + - "\aGENERIC\x10\x01\x12\n" + - "\n" + - "\x06JOINED\x10\x02\x12\v\n" + - "\aRINGING\x10\x03\x12\f\n" + - "\bACCEPTED\x10\x04\x12\f\n" + - "\bDECLINED\x10\x05\x12\n" + - "\n" + - "\x06MISSED\x10\x06\x12\x1f\n" + - "\x1bMISSED_NOTIFICATION_PROFILE\x10\a\x12\x11\n" + - "\rOUTGOING_RING\x10\bB\t\n" + - "\a_callIdB\x14\n" + - "\x12_ringerRecipientIdB\x19\n" + - "\x17_startedCallRecipientIdB\x15\n" + - "\x13_endedCallTimestamp\"\xd3\x03\n" + - "\x10SimpleChatUpdate\x128\n" + - "\x04type\x18\x01 \x01(\x0e2$.signal.backup.SimpleChatUpdate.TypeR\x04type\"\x84\x03\n" + - "\x04Type\x12\v\n" + - "\aUNKNOWN\x10\x00\x12\x11\n" + - "\rJOINED_SIGNAL\x10\x01\x12\x13\n" + - "\x0fIDENTITY_UPDATE\x10\x02\x12\x15\n" + - "\x11IDENTITY_VERIFIED\x10\x03\x12\x14\n" + - "\x10IDENTITY_DEFAULT\x10\x04\x12\x11\n" + - "\rCHANGE_NUMBER\x10\x05\x12$\n" + - " RELEASE_CHANNEL_DONATION_REQUEST\x10\x06\x12\x0f\n" + - "\vEND_SESSION\x10\a\x12\x18\n" + - "\x14CHAT_SESSION_REFRESH\x10\b\x12\x0f\n" + - "\vBAD_DECRYPT\x10\t\x12\x16\n" + - "\x12PAYMENTS_ACTIVATED\x10\n" + - "\x12\x1e\n" + - "\x1aPAYMENT_ACTIVATION_REQUEST\x10\v\x12 \n" + - "\x1cUNSUPPORTED_PROTOCOL_MESSAGE\x10\f\x12\x11\n" + - "\rREPORTED_SPAM\x10\r\x12\v\n" + - "\aBLOCKED\x10\x0e\x12\r\n" + - "\tUNBLOCKED\x10\x0f\x12\x1c\n" + - "\x18MESSAGE_REQUEST_ACCEPTED\x10\x10\"=\n" + - "\x19ExpirationTimerChatUpdate\x12 \n" + - "\vexpiresInMs\x18\x01 \x01(\x04R\vexpiresInMs\"W\n" + - "\x17ProfileChangeChatUpdate\x12\"\n" + - "\fpreviousName\x18\x01 \x01(\tR\fpreviousName\x12\x18\n" + - "\anewName\x18\x02 \x01(\tR\anewName\"^\n" + - "\x18LearnedProfileChatUpdate\x12\x14\n" + - "\x04e164\x18\x01 \x01(\x04H\x00R\x04e164\x12\x1c\n" + - "\busername\x18\x02 \x01(\tH\x00R\busernameB\x0e\n" + - "\fpreviousName\";\n" + - "\x15ThreadMergeChatUpdate\x12\"\n" + - "\fpreviousE164\x18\x01 \x01(\x04R\fpreviousE164\"1\n" + - "\x1bSessionSwitchoverChatUpdate\x12\x12\n" + - "\x04e164\x18\x01 \x01(\x04R\x04e164\"\x88!\n" + - "\x15GroupChangeChatUpdate\x12E\n" + - "\aupdates\x18\x01 \x03(\v2+.signal.backup.GroupChangeChatUpdate.UpdateR\aupdates\x1a\xa7 \n" + - "\x06Update\x12S\n" + - "\x12genericGroupUpdate\x18\x01 \x01(\v2!.signal.backup.GenericGroupUpdateH\x00R\x12genericGroupUpdate\x12V\n" + - "\x13groupCreationUpdate\x18\x02 \x01(\v2\".signal.backup.GroupCreationUpdateH\x00R\x13groupCreationUpdate\x12J\n" + - "\x0fgroupNameUpdate\x18\x03 \x01(\v2\x1e.signal.backup.GroupNameUpdateH\x00R\x0fgroupNameUpdate\x12P\n" + - "\x11groupAvatarUpdate\x18\x04 \x01(\v2 .signal.backup.GroupAvatarUpdateH\x00R\x11groupAvatarUpdate\x12_\n" + - "\x16groupDescriptionUpdate\x18\x05 \x01(\v2%.signal.backup.GroupDescriptionUpdateH\x00R\x16groupDescriptionUpdate\x12\x8f\x01\n" + - "&groupMembershipAccessLevelChangeUpdate\x18\x06 \x01(\v25.signal.backup.GroupMembershipAccessLevelChangeUpdateH\x00R&groupMembershipAccessLevelChangeUpdate\x12\x8f\x01\n" + - "&groupAttributesAccessLevelChangeUpdate\x18\a \x01(\v25.signal.backup.GroupAttributesAccessLevelChangeUpdateH\x00R&groupAttributesAccessLevelChangeUpdate\x12\x80\x01\n" + - "!groupAnnouncementOnlyChangeUpdate\x18\b \x01(\v20.signal.backup.GroupAnnouncementOnlyChangeUpdateH\x00R!groupAnnouncementOnlyChangeUpdate\x12_\n" + - "\x16groupAdminStatusUpdate\x18\t \x01(\v2%.signal.backup.GroupAdminStatusUpdateH\x00R\x16groupAdminStatusUpdate\x12\\\n" + - "\x15groupMemberLeftUpdate\x18\n" + - " \x01(\v2$.signal.backup.GroupMemberLeftUpdateH\x00R\x15groupMemberLeftUpdate\x12e\n" + - "\x18groupMemberRemovedUpdate\x18\v \x01(\v2'.signal.backup.GroupMemberRemovedUpdateH\x00R\x18groupMemberRemovedUpdate\x12e\n" + - "\x18selfInvitedToGroupUpdate\x18\f \x01(\v2'.signal.backup.SelfInvitedToGroupUpdateH\x00R\x18selfInvitedToGroupUpdate\x12\x80\x01\n" + - "!selfInvitedOtherUserToGroupUpdate\x18\r \x01(\v20.signal.backup.SelfInvitedOtherUserToGroupUpdateH\x00R!selfInvitedOtherUserToGroupUpdate\x12h\n" + - "\x19groupUnknownInviteeUpdate\x18\x0e \x01(\v2(.signal.backup.GroupUnknownInviteeUpdateH\x00R\x19groupUnknownInviteeUpdate\x12t\n" + - "\x1dgroupInvitationAcceptedUpdate\x18\x0f \x01(\v2,.signal.backup.GroupInvitationAcceptedUpdateH\x00R\x1dgroupInvitationAcceptedUpdate\x12t\n" + - "\x1dgroupInvitationDeclinedUpdate\x18\x10 \x01(\v2,.signal.backup.GroupInvitationDeclinedUpdateH\x00R\x1dgroupInvitationDeclinedUpdate\x12b\n" + - "\x17groupMemberJoinedUpdate\x18\x11 \x01(\v2&.signal.backup.GroupMemberJoinedUpdateH\x00R\x17groupMemberJoinedUpdate\x12_\n" + - "\x16groupMemberAddedUpdate\x18\x12 \x01(\v2%.signal.backup.GroupMemberAddedUpdateH\x00R\x16groupMemberAddedUpdate\x12}\n" + - " groupSelfInvitationRevokedUpdate\x18\x13 \x01(\v2/.signal.backup.GroupSelfInvitationRevokedUpdateH\x00R groupSelfInvitationRevokedUpdate\x12q\n" + - "\x1cgroupInvitationRevokedUpdate\x18\x14 \x01(\v2+.signal.backup.GroupInvitationRevokedUpdateH\x00R\x1cgroupInvitationRevokedUpdate\x12_\n" + - "\x16groupJoinRequestUpdate\x18\x15 \x01(\v2%.signal.backup.GroupJoinRequestUpdateH\x00R\x16groupJoinRequestUpdate\x12w\n" + - "\x1egroupJoinRequestApprovalUpdate\x18\x16 \x01(\v2-.signal.backup.GroupJoinRequestApprovalUpdateH\x00R\x1egroupJoinRequestApprovalUpdate\x12w\n" + - "\x1egroupJoinRequestCanceledUpdate\x18\x17 \x01(\v2-.signal.backup.GroupJoinRequestCanceledUpdateH\x00R\x1egroupJoinRequestCanceledUpdate\x12k\n" + - "\x1agroupInviteLinkResetUpdate\x18\x18 \x01(\v2).signal.backup.GroupInviteLinkResetUpdateH\x00R\x1agroupInviteLinkResetUpdate\x12q\n" + - "\x1cgroupInviteLinkEnabledUpdate\x18\x19 \x01(\v2+.signal.backup.GroupInviteLinkEnabledUpdateH\x00R\x1cgroupInviteLinkEnabledUpdate\x12\x83\x01\n" + - "\"groupInviteLinkAdminApprovalUpdate\x18\x1a \x01(\v21.signal.backup.GroupInviteLinkAdminApprovalUpdateH\x00R\"groupInviteLinkAdminApprovalUpdate\x12t\n" + - "\x1dgroupInviteLinkDisabledUpdate\x18\x1b \x01(\v2,.signal.backup.GroupInviteLinkDisabledUpdateH\x00R\x1dgroupInviteLinkDisabledUpdate\x12t\n" + - "\x1dgroupMemberJoinedByLinkUpdate\x18\x1c \x01(\v2,.signal.backup.GroupMemberJoinedByLinkUpdateH\x00R\x1dgroupMemberJoinedByLinkUpdate\x12_\n" + - "\x16groupV2MigrationUpdate\x18\x1d \x01(\v2%.signal.backup.GroupV2MigrationUpdateH\x00R\x16groupV2MigrationUpdate\x12\x80\x01\n" + - "!groupV2MigrationSelfInvitedUpdate\x18\x1e \x01(\v20.signal.backup.GroupV2MigrationSelfInvitedUpdateH\x00R!groupV2MigrationSelfInvitedUpdate\x12\x89\x01\n" + - "$groupV2MigrationInvitedMembersUpdate\x18\x1f \x01(\v23.signal.backup.GroupV2MigrationInvitedMembersUpdateH\x00R$groupV2MigrationInvitedMembersUpdate\x12\x89\x01\n" + - "$groupV2MigrationDroppedMembersUpdate\x18 \x01(\v23.signal.backup.GroupV2MigrationDroppedMembersUpdateH\x00R$groupV2MigrationDroppedMembersUpdate\x12\x92\x01\n" + - "'groupSequenceOfRequestsAndCancelsUpdate\x18! \x01(\v26.signal.backup.GroupSequenceOfRequestsAndCancelsUpdateH\x00R'groupSequenceOfRequestsAndCancelsUpdate\x12k\n" + - "\x1agroupExpirationTimerUpdate\x18\" \x01(\v2).signal.backup.GroupExpirationTimerUpdateH\x00R\x1agroupExpirationTimerUpdate\x12\x92\x01\n" + - "'groupMemberLabelAccessLevelChangeUpdate\x18# \x01(\v26.signal.backup.GroupMemberLabelAccessLevelChangeUpdateH\x00R'groupMemberLabelAccessLevelChangeUpdate\x12k\n" + - "\x1agroupTerminateChangeUpdate\x18$ \x01(\v2).signal.backup.GroupTerminateChangeUpdateH\x00R\x1agroupTerminateChangeUpdateB\b\n" + - "\x06update\"H\n" + - "\x12GenericGroupUpdate\x12#\n" + - "\n" + - "updaterAci\x18\x01 \x01(\fH\x00R\n" + - "updaterAci\x88\x01\x01B\r\n" + - "\v_updaterAci\"I\n" + - "\x13GroupCreationUpdate\x12#\n" + - "\n" + - "updaterAci\x18\x01 \x01(\fH\x00R\n" + - "updaterAci\x88\x01\x01B\r\n" + - "\v_updaterAci\"\x7f\n" + - "\x0fGroupNameUpdate\x12#\n" + - "\n" + - "updaterAci\x18\x01 \x01(\fH\x00R\n" + - "updaterAci\x88\x01\x01\x12'\n" + - "\fnewGroupName\x18\x02 \x01(\tH\x01R\fnewGroupName\x88\x01\x01B\r\n" + - "\v_updaterAciB\x0f\n" + - "\r_newGroupName\"g\n" + - "\x11GroupAvatarUpdate\x12#\n" + - "\n" + - "updaterAci\x18\x01 \x01(\fH\x00R\n" + - "updaterAci\x88\x01\x01\x12\x1e\n" + - "\n" + - "wasRemoved\x18\x02 \x01(\bR\n" + - "wasRemovedB\r\n" + - "\v_updaterAci\"\x8c\x01\n" + - "\x16GroupDescriptionUpdate\x12#\n" + - "\n" + - "updaterAci\x18\x01 \x01(\fH\x00R\n" + - "updaterAci\x88\x01\x01\x12+\n" + - "\x0enewDescription\x18\x02 \x01(\tH\x01R\x0enewDescription\x88\x01\x01B\r\n" + - "\v_updaterAciB\x11\n" + - "\x0f_newDescription\"\xa1\x01\n" + - "&GroupMembershipAccessLevelChangeUpdate\x12#\n" + - "\n" + - "updaterAci\x18\x01 \x01(\fH\x00R\n" + - "updaterAci\x88\x01\x01\x12C\n" + - "\vaccessLevel\x18\x02 \x01(\x0e2!.signal.backup.GroupV2AccessLevelR\vaccessLevelB\r\n" + - "\v_updaterAci\"\xa1\x01\n" + - "&GroupAttributesAccessLevelChangeUpdate\x12#\n" + - "\n" + - "updaterAci\x18\x01 \x01(\fH\x00R\n" + - "updaterAci\x88\x01\x01\x12C\n" + - "\vaccessLevel\x18\x02 \x01(\x0e2!.signal.backup.GroupV2AccessLevelR\vaccessLevelB\r\n" + - "\v_updaterAci\"\xa2\x01\n" + - "'GroupMemberLabelAccessLevelChangeUpdate\x12#\n" + - "\n" + - "updaterAci\x18\x01 \x01(\fH\x00R\n" + - "updaterAci\x88\x01\x01\x12C\n" + - "\vaccessLevel\x18\x02 \x01(\x0e2!.signal.backup.GroupV2AccessLevelR\vaccessLevelB\r\n" + - "\v_updaterAci\"P\n" + - "\x1aGroupTerminateChangeUpdate\x12#\n" + - "\n" + - "updaterAci\x18\x01 \x01(\fH\x00R\n" + - "updaterAci\x88\x01\x01B\r\n" + - "\v_updaterAci\"\x87\x01\n" + - "!GroupAnnouncementOnlyChangeUpdate\x12#\n" + - "\n" + - "updaterAci\x18\x01 \x01(\fH\x00R\n" + - "updaterAci\x88\x01\x01\x12.\n" + - "\x12isAnnouncementOnly\x18\x02 \x01(\bR\x12isAnnouncementOnlyB\r\n" + - "\v_updaterAci\"\xa0\x01\n" + - "\x16GroupAdminStatusUpdate\x12#\n" + - "\n" + - "updaterAci\x18\x01 \x01(\fH\x00R\n" + - "updaterAci\x88\x01\x01\x12\x1c\n" + - "\tmemberAci\x18\x02 \x01(\fR\tmemberAci\x124\n" + - "\x15wasAdminStatusGranted\x18\x03 \x01(\bR\x15wasAdminStatusGrantedB\r\n" + - "\v_updaterAci\")\n" + - "\x15GroupMemberLeftUpdate\x12\x10\n" + - "\x03aci\x18\x01 \x01(\fR\x03aci\"n\n" + - "\x18GroupMemberRemovedUpdate\x12#\n" + - "\n" + - "removerAci\x18\x01 \x01(\fH\x00R\n" + - "removerAci\x88\x01\x01\x12\x1e\n" + - "\n" + - "removedAci\x18\x02 \x01(\fR\n" + - "removedAciB\r\n" + - "\v_removerAci\"N\n" + - "\x18SelfInvitedToGroupUpdate\x12#\n" + - "\n" + - "inviterAci\x18\x01 \x01(\fH\x00R\n" + - "inviterAci\x88\x01\x01B\r\n" + - "\v_inviterAci\"O\n" + - "!SelfInvitedOtherUserToGroupUpdate\x12*\n" + - "\x10inviteeServiceId\x18\x01 \x01(\fR\x10inviteeServiceId\"s\n" + - "\x19GroupUnknownInviteeUpdate\x12#\n" + - "\n" + - "inviterAci\x18\x01 \x01(\fH\x00R\n" + - "inviterAci\x88\x01\x01\x12\"\n" + - "\finviteeCount\x18\x02 \x01(\rR\finviteeCountB\r\n" + - "\v_inviterAci\"w\n" + - "\x1dGroupInvitationAcceptedUpdate\x12#\n" + - "\n" + - "inviterAci\x18\x01 \x01(\fH\x00R\n" + - "inviterAci\x88\x01\x01\x12\"\n" + - "\fnewMemberAci\x18\x02 \x01(\fR\fnewMemberAciB\r\n" + - "\v_inviterAci\"\x87\x01\n" + - "\x1dGroupInvitationDeclinedUpdate\x12#\n" + - "\n" + - "inviterAci\x18\x01 \x01(\fH\x00R\n" + - "inviterAci\x88\x01\x01\x12#\n" + - "\n" + - "inviteeAci\x18\x02 \x01(\fH\x01R\n" + - "inviteeAci\x88\x01\x01B\r\n" + - "\v_inviterAciB\r\n" + - "\v_inviteeAci\"=\n" + - "\x17GroupMemberJoinedUpdate\x12\"\n" + - "\fnewMemberAci\x18\x01 \x01(\fR\fnewMemberAci\"\xd2\x01\n" + - "\x16GroupMemberAddedUpdate\x12#\n" + - "\n" + - "updaterAci\x18\x01 \x01(\fH\x00R\n" + - "updaterAci\x88\x01\x01\x12\"\n" + - "\fnewMemberAci\x18\x02 \x01(\fR\fnewMemberAci\x12,\n" + - "\x11hadOpenInvitation\x18\x03 \x01(\bR\x11hadOpenInvitation\x12#\n" + - "\n" + - "inviterAci\x18\x04 \x01(\fH\x01R\n" + - "inviterAci\x88\x01\x01B\r\n" + - "\v_updaterAciB\r\n" + - "\v_inviterAci\"V\n" + - " GroupSelfInvitationRevokedUpdate\x12#\n" + - "\n" + - "revokerAci\x18\x01 \x01(\fH\x00R\n" + - "revokerAci\x88\x01\x01B\r\n" + - "\v_revokerAci\"\xcb\x02\n" + - "\x1cGroupInvitationRevokedUpdate\x12#\n" + - "\n" + - "updaterAci\x18\x01 \x01(\fH\x00R\n" + - "updaterAci\x88\x01\x01\x12O\n" + - "\binvitees\x18\x02 \x03(\v23.signal.backup.GroupInvitationRevokedUpdate.InviteeR\binvitees\x1a\xa5\x01\n" + - "\aInvitee\x12#\n" + - "\n" + - "inviterAci\x18\x01 \x01(\fH\x00R\n" + - "inviterAci\x88\x01\x01\x12#\n" + - "\n" + - "inviteeAci\x18\x02 \x01(\fH\x01R\n" + - "inviteeAci\x88\x01\x01\x12#\n" + - "\n" + - "inviteePni\x18\x03 \x01(\fH\x02R\n" + - "inviteePni\x88\x01\x01B\r\n" + - "\v_inviterAciB\r\n" + - "\v_inviteeAciB\r\n" + - "\v_inviteePniB\r\n" + - "\v_updaterAci\"<\n" + - "\x16GroupJoinRequestUpdate\x12\"\n" + - "\frequestorAci\x18\x01 \x01(\fR\frequestorAci\"\x9a\x01\n" + - "\x1eGroupJoinRequestApprovalUpdate\x12\"\n" + - "\frequestorAci\x18\x01 \x01(\fR\frequestorAci\x12#\n" + - "\n" + - "updaterAci\x18\x02 \x01(\fH\x00R\n" + - "updaterAci\x88\x01\x01\x12 \n" + - "\vwasApproved\x18\x03 \x01(\bR\vwasApprovedB\r\n" + - "\v_updaterAci\"D\n" + - "\x1eGroupJoinRequestCanceledUpdate\x12\"\n" + - "\frequestorAci\x18\x01 \x01(\fR\frequestorAci\"c\n" + - "'GroupSequenceOfRequestsAndCancelsUpdate\x12\"\n" + - "\frequestorAci\x18\x01 \x01(\fR\frequestorAci\x12\x14\n" + - "\x05count\x18\x02 \x01(\rR\x05count\"P\n" + - "\x1aGroupInviteLinkResetUpdate\x12#\n" + - "\n" + - "updaterAci\x18\x01 \x01(\fH\x00R\n" + - "updaterAci\x88\x01\x01B\r\n" + - "\v_updaterAci\"\x90\x01\n" + - "\x1cGroupInviteLinkEnabledUpdate\x12#\n" + - "\n" + - "updaterAci\x18\x01 \x01(\fH\x00R\n" + - "updaterAci\x88\x01\x01\x12<\n" + - "\x19linkRequiresAdminApproval\x18\x02 \x01(\bR\x19linkRequiresAdminApprovalB\r\n" + - "\v_updaterAci\"\x96\x01\n" + - "\"GroupInviteLinkAdminApprovalUpdate\x12#\n" + - "\n" + - "updaterAci\x18\x01 \x01(\fH\x00R\n" + - "updaterAci\x88\x01\x01\x12<\n" + - "\x19linkRequiresAdminApproval\x18\x02 \x01(\bR\x19linkRequiresAdminApprovalB\r\n" + - "\v_updaterAci\"S\n" + - "\x1dGroupInviteLinkDisabledUpdate\x12#\n" + - "\n" + - "updaterAci\x18\x01 \x01(\fH\x00R\n" + - "updaterAci\x88\x01\x01B\r\n" + - "\v_updaterAci\"C\n" + - "\x1dGroupMemberJoinedByLinkUpdate\x12\"\n" + - "\fnewMemberAci\x18\x01 \x01(\fR\fnewMemberAci\"\x18\n" + - "\x16GroupV2MigrationUpdate\"#\n" + - "!GroupV2MigrationSelfInvitedUpdate\"X\n" + - "$GroupV2MigrationInvitedMembersUpdate\x120\n" + - "\x13invitedMembersCount\x18\x01 \x01(\rR\x13invitedMembersCount\"X\n" + - "$GroupV2MigrationDroppedMembersUpdate\x120\n" + - "\x13droppedMembersCount\x18\x01 \x01(\rR\x13droppedMembersCount\"r\n" + - "\x1aGroupExpirationTimerUpdate\x12 \n" + - "\vexpiresInMs\x18\x01 \x01(\x04R\vexpiresInMs\x12#\n" + - "\n" + - "updaterAci\x18\x02 \x01(\fH\x00R\n" + - "updaterAci\x88\x01\x01B\r\n" + - "\v_updaterAci\"c\n" + - "\x13PollTerminateUpdate\x120\n" + - "\x13targetSentTimestamp\x18\x01 \x01(\x04R\x13targetSentTimestamp\x12\x1a\n" + - "\bquestion\x18\x02 \x01(\tR\bquestion\"`\n" + - "\x10PinMessageUpdate\x120\n" + - "\x13targetSentTimestamp\x18\x01 \x01(\x04R\x13targetSentTimestamp\x12\x1a\n" + - "\bauthorId\x18\x02 \x01(\x04R\bauthorId\"?\n" + - "\vStickerPack\x12\x16\n" + - "\x06packId\x18\x01 \x01(\fR\x06packId\x12\x18\n" + - "\apackKey\x18\x02 \x01(\fR\apackKey\"\x80\r\n" + - "\tChatStyle\x12T\n" + - "\x0fwallpaperPreset\x18\x01 \x01(\x0e2(.signal.backup.ChatStyle.WallpaperPresetH\x00R\x0fwallpaperPreset\x12D\n" + - "\x0ewallpaperPhoto\x18\x02 \x01(\v2\x1a.signal.backup.FilePointerH\x00R\x0ewallpaperPhoto\x12Y\n" + - "\x0fautoBubbleColor\x18\x03 \x01(\v2-.signal.backup.ChatStyle.AutomaticBubbleColorH\x01R\x0fautoBubbleColor\x12Z\n" + - "\x11bubbleColorPreset\x18\x04 \x01(\x0e2*.signal.backup.ChatStyle.BubbleColorPresetH\x01R\x11bubbleColorPreset\x12&\n" + - "\rcustomColorId\x18\x05 \x01(\x04H\x01R\rcustomColorId\x126\n" + - "\x16dimWallpaperInDarkMode\x18\a \x01(\bR\x16dimWallpaperInDarkMode\x1aV\n" + - "\bGradient\x12\x14\n" + - "\x05angle\x18\x01 \x01(\rR\x05angle\x12\x16\n" + - "\x06colors\x18\x02 \x03(\aR\x06colors\x12\x1c\n" + - "\tpositions\x18\x03 \x03(\x02R\tpositions\x1a\x83\x01\n" + - "\x0fCustomChatColor\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x04R\x02id\x12\x16\n" + - "\x05solid\x18\x02 \x01(\aH\x00R\x05solid\x12?\n" + - "\bgradient\x18\x03 \x01(\v2!.signal.backup.ChatStyle.GradientH\x00R\bgradientB\a\n" + - "\x05color\x1a\x16\n" + - "\x14AutomaticBubbleColor\"\xc1\x03\n" + - "\x0fWallpaperPreset\x12\x1c\n" + - "\x18UNKNOWN_WALLPAPER_PRESET\x10\x00\x12\x0f\n" + - "\vSOLID_BLUSH\x10\x01\x12\x10\n" + - "\fSOLID_COPPER\x10\x02\x12\x0e\n" + - "\n" + - "SOLID_DUST\x10\x03\x12\x11\n" + - "\rSOLID_CELADON\x10\x04\x12\x14\n" + - "\x10SOLID_RAINFOREST\x10\x05\x12\x11\n" + - "\rSOLID_PACIFIC\x10\x06\x12\x0f\n" + - "\vSOLID_FROST\x10\a\x12\x0e\n" + - "\n" + - "SOLID_NAVY\x10\b\x12\x0f\n" + - "\vSOLID_LILAC\x10\t\x12\x0e\n" + - "\n" + - "SOLID_PINK\x10\n" + - "\x12\x12\n" + - "\x0eSOLID_EGGPLANT\x10\v\x12\x10\n" + - "\fSOLID_SILVER\x10\f\x12\x13\n" + - "\x0fGRADIENT_SUNSET\x10\r\x12\x11\n" + - "\rGRADIENT_NOIR\x10\x0e\x12\x14\n" + - "\x10GRADIENT_HEATMAP\x10\x0f\x12\x11\n" + - "\rGRADIENT_AQUA\x10\x10\x12\x17\n" + - "\x13GRADIENT_IRIDESCENT\x10\x11\x12\x15\n" + - "\x11GRADIENT_MONSTERA\x10\x12\x12\x12\n" + - "\x0eGRADIENT_BLISS\x10\x13\x12\x10\n" + - "\fGRADIENT_SKY\x10\x14\x12\x12\n" + - "\x0eGRADIENT_PEACH\x10\x15\"\xe9\x03\n" + - "\x11BubbleColorPreset\x12\x1f\n" + - "\x1bUNKNOWN_BUBBLE_COLOR_PRESET\x10\x00\x12\x15\n" + - "\x11SOLID_ULTRAMARINE\x10\x01\x12\x11\n" + - "\rSOLID_CRIMSON\x10\x02\x12\x13\n" + - "\x0fSOLID_VERMILION\x10\x03\x12\x10\n" + - "\fSOLID_BURLAP\x10\x04\x12\x10\n" + - "\fSOLID_FOREST\x10\x05\x12\x15\n" + - "\x11SOLID_WINTERGREEN\x10\x06\x12\x0e\n" + - "\n" + - "SOLID_TEAL\x10\a\x12\x0e\n" + - "\n" + - "SOLID_BLUE\x10\b\x12\x10\n" + - "\fSOLID_INDIGO\x10\t\x12\x10\n" + - "\fSOLID_VIOLET\x10\n" + - "\x12\x0e\n" + - "\n" + - "SOLID_PLUM\x10\v\x12\x0f\n" + - "\vSOLID_TAUPE\x10\f\x12\x0f\n" + - "\vSOLID_STEEL\x10\r\x12\x12\n" + - "\x0eGRADIENT_EMBER\x10\x0e\x12\x15\n" + - "\x11GRADIENT_MIDNIGHT\x10\x0f\x12\x15\n" + - "\x11GRADIENT_INFRARED\x10\x10\x12\x13\n" + - "\x0fGRADIENT_LAGOON\x10\x11\x12\x18\n" + - "\x14GRADIENT_FLUORESCENT\x10\x12\x12\x12\n" + - "\x0eGRADIENT_BASIL\x10\x13\x12\x14\n" + - "\x10GRADIENT_SUBLIME\x10\x14\x12\x10\n" + - "\fGRADIENT_SEA\x10\x15\x12\x16\n" + - "\x12GRADIENT_TANGERINE\x10\x16B\v\n" + - "\twallpaperB\r\n" + - "\vbubbleColor\"\xe8\x04\n" + - "\x13NotificationProfile\x12\x12\n" + - "\x04name\x18\x01 \x01(\tR\x04name\x12\x19\n" + - "\x05emoji\x18\x02 \x01(\tH\x00R\x05emoji\x88\x01\x01\x12\x14\n" + - "\x05color\x18\x03 \x01(\aR\x05color\x12 \n" + - "\vcreatedAtMs\x18\x04 \x01(\x04R\vcreatedAtMs\x12$\n" + - "\rallowAllCalls\x18\x05 \x01(\bR\rallowAllCalls\x12*\n" + - "\x10allowAllMentions\x18\x06 \x01(\bR\x10allowAllMentions\x12&\n" + - "\x0eallowedMembers\x18\a \x03(\x04R\x0eallowedMembers\x12(\n" + - "\x0fscheduleEnabled\x18\b \x01(\bR\x0fscheduleEnabled\x12,\n" + - "\x11scheduleStartTime\x18\t \x01(\rR\x11scheduleStartTime\x12(\n" + - "\x0fscheduleEndTime\x18\n" + - " \x01(\rR\x0fscheduleEndTime\x12^\n" + - "\x13scheduleDaysEnabled\x18\v \x03(\x0e2,.signal.backup.NotificationProfile.DayOfWeekR\x13scheduleDaysEnabled\x12\x0e\n" + - "\x02id\x18\f \x01(\fR\x02id\"t\n" + - "\tDayOfWeek\x12\v\n" + - "\aUNKNOWN\x10\x00\x12\n" + - "\n" + - "\x06MONDAY\x10\x01\x12\v\n" + - "\aTUESDAY\x10\x02\x12\r\n" + - "\tWEDNESDAY\x10\x03\x12\f\n" + - "\bTHURSDAY\x10\x04\x12\n" + - "\n" + - "\x06FRIDAY\x10\x05\x12\f\n" + - "\bSATURDAY\x10\x06\x12\n" + - "\n" + - "\x06SUNDAY\x10\aB\b\n" + - "\x06_emoji\"\xd0\x03\n" + - "\n" + - "ChatFolder\x12\x12\n" + - "\x04name\x18\x01 \x01(\tR\x04name\x12&\n" + - "\x0eshowOnlyUnread\x18\x02 \x01(\bR\x0eshowOnlyUnread\x12&\n" + - "\x0eshowMutedChats\x18\x03 \x01(\bR\x0eshowMutedChats\x12<\n" + - "\x19includeAllIndividualChats\x18\x04 \x01(\bR\x19includeAllIndividualChats\x122\n" + - "\x14includeAllGroupChats\x18\x05 \x01(\bR\x14includeAllGroupChats\x12D\n" + - "\n" + - "folderType\x18\x06 \x01(\x0e2$.signal.backup.ChatFolder.FolderTypeR\n" + - "folderType\x122\n" + - "\x14includedRecipientIds\x18\a \x03(\x04R\x14includedRecipientIds\x122\n" + - "\x14excludedRecipientIds\x18\b \x03(\x04R\x14excludedRecipientIds\x12\x0e\n" + - "\x02id\x18\t \x01(\fR\x02id\".\n" + - "\n" + - "FolderType\x12\v\n" + - "\aUNKNOWN\x10\x00\x12\a\n" + - "\x03ALL\x10\x01\x12\n" + - "\n" + - "\x06CUSTOM\x10\x02*\x85\x01\n" + - "\vAvatarColor\x12\b\n" + - "\x04A100\x10\x00\x12\b\n" + - "\x04A110\x10\x01\x12\b\n" + - "\x04A120\x10\x02\x12\b\n" + - "\x04A130\x10\x03\x12\b\n" + - "\x04A140\x10\x04\x12\b\n" + - "\x04A150\x10\x05\x12\b\n" + - "\x04A160\x10\x06\x12\b\n" + - "\x04A170\x10\a\x12\b\n" + - "\x04A180\x10\b\x12\b\n" + - "\x04A190\x10\t\x12\b\n" + - "\x04A200\x10\n" + - "\x12\b\n" + - "\x04A210\x10\v*\\\n" + - "\x12GroupV2AccessLevel\x12\v\n" + - "\aUNKNOWN\x10\x00\x12\a\n" + - "\x03ANY\x10\x01\x12\n" + - "\n" + - "\x06MEMBER\x10\x02\x12\x11\n" + - "\rADMINISTRATOR\x10\x03\x12\x11\n" + - "\rUNSATISFIABLE\x10\x04B)\n" + - "\x18org.signal.archive.proto\xba\x02\fBackupProto_b\x06proto3" - -var ( - file_backuppb_Backup_proto_rawDescOnce sync.Once - file_backuppb_Backup_proto_rawDescData []byte -) - -func file_backuppb_Backup_proto_rawDescGZIP() []byte { - file_backuppb_Backup_proto_rawDescOnce.Do(func() { - file_backuppb_Backup_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_backuppb_Backup_proto_rawDesc), len(file_backuppb_Backup_proto_rawDesc))) - }) - return file_backuppb_Backup_proto_rawDescData -} - -var file_backuppb_Backup_proto_enumTypes = make([]protoimpl.EnumInfo, 36) -var file_backuppb_Backup_proto_msgTypes = make([]protoimpl.MessageInfo, 131) -var file_backuppb_Backup_proto_goTypes = []any{ - (AvatarColor)(0), // 0: signal.backup.AvatarColor - (GroupV2AccessLevel)(0), // 1: signal.backup.GroupV2AccessLevel - (AccountData_PhoneNumberSharingMode)(0), // 2: signal.backup.AccountData.PhoneNumberSharingMode - (AccountData_SentMediaQuality)(0), // 3: signal.backup.AccountData.SentMediaQuality - (AccountData_AppTheme)(0), // 4: signal.backup.AccountData.AppTheme - (AccountData_CallsUseLessDataSetting)(0), // 5: signal.backup.AccountData.CallsUseLessDataSetting - (AccountData_UsernameLink_Color)(0), // 6: signal.backup.AccountData.UsernameLink.Color - (AccountData_AutoDownloadSettings_AutoDownloadOption)(0), // 7: signal.backup.AccountData.AutoDownloadSettings.AutoDownloadOption - (AccountData_AndroidSpecificSettings_NavigationBarSize)(0), // 8: signal.backup.AccountData.AndroidSpecificSettings.NavigationBarSize - (Contact_IdentityState)(0), // 9: signal.backup.Contact.IdentityState - (Contact_Visibility)(0), // 10: signal.backup.Contact.Visibility - (Group_StorySendMode)(0), // 11: signal.backup.Group.StorySendMode - (Group_Member_Role)(0), // 12: signal.backup.Group.Member.Role - (Group_AccessControl_AccessRequired)(0), // 13: signal.backup.Group.AccessControl.AccessRequired - (CallLink_Restrictions)(0), // 14: signal.backup.CallLink.Restrictions - (AdHocCall_State)(0), // 15: signal.backup.AdHocCall.State - (DistributionList_PrivacyMode)(0), // 16: signal.backup.DistributionList.PrivacyMode - (SendStatus_Failed_FailureReason)(0), // 17: signal.backup.SendStatus.Failed.FailureReason - (PaymentNotification_TransactionDetails_FailedTransaction_FailureReason)(0), // 18: signal.backup.PaymentNotification.TransactionDetails.FailedTransaction.FailureReason - (PaymentNotification_TransactionDetails_Transaction_Status)(0), // 19: signal.backup.PaymentNotification.TransactionDetails.Transaction.Status - (GiftBadge_State)(0), // 20: signal.backup.GiftBadge.State - (ContactAttachment_Phone_Type)(0), // 21: signal.backup.ContactAttachment.Phone.Type - (ContactAttachment_Email_Type)(0), // 22: signal.backup.ContactAttachment.Email.Type - (ContactAttachment_PostalAddress_Type)(0), // 23: signal.backup.ContactAttachment.PostalAddress.Type - (MessageAttachment_Flag)(0), // 24: signal.backup.MessageAttachment.Flag - (Quote_Type)(0), // 25: signal.backup.Quote.Type - (BodyRange_Style)(0), // 26: signal.backup.BodyRange.Style - (IndividualCall_Type)(0), // 27: signal.backup.IndividualCall.Type - (IndividualCall_Direction)(0), // 28: signal.backup.IndividualCall.Direction - (IndividualCall_State)(0), // 29: signal.backup.IndividualCall.State - (GroupCall_State)(0), // 30: signal.backup.GroupCall.State - (SimpleChatUpdate_Type)(0), // 31: signal.backup.SimpleChatUpdate.Type - (ChatStyle_WallpaperPreset)(0), // 32: signal.backup.ChatStyle.WallpaperPreset - (ChatStyle_BubbleColorPreset)(0), // 33: signal.backup.ChatStyle.BubbleColorPreset - (NotificationProfile_DayOfWeek)(0), // 34: signal.backup.NotificationProfile.DayOfWeek - (ChatFolder_FolderType)(0), // 35: signal.backup.ChatFolder.FolderType - (*BackupInfo)(nil), // 36: signal.backup.BackupInfo - (*Frame)(nil), // 37: signal.backup.Frame - (*AccountData)(nil), // 38: signal.backup.AccountData - (*Recipient)(nil), // 39: signal.backup.Recipient - (*Contact)(nil), // 40: signal.backup.Contact - (*Group)(nil), // 41: signal.backup.Group - (*Self)(nil), // 42: signal.backup.Self - (*ReleaseNotes)(nil), // 43: signal.backup.ReleaseNotes - (*Chat)(nil), // 44: signal.backup.Chat - (*CallLink)(nil), // 45: signal.backup.CallLink - (*AdHocCall)(nil), // 46: signal.backup.AdHocCall - (*DistributionListItem)(nil), // 47: signal.backup.DistributionListItem - (*DistributionList)(nil), // 48: signal.backup.DistributionList - (*ChatItem)(nil), // 49: signal.backup.ChatItem - (*SendStatus)(nil), // 50: signal.backup.SendStatus - (*Text)(nil), // 51: signal.backup.Text - (*StandardMessage)(nil), // 52: signal.backup.StandardMessage - (*ContactMessage)(nil), // 53: signal.backup.ContactMessage - (*DirectStoryReplyMessage)(nil), // 54: signal.backup.DirectStoryReplyMessage - (*PaymentNotification)(nil), // 55: signal.backup.PaymentNotification - (*GiftBadge)(nil), // 56: signal.backup.GiftBadge - (*ViewOnceMessage)(nil), // 57: signal.backup.ViewOnceMessage - (*ContactAttachment)(nil), // 58: signal.backup.ContactAttachment - (*StickerMessage)(nil), // 59: signal.backup.StickerMessage - (*RemoteDeletedMessage)(nil), // 60: signal.backup.RemoteDeletedMessage - (*Sticker)(nil), // 61: signal.backup.Sticker - (*LinkPreview)(nil), // 62: signal.backup.LinkPreview - (*MessageAttachment)(nil), // 63: signal.backup.MessageAttachment - (*FilePointer)(nil), // 64: signal.backup.FilePointer - (*Quote)(nil), // 65: signal.backup.Quote - (*BodyRange)(nil), // 66: signal.backup.BodyRange - (*Reaction)(nil), // 67: signal.backup.Reaction - (*Poll)(nil), // 68: signal.backup.Poll - (*AdminDeletedMessage)(nil), // 69: signal.backup.AdminDeletedMessage - (*ChatUpdateMessage)(nil), // 70: signal.backup.ChatUpdateMessage - (*IndividualCall)(nil), // 71: signal.backup.IndividualCall - (*GroupCall)(nil), // 72: signal.backup.GroupCall - (*SimpleChatUpdate)(nil), // 73: signal.backup.SimpleChatUpdate - (*ExpirationTimerChatUpdate)(nil), // 74: signal.backup.ExpirationTimerChatUpdate - (*ProfileChangeChatUpdate)(nil), // 75: signal.backup.ProfileChangeChatUpdate - (*LearnedProfileChatUpdate)(nil), // 76: signal.backup.LearnedProfileChatUpdate - (*ThreadMergeChatUpdate)(nil), // 77: signal.backup.ThreadMergeChatUpdate - (*SessionSwitchoverChatUpdate)(nil), // 78: signal.backup.SessionSwitchoverChatUpdate - (*GroupChangeChatUpdate)(nil), // 79: signal.backup.GroupChangeChatUpdate - (*GenericGroupUpdate)(nil), // 80: signal.backup.GenericGroupUpdate - (*GroupCreationUpdate)(nil), // 81: signal.backup.GroupCreationUpdate - (*GroupNameUpdate)(nil), // 82: signal.backup.GroupNameUpdate - (*GroupAvatarUpdate)(nil), // 83: signal.backup.GroupAvatarUpdate - (*GroupDescriptionUpdate)(nil), // 84: signal.backup.GroupDescriptionUpdate - (*GroupMembershipAccessLevelChangeUpdate)(nil), // 85: signal.backup.GroupMembershipAccessLevelChangeUpdate - (*GroupAttributesAccessLevelChangeUpdate)(nil), // 86: signal.backup.GroupAttributesAccessLevelChangeUpdate - (*GroupMemberLabelAccessLevelChangeUpdate)(nil), // 87: signal.backup.GroupMemberLabelAccessLevelChangeUpdate - (*GroupTerminateChangeUpdate)(nil), // 88: signal.backup.GroupTerminateChangeUpdate - (*GroupAnnouncementOnlyChangeUpdate)(nil), // 89: signal.backup.GroupAnnouncementOnlyChangeUpdate - (*GroupAdminStatusUpdate)(nil), // 90: signal.backup.GroupAdminStatusUpdate - (*GroupMemberLeftUpdate)(nil), // 91: signal.backup.GroupMemberLeftUpdate - (*GroupMemberRemovedUpdate)(nil), // 92: signal.backup.GroupMemberRemovedUpdate - (*SelfInvitedToGroupUpdate)(nil), // 93: signal.backup.SelfInvitedToGroupUpdate - (*SelfInvitedOtherUserToGroupUpdate)(nil), // 94: signal.backup.SelfInvitedOtherUserToGroupUpdate - (*GroupUnknownInviteeUpdate)(nil), // 95: signal.backup.GroupUnknownInviteeUpdate - (*GroupInvitationAcceptedUpdate)(nil), // 96: signal.backup.GroupInvitationAcceptedUpdate - (*GroupInvitationDeclinedUpdate)(nil), // 97: signal.backup.GroupInvitationDeclinedUpdate - (*GroupMemberJoinedUpdate)(nil), // 98: signal.backup.GroupMemberJoinedUpdate - (*GroupMemberAddedUpdate)(nil), // 99: signal.backup.GroupMemberAddedUpdate - (*GroupSelfInvitationRevokedUpdate)(nil), // 100: signal.backup.GroupSelfInvitationRevokedUpdate - (*GroupInvitationRevokedUpdate)(nil), // 101: signal.backup.GroupInvitationRevokedUpdate - (*GroupJoinRequestUpdate)(nil), // 102: signal.backup.GroupJoinRequestUpdate - (*GroupJoinRequestApprovalUpdate)(nil), // 103: signal.backup.GroupJoinRequestApprovalUpdate - (*GroupJoinRequestCanceledUpdate)(nil), // 104: signal.backup.GroupJoinRequestCanceledUpdate - (*GroupSequenceOfRequestsAndCancelsUpdate)(nil), // 105: signal.backup.GroupSequenceOfRequestsAndCancelsUpdate - (*GroupInviteLinkResetUpdate)(nil), // 106: signal.backup.GroupInviteLinkResetUpdate - (*GroupInviteLinkEnabledUpdate)(nil), // 107: signal.backup.GroupInviteLinkEnabledUpdate - (*GroupInviteLinkAdminApprovalUpdate)(nil), // 108: signal.backup.GroupInviteLinkAdminApprovalUpdate - (*GroupInviteLinkDisabledUpdate)(nil), // 109: signal.backup.GroupInviteLinkDisabledUpdate - (*GroupMemberJoinedByLinkUpdate)(nil), // 110: signal.backup.GroupMemberJoinedByLinkUpdate - (*GroupV2MigrationUpdate)(nil), // 111: signal.backup.GroupV2MigrationUpdate - (*GroupV2MigrationSelfInvitedUpdate)(nil), // 112: signal.backup.GroupV2MigrationSelfInvitedUpdate - (*GroupV2MigrationInvitedMembersUpdate)(nil), // 113: signal.backup.GroupV2MigrationInvitedMembersUpdate - (*GroupV2MigrationDroppedMembersUpdate)(nil), // 114: signal.backup.GroupV2MigrationDroppedMembersUpdate - (*GroupExpirationTimerUpdate)(nil), // 115: signal.backup.GroupExpirationTimerUpdate - (*PollTerminateUpdate)(nil), // 116: signal.backup.PollTerminateUpdate - (*PinMessageUpdate)(nil), // 117: signal.backup.PinMessageUpdate - (*StickerPack)(nil), // 118: signal.backup.StickerPack - (*ChatStyle)(nil), // 119: signal.backup.ChatStyle - (*NotificationProfile)(nil), // 120: signal.backup.NotificationProfile - (*ChatFolder)(nil), // 121: signal.backup.ChatFolder - (*AccountData_UsernameLink)(nil), // 122: signal.backup.AccountData.UsernameLink - (*AccountData_AutoDownloadSettings)(nil), // 123: signal.backup.AccountData.AutoDownloadSettings - (*AccountData_AccountSettings)(nil), // 124: signal.backup.AccountData.AccountSettings - (*AccountData_SubscriberData)(nil), // 125: signal.backup.AccountData.SubscriberData - (*AccountData_IAPSubscriberData)(nil), // 126: signal.backup.AccountData.IAPSubscriberData - (*AccountData_AndroidSpecificSettings)(nil), // 127: signal.backup.AccountData.AndroidSpecificSettings - (*Contact_Registered)(nil), // 128: signal.backup.Contact.Registered - (*Contact_NotRegistered)(nil), // 129: signal.backup.Contact.NotRegistered - (*Contact_Name)(nil), // 130: signal.backup.Contact.Name - (*Group_GroupSnapshot)(nil), // 131: signal.backup.Group.GroupSnapshot - (*Group_GroupAttributeBlob)(nil), // 132: signal.backup.Group.GroupAttributeBlob - (*Group_Member)(nil), // 133: signal.backup.Group.Member - (*Group_MemberPendingProfileKey)(nil), // 134: signal.backup.Group.MemberPendingProfileKey - (*Group_MemberPendingAdminApproval)(nil), // 135: signal.backup.Group.MemberPendingAdminApproval - (*Group_MemberBanned)(nil), // 136: signal.backup.Group.MemberBanned - (*Group_AccessControl)(nil), // 137: signal.backup.Group.AccessControl - (*ChatItem_IncomingMessageDetails)(nil), // 138: signal.backup.ChatItem.IncomingMessageDetails - (*ChatItem_OutgoingMessageDetails)(nil), // 139: signal.backup.ChatItem.OutgoingMessageDetails - (*ChatItem_DirectionlessMessageDetails)(nil), // 140: signal.backup.ChatItem.DirectionlessMessageDetails - (*ChatItem_PinDetails)(nil), // 141: signal.backup.ChatItem.PinDetails - (*SendStatus_Pending)(nil), // 142: signal.backup.SendStatus.Pending - (*SendStatus_Sent)(nil), // 143: signal.backup.SendStatus.Sent - (*SendStatus_Delivered)(nil), // 144: signal.backup.SendStatus.Delivered - (*SendStatus_Read)(nil), // 145: signal.backup.SendStatus.Read - (*SendStatus_Viewed)(nil), // 146: signal.backup.SendStatus.Viewed - (*SendStatus_Skipped)(nil), // 147: signal.backup.SendStatus.Skipped - (*SendStatus_Failed)(nil), // 148: signal.backup.SendStatus.Failed - (*DirectStoryReplyMessage_TextReply)(nil), // 149: signal.backup.DirectStoryReplyMessage.TextReply - (*PaymentNotification_TransactionDetails)(nil), // 150: signal.backup.PaymentNotification.TransactionDetails - (*PaymentNotification_TransactionDetails_MobileCoinTxoIdentification)(nil), // 151: signal.backup.PaymentNotification.TransactionDetails.MobileCoinTxoIdentification - (*PaymentNotification_TransactionDetails_FailedTransaction)(nil), // 152: signal.backup.PaymentNotification.TransactionDetails.FailedTransaction - (*PaymentNotification_TransactionDetails_Transaction)(nil), // 153: signal.backup.PaymentNotification.TransactionDetails.Transaction - (*ContactAttachment_Name)(nil), // 154: signal.backup.ContactAttachment.Name - (*ContactAttachment_Phone)(nil), // 155: signal.backup.ContactAttachment.Phone - (*ContactAttachment_Email)(nil), // 156: signal.backup.ContactAttachment.Email - (*ContactAttachment_PostalAddress)(nil), // 157: signal.backup.ContactAttachment.PostalAddress - (*FilePointer_LocatorInfo)(nil), // 158: signal.backup.FilePointer.LocatorInfo - (*Quote_QuotedAttachment)(nil), // 159: signal.backup.Quote.QuotedAttachment - (*Poll_PollOption)(nil), // 160: signal.backup.Poll.PollOption - (*Poll_PollOption_PollVote)(nil), // 161: signal.backup.Poll.PollOption.PollVote - (*GroupChangeChatUpdate_Update)(nil), // 162: signal.backup.GroupChangeChatUpdate.Update - (*GroupInvitationRevokedUpdate_Invitee)(nil), // 163: signal.backup.GroupInvitationRevokedUpdate.Invitee - (*ChatStyle_Gradient)(nil), // 164: signal.backup.ChatStyle.Gradient - (*ChatStyle_CustomChatColor)(nil), // 165: signal.backup.ChatStyle.CustomChatColor - (*ChatStyle_AutomaticBubbleColor)(nil), // 166: signal.backup.ChatStyle.AutomaticBubbleColor -} -var file_backuppb_Backup_proto_depIdxs = []int32{ - 38, // 0: signal.backup.Frame.account:type_name -> signal.backup.AccountData - 39, // 1: signal.backup.Frame.recipient:type_name -> signal.backup.Recipient - 44, // 2: signal.backup.Frame.chat:type_name -> signal.backup.Chat - 49, // 3: signal.backup.Frame.chatItem:type_name -> signal.backup.ChatItem - 118, // 4: signal.backup.Frame.stickerPack:type_name -> signal.backup.StickerPack - 46, // 5: signal.backup.Frame.adHocCall:type_name -> signal.backup.AdHocCall - 120, // 6: signal.backup.Frame.notificationProfile:type_name -> signal.backup.NotificationProfile - 121, // 7: signal.backup.Frame.chatFolder:type_name -> signal.backup.ChatFolder - 122, // 8: signal.backup.AccountData.usernameLink:type_name -> signal.backup.AccountData.UsernameLink - 125, // 9: signal.backup.AccountData.donationSubscriberData:type_name -> signal.backup.AccountData.SubscriberData - 124, // 10: signal.backup.AccountData.accountSettings:type_name -> signal.backup.AccountData.AccountSettings - 126, // 11: signal.backup.AccountData.backupsSubscriberData:type_name -> signal.backup.AccountData.IAPSubscriberData - 127, // 12: signal.backup.AccountData.androidSpecificSettings:type_name -> signal.backup.AccountData.AndroidSpecificSettings - 40, // 13: signal.backup.Recipient.contact:type_name -> signal.backup.Contact - 41, // 14: signal.backup.Recipient.group:type_name -> signal.backup.Group - 47, // 15: signal.backup.Recipient.distributionList:type_name -> signal.backup.DistributionListItem - 42, // 16: signal.backup.Recipient.self:type_name -> signal.backup.Self - 43, // 17: signal.backup.Recipient.releaseNotes:type_name -> signal.backup.ReleaseNotes - 45, // 18: signal.backup.Recipient.callLink:type_name -> signal.backup.CallLink - 10, // 19: signal.backup.Contact.visibility:type_name -> signal.backup.Contact.Visibility - 128, // 20: signal.backup.Contact.registered:type_name -> signal.backup.Contact.Registered - 129, // 21: signal.backup.Contact.notRegistered:type_name -> signal.backup.Contact.NotRegistered - 9, // 22: signal.backup.Contact.identityState:type_name -> signal.backup.Contact.IdentityState - 130, // 23: signal.backup.Contact.nickname:type_name -> signal.backup.Contact.Name - 0, // 24: signal.backup.Contact.avatarColor:type_name -> signal.backup.AvatarColor - 11, // 25: signal.backup.Group.storySendMode:type_name -> signal.backup.Group.StorySendMode - 131, // 26: signal.backup.Group.snapshot:type_name -> signal.backup.Group.GroupSnapshot - 0, // 27: signal.backup.Group.avatarColor:type_name -> signal.backup.AvatarColor - 0, // 28: signal.backup.Self.avatarColor:type_name -> signal.backup.AvatarColor - 119, // 29: signal.backup.Chat.style:type_name -> signal.backup.ChatStyle - 14, // 30: signal.backup.CallLink.restrictions:type_name -> signal.backup.CallLink.Restrictions - 15, // 31: signal.backup.AdHocCall.state:type_name -> signal.backup.AdHocCall.State - 48, // 32: signal.backup.DistributionListItem.distributionList:type_name -> signal.backup.DistributionList - 16, // 33: signal.backup.DistributionList.privacyMode:type_name -> signal.backup.DistributionList.PrivacyMode - 49, // 34: signal.backup.ChatItem.revisions:type_name -> signal.backup.ChatItem - 138, // 35: signal.backup.ChatItem.incoming:type_name -> signal.backup.ChatItem.IncomingMessageDetails - 139, // 36: signal.backup.ChatItem.outgoing:type_name -> signal.backup.ChatItem.OutgoingMessageDetails - 140, // 37: signal.backup.ChatItem.directionless:type_name -> signal.backup.ChatItem.DirectionlessMessageDetails - 52, // 38: signal.backup.ChatItem.standardMessage:type_name -> signal.backup.StandardMessage - 53, // 39: signal.backup.ChatItem.contactMessage:type_name -> signal.backup.ContactMessage - 59, // 40: signal.backup.ChatItem.stickerMessage:type_name -> signal.backup.StickerMessage - 60, // 41: signal.backup.ChatItem.remoteDeletedMessage:type_name -> signal.backup.RemoteDeletedMessage - 70, // 42: signal.backup.ChatItem.updateMessage:type_name -> signal.backup.ChatUpdateMessage - 55, // 43: signal.backup.ChatItem.paymentNotification:type_name -> signal.backup.PaymentNotification - 56, // 44: signal.backup.ChatItem.giftBadge:type_name -> signal.backup.GiftBadge - 57, // 45: signal.backup.ChatItem.viewOnceMessage:type_name -> signal.backup.ViewOnceMessage - 54, // 46: signal.backup.ChatItem.directStoryReplyMessage:type_name -> signal.backup.DirectStoryReplyMessage - 68, // 47: signal.backup.ChatItem.poll:type_name -> signal.backup.Poll - 69, // 48: signal.backup.ChatItem.adminDeletedMessage:type_name -> signal.backup.AdminDeletedMessage - 141, // 49: signal.backup.ChatItem.pinDetails:type_name -> signal.backup.ChatItem.PinDetails - 142, // 50: signal.backup.SendStatus.pending:type_name -> signal.backup.SendStatus.Pending - 143, // 51: signal.backup.SendStatus.sent:type_name -> signal.backup.SendStatus.Sent - 144, // 52: signal.backup.SendStatus.delivered:type_name -> signal.backup.SendStatus.Delivered - 145, // 53: signal.backup.SendStatus.read:type_name -> signal.backup.SendStatus.Read - 146, // 54: signal.backup.SendStatus.viewed:type_name -> signal.backup.SendStatus.Viewed - 147, // 55: signal.backup.SendStatus.skipped:type_name -> signal.backup.SendStatus.Skipped - 148, // 56: signal.backup.SendStatus.failed:type_name -> signal.backup.SendStatus.Failed - 66, // 57: signal.backup.Text.bodyRanges:type_name -> signal.backup.BodyRange - 65, // 58: signal.backup.StandardMessage.quote:type_name -> signal.backup.Quote - 51, // 59: signal.backup.StandardMessage.text:type_name -> signal.backup.Text - 63, // 60: signal.backup.StandardMessage.attachments:type_name -> signal.backup.MessageAttachment - 62, // 61: signal.backup.StandardMessage.linkPreview:type_name -> signal.backup.LinkPreview - 64, // 62: signal.backup.StandardMessage.longText:type_name -> signal.backup.FilePointer - 67, // 63: signal.backup.StandardMessage.reactions:type_name -> signal.backup.Reaction - 58, // 64: signal.backup.ContactMessage.contact:type_name -> signal.backup.ContactAttachment - 67, // 65: signal.backup.ContactMessage.reactions:type_name -> signal.backup.Reaction - 149, // 66: signal.backup.DirectStoryReplyMessage.textReply:type_name -> signal.backup.DirectStoryReplyMessage.TextReply - 67, // 67: signal.backup.DirectStoryReplyMessage.reactions:type_name -> signal.backup.Reaction - 150, // 68: signal.backup.PaymentNotification.transactionDetails:type_name -> signal.backup.PaymentNotification.TransactionDetails - 20, // 69: signal.backup.GiftBadge.state:type_name -> signal.backup.GiftBadge.State - 63, // 70: signal.backup.ViewOnceMessage.attachment:type_name -> signal.backup.MessageAttachment - 67, // 71: signal.backup.ViewOnceMessage.reactions:type_name -> signal.backup.Reaction - 154, // 72: signal.backup.ContactAttachment.name:type_name -> signal.backup.ContactAttachment.Name - 155, // 73: signal.backup.ContactAttachment.number:type_name -> signal.backup.ContactAttachment.Phone - 156, // 74: signal.backup.ContactAttachment.email:type_name -> signal.backup.ContactAttachment.Email - 157, // 75: signal.backup.ContactAttachment.address:type_name -> signal.backup.ContactAttachment.PostalAddress - 64, // 76: signal.backup.ContactAttachment.avatar:type_name -> signal.backup.FilePointer - 61, // 77: signal.backup.StickerMessage.sticker:type_name -> signal.backup.Sticker - 67, // 78: signal.backup.StickerMessage.reactions:type_name -> signal.backup.Reaction - 64, // 79: signal.backup.Sticker.data:type_name -> signal.backup.FilePointer - 64, // 80: signal.backup.LinkPreview.image:type_name -> signal.backup.FilePointer - 64, // 81: signal.backup.MessageAttachment.pointer:type_name -> signal.backup.FilePointer - 24, // 82: signal.backup.MessageAttachment.flag:type_name -> signal.backup.MessageAttachment.Flag - 158, // 83: signal.backup.FilePointer.locatorInfo:type_name -> signal.backup.FilePointer.LocatorInfo - 51, // 84: signal.backup.Quote.text:type_name -> signal.backup.Text - 159, // 85: signal.backup.Quote.attachments:type_name -> signal.backup.Quote.QuotedAttachment - 25, // 86: signal.backup.Quote.type:type_name -> signal.backup.Quote.Type - 26, // 87: signal.backup.BodyRange.style:type_name -> signal.backup.BodyRange.Style - 160, // 88: signal.backup.Poll.options:type_name -> signal.backup.Poll.PollOption - 67, // 89: signal.backup.Poll.reactions:type_name -> signal.backup.Reaction - 73, // 90: signal.backup.ChatUpdateMessage.simpleUpdate:type_name -> signal.backup.SimpleChatUpdate - 79, // 91: signal.backup.ChatUpdateMessage.groupChange:type_name -> signal.backup.GroupChangeChatUpdate - 74, // 92: signal.backup.ChatUpdateMessage.expirationTimerChange:type_name -> signal.backup.ExpirationTimerChatUpdate - 75, // 93: signal.backup.ChatUpdateMessage.profileChange:type_name -> signal.backup.ProfileChangeChatUpdate - 77, // 94: signal.backup.ChatUpdateMessage.threadMerge:type_name -> signal.backup.ThreadMergeChatUpdate - 78, // 95: signal.backup.ChatUpdateMessage.sessionSwitchover:type_name -> signal.backup.SessionSwitchoverChatUpdate - 71, // 96: signal.backup.ChatUpdateMessage.individualCall:type_name -> signal.backup.IndividualCall - 72, // 97: signal.backup.ChatUpdateMessage.groupCall:type_name -> signal.backup.GroupCall - 76, // 98: signal.backup.ChatUpdateMessage.learnedProfileChange:type_name -> signal.backup.LearnedProfileChatUpdate - 116, // 99: signal.backup.ChatUpdateMessage.pollTerminate:type_name -> signal.backup.PollTerminateUpdate - 117, // 100: signal.backup.ChatUpdateMessage.pinMessage:type_name -> signal.backup.PinMessageUpdate - 27, // 101: signal.backup.IndividualCall.type:type_name -> signal.backup.IndividualCall.Type - 28, // 102: signal.backup.IndividualCall.direction:type_name -> signal.backup.IndividualCall.Direction - 29, // 103: signal.backup.IndividualCall.state:type_name -> signal.backup.IndividualCall.State - 30, // 104: signal.backup.GroupCall.state:type_name -> signal.backup.GroupCall.State - 31, // 105: signal.backup.SimpleChatUpdate.type:type_name -> signal.backup.SimpleChatUpdate.Type - 162, // 106: signal.backup.GroupChangeChatUpdate.updates:type_name -> signal.backup.GroupChangeChatUpdate.Update - 1, // 107: signal.backup.GroupMembershipAccessLevelChangeUpdate.accessLevel:type_name -> signal.backup.GroupV2AccessLevel - 1, // 108: signal.backup.GroupAttributesAccessLevelChangeUpdate.accessLevel:type_name -> signal.backup.GroupV2AccessLevel - 1, // 109: signal.backup.GroupMemberLabelAccessLevelChangeUpdate.accessLevel:type_name -> signal.backup.GroupV2AccessLevel - 163, // 110: signal.backup.GroupInvitationRevokedUpdate.invitees:type_name -> signal.backup.GroupInvitationRevokedUpdate.Invitee - 32, // 111: signal.backup.ChatStyle.wallpaperPreset:type_name -> signal.backup.ChatStyle.WallpaperPreset - 64, // 112: signal.backup.ChatStyle.wallpaperPhoto:type_name -> signal.backup.FilePointer - 166, // 113: signal.backup.ChatStyle.autoBubbleColor:type_name -> signal.backup.ChatStyle.AutomaticBubbleColor - 33, // 114: signal.backup.ChatStyle.bubbleColorPreset:type_name -> signal.backup.ChatStyle.BubbleColorPreset - 34, // 115: signal.backup.NotificationProfile.scheduleDaysEnabled:type_name -> signal.backup.NotificationProfile.DayOfWeek - 35, // 116: signal.backup.ChatFolder.folderType:type_name -> signal.backup.ChatFolder.FolderType - 6, // 117: signal.backup.AccountData.UsernameLink.color:type_name -> signal.backup.AccountData.UsernameLink.Color - 7, // 118: signal.backup.AccountData.AutoDownloadSettings.images:type_name -> signal.backup.AccountData.AutoDownloadSettings.AutoDownloadOption - 7, // 119: signal.backup.AccountData.AutoDownloadSettings.audio:type_name -> signal.backup.AccountData.AutoDownloadSettings.AutoDownloadOption - 7, // 120: signal.backup.AccountData.AutoDownloadSettings.video:type_name -> signal.backup.AccountData.AutoDownloadSettings.AutoDownloadOption - 7, // 121: signal.backup.AccountData.AutoDownloadSettings.documents:type_name -> signal.backup.AccountData.AutoDownloadSettings.AutoDownloadOption - 2, // 122: signal.backup.AccountData.AccountSettings.phoneNumberSharingMode:type_name -> signal.backup.AccountData.PhoneNumberSharingMode - 119, // 123: signal.backup.AccountData.AccountSettings.defaultChatStyle:type_name -> signal.backup.ChatStyle - 165, // 124: signal.backup.AccountData.AccountSettings.customChatColors:type_name -> signal.backup.ChatStyle.CustomChatColor - 3, // 125: signal.backup.AccountData.AccountSettings.defaultSentMediaQuality:type_name -> signal.backup.AccountData.SentMediaQuality - 123, // 126: signal.backup.AccountData.AccountSettings.autoDownloadSettings:type_name -> signal.backup.AccountData.AutoDownloadSettings - 4, // 127: signal.backup.AccountData.AccountSettings.appTheme:type_name -> signal.backup.AccountData.AppTheme - 5, // 128: signal.backup.AccountData.AccountSettings.callsUseLessDataSetting:type_name -> signal.backup.AccountData.CallsUseLessDataSetting - 8, // 129: signal.backup.AccountData.AndroidSpecificSettings.navigationBarSize:type_name -> signal.backup.AccountData.AndroidSpecificSettings.NavigationBarSize - 132, // 130: signal.backup.Group.GroupSnapshot.title:type_name -> signal.backup.Group.GroupAttributeBlob - 132, // 131: signal.backup.Group.GroupSnapshot.description:type_name -> signal.backup.Group.GroupAttributeBlob - 132, // 132: signal.backup.Group.GroupSnapshot.disappearingMessagesTimer:type_name -> signal.backup.Group.GroupAttributeBlob - 137, // 133: signal.backup.Group.GroupSnapshot.accessControl:type_name -> signal.backup.Group.AccessControl - 133, // 134: signal.backup.Group.GroupSnapshot.members:type_name -> signal.backup.Group.Member - 134, // 135: signal.backup.Group.GroupSnapshot.membersPendingProfileKey:type_name -> signal.backup.Group.MemberPendingProfileKey - 135, // 136: signal.backup.Group.GroupSnapshot.membersPendingAdminApproval:type_name -> signal.backup.Group.MemberPendingAdminApproval - 136, // 137: signal.backup.Group.GroupSnapshot.members_banned:type_name -> signal.backup.Group.MemberBanned - 12, // 138: signal.backup.Group.Member.role:type_name -> signal.backup.Group.Member.Role - 133, // 139: signal.backup.Group.MemberPendingProfileKey.member:type_name -> signal.backup.Group.Member - 13, // 140: signal.backup.Group.AccessControl.attributes:type_name -> signal.backup.Group.AccessControl.AccessRequired - 13, // 141: signal.backup.Group.AccessControl.members:type_name -> signal.backup.Group.AccessControl.AccessRequired - 13, // 142: signal.backup.Group.AccessControl.addFromInviteLink:type_name -> signal.backup.Group.AccessControl.AccessRequired - 13, // 143: signal.backup.Group.AccessControl.memberLabel:type_name -> signal.backup.Group.AccessControl.AccessRequired - 50, // 144: signal.backup.ChatItem.OutgoingMessageDetails.sendStatus:type_name -> signal.backup.SendStatus - 17, // 145: signal.backup.SendStatus.Failed.reason:type_name -> signal.backup.SendStatus.Failed.FailureReason - 51, // 146: signal.backup.DirectStoryReplyMessage.TextReply.text:type_name -> signal.backup.Text - 64, // 147: signal.backup.DirectStoryReplyMessage.TextReply.longText:type_name -> signal.backup.FilePointer - 153, // 148: signal.backup.PaymentNotification.TransactionDetails.transaction:type_name -> signal.backup.PaymentNotification.TransactionDetails.Transaction - 152, // 149: signal.backup.PaymentNotification.TransactionDetails.failedTransaction:type_name -> signal.backup.PaymentNotification.TransactionDetails.FailedTransaction - 18, // 150: signal.backup.PaymentNotification.TransactionDetails.FailedTransaction.reason:type_name -> signal.backup.PaymentNotification.TransactionDetails.FailedTransaction.FailureReason - 19, // 151: signal.backup.PaymentNotification.TransactionDetails.Transaction.status:type_name -> signal.backup.PaymentNotification.TransactionDetails.Transaction.Status - 151, // 152: signal.backup.PaymentNotification.TransactionDetails.Transaction.mobileCoinIdentification:type_name -> signal.backup.PaymentNotification.TransactionDetails.MobileCoinTxoIdentification - 21, // 153: signal.backup.ContactAttachment.Phone.type:type_name -> signal.backup.ContactAttachment.Phone.Type - 22, // 154: signal.backup.ContactAttachment.Email.type:type_name -> signal.backup.ContactAttachment.Email.Type - 23, // 155: signal.backup.ContactAttachment.PostalAddress.type:type_name -> signal.backup.ContactAttachment.PostalAddress.Type - 63, // 156: signal.backup.Quote.QuotedAttachment.thumbnail:type_name -> signal.backup.MessageAttachment - 161, // 157: signal.backup.Poll.PollOption.votes:type_name -> signal.backup.Poll.PollOption.PollVote - 80, // 158: signal.backup.GroupChangeChatUpdate.Update.genericGroupUpdate:type_name -> signal.backup.GenericGroupUpdate - 81, // 159: signal.backup.GroupChangeChatUpdate.Update.groupCreationUpdate:type_name -> signal.backup.GroupCreationUpdate - 82, // 160: signal.backup.GroupChangeChatUpdate.Update.groupNameUpdate:type_name -> signal.backup.GroupNameUpdate - 83, // 161: signal.backup.GroupChangeChatUpdate.Update.groupAvatarUpdate:type_name -> signal.backup.GroupAvatarUpdate - 84, // 162: signal.backup.GroupChangeChatUpdate.Update.groupDescriptionUpdate:type_name -> signal.backup.GroupDescriptionUpdate - 85, // 163: signal.backup.GroupChangeChatUpdate.Update.groupMembershipAccessLevelChangeUpdate:type_name -> signal.backup.GroupMembershipAccessLevelChangeUpdate - 86, // 164: signal.backup.GroupChangeChatUpdate.Update.groupAttributesAccessLevelChangeUpdate:type_name -> signal.backup.GroupAttributesAccessLevelChangeUpdate - 89, // 165: signal.backup.GroupChangeChatUpdate.Update.groupAnnouncementOnlyChangeUpdate:type_name -> signal.backup.GroupAnnouncementOnlyChangeUpdate - 90, // 166: signal.backup.GroupChangeChatUpdate.Update.groupAdminStatusUpdate:type_name -> signal.backup.GroupAdminStatusUpdate - 91, // 167: signal.backup.GroupChangeChatUpdate.Update.groupMemberLeftUpdate:type_name -> signal.backup.GroupMemberLeftUpdate - 92, // 168: signal.backup.GroupChangeChatUpdate.Update.groupMemberRemovedUpdate:type_name -> signal.backup.GroupMemberRemovedUpdate - 93, // 169: signal.backup.GroupChangeChatUpdate.Update.selfInvitedToGroupUpdate:type_name -> signal.backup.SelfInvitedToGroupUpdate - 94, // 170: signal.backup.GroupChangeChatUpdate.Update.selfInvitedOtherUserToGroupUpdate:type_name -> signal.backup.SelfInvitedOtherUserToGroupUpdate - 95, // 171: signal.backup.GroupChangeChatUpdate.Update.groupUnknownInviteeUpdate:type_name -> signal.backup.GroupUnknownInviteeUpdate - 96, // 172: signal.backup.GroupChangeChatUpdate.Update.groupInvitationAcceptedUpdate:type_name -> signal.backup.GroupInvitationAcceptedUpdate - 97, // 173: signal.backup.GroupChangeChatUpdate.Update.groupInvitationDeclinedUpdate:type_name -> signal.backup.GroupInvitationDeclinedUpdate - 98, // 174: signal.backup.GroupChangeChatUpdate.Update.groupMemberJoinedUpdate:type_name -> signal.backup.GroupMemberJoinedUpdate - 99, // 175: signal.backup.GroupChangeChatUpdate.Update.groupMemberAddedUpdate:type_name -> signal.backup.GroupMemberAddedUpdate - 100, // 176: signal.backup.GroupChangeChatUpdate.Update.groupSelfInvitationRevokedUpdate:type_name -> signal.backup.GroupSelfInvitationRevokedUpdate - 101, // 177: signal.backup.GroupChangeChatUpdate.Update.groupInvitationRevokedUpdate:type_name -> signal.backup.GroupInvitationRevokedUpdate - 102, // 178: signal.backup.GroupChangeChatUpdate.Update.groupJoinRequestUpdate:type_name -> signal.backup.GroupJoinRequestUpdate - 103, // 179: signal.backup.GroupChangeChatUpdate.Update.groupJoinRequestApprovalUpdate:type_name -> signal.backup.GroupJoinRequestApprovalUpdate - 104, // 180: signal.backup.GroupChangeChatUpdate.Update.groupJoinRequestCanceledUpdate:type_name -> signal.backup.GroupJoinRequestCanceledUpdate - 106, // 181: signal.backup.GroupChangeChatUpdate.Update.groupInviteLinkResetUpdate:type_name -> signal.backup.GroupInviteLinkResetUpdate - 107, // 182: signal.backup.GroupChangeChatUpdate.Update.groupInviteLinkEnabledUpdate:type_name -> signal.backup.GroupInviteLinkEnabledUpdate - 108, // 183: signal.backup.GroupChangeChatUpdate.Update.groupInviteLinkAdminApprovalUpdate:type_name -> signal.backup.GroupInviteLinkAdminApprovalUpdate - 109, // 184: signal.backup.GroupChangeChatUpdate.Update.groupInviteLinkDisabledUpdate:type_name -> signal.backup.GroupInviteLinkDisabledUpdate - 110, // 185: signal.backup.GroupChangeChatUpdate.Update.groupMemberJoinedByLinkUpdate:type_name -> signal.backup.GroupMemberJoinedByLinkUpdate - 111, // 186: signal.backup.GroupChangeChatUpdate.Update.groupV2MigrationUpdate:type_name -> signal.backup.GroupV2MigrationUpdate - 112, // 187: signal.backup.GroupChangeChatUpdate.Update.groupV2MigrationSelfInvitedUpdate:type_name -> signal.backup.GroupV2MigrationSelfInvitedUpdate - 113, // 188: signal.backup.GroupChangeChatUpdate.Update.groupV2MigrationInvitedMembersUpdate:type_name -> signal.backup.GroupV2MigrationInvitedMembersUpdate - 114, // 189: signal.backup.GroupChangeChatUpdate.Update.groupV2MigrationDroppedMembersUpdate:type_name -> signal.backup.GroupV2MigrationDroppedMembersUpdate - 105, // 190: signal.backup.GroupChangeChatUpdate.Update.groupSequenceOfRequestsAndCancelsUpdate:type_name -> signal.backup.GroupSequenceOfRequestsAndCancelsUpdate - 115, // 191: signal.backup.GroupChangeChatUpdate.Update.groupExpirationTimerUpdate:type_name -> signal.backup.GroupExpirationTimerUpdate - 87, // 192: signal.backup.GroupChangeChatUpdate.Update.groupMemberLabelAccessLevelChangeUpdate:type_name -> signal.backup.GroupMemberLabelAccessLevelChangeUpdate - 88, // 193: signal.backup.GroupChangeChatUpdate.Update.groupTerminateChangeUpdate:type_name -> signal.backup.GroupTerminateChangeUpdate - 164, // 194: signal.backup.ChatStyle.CustomChatColor.gradient:type_name -> signal.backup.ChatStyle.Gradient - 195, // [195:195] is the sub-list for method output_type - 195, // [195:195] is the sub-list for method input_type - 195, // [195:195] is the sub-list for extension type_name - 195, // [195:195] is the sub-list for extension extendee - 0, // [0:195] is the sub-list for field type_name -} - -func init() { file_backuppb_Backup_proto_init() } -func file_backuppb_Backup_proto_init() { - if File_backuppb_Backup_proto != nil { - return - } - file_backuppb_Backup_proto_msgTypes[1].OneofWrappers = []any{ - (*Frame_Account)(nil), - (*Frame_Recipient)(nil), - (*Frame_Chat)(nil), - (*Frame_ChatItem)(nil), - (*Frame_StickerPack)(nil), - (*Frame_AdHocCall)(nil), - (*Frame_NotificationProfile)(nil), - (*Frame_ChatFolder)(nil), - } - file_backuppb_Backup_proto_msgTypes[2].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[3].OneofWrappers = []any{ - (*Recipient_Contact)(nil), - (*Recipient_Group)(nil), - (*Recipient_DistributionList)(nil), - (*Recipient_Self)(nil), - (*Recipient_ReleaseNotes)(nil), - (*Recipient_CallLink)(nil), - } - file_backuppb_Backup_proto_msgTypes[4].OneofWrappers = []any{ - (*Contact_Registered_)(nil), - (*Contact_NotRegistered_)(nil), - } - file_backuppb_Backup_proto_msgTypes[5].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[6].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[8].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[9].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[11].OneofWrappers = []any{ - (*DistributionListItem_DeletionTimestamp)(nil), - (*DistributionListItem_DistributionList)(nil), - } - file_backuppb_Backup_proto_msgTypes[13].OneofWrappers = []any{ - (*ChatItem_Incoming)(nil), - (*ChatItem_Outgoing)(nil), - (*ChatItem_Directionless)(nil), - (*ChatItem_StandardMessage)(nil), - (*ChatItem_ContactMessage)(nil), - (*ChatItem_StickerMessage)(nil), - (*ChatItem_RemoteDeletedMessage)(nil), - (*ChatItem_UpdateMessage)(nil), - (*ChatItem_PaymentNotification)(nil), - (*ChatItem_GiftBadge)(nil), - (*ChatItem_ViewOnceMessage)(nil), - (*ChatItem_DirectStoryReplyMessage)(nil), - (*ChatItem_Poll)(nil), - (*ChatItem_AdminDeletedMessage)(nil), - } - file_backuppb_Backup_proto_msgTypes[14].OneofWrappers = []any{ - (*SendStatus_Pending_)(nil), - (*SendStatus_Sent_)(nil), - (*SendStatus_Delivered_)(nil), - (*SendStatus_Read_)(nil), - (*SendStatus_Viewed_)(nil), - (*SendStatus_Skipped_)(nil), - (*SendStatus_Failed_)(nil), - } - file_backuppb_Backup_proto_msgTypes[16].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[18].OneofWrappers = []any{ - (*DirectStoryReplyMessage_TextReply_)(nil), - (*DirectStoryReplyMessage_Emoji)(nil), - } - file_backuppb_Backup_proto_msgTypes[19].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[22].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[25].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[26].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[27].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[28].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[29].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[30].OneofWrappers = []any{ - (*BodyRange_MentionAci)(nil), - (*BodyRange_Style_)(nil), - } - file_backuppb_Backup_proto_msgTypes[34].OneofWrappers = []any{ - (*ChatUpdateMessage_SimpleUpdate)(nil), - (*ChatUpdateMessage_GroupChange)(nil), - (*ChatUpdateMessage_ExpirationTimerChange)(nil), - (*ChatUpdateMessage_ProfileChange)(nil), - (*ChatUpdateMessage_ThreadMerge)(nil), - (*ChatUpdateMessage_SessionSwitchover)(nil), - (*ChatUpdateMessage_IndividualCall)(nil), - (*ChatUpdateMessage_GroupCall)(nil), - (*ChatUpdateMessage_LearnedProfileChange)(nil), - (*ChatUpdateMessage_PollTerminate)(nil), - (*ChatUpdateMessage_PinMessage)(nil), - } - file_backuppb_Backup_proto_msgTypes[35].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[36].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[40].OneofWrappers = []any{ - (*LearnedProfileChatUpdate_E164)(nil), - (*LearnedProfileChatUpdate_Username)(nil), - } - file_backuppb_Backup_proto_msgTypes[44].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[45].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[46].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[47].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[48].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[49].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[50].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[51].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[52].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[53].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[54].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[56].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[57].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[59].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[60].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[61].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[63].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[64].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[65].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[67].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[70].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[71].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[72].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[73].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[79].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[83].OneofWrappers = []any{ - (*ChatStyle_WallpaperPreset_)(nil), - (*ChatStyle_WallpaperPhoto)(nil), - (*ChatStyle_AutoBubbleColor)(nil), - (*ChatStyle_BubbleColorPreset_)(nil), - (*ChatStyle_CustomColorId)(nil), - } - file_backuppb_Backup_proto_msgTypes[84].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[88].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[90].OneofWrappers = []any{ - (*AccountData_IAPSubscriberData_PurchaseToken)(nil), - (*AccountData_IAPSubscriberData_OriginalTransactionId)(nil), - } - file_backuppb_Backup_proto_msgTypes[96].OneofWrappers = []any{ - (*Group_GroupAttributeBlob_Title)(nil), - (*Group_GroupAttributeBlob_Avatar)(nil), - (*Group_GroupAttributeBlob_DisappearingMessagesDuration)(nil), - (*Group_GroupAttributeBlob_DescriptionText)(nil), - } - file_backuppb_Backup_proto_msgTypes[102].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[105].OneofWrappers = []any{ - (*ChatItem_PinDetails_PinExpiresAtTimestamp)(nil), - (*ChatItem_PinDetails_PinNeverExpires)(nil), - } - file_backuppb_Backup_proto_msgTypes[114].OneofWrappers = []any{ - (*PaymentNotification_TransactionDetails_Transaction_)(nil), - (*PaymentNotification_TransactionDetails_FailedTransaction_)(nil), - } - file_backuppb_Backup_proto_msgTypes[117].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[122].OneofWrappers = []any{ - (*FilePointer_LocatorInfo_PlaintextHash)(nil), - (*FilePointer_LocatorInfo_EncryptedDigest)(nil), - } - file_backuppb_Backup_proto_msgTypes[123].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[126].OneofWrappers = []any{ - (*GroupChangeChatUpdate_Update_GenericGroupUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupCreationUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupNameUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupAvatarUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupDescriptionUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupMembershipAccessLevelChangeUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupAttributesAccessLevelChangeUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupAnnouncementOnlyChangeUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupAdminStatusUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupMemberLeftUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupMemberRemovedUpdate)(nil), - (*GroupChangeChatUpdate_Update_SelfInvitedToGroupUpdate)(nil), - (*GroupChangeChatUpdate_Update_SelfInvitedOtherUserToGroupUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupUnknownInviteeUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupInvitationAcceptedUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupInvitationDeclinedUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupMemberJoinedUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupMemberAddedUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupSelfInvitationRevokedUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupInvitationRevokedUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupJoinRequestUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupJoinRequestApprovalUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupJoinRequestCanceledUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupInviteLinkResetUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupInviteLinkEnabledUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupInviteLinkAdminApprovalUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupInviteLinkDisabledUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupMemberJoinedByLinkUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupV2MigrationUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupV2MigrationSelfInvitedUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupV2MigrationInvitedMembersUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupV2MigrationDroppedMembersUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupSequenceOfRequestsAndCancelsUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupExpirationTimerUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupMemberLabelAccessLevelChangeUpdate)(nil), - (*GroupChangeChatUpdate_Update_GroupTerminateChangeUpdate)(nil), - } - file_backuppb_Backup_proto_msgTypes[127].OneofWrappers = []any{} - file_backuppb_Backup_proto_msgTypes[129].OneofWrappers = []any{ - (*ChatStyle_CustomChatColor_Solid)(nil), - (*ChatStyle_CustomChatColor_Gradient)(nil), - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_backuppb_Backup_proto_rawDesc), len(file_backuppb_Backup_proto_rawDesc)), - NumEnums: 36, - NumMessages: 131, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_backuppb_Backup_proto_goTypes, - DependencyIndexes: file_backuppb_Backup_proto_depIdxs, - EnumInfos: file_backuppb_Backup_proto_enumTypes, - MessageInfos: file_backuppb_Backup_proto_msgTypes, - }.Build() - File_backuppb_Backup_proto = out.File - file_backuppb_Backup_proto_goTypes = nil - file_backuppb_Backup_proto_depIdxs = nil -} diff --git a/pkg/signalmeow/protobuf/backuppb/Backup.pb.raw b/pkg/signalmeow/protobuf/backuppb/Backup.pb.raw deleted file mode 100644 index c72802f..0000000 Binary files a/pkg/signalmeow/protobuf/backuppb/Backup.pb.raw and /dev/null differ diff --git a/pkg/signalmeow/protobuf/backuppb/Backup.proto b/pkg/signalmeow/protobuf/backuppb/Backup.proto deleted file mode 100644 index d7407cb..0000000 --- a/pkg/signalmeow/protobuf/backuppb/Backup.proto +++ /dev/null @@ -1,1454 +0,0 @@ -syntax = "proto3"; - -package signal.backup; - -option java_package = "org.signal.archive.proto"; -option swift_prefix = "BackupProto_"; - -message BackupInfo { - uint64 version = 1; - uint64 backupTimeMs = 2; - bytes mediaRootBackupKey = 3; // 32-byte random value generated when the backup is uploaded for the first time. - string currentAppVersion = 4; - string firstAppVersion = 5; - bytes debugInfo = 6; // Client-specific data field for debug info during testing -} - -// Frames must follow in the following ordering rules: -// -// 1. There is exactly one AccountData and it is the first frame. -// 2. A frame referenced by ID must come before the referencing frame. -// e.g. a Recipient must come before any Chat referencing it. -// 3. All ChatItems must appear in global Chat rendering order. -// (The order in which they were received by the client.) -// 4. ChatFolders must appear in render order (e.g., left to right for -// LTR locales), but can appear anywhere relative to other frames respecting -// rule 2 (after Recipients and Chats). -// -// Recipients, Chats, StickerPacks, AdHocCalls, and NotificationProfiles -// can be in any order. (But must respect rule 2.) -// -// For example, Chats may all be together at the beginning, -// or may each immediately precede its first ChatItem. -message Frame { - // If unset, importers should skip this frame without throwing an error. - oneof item { - AccountData account = 1; - Recipient recipient = 2; - Chat chat = 3; - ChatItem chatItem = 4; - StickerPack stickerPack = 5; - AdHocCall adHocCall = 6; - NotificationProfile notificationProfile = 7; - ChatFolder chatFolder = 8; - } -} - -message AccountData { - enum PhoneNumberSharingMode { - UNKNOWN = 0; // Interpret as "Nobody" - EVERYBODY = 1; - NOBODY = 2; - } - message UsernameLink { - enum Color { - UNKNOWN = 0; // Interpret as "Blue" - BLUE = 1; - WHITE = 2; - GREY = 3; - OLIVE = 4; - GREEN = 5; - ORANGE = 6; - PINK = 7; - PURPLE = 8; - } - - bytes entropy = 1; // 32 bytes of entropy used for encryption - bytes serverId = 2; // 16 bytes of encoded UUID provided by the server - Color color = 3; - } - - enum SentMediaQuality { - UNKNOWN_QUALITY = 0; // Interpret as "Standard" - STANDARD = 1; - HIGH = 2; - } - - message AutoDownloadSettings { - enum AutoDownloadOption { - UNKNOWN = 0; // Interpret as "Never" - NEVER = 1; - WIFI = 2; - WIFI_AND_CELLULAR = 3; - } - - AutoDownloadOption images = 1; - AutoDownloadOption audio = 2; - AutoDownloadOption video = 3; - AutoDownloadOption documents = 4; - } - - enum AppTheme { - UNKNOWN_APP_THEME = 0; // Interpret as "System" - SYSTEM = 1; - LIGHT = 2; - DARK = 3; - } - - enum CallsUseLessDataSetting { - UNKNOWN_CALL_DATA_SETTING = 0; // Interpret as "Never" - NEVER = 1; - MOBILE_DATA_ONLY = 2; - WIFI_AND_MOBILE_DATA = 3; - } - - message AccountSettings { - bool readReceipts = 1; - bool sealedSenderIndicators = 2; - bool typingIndicators = 3; - bool linkPreviews = 4; - bool notDiscoverableByPhoneNumber = 5; - bool preferContactAvatars = 6; - uint32 universalExpireTimerSeconds = 7; // 0 means no universal expire timer. - repeated string preferredReactionEmoji = 8; - bool displayBadgesOnProfile = 9; - bool keepMutedChatsArchived = 10; - bool hasSetMyStoriesPrivacy = 11; - bool hasViewedOnboardingStory = 12; - bool storiesDisabled = 13; - optional bool storyViewReceiptsEnabled = 14; - bool hasSeenGroupStoryEducationSheet = 15; - bool hasCompletedUsernameOnboarding = 16; - PhoneNumberSharingMode phoneNumberSharingMode = 17; - ChatStyle defaultChatStyle = 18; - repeated ChatStyle.CustomChatColor customChatColors = 19; - bool optimizeOnDeviceStorage = 20; - // See zkgroup for integer particular values. Unset if backups are not enabled. - optional uint64 backupTier = 21; - reserved /* showSealedSenderIndicators */ 22; - SentMediaQuality defaultSentMediaQuality = 23; - AutoDownloadSettings autoDownloadSettings = 24; - reserved /* wifiAutoDownloadSettings */ 25; - optional uint32 screenLockTimeoutMinutes = 26; // If unset, consider screen lock to be disabled. - optional bool pinReminders = 27; // If unset, consider pin reminders to be enabled. - AppTheme appTheme = 28; // If unset, treat the same as "Unknown" case - CallsUseLessDataSetting callsUseLessDataSetting = 29; // If unset, treat the same as "Unknown" case - bool allowSealedSenderFromAnyone = 30; - bool allowAutomaticKeyVerification = 31; - bool hasSeenAdminDeleteEducationDialog = 32; - } - - message SubscriberData { - bytes subscriberId = 1; - string currencyCode = 2; - bool manuallyCancelled = 3; - } - - message IAPSubscriberData { - bytes subscriberId = 1; - - // If unset, importers should ignore the subscriber data without throwing an error. - oneof iapSubscriptionId { - // Identifies an Android Play Store IAP subscription. - string purchaseToken = 2; - // Identifies an iOS App Store IAP subscription. - uint64 originalTransactionId = 3; - } - } - - message AndroidSpecificSettings { - enum NavigationBarSize { - UNKNOWN_BAR_SIZE = 0; // Intepret as "Normal" - NORMAL = 1; - COMPACT = 2; - } - - bool useSystemEmoji = 1; - bool screenshotSecurity = 2; - NavigationBarSize navigationBarSize = 3; // If unset, treat the same as "Unknown" case - } - - bytes profileKey = 1; - optional string username = 2; - UsernameLink usernameLink = 3; - string givenName = 4; - string familyName = 5; - string avatarUrlPath = 6; - SubscriberData donationSubscriberData = 7; - reserved /*backupsSubscriberData*/ 8; // A deprecated format - AccountSettings accountSettings = 9; - IAPSubscriberData backupsSubscriberData = 10; - string svrPin = 11; - AndroidSpecificSettings androidSpecificSettings = 12; - string bioText = 13; - string bioEmoji = 14; - optional bytes keyTransparencyData = 15; -} - -message Recipient { - uint64 id = 1; // generated id for reference only within this file - // If unset, importers should skip this frame without throwing an error. - oneof destination { - Contact contact = 2; - Group group = 3; - DistributionListItem distributionList = 4; - Self self = 5; - ReleaseNotes releaseNotes = 6; - CallLink callLink = 7; - } -} - -// If unset - computed as the value of the first byte of SHA-256(msg=CONTACT_ID) -// modulo the count of colors. Once set the avatar color for a recipient is -// never recomputed or changed. -// -// `CONTACT_ID` is the first available identifier from the list: -// - ServiceIdToBinary(ACI) -// - E164 -// - ServiceIdToBinary(PNI) -// - Group Id -enum AvatarColor { - A100 = 0; - A110 = 1; - A120 = 2; - A130 = 3; - A140 = 4; - A150 = 5; - A160 = 6; - A170 = 7; - A180 = 8; - A190 = 9; - A200 = 10; - A210 = 11; -} - -message Contact { - enum IdentityState { - DEFAULT = 0; // A valid value -- indicates unset by the user - VERIFIED = 1; - UNVERIFIED = 2; // Was once verified and is now unverified - } - - message Registered {} - message NotRegistered { - uint64 unregisteredTimestamp = 1; - } - - enum Visibility { - VISIBLE = 0; // A valid value -- the contact is not hidden - HIDDEN = 1; - HIDDEN_MESSAGE_REQUEST = 2; - } - - message Name { - string given = 1; - string family = 2; - } - - optional bytes aci = 1; // should be 16 bytes - optional bytes pni = 2; // should be 16 bytes - optional string username = 3; - optional uint64 e164 = 4; - bool blocked = 5; - Visibility visibility = 6; - - // If unset, consider the user to be registered - oneof registration { - Registered registered = 7; - NotRegistered notRegistered = 8; - } - - optional bytes profileKey = 9; - bool profileSharing = 10; - optional string profileGivenName = 11; - optional string profileFamilyName = 12; - bool hideStory = 13; - optional bytes identityKey = 14; - IdentityState identityState = 15; - Name nickname = 16; // absent iff both `given` and `family` are empty - string note = 17; - string systemGivenName = 18; - string systemFamilyName = 19; - string systemNickname = 20; - optional AvatarColor avatarColor = 21; - optional bytes keyTransparencyData = 22; -} - -message Group { - enum StorySendMode { - DEFAULT = 0; // A valid value -- indicates unset by the user - DISABLED = 1; - ENABLED = 2; - } - - bytes masterKey = 1; - bool whitelisted = 2; - bool hideStory = 3; - StorySendMode storySendMode = 4; - GroupSnapshot snapshot = 5; - bool blocked = 6; - optional AvatarColor avatarColor = 7; - - // These are simply plaintext copies of the groups proto from Groups.proto. - // They should be kept completely in-sync with Groups.proto. - // These exist to allow us to have the latest snapshot of a group during restoration without having to hit the network. - // We would use Groups.proto if we could, but we want a plaintext version to improve export readability. - // For documentation, defer to Groups.proto. The only name change is Group -> GroupSnapshot to avoid the naming conflict. - message GroupSnapshot { - reserved /*publicKey*/ 1; // The field is deprecated in the context of static group state - GroupAttributeBlob title = 2; - GroupAttributeBlob description = 11; - string avatarUrl = 3; - GroupAttributeBlob disappearingMessagesTimer = 4; - AccessControl accessControl = 5; - uint32 version = 6; - repeated Member members = 7; - repeated MemberPendingProfileKey membersPendingProfileKey = 8; - repeated MemberPendingAdminApproval membersPendingAdminApproval = 9; - bytes inviteLinkPassword = 10; - bool announcements_only = 12; - repeated MemberBanned members_banned = 13; - bool terminated = 14; - } - - message GroupAttributeBlob { - // If unset, consider the field it represents to not be present - oneof content { - string title = 1; - bytes avatar = 2; - uint32 disappearingMessagesDuration = 3; - string descriptionText = 4; - } - } - - message Member { - enum Role { - UNKNOWN = 0; // Intepret as "Default" - DEFAULT = 1; - ADMINISTRATOR = 2; - } - - bytes userId = 1; - Role role = 2; - reserved /*profileKey*/ 3; // This field is ignored in Backups, in favor of Contact frames for members - reserved /*presentation*/ 4; // This field is deprecated in the context of static group state - uint32 joinedAtVersion = 5; - string labelEmoji = 6; - string labelString = 7; - } - - message MemberPendingProfileKey { - Member member = 1; - bytes addedByUserId = 2; - uint64 timestamp = 3; - } - - message MemberPendingAdminApproval { - bytes userId = 1; - reserved /*profileKey*/ 2; // This field is ignored in Backups, in favor of Contact frames for members - reserved /*presentation*/ 3; // This field is deprecated in the context of static group state - uint64 timestamp = 4; - } - - message MemberBanned { - bytes userId = 1; - uint64 timestamp = 2; - } - - message AccessControl { - enum AccessRequired { - UNKNOWN = 0; // Intepret as "Unsatisfiable" - ANY = 1; - MEMBER = 2; - ADMINISTRATOR = 3; - UNSATISFIABLE = 4; - } - - AccessRequired attributes = 1; - AccessRequired members = 2; - AccessRequired addFromInviteLink = 3; - AccessRequired memberLabel = 4; - } -} - -message Self { - optional AvatarColor avatarColor = 1; -} - -message ReleaseNotes {} - -message Chat { - uint64 id = 1; // generated id for reference only within this file - uint64 recipientId = 2; - bool archived = 3; - optional uint32 pinnedOrder = 4; // will be displayed in ascending order - optional uint64 expirationTimerMs = 5; - optional uint64 muteUntilMs = 6; // INT64_MAX (2^63 - 1) = "always muted". - bool markedUnread = 7; - bool dontNotifyForMentionsIfMuted = 8; - ChatStyle style = 9; - uint32 expireTimerVersion = 10; -} - -/** - * Call Links have some associated data including a call, but unlike other recipients - * are not tied to threads because they do not have messages associated with them. - * - * note: - * - room id can be derived from the root key - * - the presence of an admin key means this user is a call admin - */ -message CallLink { - enum Restrictions { - UNKNOWN = 0; // Interpret as "Admin Approval" - NONE = 1; - ADMIN_APPROVAL = 2; - } - - bytes rootKey = 1; - optional bytes adminKey = 2; // Only present if the user is an admin - string name = 3; - Restrictions restrictions = 4; - uint64 expirationMs = 5; - reserved /*epoch*/ 6; -} - -message AdHocCall { - enum State { - UNKNOWN_STATE = 0; // Interpret as "Generic" - GENERIC = 1; - } - - uint64 callId = 1; - // Refers to a `CallLink` recipient. - uint64 recipientId = 2; - State state = 3; - uint64 callTimestamp = 4; -} - -message DistributionListItem { - // distribution ids are UUIDv4s. "My Story" is represented - // by an all-0 UUID (00000000-0000-0000-0000-000000000000). - bytes distributionId = 1; // distribution list ids are uuids - - // If unset, importers should skip the item entirely without showing an error. - oneof item { - uint64 deletionTimestamp = 2; - DistributionList distributionList = 3; - } -} - -message DistributionList { - enum PrivacyMode { - UNKNOWN = 0; // Interpret as "Only with" - ONLY_WITH = 1; - ALL_EXCEPT = 2; - ALL = 3; - } - - string name = 1; - bool allowReplies = 2; - PrivacyMode privacyMode = 3; - repeated uint64 memberRecipientIds = 4; // generated recipient id -} - -message ChatItem { - message IncomingMessageDetails { - uint64 dateReceived = 1; - optional uint64 dateServerSent = 2; - bool read = 3; - bool sealedSender = 4; - } - - message OutgoingMessageDetails { - repeated SendStatus sendStatus = 1; - uint64 dateReceived = 2; // may be different from dateSent for sync messages - } - - message DirectionlessMessageDetails { - } - - message PinDetails { - uint64 pinnedAtTimestamp = 1; - oneof pinExpiry { - uint64 pinExpiresAtTimestamp = 2; // timestamp when the pin should expire - bool pinNeverExpires = 3; - } - } - - uint64 chatId = 1; // conversation id - uint64 authorId = 2; // recipient id - uint64 dateSent = 3; - optional uint64 expireStartDate = 4; // timestamp of when expiration timer started ticking down - optional uint64 expiresInMs = 5; // how long timer of message is (ms) - repeated ChatItem revisions = 6; // ordered from oldest to newest - bool sms = 7; - - // If unset, importers should skip this item without throwing an error. - oneof directionalDetails { - IncomingMessageDetails incoming = 8; - OutgoingMessageDetails outgoing = 9; - DirectionlessMessageDetails directionless = 10; - } - - // If unset, importers should skip this item without throwing an error. - oneof item { - StandardMessage standardMessage = 11; - ContactMessage contactMessage = 12; - StickerMessage stickerMessage = 13; - RemoteDeletedMessage remoteDeletedMessage = 14; - ChatUpdateMessage updateMessage = 15; - PaymentNotification paymentNotification = 16; - GiftBadge giftBadge = 17; - ViewOnceMessage viewOnceMessage = 18; - DirectStoryReplyMessage directStoryReplyMessage = 19; // group story reply messages are not backed up - Poll poll = 20; - AdminDeletedMessage adminDeletedMessage = 22; - } - - PinDetails pinDetails = 21; // only set if message is pinned -} - -message SendStatus { - message Pending {} - - message Sent { - bool sealedSender = 1; - } - - message Delivered { - bool sealedSender = 1; - } - - message Read { - bool sealedSender = 1; - } - - message Viewed { - bool sealedSender = 1; - } - - // e.g. user in group was blocked, so we skipped sending to them - message Skipped {} - - message Failed { - enum FailureReason { - UNKNOWN = 0; // A valid value -- could indicate a crash or lack of information - NETWORK = 1; - IDENTITY_KEY_MISMATCH = 2; - } - - FailureReason reason = 1; - } - - uint64 recipientId = 1; - uint64 timestamp = 2; // the time the status was last updated -- if from a receipt, it should be the sentTime of the receipt - - // If unset, importers should consider the status to be "pending" - oneof deliveryStatus { - Pending pending = 3; - Sent sent = 4; - Delivered delivered = 5; - Read read = 6; - Viewed viewed = 7; - Skipped skipped = 8; - Failed failed = 9; - } -} - -message Text { - string body = 1; - repeated BodyRange bodyRanges = 2; -} - -message StandardMessage { - optional Quote quote = 1; - optional Text text = 2; - repeated MessageAttachment attachments = 3; - repeated LinkPreview linkPreview = 4; - optional FilePointer longText = 5; - repeated Reaction reactions = 6; -} - -message ContactMessage { - ContactAttachment contact = 1; - repeated Reaction reactions = 2; -} - -message DirectStoryReplyMessage { - message TextReply { - Text text = 1; - FilePointer longText = 2; - } - - // If unset, importers should ignore the message without throwing an error. - oneof reply { - TextReply textReply = 1; - string emoji = 2; - } - - repeated Reaction reactions = 3; - reserved /*storySentTimestamp*/ 4; -} - -message PaymentNotification { - message TransactionDetails { - message MobileCoinTxoIdentification { // Used to map to payments on the ledger - repeated bytes publicKey = 1; // for received transactions - repeated bytes keyImages = 2; // for sent transactions - } - - message FailedTransaction { // Failed payments can't be synced from the ledger - enum FailureReason { - GENERIC = 0; // A valid value -- reason unknown - NETWORK = 1; - INSUFFICIENT_FUNDS = 2; - } - FailureReason reason = 1; - } - - message Transaction { - enum Status { - INITIAL = 0; // A valid value -- state unconfirmed - SUBMITTED = 1; - SUCCESSFUL = 2; - } - Status status = 1; - - // This identification is used to map the payment table to the ledger - // and is likely required otherwise we may have issues reconciling with - // the ledger - MobileCoinTxoIdentification mobileCoinIdentification = 2; - optional uint64 timestamp = 3; - optional uint64 blockIndex = 4; - optional uint64 blockTimestamp = 5; - optional bytes transaction = 6; // mobile coin blobs - optional bytes receipt = 7; // mobile coin blobs - } - - // If unset, importers should treat the transaction as successful with no metadata. - oneof payment { - Transaction transaction = 1; - FailedTransaction failedTransaction = 2; - } - } - - optional string amountMob = 1; // stored as a decimal string, e.g. 1.00001 - optional string feeMob = 2; // stored as a decimal string, e.g. 1.00001 - optional string note = 3; - TransactionDetails transactionDetails = 4; -} - -message GiftBadge { - enum State { - UNOPENED = 0; // A valid state - OPENED = 1; - REDEEMED = 2; - FAILED = 3; - } - - bytes receiptCredentialPresentation = 1; - State state = 2; -} - -message ViewOnceMessage { - // Will be null for viewed messages - MessageAttachment attachment = 1; - repeated Reaction reactions = 2; -} - -message ContactAttachment { - message Name { - string givenName = 1; - string familyName = 2; - string prefix = 3; - string suffix = 4; - string middleName = 5; - string nickname = 6; - } - - message Phone { - enum Type { - UNKNOWN = 0; // Interpret as "Home" - HOME = 1; - MOBILE = 2; - WORK = 3; - CUSTOM = 4; - } - - string value = 1; - Type type = 2; - string label = 3; - } - - message Email { - enum Type { - UNKNOWN = 0; // Intepret as "Home" - HOME = 1; - MOBILE = 2; - WORK = 3; - CUSTOM = 4; - } - - string value = 1; - Type type = 2; - string label = 3; - } - - message PostalAddress { - enum Type { - UNKNOWN = 0; // Interpret as "Home" - HOME = 1; - WORK = 2; - CUSTOM = 3; - } - - Type type = 1; - string label = 2; - string street = 3; - string pobox = 4; - string neighborhood = 5; - string city = 6; - string region = 7; - string postcode = 8; - string country = 9; - } - - optional Name name = 1; - repeated Phone number = 3; - repeated Email email = 4; - repeated PostalAddress address = 5; - optional FilePointer avatar = 6; - string organization = 7; -} - -message StickerMessage { - Sticker sticker = 1; - repeated Reaction reactions = 2; -} - -// Tombstone for remote delete -message RemoteDeletedMessage {} - -message Sticker { - bytes packId = 1; - bytes packKey = 2; - uint32 stickerId = 3; - optional string emoji = 4; - // Stickers are uploaded to be sent as attachments; we also - // back them up as normal attachments when they are in messages. - // DO NOT treat this as the definitive source of a sticker in - // an installed StickerPack that shares the same packId. - FilePointer data = 5; -} - -message LinkPreview { - string url = 1; - optional string title = 2; - optional FilePointer image = 3; - optional string description = 4; - optional uint64 date = 5; -} - -// A FilePointer on a message that has additional -// metadata that applies only to message attachments. -message MessageAttachment { - // Similar to SignalService.AttachmentPointer.Flags, - // but explicitly mutually exclusive. Note the different raw values - // (non-zero starting values are not supported in proto3.) - enum Flag { - NONE = 0; // A valid value -- no flag applied - VOICE_MESSAGE = 1; - BORDERLESS = 2; - GIF = 3; - } - - FilePointer pointer = 1; - Flag flag = 2; - bool wasDownloaded = 3; - // Cross-client identifier for this attachment among all attachments on the - // owning message. See: SignalService.AttachmentPointer.clientUuid. - optional bytes clientUuid = 4; -} - -message FilePointer { - message LocatorInfo { - // Must be non-empty if transitCdnKey or plaintextHash are set/nonempty. - // Otherwise must be empty. - bytes key = 1; - - reserved /*legacyDigest*/ 2; - - oneof integrityCheck { - // Set if file was at one point downloaded and its plaintextHash was calculated - bytes plaintextHash = 10; - - // Set if file has not been downloaded so its integrity has not been verified - // From the sender of the attachment - bytes encryptedDigest = 11; - } - - // NB: This is the plaintext size, and empty content attachments are legal, so this - // may be zero even if transitCdnKey or mediaName are set/nonempty. - uint32 size = 3; - - // Either both transit cdn key and number are set or neither should be set. - // Upload timestamp is optional but should only be set if key/number are set. - optional string transitCdnKey = 4; - optional uint32 transitCdnNumber = 5; - optional uint64 transitTierUploadTimestamp = 6; - - // If present, the cdn number of the succesful upload to media tier. - // If unset, may still have been uploaded, and clients - // can discover the cdn number via the list endpoint. - // Exporting clients should set this as long as their subscription - // has not rotated since last upload; even if currently free tier. - optional uint32 mediaTierCdnNumber = 7; - - reserved /*legacyMediaName*/ 8; - - // Separate key used to encrypt this file for the local backup. - // Generally required for local backups. - // Missing field indicates attachment was not available locally - // when the backup was generated, but remote backup or transit - // info was available. - optional bytes localKey = 9; - } - - reserved /*backupLocator*/ 1; - reserved /*attachmentLocator*/ 2; - reserved /*invalidAttachmentLocator*/ 3; - reserved /*localLocator*/ 12; - - optional string contentType = 4; - optional bytes incrementalMac = 5; - optional uint32 incrementalMacChunkSize = 6; - optional string fileName = 7; - optional uint32 width = 8; - optional uint32 height = 9; - optional string caption = 10; - optional string blurHash = 11; - LocatorInfo locatorInfo = 13; -} - -message Quote { - enum Type { - UNKNOWN = 0; // Interpret as "Normal" - NORMAL = 1; - GIFT_BADGE = 2; - VIEW_ONCE = 3; - POLL = 4; - } - - message QuotedAttachment { - optional string contentType = 1; - optional string fileName = 2; - optional MessageAttachment thumbnail = 3; - } - - optional uint64 targetSentTimestamp = 1; // null if the target message could not be found at time of quote insert - uint64 authorId = 2; - optional Text text = 3; - repeated QuotedAttachment attachments = 4; - Type type = 5; -} - -message BodyRange { - enum Style { - NONE = 0; // Importers should ignore the body range without throwing an error. - BOLD = 1; - ITALIC = 2; - SPOILER = 3; - STRIKETHROUGH = 4; - MONOSPACE = 5; - } - - // 'start' and 'length' are measured in UTF-16 code units. - // They may refer to offsets in a longText attachment. - uint32 start = 1; - uint32 length = 2; - - // If unset, importers should ignore the body range without throwing an error. - oneof associatedValue { - bytes mentionAci = 3; - Style style = 4; - } -} - -message Reaction { - string emoji = 1; - uint64 authorId = 2; - uint64 sentTimestamp = 3; - // A higher sort order means that a reaction is more recent. Some clients may export this as - // incrementing numbers (e.g. 1, 2, 3), others as timestamps. - uint64 sortOrder = 4; -} - -message Poll { - - message PollOption { - - message PollVote { - uint64 voterId = 1; // A direct reference to Recipient proto id. Must be self or contact. - uint32 voteCount = 2; // Tracks how many times you voted. - } - - string option = 1; // Between 1-100 characters - repeated PollVote votes = 2; - } - - string question = 1; // Between 1-100 characters - bool allowMultiple = 2; - repeated PollOption options = 3; // At least two - bool hasEnded = 4; - repeated Reaction reactions = 5; -} - -message AdminDeletedMessage { - uint64 adminId = 1; // id of the admin that deleted the message -} - -message ChatUpdateMessage { - // If unset, importers should ignore the update message without throwing an error. - oneof update { - SimpleChatUpdate simpleUpdate = 1; - GroupChangeChatUpdate groupChange = 2; - ExpirationTimerChatUpdate expirationTimerChange = 3; - ProfileChangeChatUpdate profileChange = 4; - ThreadMergeChatUpdate threadMerge = 5; - SessionSwitchoverChatUpdate sessionSwitchover = 6; - IndividualCall individualCall = 7; - GroupCall groupCall = 8; - LearnedProfileChatUpdate learnedProfileChange = 9; - PollTerminateUpdate pollTerminate = 10; - PinMessageUpdate pinMessage = 11; - } -} - -message IndividualCall { - enum Type { - UNKNOWN_TYPE = 0; // Interpret as "Audio call" - AUDIO_CALL = 1; - VIDEO_CALL = 2; - } - - enum Direction { - UNKNOWN_DIRECTION = 0; // Interpret as "Incoming" - INCOMING = 1; - OUTGOING = 2; - } - - enum State { - UNKNOWN_STATE = 0; // Interpret as "Accepted" - ACCEPTED = 1; - NOT_ACCEPTED = 2; - // An incoming call that is no longer ongoing, which we neither accepted - // not actively declined. For example, it expired, was canceled by the - // sender, or was rejected due to being in another call. - MISSED = 3; - // We auto-declined an incoming call due to a notification profile. - MISSED_NOTIFICATION_PROFILE = 4; - } - - optional uint64 callId = 1; - Type type = 2; - Direction direction = 3; - State state = 4; - uint64 startedCallTimestamp = 5; - bool read = 6; -} - -message GroupCall { - enum State { - UNKNOWN_STATE = 0; // Interpret as "Generic" - // A group call was started without ringing. - GENERIC = 1; - // We joined a group call that was started without ringing. - JOINED = 2; - // An incoming group call is actively ringing. - RINGING = 3; - // We accepted an incoming group ring. - ACCEPTED = 4; - // We declined an incoming group ring. - DECLINED = 5; - // We missed an incoming group ring, for example because it expired. - MISSED = 6; - // We auto-declined an incoming group ring due to a notification profile. - MISSED_NOTIFICATION_PROFILE = 7; - // An outgoing ring was started. We don't track any state for outgoing rings - // beyond that they started. - OUTGOING_RING = 8; - } - - optional uint64 callId = 1; - State state = 2; - optional uint64 ringerRecipientId = 3; - optional uint64 startedCallRecipientId = 4; - uint64 startedCallTimestamp = 5; - optional uint64 endedCallTimestamp = 6; // The time the call ended. - bool read = 7; -} - -message SimpleChatUpdate { - enum Type { - UNKNOWN = 0; // Importers should skip the update without throwing an error. - JOINED_SIGNAL = 1; - IDENTITY_UPDATE = 2; - IDENTITY_VERIFIED = 3; - IDENTITY_DEFAULT = 4; // marking as unverified - CHANGE_NUMBER = 5; - RELEASE_CHANNEL_DONATION_REQUEST = 6; - END_SESSION = 7; - CHAT_SESSION_REFRESH = 8; - BAD_DECRYPT = 9; - PAYMENTS_ACTIVATED = 10; - PAYMENT_ACTIVATION_REQUEST = 11; - UNSUPPORTED_PROTOCOL_MESSAGE = 12; - REPORTED_SPAM = 13; - BLOCKED = 14; - UNBLOCKED = 15; - MESSAGE_REQUEST_ACCEPTED = 16; - } - - Type type = 1; -} - -// For 1:1 chat updates only. -// For group thread updates use GroupExpirationTimerUpdate. -message ExpirationTimerChatUpdate { - uint64 expiresInMs = 1; // 0 means the expiration timer was disabled -} - -message ProfileChangeChatUpdate { - string previousName = 1; - string newName = 2; -} - -message LearnedProfileChatUpdate { - // If unset, importers should consider the previous name to be an empty string. - oneof previousName { - uint64 e164 = 1; - string username = 2; - } -} - -message ThreadMergeChatUpdate { - uint64 previousE164 = 1; -} - -message SessionSwitchoverChatUpdate { - uint64 e164 = 1; -} - -message GroupChangeChatUpdate { - message Update { - // If unset, importers should consider it to be a GenericGroupUpdate with unset updaterAci - oneof update { - GenericGroupUpdate genericGroupUpdate = 1; - GroupCreationUpdate groupCreationUpdate = 2; - GroupNameUpdate groupNameUpdate = 3; - GroupAvatarUpdate groupAvatarUpdate = 4; - GroupDescriptionUpdate groupDescriptionUpdate = 5; - GroupMembershipAccessLevelChangeUpdate groupMembershipAccessLevelChangeUpdate = 6; - GroupAttributesAccessLevelChangeUpdate groupAttributesAccessLevelChangeUpdate = 7; - GroupAnnouncementOnlyChangeUpdate groupAnnouncementOnlyChangeUpdate = 8; - GroupAdminStatusUpdate groupAdminStatusUpdate = 9; - GroupMemberLeftUpdate groupMemberLeftUpdate = 10; - GroupMemberRemovedUpdate groupMemberRemovedUpdate = 11; - SelfInvitedToGroupUpdate selfInvitedToGroupUpdate = 12; - SelfInvitedOtherUserToGroupUpdate selfInvitedOtherUserToGroupUpdate = 13; - GroupUnknownInviteeUpdate groupUnknownInviteeUpdate = 14; - GroupInvitationAcceptedUpdate groupInvitationAcceptedUpdate = 15; - GroupInvitationDeclinedUpdate groupInvitationDeclinedUpdate = 16; - GroupMemberJoinedUpdate groupMemberJoinedUpdate = 17; - GroupMemberAddedUpdate groupMemberAddedUpdate = 18; - GroupSelfInvitationRevokedUpdate groupSelfInvitationRevokedUpdate = 19; - GroupInvitationRevokedUpdate groupInvitationRevokedUpdate = 20; - GroupJoinRequestUpdate groupJoinRequestUpdate = 21; - GroupJoinRequestApprovalUpdate groupJoinRequestApprovalUpdate = 22; - GroupJoinRequestCanceledUpdate groupJoinRequestCanceledUpdate = 23; - GroupInviteLinkResetUpdate groupInviteLinkResetUpdate = 24; - GroupInviteLinkEnabledUpdate groupInviteLinkEnabledUpdate = 25; - GroupInviteLinkAdminApprovalUpdate groupInviteLinkAdminApprovalUpdate = 26; - GroupInviteLinkDisabledUpdate groupInviteLinkDisabledUpdate = 27; - GroupMemberJoinedByLinkUpdate groupMemberJoinedByLinkUpdate = 28; - GroupV2MigrationUpdate groupV2MigrationUpdate = 29; - GroupV2MigrationSelfInvitedUpdate groupV2MigrationSelfInvitedUpdate = 30; - GroupV2MigrationInvitedMembersUpdate groupV2MigrationInvitedMembersUpdate = 31; - GroupV2MigrationDroppedMembersUpdate groupV2MigrationDroppedMembersUpdate = 32; - GroupSequenceOfRequestsAndCancelsUpdate groupSequenceOfRequestsAndCancelsUpdate = 33; - GroupExpirationTimerUpdate groupExpirationTimerUpdate = 34; - GroupMemberLabelAccessLevelChangeUpdate groupMemberLabelAccessLevelChangeUpdate = 35; - GroupTerminateChangeUpdate groupTerminateChangeUpdate = 36; - } - } - - // Must be one or more; all updates batched together came from - // a single batched group state update. - repeated Update updates = 1; -} - -message GenericGroupUpdate { - optional bytes updaterAci = 1; -} - -message GroupCreationUpdate { - optional bytes updaterAci = 1; -} - -message GroupNameUpdate { - optional bytes updaterAci = 1; - // Null value means the group name was removed. - optional string newGroupName = 2; -} - -message GroupAvatarUpdate { - optional bytes updaterAci = 1; - bool wasRemoved = 2; -} - -message GroupDescriptionUpdate { - optional bytes updaterAci = 1; - // Null value means the group description was removed. - optional string newDescription = 2; -} - -enum GroupV2AccessLevel { - UNKNOWN = 0; // Interpret as "Unsatisfiable" - ANY = 1; - MEMBER = 2; - ADMINISTRATOR = 3; - UNSATISFIABLE = 4; -} - -message GroupMembershipAccessLevelChangeUpdate { - optional bytes updaterAci = 1; - GroupV2AccessLevel accessLevel = 2; -} - -message GroupAttributesAccessLevelChangeUpdate { - optional bytes updaterAci = 1; - GroupV2AccessLevel accessLevel = 2; -} - -message GroupMemberLabelAccessLevelChangeUpdate { - optional bytes updaterAci = 1; - GroupV2AccessLevel accessLevel = 2; -} - -message GroupTerminateChangeUpdate { - optional bytes updaterAci = 1; -} - -message GroupAnnouncementOnlyChangeUpdate { - optional bytes updaterAci = 1; - bool isAnnouncementOnly = 2; -} - -message GroupAdminStatusUpdate { - optional bytes updaterAci = 1; - // The aci who had admin status granted or revoked. - bytes memberAci = 2; - bool wasAdminStatusGranted = 3; -} - -message GroupMemberLeftUpdate { - bytes aci = 1; -} - -message GroupMemberRemovedUpdate { - optional bytes removerAci = 1; - bytes removedAci = 2; -} - -message SelfInvitedToGroupUpdate { - optional bytes inviterAci = 1; -} - -message SelfInvitedOtherUserToGroupUpdate { - // If no invitee id available, use GroupUnknownInviteeUpdate - bytes inviteeServiceId = 1; -} - -message GroupUnknownInviteeUpdate { - // Can be the self user. - optional bytes inviterAci = 1; - uint32 inviteeCount = 2; -} - -message GroupInvitationAcceptedUpdate { - optional bytes inviterAci = 1; - bytes newMemberAci = 2; -} - -message GroupInvitationDeclinedUpdate { - optional bytes inviterAci = 1; - // Note: if invited by pni, just set inviteeAci to nil. - optional bytes inviteeAci = 2; -} - -message GroupMemberJoinedUpdate { - bytes newMemberAci = 1; -} - -message GroupMemberAddedUpdate { - optional bytes updaterAci = 1; - bytes newMemberAci = 2; - bool hadOpenInvitation = 3; - // If hadOpenInvitation is true, optionally include aci of the inviter. - optional bytes inviterAci = 4; -} - -// An invitation to self was revoked. -message GroupSelfInvitationRevokedUpdate { - optional bytes revokerAci = 1; -} - -// These invitees should never be the local user. -// Use GroupSelfInvitationRevokedUpdate in those cases. -// The inviter or updater can be the local user. -message GroupInvitationRevokedUpdate { - message Invitee { - optional bytes inviterAci = 1; - // Prefer to use aci over pni. No need to set - // pni if aci is set. Both can be missing. - optional bytes inviteeAci = 2; - optional bytes inviteePni = 3; - } - - // The member that revoked the invite(s), not the inviter! - // Assumed to be an admin (at the time, may no longer be an - // admin or even a member). - optional bytes updaterAci = 1; - repeated Invitee invitees = 2; -} - -message GroupJoinRequestUpdate { - bytes requestorAci = 1; -} - -message GroupJoinRequestApprovalUpdate { - bytes requestorAci = 1; - // The aci that approved or rejected the request. - optional bytes updaterAci = 2; - bool wasApproved = 3; -} - -message GroupJoinRequestCanceledUpdate { - bytes requestorAci = 1; -} - -// A single requestor has requested to join and cancelled -// their request repeatedly with no other updates in between. -// The last action encompassed by this update is always a -// cancellation; if there was another open request immediately -// after, it will be a separate GroupJoinRequestUpdate, either -// in the same frame or in a subsequent frame. -message GroupSequenceOfRequestsAndCancelsUpdate { - bytes requestorAci = 1; - uint32 count = 2; -} - -message GroupInviteLinkResetUpdate { - optional bytes updaterAci = 1; -} - -message GroupInviteLinkEnabledUpdate { - optional bytes updaterAci = 1; - bool linkRequiresAdminApproval = 2; -} - -message GroupInviteLinkAdminApprovalUpdate { - optional bytes updaterAci = 1; - bool linkRequiresAdminApproval = 2; -} - -message GroupInviteLinkDisabledUpdate { - optional bytes updaterAci = 1; -} - -message GroupMemberJoinedByLinkUpdate { - bytes newMemberAci = 1; -} - -// A gv1->gv2 migration occurred. -message GroupV2MigrationUpdate {} - -// Another user migrated gv1->gv2 but was unable to add -// the local user and invited them instead. -message GroupV2MigrationSelfInvitedUpdate {} - -// The local user migrated gv1->gv2 but was unable to -// add some members and invited them instead. -// (Happens if we don't have the invitee's profile key) -message GroupV2MigrationInvitedMembersUpdate { - uint32 invitedMembersCount = 1; -} - -// The local user migrated gv1->gv2 but was unable to -// add or invite some members and dropped them instead. -// (Happens for e164 members where we don't have an aci). -message GroupV2MigrationDroppedMembersUpdate { - uint32 droppedMembersCount = 1; -} - -// For 1:1 timer updates, use ExpirationTimerChatUpdate. -message GroupExpirationTimerUpdate { - uint64 expiresInMs = 1; // 0 means the expiration timer was disabled - optional bytes updaterAci = 2; -} - -message PollTerminateUpdate { - uint64 targetSentTimestamp = 1; - string question = 2; // Between 1-100 characters -} - -message PinMessageUpdate { - uint64 targetSentTimestamp = 1; - uint64 authorId = 2; // recipient id -} - -message StickerPack { - bytes packId = 1; - bytes packKey = 2; -} - -message ChatStyle { - message Gradient { - uint32 angle = 1; // degrees - repeated fixed32 colors = 2; // 0xAARRGGBB - repeated float positions = 3; // percent from 0 to 1 - } - - message CustomChatColor { - uint64 id = 1; - - // If unset, use the default chat color - oneof color { - fixed32 solid = 2; // 0xAARRGGBB - Gradient gradient = 3; - } - } - - message AutomaticBubbleColor { - } - - enum WallpaperPreset { - UNKNOWN_WALLPAPER_PRESET = 0; // Interpret as the wallpaper being unset - SOLID_BLUSH = 1; - SOLID_COPPER = 2; - SOLID_DUST = 3; - SOLID_CELADON = 4; - SOLID_RAINFOREST = 5; - SOLID_PACIFIC = 6; - SOLID_FROST = 7; - SOLID_NAVY = 8; - SOLID_LILAC = 9; - SOLID_PINK = 10; - SOLID_EGGPLANT = 11; - SOLID_SILVER = 12; - GRADIENT_SUNSET = 13; - GRADIENT_NOIR = 14; - GRADIENT_HEATMAP = 15; - GRADIENT_AQUA = 16; - GRADIENT_IRIDESCENT = 17; - GRADIENT_MONSTERA = 18; - GRADIENT_BLISS = 19; - GRADIENT_SKY = 20; - GRADIENT_PEACH = 21; - } - - enum BubbleColorPreset { - UNKNOWN_BUBBLE_COLOR_PRESET = 0; // Interpret as the user's default chat bubble color - SOLID_ULTRAMARINE = 1; - SOLID_CRIMSON = 2; - SOLID_VERMILION = 3; - SOLID_BURLAP = 4; - SOLID_FOREST = 5; - SOLID_WINTERGREEN = 6; - SOLID_TEAL = 7; - SOLID_BLUE = 8; - SOLID_INDIGO = 9; - SOLID_VIOLET = 10; - SOLID_PLUM = 11; - SOLID_TAUPE = 12; - SOLID_STEEL = 13; - GRADIENT_EMBER = 14; - GRADIENT_MIDNIGHT = 15; - GRADIENT_INFRARED = 16; - GRADIENT_LAGOON = 17; - GRADIENT_FLUORESCENT = 18; - GRADIENT_BASIL = 19; - GRADIENT_SUBLIME = 20; - GRADIENT_SEA = 21; - GRADIENT_TANGERINE = 22; - } - - // If unset, importers should consider there to be no wallpaper. - oneof wallpaper { - WallpaperPreset wallpaperPreset = 1; - // This `FilePointer` is expected not to contain a `fileName`, `width`, - // `height`, or `caption`. - FilePointer wallpaperPhoto = 2; - } - - // If unset, importers should consider it to be AutomaticBubbleColor - oneof bubbleColor { - // Bubble setting is automatically determined based on the wallpaper setting, - // or `SOLID_ULTRAMARINE` for `noWallpaper` - AutomaticBubbleColor autoBubbleColor = 3; - BubbleColorPreset bubbleColorPreset = 4; - - // See AccountSettings.customChatColors - uint64 customColorId = 5; - } - - bool dimWallpaperInDarkMode = 7; -} - -message NotificationProfile { - enum DayOfWeek { - UNKNOWN = 0; // Interpret as "Monday" - MONDAY = 1; - TUESDAY = 2; - WEDNESDAY = 3; - THURSDAY = 4; - FRIDAY = 5; - SATURDAY = 6; - SUNDAY = 7; - } - - string name = 1; - optional string emoji = 2; - fixed32 color = 3; // 0xAARRGGBB - uint64 createdAtMs = 4; - bool allowAllCalls = 5; - bool allowAllMentions = 6; - repeated uint64 allowedMembers = 7; // generated recipient id for allowed groups and contacts - bool scheduleEnabled = 8; - uint32 scheduleStartTime = 9; // 24-hour clock int, 0000-2359 (e.g., 15, 900, 1130, 2345) - uint32 scheduleEndTime = 10; // 24-hour clock int, 0000-2359 (e.g., 15, 900, 1130, 2345) - repeated DayOfWeek scheduleDaysEnabled = 11; - bytes id = 12; // should be 16 bytes -} - -message ChatFolder { - // Represents the default "All chats" folder record vs all other custom folders - enum FolderType { - UNKNOWN = 0; // Interpret as "Custom" - ALL = 1; - CUSTOM = 2; - } - - string name = 1; - bool showOnlyUnread = 2; - bool showMutedChats = 3; - // Folder includes all 1:1 chats, unless excluded - bool includeAllIndividualChats = 4; - // Folder includes all group chats, unless excluded - bool includeAllGroupChats = 5; - FolderType folderType = 6; - repeated uint64 includedRecipientIds = 7; // generated recipient id of groups, contacts, and/or note to self - repeated uint64 excludedRecipientIds = 8; // generated recipient id of groups, contacts, and/or note to self - bytes id = 9; // should be 16 bytes -} diff --git a/pkg/signalmeow/protobuf/build-protos.sh b/pkg/signalmeow/protobuf/build-protos.sh index 54116ec..60b622b 100755 --- a/pkg/signalmeow/protobuf/build-protos.sh +++ b/pkg/signalmeow/protobuf/build-protos.sh @@ -1,15 +1,17 @@ -#!/bin/sh +#!/usr/bin/env bash + +# This script is used to generate the protobuf files for the project. +# It is assumed that the protoc compiler is installed and available on the path. + +# The script will generate the protobuf files for the following languages: +# - Go + PKG_IMPORT_PATH="go.mau.fi/mautrix-signal/pkg/signalmeow/signalpb" + for file in *.proto do - # Requires https://go-review.googlesource.com/c/protobuf/+/369634 - protoc --go_out=. \ - --go_opt=M${file}=$PKG_IMPORT_PATH \ - --go_opt=paths=source_relative \ - $file + protoc --go_out=. \ + --go_opt=M${file}=$PKG_IMPORT_PATH \ + --go_opt=paths=source_relative \ + $file done -protoc --go_out=. \ - --go_opt=Mbackuppb/Backup.proto=$PKG_IMPORT_PATH/backuppb \ - --go_opt=paths=source_relative \ - backuppb/Backup.proto -pre-commit run -a diff --git a/pkg/signalmeow/protobuf/update-protos.sh b/pkg/signalmeow/protobuf/update-protos.sh index f9c86fc..c24bc3a 100755 --- a/pkg/signalmeow/protobuf/update-protos.sh +++ b/pkg/signalmeow/protobuf/update-protos.sh @@ -1,29 +1,22 @@ #!/bin/bash set -euo pipefail -ANDROID_GIT_REVISION=${1:-439760e7732585bfd078d92d93732c04cc31e29e} -DESKTOP_GIT_REVISION=${1:-1b2a3e7b283c32c5654a39da12fc04139fd26dbd} +ANDROID_GIT_REVISION=${1:-e17b07bb12110c0ebeae193cb6fad35d33b57d40} +DESKTOP_GIT_REVISION=${1:-c6c072319993fefd9fcfab55ca77dc75263bc875} update_proto() { case "$1" in Signal-Android) - REPO="Signal-Android" - prefix="lib/libsignal-service/src/main/protowire/" - GIT_REVISION=$ANDROID_GIT_REVISION - ;; - Signal-Android-Archive) - REPO="Signal-Android" - prefix="lib/archive/src/main/protowire/" + prefix="libsignal-service/src/main/protowire/" GIT_REVISION=$ANDROID_GIT_REVISION ;; Signal-Desktop) - REPO="Signal-Desktop" prefix="protos/" GIT_REVISION=$DESKTOP_GIT_REVISION ;; esac - echo https://raw.githubusercontent.com/signalapp/${REPO}/${GIT_REVISION}/${prefix}${2} - curl -LOf https://raw.githubusercontent.com/signalapp/${REPO}/${GIT_REVISION}/${prefix}${2} + echo https://raw.githubusercontent.com/signalapp/${1}/${GIT_REVISION}/${prefix}${2} + curl -LOf https://raw.githubusercontent.com/signalapp/${1}/${GIT_REVISION}/${prefix}${2} } @@ -32,12 +25,6 @@ update_proto Signal-Android Provisioning.proto update_proto Signal-Android SignalService.proto update_proto Signal-Android StickerResources.proto update_proto Signal-Android WebSocketResources.proto -update_proto Signal-Android StorageService.proto - -update_proto Signal-Android-Archive Backup.proto -mv Backup.proto backuppb/Backup.proto update_proto Signal-Desktop DeviceName.proto -# TODO these were moved to libsignal only -#update_proto Signal-Desktop UnidentifiedDelivery.proto -#update_proto Signal-Desktop ContactDiscovery.proto +update_proto Signal-Desktop UnidentifiedDelivery.proto diff --git a/pkg/signalmeow/provisioning.go b/pkg/signalmeow/provisioning.go index 8e0fa96..8a1fd71 100644 --- a/pkg/signalmeow/provisioning.go +++ b/pkg/signalmeow/provisioning.go @@ -18,33 +18,41 @@ package signalmeow import ( "context" + crand "crypto/rand" "encoding/base64" "encoding/json" "fmt" - mrand "math/rand/v2" + "math/big" + mrand "math/rand" "net/http" "net/url" "time" - "github.com/coder/websocket" - "github.com/google/uuid" - "github.com/rs/zerolog" - "go.mau.fi/util/exerrors" - "go.mau.fi/util/random" "google.golang.org/protobuf/proto" + "nhooyr.io/websocket" "go.mau.fi/mautrix-signal/pkg/libsignalgo" signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" - "go.mau.fi/mautrix-signal/pkg/signalmeow/store" - "go.mau.fi/mautrix-signal/pkg/signalmeow/types" "go.mau.fi/mautrix-signal/pkg/signalmeow/web" "go.mau.fi/mautrix-signal/pkg/signalmeow/wspb" ) type ConfirmDeviceResponse struct { - ACI uuid.UUID `json:"uuid"` - PNI uuid.UUID `json:"pni,omitempty"` - DeviceID int `json:"deviceId"` + Uuid string `json:"uuid"` + Pni string `json:"pni,omitempty"` + DeviceId int `json:"deviceId"` +} + +type ProvisioningData struct { + AciIdentityKeyPair *libsignalgo.IdentityKeyPair + PniIdentityKeyPair *libsignalgo.IdentityKeyPair + RegistrationId int + PniRegistrationId int + AciUuid string + PniUuid string + DeviceId int + Number string + Password string } type ProvisioningState int @@ -53,6 +61,7 @@ const ( StateProvisioningError ProvisioningState = iota StateProvisioningURLReceived StateProvisioningDataReceived + StateProvisioningPreKeysRegistered ) func (s ProvisioningState) String() string { @@ -63,6 +72,8 @@ func (s ProvisioningState) String() string { return "StateProvisioningURLReceived" case StateProvisioningDataReceived: return "StateProvisioningDataReceived" + case StateProvisioningPreKeysRegistered: + return "StateProvisioningPreKeysRegistered" default: return fmt.Sprintf("ProvisioningState(%d)", s) } @@ -71,72 +82,69 @@ func (s ProvisioningState) String() string { // Enum for the provisioningUrl, ProvisioningMessage, and error type ProvisioningResponse struct { State ProvisioningState - ProvisioningURL string - ProvisioningData *store.DeviceData + ProvisioningUrl string + ProvisioningData *DeviceData Err error } -func PerformProvisioning(ctx context.Context, deviceStore store.DeviceStore, deviceName string, allowBackup bool) chan ProvisioningResponse { - log := zerolog.Ctx(ctx).With().Str("action", "perform provisioning").Logger() - c := make(chan ProvisioningResponse, 4) +func PerformProvisioning(incomingCtx context.Context, deviceStore DeviceStore, deviceName string) chan ProvisioningResponse { + c := make(chan ProvisioningResponse) go func() { defer close(c) - timeoutCtx, cancel := context.WithTimeout(ctx, 2*time.Minute) + ctx, cancel := context.WithTimeout(incomingCtx, 2*time.Minute) defer cancel() - ws, resp, err := web.OpenWebsocket(timeoutCtx, (&url.URL{ - Scheme: "wss", - Host: web.APIHostname, - Path: web.WebsocketProvisioningPath, - }).String()) + ws, resp, err := web.OpenWebsocket(ctx, web.WebsocketProvisioningPath) if err != nil { - log.Err(err).Any("resp", resp).Msg("error opening provisioning websocket") + zlog.Err(err).Any("resp", resp).Msg("error opening provisioning websocket") c <- ProvisioningResponse{State: StateProvisioningError, Err: err} return } defer ws.Close(websocket.StatusInternalError, "Websocket StatusInternalError") provisioningCipher := NewProvisioningCipher() - provisioningURL, err := startProvisioning(timeoutCtx, ws, provisioningCipher, allowBackup) + provisioningUrl, err := startProvisioning(ctx, ws, provisioningCipher) if err != nil { - log.Err(err).Msg("startProvisioning error") + zlog.Err(err).Msg("startProvisioning error") c <- ProvisioningResponse{State: StateProvisioningError, Err: err} return } - c <- ProvisioningResponse{State: StateProvisioningURLReceived, ProvisioningURL: provisioningURL, Err: err} + c <- ProvisioningResponse{State: StateProvisioningURLReceived, ProvisioningUrl: provisioningUrl, Err: err} - provisioningMessage, err := continueProvisioning(timeoutCtx, ws, provisioningCipher) + provisioningMessage, err := continueProvisioning(ctx, ws, provisioningCipher) if err != nil { - log.Err(err).Msg("continueProvisioning error") + zlog.Err(err).Msg("continueProvisioning error") c <- ProvisioningResponse{State: StateProvisioningError, Err: err} return } ws.Close(websocket.StatusNormalClosure, "") - aciPublicKey := exerrors.Must(libsignalgo.DeserializePublicKey(provisioningMessage.GetAciIdentityKeyPublic())) - aciPrivateKey := exerrors.Must(libsignalgo.DeserializePrivateKey(provisioningMessage.GetAciIdentityKeyPrivate())) - aciIdentityKeyPair := exerrors.Must(libsignalgo.NewIdentityKeyPair(aciPublicKey, aciPrivateKey)) - pniPublicKey := exerrors.Must(libsignalgo.DeserializePublicKey(provisioningMessage.GetPniIdentityKeyPublic())) - pniPrivateKey := exerrors.Must(libsignalgo.DeserializePrivateKey(provisioningMessage.GetPniIdentityKeyPrivate())) - pniIdentityKeyPair := exerrors.Must(libsignalgo.NewIdentityKeyPair(pniPublicKey, pniPrivateKey)) + aciPublicKey, _ := libsignalgo.DeserializePublicKey(provisioningMessage.GetAciIdentityKeyPublic()) + aciPrivateKey, _ := libsignalgo.DeserializePrivateKey(provisioningMessage.GetAciIdentityKeyPrivate()) + aciIdentityKeyPair, _ := libsignalgo.NewIdentityKeyPair(aciPublicKey, aciPrivateKey) + pniPublicKey, _ := libsignalgo.DeserializePublicKey(provisioningMessage.GetPniIdentityKeyPublic()) + pniPrivateKey, _ := libsignalgo.DeserializePrivateKey(provisioningMessage.GetPniIdentityKeyPrivate()) + pniIdentityKeyPair, _ := libsignalgo.NewIdentityKeyPair(pniPublicKey, pniPrivateKey) profileKey := libsignalgo.ProfileKey(provisioningMessage.GetProfileKey()) username := *provisioningMessage.Number - password := random.String(22) + password, _ := generateRandomPassword(22) code := provisioningMessage.ProvisioningCode - aciRegistrationID := mrand.IntN(16383) + 1 - pniRegistrationID := mrand.IntN(16383) + 1 - aciSignedPreKey := GenerateSignedPreKey(1, aciIdentityKeyPair) - pniSignedPreKey := GenerateSignedPreKey(1, pniIdentityKeyPair) - aciPQLastResortPreKey := GenerateKyberPreKeys(1, 1, aciIdentityKeyPair)[0] - pniPQLastResortPreKey := GenerateKyberPreKeys(1, 1, pniIdentityKeyPair)[0] + registrationId := mrand.Intn(16383) + 1 + pniRegistrationId := mrand.Intn(16383) + 1 + aciSignedPreKey := GenerateSignedPreKey(1, UUID_KIND_ACI, aciIdentityKeyPair) + pniSignedPreKey := GenerateSignedPreKey(2, UUID_KIND_PNI, pniIdentityKeyPair) + aciPQLastResortPreKeys := GenerateKyberPreKeys(1, 1, UUID_KIND_ACI, aciIdentityKeyPair) + pniPQLastResortPreKeys := GenerateKyberPreKeys(1, 1, UUID_KIND_PNI, pniIdentityKeyPair) + aciPQLastResortPreKey := aciPQLastResortPreKeys[0] + pniPQLastResortPreKey := pniPQLastResortPreKeys[0] deviceResponse, err := confirmDevice( ctx, username, password, *code, - aciRegistrationID, - pniRegistrationID, + registrationId, + pniRegistrationId, aciSignedPreKey, pniSignedPreKey, aciPQLastResortPreKey, @@ -145,160 +153,133 @@ func PerformProvisioning(ctx context.Context, deviceStore store.DeviceStore, dev deviceName, ) if err != nil { - log.Err(err).Msg("confirmDevice error") + zlog.Err(err).Msg("confirmDevice error") c <- ProvisioningResponse{State: StateProvisioningError, Err: err} return } deviceId := 1 - if deviceResponse.DeviceID != 0 { - deviceId = deviceResponse.DeviceID + if deviceResponse.DeviceId != 0 { + deviceId = deviceResponse.DeviceId } - data := &store.DeviceData{ - ACIIdentityKeyPair: aciIdentityKeyPair, - PNIIdentityKeyPair: pniIdentityKeyPair, - ACIRegistrationID: aciRegistrationID, - PNIRegistrationID: pniRegistrationID, - ACI: deviceResponse.ACI, - PNI: deviceResponse.PNI, - DeviceID: deviceId, + data := &DeviceData{ + AciIdentityKeyPair: aciIdentityKeyPair, + PniIdentityKeyPair: pniIdentityKeyPair, + RegistrationId: registrationId, + PniRegistrationId: pniRegistrationId, + AciUuid: deviceResponse.Uuid, + PniUuid: deviceResponse.Pni, + DeviceId: deviceId, Number: *provisioningMessage.Number, Password: password, - AccountEntropyPool: libsignalgo.AccountEntropyPool(provisioningMessage.GetAccountEntropyPool()), - EphemeralBackupKey: libsignalgo.BytesToBackupKey(provisioningMessage.GetEphemeralBackupKey()), - MediaRootBackupKey: libsignalgo.BytesToBackupKey(provisioningMessage.GetMediaRootBackupKey()), - } - if provisioningMessage.GetAccountEntropyPool() != "" { - data.MasterKey, err = libsignalgo.AccountEntropyPool(provisioningMessage.GetAccountEntropyPool()).DeriveSVRKey() - if err != nil { - log.Err(err).Msg("Failed to derive master key from account entropy pool") - } else { - log.Debug().Msg("Derived master key from account entropy pool") - } - } else { - log.Warn().Msg("No account entropy pool in provisioning message") } // Store the provisioning data - err = deviceStore.PutDevice(ctx, data) + err = deviceStore.PutDevice(data) if err != nil { - log.Err(err).Msg("error storing new device") + zlog.Err(err).Msg("error storing new device") c <- ProvisioningResponse{State: StateProvisioningError, Err: err} return } - device, err := deviceStore.DeviceByACI(ctx, data.ACI) + device, err := deviceStore.DeviceByAci(data.AciUuid) if err != nil { - log.Err(err).Msg("error retrieving new device") + zlog.Err(err).Msg("error retrieving new device") c <- ProvisioningResponse{State: StateProvisioningError, Err: err} return } // In case this is an existing device, we gotta clear out keys - device.ClearDeviceKeys(ctx) + device.ClearDeviceKeys() // Store identity keys? - _, err = device.IdentityKeyStore.SaveIdentityKey(ctx, device.ACIServiceID(), device.ACIIdentityKeyPair.GetIdentityKey()) + address, err := libsignalgo.NewAddress(device.Data.AciUuid, uint(device.Data.DeviceId)) + _, err = device.IdentityStore.SaveIdentityKey(address, device.Data.AciIdentityKeyPair.GetIdentityKey(), ctx) if err != nil { - c <- ProvisioningResponse{ - State: StateProvisioningError, - Err: fmt.Errorf("error saving identity key: %w", err), - } - return - } - _, err = device.IdentityKeyStore.SaveIdentityKey(ctx, device.PNIServiceID(), device.PNIIdentityKeyPair.GetIdentityKey()) - if err != nil { - c <- ProvisioningResponse{ - State: StateProvisioningError, - Err: fmt.Errorf("error saving identity key: %w", err), - } + zlog.Err(err).Msg("error saving identity key") + c <- ProvisioningResponse{State: StateProvisioningError, Err: err} return } // Store signed prekeys (now that we have a device) - device.ACIPreKeyStore.StoreSignedPreKey(ctx, 1, aciSignedPreKey) - device.PNIPreKeyStore.StoreSignedPreKey(ctx, 1, pniSignedPreKey) - device.ACIPreKeyStore.StoreLastResortKyberPreKey(ctx, 1, aciPQLastResortPreKey) - device.PNIPreKeyStore.StoreLastResortKyberPreKey(ctx, 1, pniPQLastResortPreKey) + StoreSignedPreKey(device, aciSignedPreKey, UUID_KIND_ACI) + StoreSignedPreKey(device, pniSignedPreKey, UUID_KIND_PNI) + StoreKyberLastResortPreKey(device, aciPQLastResortPreKey, UUID_KIND_ACI) + StoreKyberLastResortPreKey(device, pniPQLastResortPreKey, UUID_KIND_PNI) // Store our profile key - err = device.RecipientStore.StoreRecipient(ctx, &types.Recipient{ - ACI: data.ACI, - PNI: data.PNI, - E164: data.Number, - Profile: types.Profile{ - Key: profileKey, - }, - }) + err = device.ProfileKeyStore.StoreProfileKey(data.AciUuid, profileKey, ctx) if err != nil { - c <- ProvisioningResponse{ - State: StateProvisioningError, - Err: fmt.Errorf("error storing profile key: %w", err), - } + zlog.Err(err).Msg("error storing profile key") + c <- ProvisioningResponse{State: StateProvisioningError, Err: err} return } // Return the provisioning data c <- ProvisioningResponse{State: StateProvisioningDataReceived, ProvisioningData: data} + + // Generate, store, and register prekeys + err = GenerateAndRegisterPreKeys(device, UUID_KIND_ACI) + err = GenerateAndRegisterPreKeys(device, UUID_KIND_PNI) + + if err != nil { + zlog.Err(err).Msg("error generating and registering prekeys") + c <- ProvisioningResponse{State: StateProvisioningError, Err: err} + return + } + + c <- ProvisioningResponse{State: StateProvisioningPreKeysRegistered} }() return c } // Returns the provisioningUrl and an error -func startProvisioning(ctx context.Context, ws *websocket.Conn, provisioningCipher *ProvisioningCipher, allowBackup bool) (string, error) { - log := zerolog.Ctx(ctx).With().Str("action", "start provisioning").Logger() +func startProvisioning(ctx context.Context, ws *websocket.Conn, provisioningCipher *ProvisioningCipher) (string, error) { pubKey := provisioningCipher.GetPublicKey() + provisioningUrl := "" + msg := &signalpb.WebSocketMessage{} err := wspb.Read(ctx, ws, msg) if err != nil { - log.Err(err).Msg("error reading websocket message") + zlog.Err(err).Msg("error reading websocket message") return "", err } // Ensure the message is a request and has a valid verb and path - if msg.GetType() != signalpb.WebSocketMessage_REQUEST || msg.GetRequest().GetVerb() != http.MethodPut || msg.GetRequest().GetPath() != "/v1/address" { - return "", fmt.Errorf("unexpected websocket message: %v", msg) - } + if *msg.Type == signalpb.WebSocketMessage_REQUEST && + *msg.Request.Verb == http.MethodPut && + *msg.Request.Path == "/v1/address" { - var provisioningBody signalpb.ProvisioningAddress - err = proto.Unmarshal(msg.GetRequest().GetBody(), &provisioningBody) - if err != nil { - return "", fmt.Errorf("failed to unmarshal provisioning UUID: %w", err) - } + // Decode provisioning UUID + provisioningUuid := &signalpb.ProvisioningUuid{} + err = proto.Unmarshal(msg.Request.Body, provisioningUuid) - linkCapabilities := []string{"backup4,backup5"} - if !allowBackup { - linkCapabilities = []string{} - } - provisioningURL := (&url.URL{ - Scheme: "sgnl", - Host: "linkdevice", - RawQuery: url.Values{ - "uuid": []string{provisioningBody.GetAddress()}, - "pub_key": []string{base64.StdEncoding.EncodeToString(exerrors.Must(pubKey.Serialize()))}, - "capabilities": linkCapabilities, - }.Encode(), - }).String() + // Create provisioning URL + bytesKey, _ := pubKey.Serialize() + base64Key := base64.StdEncoding.EncodeToString(bytesKey) + uuid := url.QueryEscape(*provisioningUuid.Uuid) + pubKey := url.QueryEscape(base64Key) + provisioningUrl = "sgnl://linkdevice?uuid=" + uuid + "&pub_key=" + pubKey - // Create and send response - response := web.CreateWSResponse(ctx, msg.GetRequest().GetId(), 200) - err = wspb.Write(ctx, ws, response) - if err != nil { - log.Err(err).Msg("error writing websocket message") - return "", err + // Create and send response + response := web.CreateWSResponse(*msg.Request.Id, 200) + err = wspb.Write(ctx, ws, response) + if err != nil { + zlog.Err(err).Msg("error writing websocket message") + return "", err + } } - return provisioningURL, nil + return provisioningUrl, nil } func continueProvisioning(ctx context.Context, ws *websocket.Conn, provisioningCipher *ProvisioningCipher) (*signalpb.ProvisionMessage, error) { - log := zerolog.Ctx(ctx).With().Str("action", "continue provisioning").Logger() envelope := &signalpb.ProvisionEnvelope{} msg := &signalpb.WebSocketMessage{} err := wspb.Read(ctx, ws, msg) if err != nil { - log.Err(err).Msg("error reading websocket message") + zlog.Err(err).Msg("error reading websocket message") return nil, err } @@ -312,51 +293,28 @@ func continueProvisioning(ctx context.Context, ws *websocket.Conn, provisioningC return nil, err } - response := web.CreateWSResponse(ctx, *msg.Request.Id, 200) + response := web.CreateWSResponse(*msg.Request.Id, 200) err = wspb.Write(ctx, ws, response) if err != nil { - log.Err(err).Msg("error writing websocket message") + zlog.Err(err).Msg("error writing websocket message") return nil, err } } else { err = fmt.Errorf("invalid provisioning message, type: %v, verb: %v, path: %v", *msg.Type, *msg.Request.Verb, *msg.Request.Path) - log.Err(err).Msg("problem reading websocket message") + zlog.Err(err).Msg("problem reading websocket message") return nil, err } provisioningMessage, err := provisioningCipher.Decrypt(envelope) return provisioningMessage, err } -var signalCapabilities = map[string]any{ - "attachmentBackfill": true, - "spqr": true, -} - -var signalCapabilitiesBody = exerrors.Must(json.Marshal(signalCapabilities)) - -func (cli *Client) RegisterCapabilities(ctx context.Context) error { - resp, err := cli.AuthedWS.SendRequest(ctx, http.MethodPut, "/v1/devices/capabilities", signalCapabilitiesBody, nil) - if err != nil { - return err - } - return web.DecodeWSResponseBody(ctx, nil, resp) -} - -func (cli *Client) Unlink(ctx context.Context) error { - resp, err := cli.AuthedWS.SendRequest(ctx, http.MethodDelete, fmt.Sprintf("/v1/devices/%d", cli.Store.DeviceID), nil, nil) - if err != nil { - return err - } - return web.DecodeWSResponseBody(ctx, nil, resp) -} - func confirmDevice( ctx context.Context, username string, password string, code string, - aciRegistrationID int, - pniRegistrationID int, + registrationId int, + pniRegistrationId int, aciSignedPreKey *libsignalgo.SignedPreKeyRecord, pniSignedPreKey *libsignalgo.SignedPreKeyRecord, aciPQLastResortPreKey *libsignalgo.KyberPreKeyRecord, @@ -364,50 +322,34 @@ func confirmDevice( aciIdentityKeyPair *libsignalgo.IdentityKeyPair, deviceName string, ) (*ConfirmDeviceResponse, error) { - log := zerolog.Ctx(ctx).With().Str("action", "confirm device").Logger() - ctx = log.WithContext(ctx) encryptedDeviceName, err := EncryptDeviceName(deviceName, aciIdentityKeyPair.GetPublicKey()) if err != nil { return nil, fmt.Errorf("failed to encrypt device name: %w", err) } - ws, resp, err := web.OpenWebsocket(ctx, (&url.URL{ - Scheme: "wss", - Host: web.APIHostname, - Path: web.WebsocketPath, - }).String()) + ws, resp, err := web.OpenWebsocket(ctx, web.WebsocketPath) if err != nil { - log.Err(err).Any("resp", resp).Msg("error opening websocket") + zlog.Err(err).Any("resp", resp).Msg("error opening websocket") return nil, err } defer ws.Close(websocket.StatusInternalError, "Websocket StatusInternalError") - aciSignedPreKeyJson, err := SignedPreKeyToJSON(aciSignedPreKey) - if err != nil { - return nil, fmt.Errorf("failed to convert signed ACI prekey to JSON: %w", err) - } - pniSignedPreKeyJson, err := SignedPreKeyToJSON(pniSignedPreKey) - if err != nil { - return nil, fmt.Errorf("failed to convert signed PNI prekey to JSON: %w", err) - } + aciSignedPreKeyJson := SignedPreKeyToJSON(aciSignedPreKey) + pniSignedPreKeyJson := SignedPreKeyToJSON(pniSignedPreKey) - aciPQLastResortPreKeyJson, err := KyberPreKeyToJSON(aciPQLastResortPreKey) - if err != nil { - return nil, fmt.Errorf("failed to convert ACI kyber last resort prekey to JSON: %w", err) - } - pniPQLastResortPreKeyJson, err := KyberPreKeyToJSON(pniPQLastResortPreKey) - if err != nil { - return nil, fmt.Errorf("failed to convert PNI kyber last resort prekey to JSON: %w", err) - } + aciPQLastResortPreKeyJson := KyberPreKeyToJSON(aciPQLastResortPreKey) + pniPQLastResortPreKeyJson := KyberPreKeyToJSON(pniPQLastResortPreKey) - data := map[string]any{ + data := map[string]interface{}{ "verificationCode": code, - "accountAttributes": map[string]any{ + "accountAttributes": map[string]interface{}{ "fetchesMessages": true, "name": encryptedDeviceName, - "registrationId": aciRegistrationID, - "pniRegistrationId": pniRegistrationID, - "capabilities": signalCapabilities, + "registrationId": registrationId, + "pniRegistrationId": pniRegistrationId, + "capabilities": map[string]interface{}{ + "pni": true, + }, }, "aciSignedPreKey": aciSignedPreKeyJson, "pniSignedPreKey": pniSignedPreKeyJson, @@ -415,9 +357,12 @@ func confirmDevice( "pniPqLastResortPreKey": pniPQLastResortPreKeyJson, } + // TODO: Set deviceName with "Signal Bridge" or something properly encrypted + jsonBytes, err := json.Marshal(data) if err != nil { - return nil, fmt.Errorf("failed to marshal JSON: %w", err) + zlog.Err(err).Msg("failed to marshal JSON") + return nil, err } // Create and send request TODO: Use SignalWebsocket @@ -431,26 +376,49 @@ func confirmDevice( } err = wspb.Write(ctx, ws, message) if err != nil { - return nil, fmt.Errorf("failed on write protobuf data to websocket: %w", err) + zlog.Err(err).Msg("failed on write protobuf data to websocket") + return nil, err } receivedMsg := &signalpb.WebSocketMessage{} err = wspb.Read(ctx, ws, receivedMsg) if err != nil { - return nil, fmt.Errorf("failed to read from websocket after devices call: %w", err) + zlog.Err(err).Msg("failed to read from websocket after devices call") + return nil, err } status := int(*receivedMsg.Response.Status) if status < 200 || status >= 300 { - return nil, fmt.Errorf("non-200 status code (%d) from devices response: %s", status, *receivedMsg.Response.Message) + err := fmt.Errorf("problem with devices response - status: %d, message: %s", status, *receivedMsg.Response.Message) + zlog.Err(err).Msg("non-200 status code from devices response") + return nil, err } // unmarshal JSON response into ConfirmDeviceResponse deviceResp := ConfirmDeviceResponse{} err = json.Unmarshal(receivedMsg.Response.Body, &deviceResp) if err != nil { - return nil, fmt.Errorf("failed to unmarshal JSON: %w", err) + zlog.Err(err).Msg("failed to unmarshal JSON") + return nil, err } return &deviceResp, nil } + +func generateRandomPassword(length int) (string, error) { + if length < 1 { + return "", fmt.Errorf("password length must be at least 1") + } + + const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" + var password []byte + for i := 0; i < length; i++ { + index, err := crand.Int(crand.Reader, big.NewInt(int64(len(charset)))) + if err != nil { + return "", fmt.Errorf("error generating random index: %v", err) + } + password = append(password, charset[index.Int64()]) + } + + return string(password), nil +} diff --git a/pkg/signalmeow/provisioning_cipher.go b/pkg/signalmeow/provisioning_cipher.go index 8670274..ec39b7e 100644 --- a/pkg/signalmeow/provisioning_cipher.go +++ b/pkg/signalmeow/provisioning_cipher.go @@ -44,7 +44,8 @@ func (c *ProvisioningCipher) GetPublicKey() *libsignalgo.PublicKey { if c.keyPair == nil { keyPair, err := libsignalgo.GenerateIdentityKeyPair() if err != nil { - panic(fmt.Errorf("unable to generate key pair: %w", err)) + zlog.Err(err).Msg("") + zlog.Fatal().Msg("Unable to generate key pair") } c.keyPair = keyPair } @@ -64,40 +65,52 @@ const CIPHERTEXT_OFFSET uint = IV_OFFSET + IV_LENGTH func (c *ProvisioningCipher) Decrypt(env *signalpb.ProvisionEnvelope) (*signalpb.ProvisionMessage, error) { masterEphemeral, err := libsignalgo.DeserializePublicKey(env.GetPublicKey()) if err != nil { - return nil, fmt.Errorf("unable to deserialize public key: %w", err) + zlog.Err(err).Msg("Unable to deserialize public key") + return nil, err } if masterEphemeral == nil { - return nil, fmt.Errorf("no public key: %v", env) + err = fmt.Errorf("No public key: %v", env) + zlog.Err(err).Msg("") + return nil, err } body := env.GetBody() if body == nil { - return nil, fmt.Errorf("no body: %v", env) + err = fmt.Errorf("No body: %v", env) + zlog.Err(err).Msg("") + return nil, err } if body[0] != 1 { - return nil, fmt.Errorf("invalid ProvisionMessage version: %v", body[0]) + err = fmt.Errorf("Invalid ProvisionMessage version: %v", body[0]) + zlog.Err(err).Msg("") + return nil, err } bodyLen := uint(len(body)) iv := body[IV_OFFSET : IV_OFFSET+IV_LENGTH] mac := body[bodyLen-MAC_SIZE : bodyLen] if uint(len(mac)) != MAC_SIZE { - return nil, fmt.Errorf("invalid MAC size: %d", len(mac)) + err = fmt.Errorf("Invalid MAC size: %v", len(mac)) + zlog.Err(err).Msg("") + return nil, err } if uint(len(iv)) != IV_LENGTH { - return nil, fmt.Errorf("invalid IV size: %d", len(iv)) + err = fmt.Errorf("Invalid IV size: %v", len(iv)) + zlog.Err(err).Msg("") + return nil, err } cipherText := body[CIPHERTEXT_OFFSET : bodyLen-CIPHER_KEY_SIZE] ivAndCipherText := body[0 : bodyLen-CIPHER_KEY_SIZE] agreement, err := c.keyPair.GetPrivateKey().Agree(masterEphemeral) if err != nil { - return nil, fmt.Errorf("unable to agree on key: %w", err) + zlog.Err(err).Msg("Unable to agree on key") + return nil, err } sharedSecrets := make([]byte, 64) hkdfReader := hkdf.New(sha256.New, agreement, nil, []byte("TextSecure Provisioning Message")) if _, err := io.ReadFull(hkdfReader, sharedSecrets); err != nil { - return nil, fmt.Errorf("unable to read from hkdfReader: %w", err) + zlog.Err(err).Msg("Unable to read from hkdfReader") } parts1 := sharedSecrets[:32] @@ -107,15 +120,18 @@ func (c *ProvisioningCipher) Decrypt(env *signalpb.ProvisionEnvelope) (*signalpb verifier.Write(ivAndCipherText) ourMac := verifier.Sum(nil) if len(ourMac) != len(mac) { - return nil, fmt.Errorf("Invalid MAC length: ourmac:%d mac:%d", len(ourMac), len(mac)) + err = fmt.Errorf("Invalid MAC length: ourmac:%v mac:%v", len(ourMac), len(mac)) + zlog.Err(err).Msg("") } if !hmac.Equal(ourMac[:32], mac) { - return nil, fmt.Errorf("invalid MAC: %v", ourMac) + err = fmt.Errorf("Invalid MAC: %v", ourMac) + zlog.Err(err).Msg("") } block, err := aes.NewCipher(parts1) if err != nil { - return nil, fmt.Errorf("unable to create cipher: %w", err) + zlog.Err(err).Msg("Unable to create cipher") + return nil, err } mode := cipher.NewCBCDecrypter(block, iv) @@ -124,13 +140,14 @@ func (c *ProvisioningCipher) Decrypt(env *signalpb.ProvisionEnvelope) (*signalpb decrypted, err := UnpadPKCS7(decryptedWithPadding) if err != nil { - return nil, fmt.Errorf("unable to unpad: %w", err) + zlog.Err(err).Msg("Unable to unpad") } message := &signalpb.ProvisionMessage{} err = proto.Unmarshal(decrypted, message) if err != nil { - return nil, fmt.Errorf("unable to unmarshal ProvisionMessage: %w", err) + zlog.Err(err).Msg("Unable to unmarshal ProvisionMessage") + return nil, err } return message, nil diff --git a/pkg/signalmeow/pushreg.go b/pkg/signalmeow/pushreg.go deleted file mode 100644 index 79d0318..0000000 --- a/pkg/signalmeow/pushreg.go +++ /dev/null @@ -1,73 +0,0 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2024 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package signalmeow - -import ( - "context" - "encoding/json" - "net/http" - - signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" - "go.mau.fi/mautrix-signal/pkg/signalmeow/web" -) - -type ReqRegisterFCM struct { - GCMRegistrationID string `json:"gcmRegistrationId,omitempty"` - WebSocketChannel bool `json:"webSocketChannel"` -} - -type ReqRegisterAPNs struct { - APNRegistrationID string `json:"apnRegistrationId,omitempty"` - VoIPRegistrationID string `json:"voipRegistrationId,omitempty"` -} - -func (cli *Client) registerPush(ctx context.Context, pushType string, data any) error { - var resp *signalpb.WebSocketResponseMessage - var err error - if data != nil { - body, err := json.Marshal(data) - if err != nil { - return err - } - resp, err = cli.AuthedWS.SendRequest(ctx, http.MethodPut, "/v1/accounts/"+pushType, body, nil) - } else { - resp, err = cli.AuthedWS.SendRequest(ctx, http.MethodDelete, "/v1/accounts/"+pushType, nil, nil) - } - if err != nil { - return err - } - return web.DecodeWSResponseBody(ctx, nil, resp) -} - -func (cli *Client) RegisterFCM(ctx context.Context, token string) error { - if token == "" { - return cli.registerPush(ctx, "gcm", nil) - } - return cli.registerPush(ctx, "gcm", &ReqRegisterFCM{ - GCMRegistrationID: token, - WebSocketChannel: true, - }) -} - -func (cli *Client) RegisterAPNs(ctx context.Context, token string) error { - if token == "" { - return cli.registerPush(ctx, "apn", nil) - } - return cli.registerPush(ctx, "apn", &ReqRegisterAPNs{ - APNRegistrationID: token, - }) -} diff --git a/pkg/signalmeow/receiving.go b/pkg/signalmeow/receiving.go index 6b92d04..3b159bc 100644 --- a/pkg/signalmeow/receiving.go +++ b/pkg/signalmeow/receiving.go @@ -1,6 +1,5 @@ // mautrix-signal - A Matrix-signal puppeting bridge. // Copyright (C) 2023 Scott Weber -// Copyright (C) 2025 Tulir Asokan // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by @@ -18,19 +17,16 @@ package signalmeow import ( - "bytes" "context" "encoding/base64" - "errors" "fmt" "net/http" "strings" "time" "github.com/google/uuid" - "github.com/rs/zerolog" - "go.mau.fi/util/ptr" "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" "go.mau.fi/mautrix-signal/pkg/libsignalgo" "go.mau.fi/mautrix-signal/pkg/signalmeow/events" @@ -47,7 +43,6 @@ const ( SignalConnectionEventDisconnected SignalConnectionEventLoggedOut SignalConnectionEventError - SignalConnectionEventFatalError SignalConnectionCleanShutdown ) @@ -58,7 +53,6 @@ var signalConnectionEventNames = map[SignalConnectionEvent]string{ SignalConnectionEventDisconnected: "SignalConnectionEventDisconnected", SignalConnectionEventLoggedOut: "SignalConnectionEventLoggedOut", SignalConnectionEventError: "SignalConnectionEventError", - SignalConnectionEventFatalError: "SignalConnectionEventFatalError", SignalConnectionCleanShutdown: "SignalConnectionCleanShutdown", } @@ -72,83 +66,39 @@ type SignalConnectionStatus struct { Err error } -func (cli *Client) StartWebsockets(ctx context.Context) (authChan, unauthChan chan web.SignalWebsocketConnectionStatus, err error) { - authChan, unauthChan, _, _, err = cli.startWebsocketsInternal(ctx) - return -} - -func (cli *Client) startWebsocketsInternal( - ctx context.Context, -) ( - authChan, unauthChan chan web.SignalWebsocketConnectionStatus, - loopCtx context.Context, loopCancel context.CancelFunc, - err error, -) { - loopCtx, loopCancel = context.WithCancel(ctx) - unauthChan, err = cli.connectUnauthedWS(loopCtx) - if err != nil { - loopCancel() - return - } - zerolog.Ctx(ctx).Info().Msg("Unauthed websocket connecting") - authChan, err = cli.connectAuthedWS(loopCtx, cli.incomingRequestHandler) - if err != nil { - loopCancel() - return - } - zerolog.Ctx(ctx).Info().Msg("Authed websocket connecting") - cli.loopCancel = loopCancel - return -} - -func (cli *Client) StartReceiveLoops(ctx context.Context) (chan SignalConnectionStatus, error) { - log := zerolog.Ctx(ctx).With().Str("action", "start receive loops").Logger() - cbc := make(chan time.Time, 1) - cli.writeCallbackCounter = cbc - - authChan, unauthChan, loopCtx, loopCancel, err := cli.startWebsocketsInternal(log.WithContext(ctx)) +func StartReceiveLoops(ctx context.Context, d *Device) (chan SignalConnectionStatus, error) { + ctx, cancel := context.WithCancel(ctx) + d.Connection.WSCancel = cancel + authChan, err := d.Connection.ConnectAuthedWS(ctx, d.Data, d.incomingRequestHandler) if err != nil { + cancel() return nil, err } - statusChan := make(chan SignalConnectionStatus, 128) + zlog.Info().Msg("Authed websocket connecting") + unauthChan, err := d.Connection.ConnectUnauthedWS(ctx, d.Data) + if err != nil { + cancel() + return nil, err + } + zlog.Info().Msg("Unauthed websocket connecting") + statusChan := make(chan SignalConnectionStatus, 10000) initialConnectChan := make(chan struct{}) - resetWriteCount := make(chan struct{}, 1) // Combine both websocket status channels into a single, more generic "Signal" connection status channel - cli.loopWg.Add(2) go func() { - defer cli.loopWg.Done() - writeCallbackTimer := time.Now() - callbackCount := 0 - for { - select { - case <-loopCtx.Done(): - return - case <-resetWriteCount: - callbackCount = 0 - case nextTS := <-cbc: - if callbackCount >= 4 && time.Since(writeCallbackTimer) > 1*time.Minute { - err := cli.Store.EventBuffer.DeleteBufferedEventsOlderThan(ctx, writeCallbackTimer) - if err != nil { - log.Err(err).Msg("Failed to delete old buffered event hashes") - } - writeCallbackTimer = nextTS - } else { - callbackCount++ - } - } - } - }() - go func() { - defer cli.loopWg.Done() defer close(statusChan) - defer loopCancel() + defer cancel() var currentStatus, lastAuthStatus, lastUnauthStatus web.SignalWebsocketConnectionStatus + var lastSentStatus SignalConnectionStatus for { + if d == nil { + zlog.Info().Msg("Device is nil, exiting websocket status loop") + return + } select { - case <-loopCtx.Done(): - log.Info().Msg("Context done, exiting websocket status loop") + case <-ctx.Done(): + zlog.Info().Msg("Context done, exiting websocket status loop") return case status := <-authChan: lastAuthStatus = status @@ -158,25 +108,17 @@ func (cli *Client) StartReceiveLoops(ctx context.Context) (chan SignalConnection case web.SignalWebsocketConnectionEventConnecting: // do nothing? case web.SignalWebsocketConnectionEventConnected: - log.Info().Msg("Authed websocket connected") + zlog.Info().Msg("Authed websocket connected") case web.SignalWebsocketConnectionEventDisconnected: - log.Err(status.Err).Msg("Authed websocket disconnected") + zlog.Err(status.Err).Msg("Authed websocket disconnected") case web.SignalWebsocketConnectionEventLoggedOut: - log.Err(status.Err).Msg("Authed websocket logged out") + zlog.Err(status.Err).Msg("Authed websocket logged out") // TODO: Also make sure unauthed websocket is disconnected //StopReceiveLoops(d) case web.SignalWebsocketConnectionEventError: - log.Err(status.Err).Msg("Authed websocket error") - case web.SignalWebsocketConnectionEventFatalError: - log.Err(status.Err).Msg("Authed websocket fatal error") + zlog.Err(status.Err).Msg("Authed websocket error") case web.SignalWebsocketConnectionEventCleanShutdown: - log.Info().Msg("Authed websocket clean shutdown") - } - if status.Event != web.SignalWebsocketConnectionEventConnected { - select { - case resetWriteCount <- struct{}{}: - default: - } + zlog.Info().Msg("Authed websocket clean shutdown") } case status := <-unauthChan: lastUnauthStatus = status @@ -186,21 +128,16 @@ func (cli *Client) StartReceiveLoops(ctx context.Context) (chan SignalConnection case web.SignalWebsocketConnectionEventConnecting: // do nothing? case web.SignalWebsocketConnectionEventConnected: - log.Info(). - Any("last_unauth_status", lastUnauthStatus). - Any("last_auth_status", lastAuthStatus). - Any("current_status", currentStatus). - Msg("Unauthed websocket connected") + zlog.Info().Msg("Unauthed websocket connected") + zlog.Info().Msgf("lastUnauthStatus: %v, lastAuthStatus: %v, currentStatus: %v", lastUnauthStatus, lastAuthStatus, currentStatus) case web.SignalWebsocketConnectionEventDisconnected: - log.Err(status.Err).Msg("Unauthed websocket disconnected") + zlog.Err(status.Err).Msg("Unauthed websocket disconnected") case web.SignalWebsocketConnectionEventLoggedOut: - log.Err(status.Err).Msg("Unauthed websocket logged out ** THIS SHOULD BE IMPOSSIBLE **") + zlog.Err(status.Err).Msg("Unauthed websocket logged out ** THIS SHOULD BE IMPOSSIBLE **") case web.SignalWebsocketConnectionEventError: - log.Err(status.Err).Msg("Unauthed websocket error") - case web.SignalWebsocketConnectionEventFatalError: - log.Err(status.Err).Msg("Unauthed websocket fatal error") + zlog.Err(status.Err).Msg("Unauthed websocket error") case web.SignalWebsocketConnectionEventCleanShutdown: - log.Info().Msg("Unauthed websocket clean shutdown") + zlog.Info().Msg("Unauthed websocket clean shutdown") } } @@ -228,51 +165,29 @@ func (cli *Client) StartReceiveLoops(ctx context.Context) (chan SignalConnection Event: SignalConnectionEventError, Err: currentStatus.Err, } - } else if currentStatus.Event == web.SignalWebsocketConnectionEventFatalError { - statusToSend = SignalConnectionStatus{ - Event: SignalConnectionEventFatalError, - Err: currentStatus.Err, - } } else if currentStatus.Event == web.SignalWebsocketConnectionEventCleanShutdown { statusToSend = SignalConnectionStatus{ Event: SignalConnectionCleanShutdown, } } - if statusToSend.Event != 0 && statusToSend.Event != cli.lastConnectionStatus.Event { - log.Info().Any("status_to_send", statusToSend).Msg("Sending connection status") + if statusToSend.Event != 0 && statusToSend.Event != lastSentStatus.Event { + zlog.Info().Msgf("Sending connection status: %v", statusToSend) statusChan <- statusToSend - cli.lastConnectionStatus = statusToSend + lastSentStatus = statusToSend } } }() // Send sync message once both websockets are connected - cli.loopWg.Add(1) go func() { - defer cli.loopWg.Done() - select { - case <-loopCtx.Done(): - return - case <-initialConnectChan: - log.Info().Msg("Both websockets connected, sending contacts sync request") - err = cli.RegisterCapabilities(ctx) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to register capabilities") - } else { - zerolog.Ctx(ctx).Debug().Msg("Successfully registered capabilities") - } - // Start loop to check for and upload more prekeys - cli.loopWg.Add(1) - go func() { - defer cli.loopWg.Done() - cli.keyCheckLoop(loopCtx) - }() - // TODO hacky - if cli.SyncContactsOnConnect { - cli.SendContactSyncRequest(loopCtx) - } - if cli.Store.MasterKey == nil { - cli.SendStorageMasterKeyRequest(loopCtx) + for { + select { + case <-ctx.Done(): + return + case <-initialConnectChan: + zlog.Info().Msg("Both websockets connected, sending contacts sync request") + SendContactSyncRequest(ctx, d) + return } } }() @@ -280,21 +195,15 @@ func (cli *Client) StartReceiveLoops(ctx context.Context) (chan SignalConnection return statusChan, nil } -func (cli *Client) ForceReconnect() { - cli.AuthedWS.ForceReconnect() - cli.UnauthedWS.ForceReconnect() -} - -func (cli *Client) StopReceiveLoops() error { +func StopReceiveLoops(d *Device) error { defer func() { - cli.AuthedWS = nil - cli.UnauthedWS = nil + d.Connection.AuthedWS = nil + d.Connection.UnauthedWS = nil }() - authErr := cli.AuthedWS.Close() - unauthErr := cli.UnauthedWS.Close() - if cli.loopCancel != nil { - cli.loopCancel() - cli.loopWg.Wait() + authErr := d.Connection.AuthedWS.Close() + unauthErr := d.Connection.UnauthedWS.Close() + if d.Connection.WSCancel != nil { + d.Connection.WSCancel() } if authErr != nil { return authErr @@ -305,728 +214,742 @@ func (cli *Client) StopReceiveLoops() error { return nil } -func (cli *Client) LastConnectionStatus() SignalConnectionStatus { - return cli.lastConnectionStatus +// If a bridge can't decrypt prekeys, it's probably because the prekeys are broken so force re-registration +func checkDecryptionErrorAndDisconnect(err error, device *Device) { + if err != nil { + if strings.Contains(err.Error(), "30: invalid PreKey message: decryption failed") || + strings.Contains(err.Error(), "70: invalid signed prekey identifier") { + zlog.Warn().Msg("Failed decrypting a PreKey message, probably our prekeys are broken, force re-registration") + disconnectErr := device.ClearKeysAndDisconnect() + if disconnectErr != nil { + zlog.Err(disconnectErr).Msg("ClearKeysAndDisconnect error") + } + } + } } -func (cli *Client) ClearKeysAndDisconnect(ctx context.Context) error { - // Essentially logout, clearing sessions and keys, and disconnecting websockets - // but don't clear ACI UUID or profile keys or contacts, or anything else that - // we can reuse if we reassociate with the same Signal account. - // To fully "logout" delete the device from the database. - clearErr := cli.Store.ClearDeviceKeys(ctx) - clearErr2 := cli.Store.ClearPassword(ctx) - stopLoopErr := cli.StopReceiveLoops() - - if clearErr != nil { - return clearErr - } - if clearErr2 != nil { - return clearErr2 - } - return stopLoopErr -} - -func (cli *Client) incomingRequestHandler(ctx context.Context, req *signalpb.WebSocketRequestMessage) (*web.SimpleResponse, error) { - log := zerolog.Ctx(ctx).With(). - Str("handler", "incoming request handler"). - Str("verb", *req.Verb). - Str("path", *req.Path). - Uint64("incoming_request_id", *req.Id). - Logger() - ctx = log.WithContext(ctx) +func (d *Device) incomingRequestHandler(ctx context.Context, req *signalpb.WebSocketRequestMessage) (*web.SimpleResponse, error) { if *req.Verb == http.MethodPut && *req.Path == "/api/v1/message" { - return cli.incomingAPIMessageHandler(ctx, req) + return d.incomingAPIMessageHandler(ctx, req) } else if *req.Verb == http.MethodPut && *req.Path == "/api/v1/queue/empty" { - log.Debug().Msg("Received queue empty notice") - cli.handleEvent(&events.QueueEmpty{}) + zlog.Trace().Msgf("Received queue empty. verb: %v, path: %v", *req.Verb, *req.Path) } else { - log.Warn().Any("req", req).Msg("Unknown websocket request message") + zlog.Warn().Msgf("######## Don't know what I received ########## req: %v", req) } return &web.SimpleResponse{ Status: 200, }, nil } -func (cli *Client) incomingAPIMessageHandler(ctx context.Context, req *signalpb.WebSocketRequestMessage) (*web.SimpleResponse, error) { - log := *zerolog.Ctx(ctx) +func (d *Device) incomingAPIMessageHandler(ctx context.Context, req *signalpb.WebSocketRequestMessage) (*web.SimpleResponse, error) { + responseCode := 200 envelope := &signalpb.Envelope{} err := proto.Unmarshal(req.Body, envelope) if err != nil { - log.Err(err).Msg("Unmarshal error") + zlog.Err(err).Msg("Unmarshal error") return nil, err } - log = log.With(). - Uint64("envelope_timestamp", envelope.GetClientTimestamp()). - Uint64("server_timestamp", envelope.GetServerTimestamp()). - Logger() - ctx = log.WithContext(ctx) - destinationServiceID, _ := ParseStringOrBinaryServiceID(envelope.GetDestinationServiceId(), envelope.GetDestinationServiceIdBinary()) - sourceServiceID, _ := ParseStringOrBinaryServiceID(envelope.GetSourceServiceId(), envelope.GetSourceServiceIdBinary()) - log.Debug(). - Str("destination_service_id", envelope.GetDestinationServiceId()). - Str("source_service_id", envelope.GetSourceServiceId()). - Hex("destination_service_id_bytes", envelope.GetDestinationServiceIdBinary()). - Hex("source_service_id_bytes", envelope.GetSourceServiceIdBinary()). - Uint32("source_device_id", envelope.GetSourceDeviceId()). - Object("parsed_destination_service_id", destinationServiceID). - Object("parsed_source_service_id", sourceServiceID). - Int32("envelope_type_id", int32(envelope.GetType())). - Str("envelope_type", signalpb.Envelope_Type_name[int32(envelope.GetType())]). - Msg("Received envelope") + var result *DecryptionResult - result := cli.decryptEnvelope(ctx, envelope, sourceServiceID, destinationServiceID) - - err = cli.handleDecryptedResult(ctx, result, envelope, destinationServiceID) - if err != nil { - log.Err(err).Msg("Error handling decrypted result") - return nil, err - } - - return &web.SimpleResponse{ - Status: 200, - WriteCallback: cli.writeCallback, - }, nil -} - -func (cli *Client) writeCallback(preWriteTime time.Time) { - ch := cli.writeCallbackCounter - if ch != nil { - select { - case ch <- preWriteTime: - default: + switch *envelope.Type { + case signalpb.Envelope_UNIDENTIFIED_SENDER: + zlog.Trace().Msgf("Received envelope type UNIDENTIFIED_SENDER, verb: %v, path: %v", *req.Verb, *req.Path) + ctx := context.Background() + usmc, err := libsignalgo.SealedSenderDecryptToUSMC( + envelope.GetContent(), + d.IdentityStore, + libsignalgo.NewCallbackContext(ctx), + ) + if err != nil || usmc == nil { + if err == nil { + err = fmt.Errorf("usmc is nil") + } + zlog.Err(err).Msg("SealedSenderDecryptToUSMC error") + return nil, err } - } -} -var ErrHandlerFailed = errors.New("event handler returned non-success status") + messageType, err := usmc.GetMessageType() + if err != nil { + zlog.Err(err).Msg("GetMessageType error") + } + senderCertificate, err := usmc.GetSenderCertificate() + if err != nil { + zlog.Err(err).Msg("GetSenderCertificate error") + } + senderUUID, err := senderCertificate.GetSenderUUID() + if err != nil { + zlog.Err(err).Msg("GetSenderUUID error") + } + senderDeviceID, err := senderCertificate.GetDeviceID() + if err != nil { + zlog.Err(err).Msg("GetDeviceID error") + } + senderAddress, err := libsignalgo.NewAddress(senderUUID.String(), uint(senderDeviceID)) + if err != nil { + zlog.Err(err).Msg("NewAddress error") + } + senderE164, err := senderCertificate.GetSenderE164() + if err != nil { + zlog.Err(err).Msg("GetSenderE164 error") + } + usmcContents, err := usmc.GetContents() + if err != nil { + zlog.Err(err).Msg("GetContents error") + } + zlog.Trace().Msgf("SealedSender senderUUID: %v, senderDeviceID: %v", senderUUID, senderDeviceID) -// TODO: we should split this up into multiple functions -func (cli *Client) handleDecryptedResult( - ctx context.Context, - result DecryptionResult, - envelope *signalpb.Envelope, - destinationServiceID libsignalgo.ServiceID, -) (retErr error) { - if errors.Is(result.Err, context.Canceled) { - return result.Err - } else if ctx.Err() != nil { - return ctx.Err() - } - log := zerolog.Ctx(ctx) - if result.CiphertextHash != nil { - defer func() { - err := cli.Store.EventBuffer.ClearBufferedEventPlaintext(ctx, *result.CiphertextHash) + d.UpdateContactE164(senderUUID, senderE164) + + switch messageType { + case libsignalgo.CiphertextMessageTypeSenderKey: + zlog.Trace().Msg("SealedSender messageType is CiphertextMessageTypeSenderKey ") + decryptedText, err := libsignalgo.GroupDecrypt( + usmcContents, + senderAddress, + d.SenderKeyStore, + libsignalgo.NewCallbackContext(ctx), + ) if err != nil { - log.Err(err). - Hex("ciphertext_hash", result.CiphertextHash[:]). - Msg("Failed to clear buffered event plaintext") + if strings.Contains(err.Error(), "message with old counter") { + zlog.Warn().Msg("Duplicate message, ignoring") + } else { + zlog.Err(err).Msg("GroupDecrypt error") + } } else { - log.Debug(). - Hex("ciphertext_hash", result.CiphertextHash[:]). - Msg("Deleted event plaintext from buffer") - } - }() - } - - var theirServiceID libsignalgo.ServiceID - var err error - if result.SenderAddress == nil { - log.Err(result.Err). - Bool("urgent", envelope.GetUrgent()). - Stringer("content_hint", result.ContentHint). - Uint64("server_ts", envelope.GetServerTimestamp()). - Uint64("client_ts", envelope.GetClientTimestamp()). - Msg("No sender address received") - return nil - } else if theirServiceID, err = result.SenderAddress.NameServiceID(); err != nil { - log.Warn(). - Uint64("server_ts", envelope.GetServerTimestamp()). - Uint64("client_ts", envelope.GetClientTimestamp()). - Msg("Failed to get sender name as service ID") - return fmt.Errorf("failed to get sender name as service ID: %w", err) - } else if theirServiceID.Type != libsignalgo.ServiceIDTypeACI { - log.Warn(). - Any("their_service_id", theirServiceID). - Uint64("server_ts", envelope.GetServerTimestamp()). - Uint64("client_ts", envelope.GetClientTimestamp()). - Msg("Dropping message from non-ACI sender") - return nil - } - cli.Store.RecipientStore.MarkUnregistered(ctx, theirServiceID, false) - - handlerSuccess := true - defer func() { - if retErr == nil && !handlerSuccess { - retErr = ErrHandlerFailed - } - }() - // result.Err is set if there was an error during decryption and we - // should notifiy the user that the message could not be decrypted - if result.Err != nil { - if errors.Is(result.Err, EventAlreadyProcessed) { - log.Debug().Err(result.Err). - Bool("urgent", envelope.GetUrgent()). - Stringer("content_hint", result.ContentHint). - Uint64("server_ts", envelope.GetServerTimestamp()). - Uint64("client_ts", envelope.GetClientTimestamp()). - Stringer("sender", theirServiceID). - Msg("Ignoring already processed event") - return nil - } - log.Err(result.Err). - Bool("urgent", envelope.GetUrgent()). - Stringer("content_hint", result.ContentHint). - Uint64("server_ts", envelope.GetServerTimestamp()). - Uint64("client_ts", envelope.GetClientTimestamp()). - Stringer("sender", theirServiceID). - Msg("Decryption error with known sender") - // Only send decryption error event if the message was urgent, - // to prevent spamming errors for typing notifications and whatnot - if envelope.GetUrgent() && - result.ContentHint != signalpb.UnidentifiedSenderMessage_Message_IMPLICIT && - !strings.Contains(result.Err.Error(), "message with old counter") { - handlerSuccess = cli.handleEvent(&events.DecryptionError{ - Sender: theirServiceID.UUID, - Err: result.Err, - Timestamp: envelope.GetClientTimestamp(), - }) - } - if result.Retriable { - go func() { - err := cli.sendRetryRequest(ctx, result, envelope.GetClientTimestamp()) + err = stripPadding(&decryptedText) if err != nil { - log.Err(err).Msg("Failed to send retry request in background") + return nil, fmt.Errorf("stripPadding error: %v", err) } - }() + content := signalpb.Content{} + err = proto.Unmarshal(decryptedText, &content) + if err != nil { + zlog.Err(err).Msg("Unmarshal error") + } + result = &DecryptionResult{ + SenderAddress: senderAddress, + Content: &content, + SealedSender: true, + } + } + + case libsignalgo.CiphertextMessageTypePreKey: + zlog.Trace().Msg("SealedSender messageType is CiphertextMessageTypePreKey") + result, err = prekeyDecrypt(senderAddress, usmcContents, d, ctx) + if err != nil { + zlog.Err(err).Msg("prekeyDecrypt error") + } + + case libsignalgo.CiphertextMessageTypeWhisper: + zlog.Trace().Msg("SealedSender messageType is CiphertextMessageTypeWhisper") + message, err := libsignalgo.DeserializeMessage(usmcContents) + if err != nil { + zlog.Err(err).Msg("DeserializeMessage error") + } + decryptedText, err := libsignalgo.Decrypt( + message, + senderAddress, + d.SessionStore, + d.IdentityStore, + libsignalgo.NewCallbackContext(ctx), + ) + if err != nil { + zlog.Err(err).Msg("Sealed sender Whisper Decryption error") + } else { + err = stripPadding(&decryptedText) + if err != nil { + return nil, fmt.Errorf("stripPadding error: %v", err) + } + content := signalpb.Content{} + err = proto.Unmarshal(decryptedText, &content) + if err != nil { + zlog.Err(err).Msg("Unmarshal error") + } + result = &DecryptionResult{ + SenderAddress: senderAddress, + Content: &content, + SealedSender: true, + } + } + + case libsignalgo.CiphertextMessageTypePlaintext: + zlog.Debug().Msg("SealedSender messageType is CiphertextMessageTypePlaintext") + // TODO: handle plaintext (usually DecryptionErrorMessage) and retries + // when implementing SenderKey groups + + //plaintextContent, err := libsignalgo.DeserializePlaintextContent(usmcContents) + //if err != nil { + // zlog.Err(err).Msg("DeserializePlaintextContent error") + //} + //body, err := plaintextContent.GetBody() + //if err != nil { + // zlog.Err(err).Msg("PlaintextContent GetBody error") + //} + //content := signalpb.Content{} + //err = proto.Unmarshal(body, &content) + //if err != nil { + // zlog.Err(err).Msg("PlaintextContent Unmarshal error") + //} + //result = &DecryptionResult{ + // SenderAddress: *senderAddress, + // Content: &content, + // SealedSender: true, + //} + + return &web.SimpleResponse{ + Status: responseCode, + }, nil + + default: + zlog.Warn().Msg("SealedSender messageType is unknown") } - if !handlerSuccess { - return ErrHandlerFailed + + // If we couldn't decrypt with specific decryption methods, try sealedSenderDecrypt + if result == nil || responseCode != 200 { + zlog.Debug().Msg("Didn't decrypt with specific methods, trying sealedSenderDecrypt") + var err error + result, err = sealedSenderDecrypt(envelope, d, ctx) + if err != nil { + if strings.Contains(err.Error(), "self send of a sealed sender message") { + zlog.Debug().Msg("Message sent by us, ignoring") + } else { + zlog.Err(err).Msg("sealedSenderDecrypt error") + checkDecryptionErrorAndDisconnect(err, d) + } + } else { + zlog.Trace().Msgf("SealedSender decrypt result - address: %v, content: %v", result.SenderAddress, result.Content) + } } - return nil - } - rawContent := result.Content - if rawContent == nil { - log.Warn().Msg("Decrypted content is nil") - return nil - } - - deviceID, _ := result.SenderAddress.DeviceID() - log.Trace(). - Any("raw_data", rawContent). - Stringer("sender", theirServiceID). - Uint("sender_device", deviceID). - Msg("Raw event data") - newLog := log.With(). - Stringer("sender_name", theirServiceID). - Uint("sender_device_id", deviceID). - Str("destination_service_id", destinationServiceID.String()). - Logger() - log = &newLog - ctx = log.WithContext(ctx) - logEvt := log.Debug() - if result.CiphertextHash != nil { - logEvt = logEvt.Hex("ciphertext_hash", result.CiphertextHash[:]) - } - logEvt.Bool("unencrypted", result.Unencrypted).Msg("Decrypted message") - - // Handle unencrypted types early and refuse any other unencrypted message - if rawContent.GetDecryptionErrorMessage() != nil { - handlerSuccess = true - dem, err := libsignalgo.DeserializeDecryptionErrorMessage(rawContent.GetDecryptionErrorMessage()) + case signalpb.Envelope_PREKEY_BUNDLE: + zlog.Debug().Msgf("Received envelope type PREKEY_BUNDLE, verb: %v, path: %v", *req.Verb, *req.Path) + sender, err := libsignalgo.NewAddress( + *envelope.SourceServiceId, + uint(*envelope.SourceDevice), + ) if err != nil { - log.Warn().Err(err).Msg("Failed to unmarshal decryption error message") + return nil, fmt.Errorf("NewAddress error: %v", err) + } + result, err = prekeyDecrypt(sender, envelope.Content, d, ctx) + if err != nil { + zlog.Err(err).Msg("prekeyDecrypt error") + checkDecryptionErrorAndDisconnect(err, d) } else { - go func() { - err := cli.handleRetryRequest(ctx, result, dem) - if err != nil { - log.Err(err).Msg("Failed to handle decryption error message in background") + zlog.Trace().Msgf("prekey decrypt result - address: %v, data: %v", result.SenderAddress, result.Content) + } + + case signalpb.Envelope_PLAINTEXT_CONTENT: + zlog.Debug().Msgf("Received envelope type PLAINTEXT_CONTENT, verb: %v, path: %v", *req.Verb, *req.Path) + + case signalpb.Envelope_CIPHERTEXT: + zlog.Debug().Msgf("Received envelope type CIPHERTEXT, verb: %v, path: %v", *req.Verb, *req.Path) + message, err := libsignalgo.DeserializeMessage(envelope.Content) + if err != nil { + zlog.Err(err).Msg("DeserializeMessage error") + } + senderAddress, err := libsignalgo.NewAddress( + *envelope.SourceServiceId, + uint(*envelope.SourceDevice), + ) + decryptedText, err := libsignalgo.Decrypt( + message, + senderAddress, + d.SessionStore, + d.IdentityStore, + libsignalgo.NewCallbackContext(ctx), + ) + if err != nil { + if strings.Contains(err.Error(), "message with old counter") { + zlog.Info().Msg("Duplicate message, ignoring") + } else { + zlog.Err(err).Msg("Whisper Decryption error") + } + } else { + err = stripPadding(&decryptedText) + if err != nil { + return nil, fmt.Errorf("stripPadding error: %v", err) + } + content := signalpb.Content{} + err = proto.Unmarshal(decryptedText, &content) + if err != nil { + zlog.Err(err).Msg("Unmarshal error") + } + result = &DecryptionResult{ + SenderAddress: senderAddress, + Content: &content, + } + } + + case signalpb.Envelope_RECEIPT: + zlog.Debug().Msgf("Received envelope type RECEIPT, verb: %v, path: %v", *req.Verb, *req.Path) + // TODO: handle receipt + + case signalpb.Envelope_KEY_EXCHANGE: + zlog.Debug().Msgf("Received envelope type KEY_EXCHANGE, verb: %v, path: %v", *req.Verb, *req.Path) + responseCode = 400 + + case signalpb.Envelope_UNKNOWN: + zlog.Warn().Msgf("Received envelope type UNKNOWN, verb: %v, path: %v", *req.Verb, *req.Path) + responseCode = 400 + + default: + zlog.Warn().Msgf("Received actual unknown envelope type, verb: %v, path: %v", *req.Verb, *req.Path) + responseCode = 400 + } + + // Handle content that is now decrypted + if result != nil && result.Content != nil { + content := result.Content + zlog.Trace().Any("raw_data", content).Msg("Raw event data") + + name, _ := result.SenderAddress.Name() + deviceId, _ := result.SenderAddress.DeviceID() + zlog.Debug().Msgf("Decrypted message from %v:%v", name, deviceId) + printMessage := fmt.Sprintf("Decrypted content fields (%v:%v)", name, deviceId) + printContentFieldString(content, printMessage) + + // If there's a sender key distribution message, process it + if content.GetSenderKeyDistributionMessage() != nil { + zlog.Debug().Msg("content includes sender key distribution message") + skdm, err := libsignalgo.DeserializeSenderKeyDistributionMessage(content.GetSenderKeyDistributionMessage()) + if err != nil { + zlog.Err(err).Msg("DeserializeSenderKeyDistributionMessage error") + return nil, err + } + err = libsignalgo.ProcessSenderKeyDistributionMessage( + skdm, + result.SenderAddress, + d.SenderKeyStore, + libsignalgo.NewCallbackContext(ctx), + ) + if err != nil { + zlog.Err(err).Msg("ProcessSenderKeyDistributionMessage error") + return nil, err + } + } + + theirUUID, err := result.SenderAddress.NameUUID() + if err != nil { + zlog.Err(err).Msg("Name error") + return nil, err + } + + // TODO: handle more sync messages + if content.SyncMessage != nil { + syncSent := content.SyncMessage.GetSent() + if syncSent.GetMessage() != nil || syncSent.GetEditMessage() != nil { + destination := syncSent.DestinationServiceId + var ourUUID, destinationUUID uuid.UUID + ourUUID, _ = uuid.Parse(d.Data.AciUuid) + if destination != nil { + destinationUUID, err = uuid.Parse(*destination) + if err != nil { + zlog.Err(err).Msg("Sync message destination parse error") + return nil, err + } + } + if destination == nil && syncSent.GetMessage().GetGroupV2() == nil && syncSent.GetEditMessage().GetDataMessage().GetGroupV2() == nil { + zlog.Warn().Msg("sync message sent destination is nil") + } else if content.SyncMessage.Sent.Message != nil { + // TODO handle expiration start ts, and maybe the sync message ts? + incomingDataMessage(ctx, d, content.SyncMessage.Sent.Message, ourUUID, destinationUUID) + } else if content.SyncMessage.Sent.EditMessage != nil { + incomingEditMessage(ctx, d, content.SyncMessage.Sent.EditMessage, ourUUID, destinationUUID) } - }() - } - return - } else if result.Unencrypted { - log.Warn().Msg("Unexpected non-decryption-error content in unencrypted message") - return nil - } - - // If there's a sender key distribution message, process it - if rawContent.SenderKeyDistributionMessage != nil { - log.Debug().Msg("content includes sender key distribution message") - skdm, err := libsignalgo.DeserializeSenderKeyDistributionMessage(rawContent.SenderKeyDistributionMessage) - if err != nil { - log.Err(err).Msg("DeserializeSenderKeyDistributionMessage error") - return err - } - err = libsignalgo.ProcessSenderKeyDistributionMessage( - ctx, - skdm, - result.SenderAddress, - cli.Store.SenderKeyStore, - ) - if err != nil { - log.Err(err).Msg("ProcessSenderKeyDistributionMessage error") - return err - } - } - - // If we're getting a message to our PNI, mark it as needing a PNI signature message on the next send - if destinationServiceID == cli.Store.PNIServiceID() { - _, err = cli.Store.RecipientStore.LoadAndUpdateRecipient(ctx, theirServiceID.UUID, uuid.Nil, func(recipient *types.Recipient) (changed bool, err error) { - if recipient.Whitelisted == nil { - log.Debug().Msg("Marking recipient as not whitelisted") - recipient.Whitelisted = ptr.Ptr(false) - changed = true } - if !recipient.NeedsPNISignature { - log.Debug().Msg("Marking recipient as needing PNI signature") - recipient.NeedsPNISignature = true - changed = true + if content.SyncMessage.Contacts != nil { + zlog.Debug().Msgf("Recieved sync message contacts") + blob := content.SyncMessage.Contacts.Blob + if blob != nil { + contactsBytes, err := DownloadAttachment(ctx, blob) + if err != nil { + zlog.Err(err).Msg("Contacts Sync DownloadAttachment error") + } + // unmarshall contacts + contacts, avatars, err := unmarshalContactDetailsMessages(contactsBytes) + if err != nil { + zlog.Err(err).Msg("Contacts Sync unmarshalContactDetailsMessages error") + } + zlog.Debug().Msgf("Contacts Sync received %v contacts", len(contacts)) + for i, signalContact := range contacts { + if signalContact.Aci == nil || *signalContact.Aci == "" { + zlog.Info().Msgf("Signal Contact UUID is nil, skipping: %v", signalContact) + continue + } + contact, contactAvatar, err := StoreContactDetailsAsContact(d, signalContact, &avatars[i]) + if err != nil { + zlog.Err(err).Msg("StoreContactDetailsAsContact error") + continue + } + // Model each contact as an incoming contact change message + d.Connection.handleEvent(&events.ContactChange{ + Contact: contact, + Avatar: contactAvatar, + }) + } + } + } + if content.SyncMessage.Read != nil { + d.Connection.handleEvent(&events.ReadSelf{ + Messages: content.SyncMessage.GetRead(), + }) } - return - }) - if err != nil { - log.Err(err).Msg("Failed to set needs_pni_signature flag after receiving message to PNI service ID") - } - } - // If we receive a PNI signature message (because we sent to a PNI earlier), process it - if rawContent.PniSignatureMessage != nil { - log.Debug().Msg("Content includes PNI signature message") - err = cli.handlePNISignatureMessage(ctx, theirServiceID, rawContent.PniSignatureMessage) - if err != nil { - log.Err(err). - Hex("pni_raw", rawContent.PniSignatureMessage.GetPni()). - Stringer("aci", theirServiceID.UUID). - Msg("Failed to verify ACI-PNI mapping") } - } - isBlocked, err := cli.Store.RecipientStore.IsBlocked(ctx, theirServiceID.UUID) - if err != nil { - log.Err(err).Stringer("sender", theirServiceID).Msg("Failed to check if sender is blocked") - } + var sendDeliveryReceipt bool + if content.DataMessage != nil { + sendDeliveryReceipt = incomingDataMessage(ctx, d, content.DataMessage, theirUUID, theirUUID) + } else if content.EditMessage != nil { + sendDeliveryReceipt = incomingEditMessage(ctx, d, content.EditMessage, theirUUID, theirUUID) + } + if sendDeliveryReceipt { + // TODO send delivery receipts after actually bridging instead of here + err = sendDeliveryReceipts(ctx, d, []uint64{content.DataMessage.GetTimestamp()}, theirUUID) + if err != nil { + zlog.Err(err).Msg("sendDeliveryReceipts error") + } + } - var sendDeliveryReceipt bool - var deliveryReceiptTS uint64 - switch content := rawContent.Content.(type) { - case *signalpb.Content_SyncMessage: - if theirServiceID == cli.Store.ACIServiceID() { - handlerSuccess = cli.handleSyncMessage(ctx, content.SyncMessage, envelope) - } - return nil - case *signalpb.Content_DataMessage: - handlerSuccess, sendDeliveryReceipt = cli.incomingDataMessage( - ctx, content.DataMessage, theirServiceID.UUID, theirServiceID, envelope.GetServerTimestamp(), isBlocked, - ) - deliveryReceiptTS = content.DataMessage.GetTimestamp() - case *signalpb.Content_EditMessage: - handlerSuccess, sendDeliveryReceipt = cli.incomingEditMessage( - ctx, content.EditMessage, theirServiceID.UUID, theirServiceID, envelope.GetServerTimestamp(), isBlocked, - ) - deliveryReceiptTS = content.EditMessage.GetDataMessage().GetTimestamp() - case *signalpb.Content_ReceiptMessage: - if content.ReceiptMessage.GetType() == signalpb.ReceiptMessage_DELIVERY && theirServiceID == cli.Store.ACIServiceID() { - // Ignore delivery receipts from other own devices - return nil - } - handlerSuccess = cli.handleEvent(&events.Receipt{ - Sender: theirServiceID.UUID, - Content: content.ReceiptMessage, - }) - case *signalpb.Content_TypingMessage: - var groupID types.GroupIdentifier - if content.TypingMessage.GetGroupId() != nil { - gidBytes := content.TypingMessage.GetGroupId() - groupID = types.GroupIdentifier(base64.StdEncoding.EncodeToString(gidBytes)) - } - if !isBlocked || groupID != "" { - // No handler success check here, nobody cares if typing notifications are dropped - cli.handleEvent(&events.ChatEvent{ + if content.TypingMessage != nil { + var groupID types.GroupIdentifier + if content.TypingMessage.GetGroupId() != nil { + gidBytes := content.TypingMessage.GetGroupId() + groupID = types.GroupIdentifier(base64.StdEncoding.EncodeToString(gidBytes)) + } + d.Connection.handleEvent(&events.ChatEvent{ Info: events.MessageInfo{ - Sender: theirServiceID.UUID, - ChatID: groupOrUserID(groupID, theirServiceID), - ServerTimestamp: envelope.GetServerTimestamp(), + Sender: theirUUID, + ChatID: groupOrUserID(groupID, theirUUID), }, Event: content.TypingMessage, }) } - case *signalpb.Content_CallMessage: - if !isBlocked && (content.CallMessage.Offer != nil || content.CallMessage.Hangup != nil) { - handlerSuccess = cli.handleEvent(&events.Call{ + + // DM call message (group call is an opaque callMessage and a groupCallUpdate in a dataMessage) + if content.CallMessage != nil && (content.CallMessage.Offer != nil || content.CallMessage.Hangup != nil) { + d.Connection.handleEvent(&events.Call{ Info: events.MessageInfo{ - Sender: theirServiceID.UUID, - ChatID: theirServiceID.String(), - ServerTimestamp: envelope.GetServerTimestamp(), + Sender: theirUUID, + ChatID: theirUUID.String(), }, - // CallMessage doesn't have its own timestamp, use one from the envelope - Timestamp: envelope.GetClientTimestamp(), IsRinging: content.CallMessage.Offer != nil, }) } - case *signalpb.Content_DecryptionErrorMessage: - // These should've been handled earlier - log.Warn().Msg("Unexpected decryption error message content in decrypted message") - case *signalpb.Content_NullMessage: - // This is intentionally ignored - case *signalpb.Content_StoryMessage: - // This is also ignored for now - default: - if rawContent.PniSignatureMessage == nil && rawContent.SenderKeyDistributionMessage == nil { - log.Warn().Type("content_type", content).Msg("Unrecognized message content type") + + // Read and delivery receipts + if content.ReceiptMessage != nil { + if content.GetReceiptMessage().GetType() == signalpb.ReceiptMessage_DELIVERY && theirUUID.String() == d.Data.AciUuid { + // Ignore delivery receipts from other own devices + return &web.SimpleResponse{ + Status: responseCode, + }, nil + } + d.Connection.handleEvent(&events.Receipt{ + Sender: theirUUID, + Content: content.ReceiptMessage, + }) } } - - if sendDeliveryReceipt && handlerSuccess { - err = cli.sendDeliveryReceipts(ctx, []uint64{deliveryReceiptTS}, theirServiceID.UUID) - if err != nil { - log.Err(err).Msg("sendDeliveryReceipts error") - } - } - - return nil + return &web.SimpleResponse{ + Status: responseCode, + }, nil } -func groupOrUserID(groupID types.GroupIdentifier, userID libsignalgo.ServiceID) string { +func printStructFields(message protoreflect.Message, parent string, builder *strings.Builder) { + message.Range(func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool { + fieldName := string(fd.Name()) + currentField := parent + fieldName + builder.WriteString(fmt.Sprintf("%s (%s), ", currentField, fd.Kind().String())) + //builder.WriteString(fmt.Sprintf("%s (%s): %s, ", currentField, fd.Kind().String(), v.String())) // DEBUG: printing value, don't commit + if fd.Kind() == protoreflect.MessageKind && !fd.IsList() && v.Message().IsValid() { + builder.WriteString("{ ") + printStructFields(v.Message(), "", builder) + builder.WriteString("} ") + } else if fd.Kind() == protoreflect.MessageKind && fd.IsList() { + builder.WriteString("[ ") + for i := 0; i < v.List().Len(); i++ { + v := v.List().Get(i) + builder.WriteString("{ ") + printStructFields(v.Message(), "", builder) + builder.WriteString("} ") + } + builder.WriteString("] ") + } else if fd.IsList() { + builder.WriteString("[ ") + for i := 0; i < v.List().Len(); i++ { + //v := v.List().Get(i) + //builder.WriteString(fmt.Sprintf("%s, ", v.String())) // DEBUG: printing value, don't commit + builder.WriteString("<>, ") + } + builder.WriteString("] ") + } + return true + }) +} + +func printContentFieldString(c *signalpb.Content, message string) { + go func() { + // catch panic + defer func() { + if r := recover(); r != nil { + zlog.Warn().Msgf("Panic in contentFieldsString: %v", r) + } + }() + zlog.Debug().Msgf("%v: %v", message, contentFieldsString(c)) + }() +} + +func contentFieldsString(c *signalpb.Content) string { + builder := &strings.Builder{} + printStructFields(c.ProtoReflect(), "", builder) + return builder.String() +} + +func groupOrUserID(groupID types.GroupIdentifier, userID uuid.UUID) string { if groupID == "" { return userID.String() } return string(groupID) } -func (cli *Client) handleSyncMessage(ctx context.Context, msg *signalpb.SyncMessage, envelope *signalpb.Envelope) (handlerSuccess bool) { - // TODO: handle more sync messages - handlerSuccess = true - log := zerolog.Ctx(ctx) - switch content := msg.Content.(type) { - case *signalpb.SyncMessage_Keys_: - aep := libsignalgo.AccountEntropyPool(content.Keys.GetAccountEntropyPool()) - if aep != "" { - aepMasterKey, err := aep.DeriveSVRKey() - if err != nil { - log.Err(err).Msg("Failed to derive master key from account entropy pool") - } else if cli.Store.MasterKey == nil { - cli.Store.MasterKey = aepMasterKey - log.Debug().Msg("Derived master key from account entropy pool (no master key in sync message)") - } else if !bytes.Equal(aepMasterKey, cli.Store.MasterKey) { - log.Warn().Msg("Derived master key doesn't match one in sync message") - } else { - log.Debug().Msg("Derived master key matches one in sync message") - } - } else { - log.Debug().Msg("No account entropy pool in sync message") - } - err := cli.Store.DeviceStore.PutDevice(ctx, &cli.Store.DeviceData) - if err != nil { - log.Err(err).Msg("Failed to save device after receiving master key") - } else { - log.Info().Msg("Received master key") - go cli.SyncStorage(ctx) - } - case *signalpb.SyncMessage_FetchLatest_: - switch content.FetchLatest.GetType() { - case signalpb.SyncMessage_FetchLatest_STORAGE_MANIFEST: - log.Debug().Msg("Received storage manifest fetch latest notice") - go cli.SyncStorage(ctx) - default: - log.Debug(). - Stringer("fetch_latest_type", content.FetchLatest.GetType()). - Msg("Received unknown fetch latest notice") - } - case *signalpb.SyncMessage_Sent_: - syncSent := content.Sent - if syncSent.GetMessage() != nil || syncSent.GetEditMessage() != nil { - syncDestinationServiceID, err := ParseStringOrBinaryServiceID(syncSent.GetDestinationServiceId(), syncSent.GetDestinationServiceIdBinary()) - if err != nil && !errors.Is(err, ErrEmptyUUIDInput) { - log.Err(err).Msg("Sync message destination parse error") - } - if syncSent.GetDestinationE164() != "" && !syncDestinationServiceID.IsEmpty() { - aci, pni := syncDestinationServiceID.ToACIAndPNI() - _, err = cli.Store.RecipientStore.UpdateRecipientE164(ctx, aci, pni, syncSent.GetDestinationE164()) - if err != nil { - log.Err(err).Msg("Failed to update recipient E164 after receiving sync message") - } - } - for _, unident := range syncSent.GetUnidentifiedStatus() { - serviceID, err := ParseStringOrBinaryServiceID(unident.GetDestinationServiceId(), unident.GetDestinationServiceIdBinary()) - if err != nil { - log.Err(err). - Str("destination_service_id", unident.GetDestinationServiceId()). - Hex("destination_service_id_bytes", unident.GetDestinationServiceIdBinary()). - Msg("Failed to parse destination service ID of unidentified send") - continue - } - changed, err := cli.saveSyncPNIIdentityKey(ctx, serviceID, unident.GetDestinationPniIdentityKey()) - if err != nil { - log.Err(err). - Stringer("destination_service_id", serviceID). - Msg("Failed to save PNI identity key from sync message") - } else if changed { - log.Debug(). - Stringer("destination_service_id", serviceID). - Msg("Saved new PNI identity key from sync message") - } - } - - if syncDestinationServiceID.IsEmpty() && syncSent.GetMessage().GetGroupV2() == nil && syncSent.GetEditMessage().GetDataMessage().GetGroupV2() == nil { - log.Warn().Msg("sync message sent destination is nil") - } else if syncSent.Message != nil { - // TODO handle expiration start ts, and maybe the sync message ts? - cli.incomingDataMessage(ctx, syncSent.Message, cli.Store.ACI, syncDestinationServiceID, envelope.GetServerTimestamp(), false) - } else if syncSent.EditMessage != nil { - cli.incomingEditMessage(ctx, syncSent.EditMessage, cli.Store.ACI, syncDestinationServiceID, envelope.GetServerTimestamp(), false) - } - } - case *signalpb.SyncMessage_Contacts_: - log.Debug().Msg("Recieved sync message contacts") - if content.Contacts.Blob != nil { - // TODO roundtrip via disk to save memory - contactsBytes, err := DownloadAttachmentWithPointer(ctx, content.Contacts.Blob, nil, nil) - if err != nil { - log.Err(err).Msg("Contacts Sync DownloadAttachment error") - } - // unmarshall contacts - contacts, avatars, err := unmarshalContactDetailsMessages(contactsBytes) - if err != nil { - log.Err(err).Msg("Contacts Sync unmarshalContactDetailsMessages error") - } - log.Debug().Int("contact_count", len(contacts)).Msg("Contacts Sync received contacts") - convertedContacts := make([]*types.Recipient, 0, len(contacts)) - err = cli.Store.DoContactTxn(ctx, func(ctx context.Context) error { - for i, signalContact := range contacts { - if (signalContact.Aci == nil || *signalContact.Aci == "") && len(signalContact.AciBinary) != 16 { - // TODO lookup PNI via CDSI and store that when ACI is missing? - log.Info(). - Any("contact", signalContact). - Msg("Signal Contact UUID is nil, skipping") - continue - } - contact, err := cli.StoreContactDetailsAsContact(ctx, signalContact, &avatars[i]) - if err != nil { - return err - } - convertedContacts = append(convertedContacts, contact) - } - return nil - }) - if err != nil { - log.Err(err).Msg("Error storing contacts") - } else { - handlerSuccess = cli.handleEvent(&events.ContactList{ - Contacts: convertedContacts, - }) - } - } - case *signalpb.SyncMessage_DeleteForMe_: - handlerSuccess = cli.handleEvent(&events.DeleteForMe{ - Timestamp: envelope.GetClientTimestamp(), - SyncMessage_DeleteForMe: content.DeleteForMe, - }) - case *signalpb.SyncMessage_MessageRequestResponse_: - aciUUID, _ := ParseStringOrBinaryUUID(content.MessageRequestResponse.GetThreadAci(), content.MessageRequestResponse.GetThreadAciBinary()) - if aciUUID != uuid.Nil && content.MessageRequestResponse.GetType() == signalpb.SyncMessage_MessageRequestResponse_ACCEPT { - _, err := cli.Store.RecipientStore.LoadAndUpdateRecipient(ctx, aciUUID, uuid.Nil, func(recipient *types.Recipient) (changed bool, err error) { - changed = !ptr.Val(recipient.Whitelisted) || recipient.NeedsPNISignature - recipient.Whitelisted = ptr.Ptr(true) - recipient.NeedsPNISignature = false - return - }) - if err != nil { - log.Err(err).Msg("Failed to clear needs_pni_signature flag after message request accept") - } - } - var groupID *libsignalgo.GroupIdentifier - if len(content.MessageRequestResponse.GroupId) == libsignalgo.GroupIdentifierLength { - groupID = (*libsignalgo.GroupIdentifier)(content.MessageRequestResponse.GroupId) - } - handlerSuccess = cli.handleEvent(&events.MessageRequestResponse{ - Timestamp: envelope.GetClientTimestamp(), - ThreadACI: aciUUID, - GroupID: groupID, - Type: content.MessageRequestResponse.GetType(), - Raw: content.MessageRequestResponse, - }) - default: - if msg.Read != nil { - handlerSuccess = cli.handleEvent(&events.ReadSelf{ - Timestamp: envelope.GetClientTimestamp(), - Messages: msg.Read, - }) - } - } - return -} - -func (cli *Client) saveSyncPNIIdentityKey(ctx context.Context, serviceID libsignalgo.ServiceID, identityKeyBytes []byte) (bool, error) { - if identityKeyBytes == nil || serviceID.Type != libsignalgo.ServiceIDTypePNI { - return false, nil - } - identityKey, err := libsignalgo.DeserializeIdentityKey(identityKeyBytes) - if err != nil { - return false, fmt.Errorf("failed to deserialize PNI identity key: %w", err) - } - changed, err := cli.Store.IdentityKeyStore.SaveIdentityKey(ctx, serviceID, identityKey) - if err != nil { - return false, fmt.Errorf("failed to save PNI identity key: %w", err) - } - return changed, nil -} - -func (cli *Client) handlePNISignatureMessage(ctx context.Context, sender libsignalgo.ServiceID, msg *signalpb.PniSignatureMessage) error { - if sender.Type != libsignalgo.ServiceIDTypeACI { - return fmt.Errorf("PNI signature message sender is not an ACI") - } - pniBytes := msg.GetPni() - if len(pniBytes) != 16 { - return fmt.Errorf("unexpected PNI length %d (expected 16)", len(pniBytes)) - } - pni := uuid.UUID(pniBytes) - pniServiceID := libsignalgo.NewPNIServiceID(pni) - pniIdentity, err := cli.Store.IdentityKeyStore.GetIdentityKey(ctx, pniServiceID) - if err != nil { - return fmt.Errorf("failed to get identity for PNI %s: %w", pni, err) - } else if pniIdentity == nil { - zerolog.Ctx(ctx).Debug(). - Stringer("aci", sender.UUID). - Stringer("pni", pni). - Msg("Fetching PNI identity for signature verification as it wasn't found in store") - err = cli.FetchAndProcessPreKey(ctx, pniServiceID, 0) - if err != nil { - return fmt.Errorf("failed to fetch prekey for PNI %s after identity wasn't found in store: %w", pni, err) - } else if pniIdentity, err = cli.Store.IdentityKeyStore.GetIdentityKey(ctx, pniServiceID); err != nil { - return fmt.Errorf("failed to get identity for PNI %s after fetching: %w", pni, err) - } else if pniIdentity == nil { - return fmt.Errorf("identity not found for PNI %s even after fetching", pni) - } - } - aciIdentity, err := cli.Store.IdentityKeyStore.GetIdentityKey(ctx, sender) - if err != nil { - return fmt.Errorf("failed to get identity for ACI %s: %w", sender, err) - } else if aciIdentity == nil { - return fmt.Errorf("identity not found for ACI %s", sender) - } - if ok, err := pniIdentity.VerifyAlternateIdentity(aciIdentity, msg.GetSignature()); err != nil { - return fmt.Errorf("signature validation failed: %w", err) - } else if !ok { - return fmt.Errorf("signature is invalid") - } - zerolog.Ctx(ctx).Debug(). - Stringer("aci", sender.UUID). - Stringer("pni", pni). - Msg("Verified ACI-PNI mapping") - _, err = cli.Store.RecipientStore.LoadAndUpdateRecipient(ctx, sender.UUID, pni, nil) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to update aci/pni mapping in store") - } - cli.handleEvent(&events.ACIFound{ACI: sender, PNI: pniServiceID}) - return nil -} - -func (cli *Client) incomingEditMessage( - ctx context.Context, - editMessage *signalpb.EditMessage, - messageSenderACI uuid.UUID, - chatRecipient libsignalgo.ServiceID, - serverTimestamp uint64, - isBlocked bool, -) (handlerSuccess, sendDeliveryReceipt bool) { +func incomingEditMessage(ctx context.Context, device *Device, editMessage *signalpb.EditMessage, messageSender, chatRecipient uuid.UUID) bool { // If it's a group message, get the ID and invalidate cache if necessary var groupID types.GroupIdentifier - var groupRevision uint32 + var groupRevision int if editMessage.GetDataMessage().GetGroupV2() != nil { // Pull out the master key then store it ASAP - we should pass around GroupIdentifier groupMasterKeyBytes := editMessage.GetDataMessage().GetGroupV2().GetMasterKey() masterKey := masterKeyFromBytes(libsignalgo.GroupMasterKey(groupMasterKeyBytes)) var err error - groupID, err = cli.StoreMasterKey(ctx, masterKey) + groupID, err = StoreMasterKey(ctx, device, masterKey) if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("StoreMasterKey error") - return + zlog.Err(err).Msg("StoreMasterKey error") + return false } - groupRevision = editMessage.GetDataMessage().GetGroupV2().GetRevision() - } else if isBlocked { - zerolog.Ctx(ctx).Debug().Msg("Dropping direct message from blocked user") - return true, false + groupRevision = int(editMessage.GetDataMessage().GetGroupV2().GetRevision()) } - return cli.handleEvent(&events.ChatEvent{ + device.Connection.handleEvent(&events.ChatEvent{ Info: events.MessageInfo{ - Sender: messageSenderACI, - ChatID: groupOrUserID(groupID, chatRecipient), - GroupRevision: groupRevision, - ServerTimestamp: serverTimestamp, + Sender: messageSender, + ChatID: groupOrUserID(groupID, chatRecipient), + GroupRevision: groupRevision, }, Event: editMessage, - }), true + }) + return true } -func (cli *Client) incomingDataMessage( - ctx context.Context, - dataMessage *signalpb.DataMessage, - messageSenderACI uuid.UUID, - chatRecipient libsignalgo.ServiceID, - serverTimestamp uint64, - isBlocked bool, -) (handlerSuccess, sendDeliveryReceipt bool) { +func incomingDataMessage(ctx context.Context, device *Device, dataMessage *signalpb.DataMessage, messageSender, chatRecipient uuid.UUID) bool { // If there's a profile key, save it if dataMessage.ProfileKey != nil { profileKey := libsignalgo.ProfileKey(dataMessage.ProfileKey) - err := cli.Store.RecipientStore.StoreProfileKey(ctx, messageSenderACI, profileKey) + err := device.ProfileKeyStore.StoreProfileKey(messageSender.String(), profileKey, ctx) if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("StoreProfileKey error") - return + zlog.Err(err).Msg("StoreProfileKey error") + return false } } // If it's a group message, get the ID and invalidate cache if necessary var groupID types.GroupIdentifier - var groupRevision uint32 + var groupRevision int if dataMessage.GetGroupV2() != nil { // Pull out the master key then store it ASAP - we should pass around GroupIdentifier groupMasterKeyBytes := dataMessage.GetGroupV2().GetMasterKey() masterKey := masterKeyFromBytes(libsignalgo.GroupMasterKey(groupMasterKeyBytes)) var err error - groupID, err = cli.StoreMasterKey(ctx, masterKey) + groupID, err = StoreMasterKey(ctx, device, masterKey) if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("StoreMasterKey error") - return + zlog.Err(err).Msg("StoreMasterKey error") + return false + } + groupRevision = int(dataMessage.GetGroupV2().GetRevision()) + + var groupHasChanged = false + if dataMessage.GetGroupV2().GroupChange != nil { + // TODO: don't parse the change for now, just invalidate our cache + zlog.Debug().Msgf("Invalidating group %v due to change: %v", groupID, dataMessage.GetGroupV2().GroupChange) + InvalidateGroupCache(device, groupID) + groupHasChanged = true + } else if dataMessage.GetGroupV2().GetRevision() > 0 { + // Compare revision, and if it's newer, invalidate our cache + ourGroup, err := RetrieveGroupByID(ctx, device, groupID) + if err != nil { + zlog.Err(err).Msg("RetrieveGroupByID error") + } else if dataMessage.GetGroupV2().GetRevision() > ourGroup.Revision { + zlog.Debug().Msgf("Invalidating group %v due to new revision %v > our revision: %v", groupID, dataMessage.GetGroupV2().GetRevision(), ourGroup.Revision) + InvalidateGroupCache(device, groupID) + groupHasChanged = true + } + } + if groupHasChanged { + device.Connection.handleEvent(&events.GroupChange{ + SenderID: messageSender, + Timestamp: dataMessage.GetTimestamp(), + GroupID: groupID, + Revision: groupRevision, + }) } - groupRevision = dataMessage.GetGroupV2().GetRevision() - } else if isBlocked { - zerolog.Ctx(ctx).Debug().Msg("Dropping direct message from blocked user") - return true, false } evtInfo := events.MessageInfo{ - Sender: messageSenderACI, - ChatID: groupOrUserID(groupID, chatRecipient), - GroupRevision: groupRevision, - ServerTimestamp: serverTimestamp, + Sender: messageSender, + ChatID: groupOrUserID(groupID, chatRecipient), + GroupRevision: groupRevision, } // Hacky special case for group calls to cache the state if dataMessage.GroupCallUpdate != nil { - isRinging := cli.GroupCache.UpdateActiveCall(groupID, dataMessage.GroupCallUpdate.GetEraId()) - return cli.handleEvent(&events.Call{ + isRinging := device.UpdateActiveCalls(groupID, *dataMessage.GroupCallUpdate.EraId) + device.Connection.handleEvent(&events.Call{ Info: evtInfo, Timestamp: dataMessage.GetTimestamp(), IsRinging: isRinging, - }), true + }) } else { - return cli.handleEvent(&events.ChatEvent{ + device.Connection.handleEvent(&events.ChatEvent{ Info: evtInfo, Event: dataMessage, - }), true + }) } + + return true } -func (cli *Client) sendDeliveryReceipts(ctx context.Context, deliveredTimestamps []uint64, senderUUID uuid.UUID) error { +func sendDeliveryReceipts(ctx context.Context, device *Device, deliveredTimestamps []uint64, senderUUID uuid.UUID) error { // Send delivery receipts if len(deliveredTimestamps) > 0 { receipt := DeliveredReceiptMessageForTimestamps(deliveredTimestamps) - result := cli.SendMessage(ctx, libsignalgo.NewACIServiceID(senderUUID), receipt) + result := SendMessage(ctx, device, senderUUID.String(), receipt) if !result.WasSuccessful { - return fmt.Errorf("failed to send delivery receipts: %v", result) + zlog.Error().Msgf("Failed to send delivery receipts: %v", result) } } return nil } + +type DecryptionResult struct { + SenderAddress *libsignalgo.Address + Content *signalpb.Content + SealedSender bool +} + +func serverTrustRootKey() *libsignalgo.PublicKey { + // TODO: put this server's trust root in the config or DB or something + serverTrustRoot := "BXu6QIKVz5MA8gstzfOgRQGqyLqOwNKHL6INkv3IHWMF" + serverTrustRootBytes, err := base64.StdEncoding.DecodeString(serverTrustRoot) + if err != nil { + zlog.Err(err).Msg("DecodeString error") + panic(err) + } + serverTrustRootKey, err := libsignalgo.DeserializePublicKey(serverTrustRootBytes) + if err != nil { + zlog.Err(err).Msg("DeserializePublicKey error") + panic(err) + } + return serverTrustRootKey +} + +func sealedSenderDecrypt(envelope *signalpb.Envelope, device *Device, ctx context.Context) (*DecryptionResult, error) { + localAddress := libsignalgo.NewSealedSenderAddress( + device.Data.Number, + uuid.MustParse(device.Data.AciUuid), + uint32(device.Data.DeviceId), + ) + timestamp := time.Unix(0, int64(*envelope.Timestamp)) + result, err := libsignalgo.SealedSenderDecrypt( + envelope.Content, + localAddress, + serverTrustRootKey(), + timestamp, + device.SessionStore, + device.IdentityStore, + device.PreKeyStore, + device.SignedPreKeyStore, + libsignalgo.NewCallbackContext(ctx), + ) + + if err != nil { + zlog.Err(err).Msg("SealedSenderDecrypt error") + return nil, err + } + msg := result.Message + err = stripPadding(&msg) + if err != nil { + zlog.Err(err).Msg("stripPadding error") + return nil, err + } + address, err := libsignalgo.NewAddress( + result.Sender.UUID.String(), + uint(result.Sender.DeviceID), + ) + if err != nil { + zlog.Err(err).Msg("NewAddress error") + return nil, err + } + content := &signalpb.Content{} + err = proto.Unmarshal(msg, content) + if err != nil { + zlog.Err(err).Msg("Unmarshal error") + return nil, err + } + DecryptionResult := &DecryptionResult{ + SenderAddress: address, + Content: content, + } + return DecryptionResult, nil +} + +func prekeyDecrypt(sender *libsignalgo.Address, encryptedContent []byte, device *Device, ctx context.Context) (*DecryptionResult, error) { + preKeyMessage, err := libsignalgo.DeserializePreKeyMessage(encryptedContent) + if err != nil { + err = fmt.Errorf("DeserializePreKeyMessage error: %v", err) + return nil, err + } + if preKeyMessage == nil { + err = fmt.Errorf("preKeyMessage is nil") + return nil, err + } + + data, err := libsignalgo.DecryptPreKey( + preKeyMessage, + sender, + device.SessionStore, + device.IdentityStore, + device.PreKeyStore, + device.SignedPreKeyStore, + device.KyberPreKeyStore, + libsignalgo.NewCallbackContext(ctx), + ) + if err != nil { + err = fmt.Errorf("DecryptPreKey error: %v", err) + return nil, err + } + err = stripPadding(&data) + if err != nil { + err = fmt.Errorf("stripPadding error: %v", err) + return nil, err + } + content := &signalpb.Content{} + err = proto.Unmarshal(data, content) + if err != nil { + err = fmt.Errorf("Unmarshal error: %v", err) + return nil, err + } + DecryptionResult := &DecryptionResult{ + SenderAddress: sender, + Content: content, + } + return DecryptionResult, nil +} + +func stripPadding(contents *[]byte) error { + for i := len(*contents) - 1; i >= 0; i-- { + if (*contents)[i] == 0x80 { + *contents = (*contents)[:i] + return nil + } else if (*contents)[i] != 0x00 { + return fmt.Errorf("Invalid ISO7816 padding") + } + } + return fmt.Errorf("Invalid ISO7816 padding, len(contents): %v", len(*contents)) +} diff --git a/pkg/signalmeow/receiving_decrypt.go b/pkg/signalmeow/receiving_decrypt.go deleted file mode 100644 index 1d2c8cc..0000000 --- a/pkg/signalmeow/receiving_decrypt.go +++ /dev/null @@ -1,430 +0,0 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2023 Scott Weber -// Copyright (C) 2025 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package signalmeow - -import ( - "context" - "crypto/sha256" - "errors" - "fmt" - "time" - - "github.com/google/uuid" - "github.com/rs/zerolog" - "google.golang.org/protobuf/proto" - - "go.mau.fi/mautrix-signal/pkg/libsignalgo" - signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" - "go.mau.fi/mautrix-signal/pkg/signalmeow/store" -) - -type DecryptionResult struct { - SenderAddress *libsignalgo.Address - CiphertextHash *[32]byte - Content *signalpb.Content - ContentHint signalpb.UnidentifiedSenderMessage_Message_ContentHint - Err error - GroupID *libsignalgo.GroupIdentifier - Unencrypted bool - - Retriable bool - Ciphertext []byte - CiphertextType libsignalgo.CiphertextMessageType -} - -func (cli *Client) decryptEnvelope( - ctx context.Context, - envelope *signalpb.Envelope, - sourceServiceID, destinationServiceID libsignalgo.ServiceID, -) DecryptionResult { - if destinationServiceID.IsEmpty() { - return DecryptionResult{Err: fmt.Errorf("envelope missing destination service ID")} - } - - switch *envelope.Type { - case signalpb.Envelope_UNIDENTIFIED_SENDER: - result, err := cli.decryptUnidentifiedSenderEnvelope(ctx, destinationServiceID, envelope) - if err != nil { - result.Err = fmt.Errorf("failed to decrypt unidentified sender envelope: %w", err) - } - return result - - case signalpb.Envelope_PREKEY_MESSAGE, signalpb.Envelope_DOUBLE_RATCHET: - sender, err := sourceServiceID.Address(uint(envelope.GetSourceDeviceId())) - if err != nil { - return DecryptionResult{Err: fmt.Errorf("failed to wrap address: %v", err)} - } - var result *DecryptionResult - var bundleType string - if *envelope.Type == signalpb.Envelope_PREKEY_MESSAGE { - result, err = cli.prekeyDecrypt(ctx, destinationServiceID, sender, envelope.Content, envelope.GetServerTimestamp()) - bundleType = "prekey bundle" - } else { - result, err = cli.decryptCiphertextEnvelope(ctx, destinationServiceID, sender, envelope.Content, envelope.GetServerTimestamp()) - bundleType = "ciphertext" - } - if err != nil { - return DecryptionResult{ - SenderAddress: sender, - Err: fmt.Errorf("failed to decrypt %s envelope: %w", bundleType, err), - Retriable: true, // TODO should these ever be not retriable? - Ciphertext: envelope.Content, - CiphertextType: libsignalgo.CiphertextMessageType(envelope.GetType()), - } - } - return *result - - case signalpb.Envelope_PLAINTEXT_CONTENT: - addr, err := sourceServiceID.Address(uint(envelope.GetSourceDeviceId())) - if err != nil { - return DecryptionResult{Err: fmt.Errorf("failed to wrap address: %v", err)} - } - content, err := stripPadding(envelope.GetContent()) - if err != nil { - return DecryptionResult{Err: fmt.Errorf("failed to strip padding: %w", err)} - } - return DecryptionResult{ - SenderAddress: addr, - Content: &signalpb.Content{Content: &signalpb.Content_DecryptionErrorMessage{DecryptionErrorMessage: content}}, - Unencrypted: true, - } - - case signalpb.Envelope_SERVER_DELIVERY_RECEIPT: - return DecryptionResult{Err: fmt.Errorf("server delivery receipt envelopes are not yet supported")} - - case signalpb.Envelope_UNKNOWN: - return DecryptionResult{Err: fmt.Errorf("unknown envelope type")} - - default: - return DecryptionResult{Err: fmt.Errorf("unrecognized envelope type %d", envelope.GetType())} - } -} - -var EventAlreadyProcessed = errors.New("event was already processed") - -func (cli *Client) bufferedDecryptTxn(ctx context.Context, ciphertext []byte, serverTimestamp uint64, decrypt func(context.Context) ([]byte, error)) (plaintext []byte, ciphertextHash [32]byte, err error) { - ciphertextHash = sha256.Sum256(ciphertext) - - var buf *store.BufferedEvent - buf, err = cli.Store.EventBuffer.GetBufferedEvent(ctx, ciphertextHash) - if err != nil { - err = fmt.Errorf("failed to get buffered event: %w", err) - return - } else if buf != nil { - plaintext = buf.Plaintext - insertTime := time.UnixMilli(buf.InsertTimestamp) - if plaintext == nil { - zerolog.Ctx(ctx).Debug(). - Hex("ciphertext_hash", ciphertextHash[:]). - Time("insertion_time", insertTime). - Msg("Returning event already processed error") - err = fmt.Errorf("%w at %s", EventAlreadyProcessed, insertTime.String()) - } else { - zerolog.Ctx(ctx).Debug(). - Hex("ciphertext_hash", ciphertextHash[:]). - Time("insertion_time", insertTime). - Msg("Returning previously decrypted plaintext") - } - return - } - - err = cli.Store.DoDecryptionTxn(ctx, func(ctx context.Context) (innerErr error) { - plaintext, innerErr = decrypt(ctx) - if innerErr != nil { - return - } - innerErr = cli.Store.EventBuffer.PutBufferedEvent(ctx, ciphertextHash, plaintext, serverTimestamp) - if innerErr != nil { - innerErr = fmt.Errorf("failed to save decrypted event to buffer: %w", innerErr) - } - zerolog.Ctx(ctx).Trace(). - Hex("ciphertext_hash", ciphertextHash[:]). - Msg("Successfully decrypted and saved event") - return - }) - return -} - -func (cli *Client) prekeyDecrypt( - ctx context.Context, - destination libsignalgo.ServiceID, - sender *libsignalgo.Address, - encryptedContent []byte, - serverTimestamp uint64, -) (*DecryptionResult, error) { - preKeyMessage, err := libsignalgo.DeserializePreKeyMessage(encryptedContent) - if err != nil { - return nil, fmt.Errorf("failed to deserialize prekey message: %w", err) - } else if preKeyMessage == nil { - return nil, fmt.Errorf("deserializing prekey message returned nil") - } - pks := cli.Store.PreKeyStore(destination) - if pks == nil { - return nil, fmt.Errorf("no prekey store found for %s", destination) - } - ss := cli.Store.SessionStore(destination) - if ss == nil { - return nil, fmt.Errorf("no session store found for %s", destination) - } - is := cli.Store.IdentityStore(destination) - if is == nil { - return nil, fmt.Errorf("no identity store found for %s", destination) - } - destinationAddress, err := destination.Address(uint(cli.Store.DeviceID)) - if err != nil { - return nil, fmt.Errorf("failed to get own/destination address: %w", err) - } - - plaintext, ciphertextHash, err := cli.bufferedDecryptTxn(ctx, encryptedContent, serverTimestamp, func(ctx context.Context) ([]byte, error) { - return libsignalgo.DecryptPreKey( - ctx, - preKeyMessage, - sender, - destinationAddress, - ss, - is, - pks, - pks, - pks, - ) - }) - if err != nil { - return nil, fmt.Errorf("failed to decrypt prekey message: %w", err) - } - plaintext, err = stripPadding(plaintext) - if err != nil { - return nil, fmt.Errorf("failed to strip padding: %w", err) - } - content := &signalpb.Content{} - err = proto.Unmarshal(plaintext, content) - if err != nil { - return nil, fmt.Errorf("failed to unmarshal decrypted prekey message: %w", err) - } - return &DecryptionResult{ - SenderAddress: sender, - Content: content, - CiphertextHash: &ciphertextHash, - }, nil -} - -func (cli *Client) decryptCiphertextEnvelope( - ctx context.Context, - destinationServiceID libsignalgo.ServiceID, - senderAddress *libsignalgo.Address, - ciphertext []byte, - serverTimestamp uint64, -) (*DecryptionResult, error) { - log := zerolog.Ctx(ctx) - message, err := libsignalgo.DeserializeMessage(ciphertext) - if err != nil { - log.Err(err).Msg("Failed to deserialize ciphertext message") - return nil, fmt.Errorf("failed to deserialize message: %w", err) - } - sessionStore := cli.Store.SessionStore(destinationServiceID) - if sessionStore == nil { - return nil, fmt.Errorf("no session store for destination service ID %s", destinationServiceID) - } - identityStore := cli.Store.IdentityStore(destinationServiceID) - if identityStore == nil { - return nil, fmt.Errorf("no identity store for destination service ID %s", destinationServiceID) - } - destinationAddress, err := destinationServiceID.Address(uint(cli.Store.DeviceID)) - if err != nil { - return nil, fmt.Errorf("failed to get own address: %w", err) - } - plaintext, ciphertextHash, err := cli.bufferedDecryptTxn(ctx, ciphertext, serverTimestamp, func(ctx context.Context) ([]byte, error) { - return libsignalgo.Decrypt( - ctx, - message, - senderAddress, - destinationAddress, - sessionStore, - identityStore, - ) - }) - if err != nil { - return nil, fmt.Errorf("failed to decrypt ciphertext message: %w", err) - } - plaintext, err = stripPadding(plaintext) - if err != nil { - return nil, fmt.Errorf("failed to strip padding: %w", err) - } - content := signalpb.Content{} - err = proto.Unmarshal(plaintext, &content) - if err != nil { - return nil, fmt.Errorf("failed to unmarshal decrypted message: %w", err) - } - return &DecryptionResult{ - SenderAddress: senderAddress, - Content: &content, - CiphertextHash: &ciphertextHash, - }, nil -} - -func (cli *Client) decryptSenderKeyMessage( - ctx context.Context, - senderAddress *libsignalgo.Address, - ciphertext []byte, - serverTimestamp uint64, -) (*DecryptionResult, error) { - plaintext, ciphertextHash, err := cli.bufferedDecryptTxn(ctx, ciphertext, serverTimestamp, func(ctx context.Context) ([]byte, error) { - return libsignalgo.GroupDecrypt( - ctx, - ciphertext, - senderAddress, - cli.Store.SenderKeyStore, - ) - }) - if err != nil { - return nil, fmt.Errorf("failed to decrypt sender key message: %w", err) - } - plaintext, err = stripPadding(plaintext) - if err != nil { - return nil, fmt.Errorf("failed to strip padding: %w", err) - } - content := signalpb.Content{} - err = proto.Unmarshal(plaintext, &content) - if err != nil { - return nil, fmt.Errorf("failed to unmarshal decrypted sender key message: %w", err) - } - return &DecryptionResult{ - SenderAddress: senderAddress, - Content: &content, - CiphertextHash: &ciphertextHash, - }, nil -} - -func (cli *Client) decryptUnidentifiedSenderEnvelope(ctx context.Context, destinationServiceID libsignalgo.ServiceID, envelope *signalpb.Envelope) (result DecryptionResult, err error) { - log := zerolog.Ctx(ctx) - - if destinationServiceID != cli.Store.ACIServiceID() { - log.Warn().Stringer("destination_service_id", destinationServiceID). - Msg("Received UNIDENTIFIED_SENDER envelope for non-ACI destination") - return result, fmt.Errorf("received unidentified sender envelope for non-ACI destination") - } - usmc, err := libsignalgo.SealedSenderDecryptToUSMC( - ctx, - envelope.GetContent(), - cli.Store.ACIIdentityStore, - ) - if err != nil { - return result, fmt.Errorf("failed to decrypt to USMC: %w", err) - } else if usmc == nil { - return result, fmt.Errorf("decrypting to USMC returned nil") - } - - messageType, err := usmc.GetMessageType() - if err != nil { - return result, fmt.Errorf("failed to get message type: %w", err) - } - senderCertificate, err := usmc.GetSenderCertificate() - if err != nil { - return result, fmt.Errorf("failed to get sender certificate: %w", err) - } - contentHint, err := usmc.GetContentHint() - if err != nil { - return result, fmt.Errorf("failed to get content hint: %w", err) - } - result.GroupID, err = usmc.GetGroupID() - if err != nil { - return result, fmt.Errorf("failed to get group ID: %w", err) - } - result.ContentHint = signalpb.UnidentifiedSenderMessage_Message_ContentHint(contentHint) - senderUUID, err := senderCertificate.GetSenderUUID() - if err != nil { - return result, fmt.Errorf("failed to get sender UUID: %w", err) - } - senderDeviceID, err := senderCertificate.GetDeviceID() - if err != nil { - return result, fmt.Errorf("failed to get sender device ID: %w", err) - } - senderAddress, err := libsignalgo.NewACIServiceID(senderUUID).Address(uint(senderDeviceID)) - if err != nil { - return result, fmt.Errorf("failed to create sender address: %w", err) - } - result.SenderAddress = senderAddress - senderE164, err := senderCertificate.GetSenderE164() - if err != nil { - return result, fmt.Errorf("failed to get sender E164: %w", err) - } - usmcContents, err := usmc.GetContents() - if err != nil { - return result, fmt.Errorf("failed to get USMC contents: %w", err) - } - result.Ciphertext = usmcContents - result.CiphertextType = messageType - newLog := log.With(). - Stringer("sender_uuid", senderUUID). - Stringer("group_id", result.GroupID). - Uint32("sender_device_id", senderDeviceID). - Str("sender_e164", senderE164). - Uint8("sealed_sender_type", uint8(messageType)). - Logger() - log = &newLog - ctx = log.WithContext(ctx) - log.Trace().Msg("Received SealedSender message") - - if senderE164 != "" { - _, err = cli.Store.RecipientStore.UpdateRecipientE164(ctx, senderUUID, uuid.Nil, senderE164) - if err != nil { - log.Warn().Err(err).Msg("Failed to update sender E164 in recipient store") - } - } - - var resultPtr *DecryptionResult - switch messageType { - case libsignalgo.CiphertextMessageTypeSenderKey: - resultPtr, err = cli.decryptSenderKeyMessage(ctx, senderAddress, usmcContents, envelope.GetServerTimestamp()) - case libsignalgo.CiphertextMessageTypePreKey: - resultPtr, err = cli.prekeyDecrypt(ctx, destinationServiceID, senderAddress, usmcContents, envelope.GetServerTimestamp()) - case libsignalgo.CiphertextMessageTypeWhisper: - resultPtr, err = cli.decryptCiphertextEnvelope(ctx, destinationServiceID, senderAddress, usmcContents, envelope.GetServerTimestamp()) - case libsignalgo.CiphertextMessageTypePlaintext: - usmcContents, err = stripPadding(usmcContents) - if err != nil { - err = fmt.Errorf("failed to strip padding: %w", err) - } - result.Unencrypted = true - result.Content = &signalpb.Content{ - Content: &signalpb.Content_DecryptionErrorMessage{ - DecryptionErrorMessage: usmcContents, - }, - } - return result, err - default: - return result, fmt.Errorf("unsupported sealed sender message type %d", messageType) - } - if err != nil { - result.Retriable = result.ContentHint == signalpb.UnidentifiedSenderMessage_Message_RESENDABLE - return result, err - } - resultPtr.GroupID = result.GroupID - return *resultPtr, nil -} - -func stripPadding(contents []byte) ([]byte, error) { - for i := len(contents) - 1; i >= 0; i-- { - if contents[i] == 0x80 { - contents = contents[:i] - return contents, nil - } else if contents[i] != 0x00 { - return nil, fmt.Errorf("invalid ISO7816 padding") - } - } - return nil, fmt.Errorf("invalid ISO7816 padding (length %d)", len(contents)) -} diff --git a/pkg/signalmeow/retry.go b/pkg/signalmeow/retry.go deleted file mode 100644 index a581075..0000000 --- a/pkg/signalmeow/retry.go +++ /dev/null @@ -1,214 +0,0 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2025 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package signalmeow - -import ( - "context" - "fmt" - "math/rand/v2" - "slices" - "time" - - "github.com/rs/zerolog" - "go.mau.fi/util/random" - - "go.mau.fi/mautrix-signal/pkg/libsignalgo" - signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" - "go.mau.fi/mautrix-signal/pkg/signalmeow/types" -) - -type sendCacheKey struct { - recipient libsignalgo.ServiceID - groupID types.GroupIdentifier - timestamp uint64 -} - -const RetryRespondMaxAge = 30 * 24 * time.Hour - -func (cli *Client) sendRetryRequest(ctx context.Context, result DecryptionResult, originalTS uint64) error { - serviceID, err := result.SenderAddress.NameServiceID() - if err != nil { - return fmt.Errorf("failed to get sender name as service ID: %w", err) - } - deviceID, err := result.SenderAddress.DeviceID() - if err != nil { - return fmt.Errorf("failed to get sender device ID: %w", err) - } - dem, err := libsignalgo.DecryptionErrorMessageForOriginalMessage(result.Ciphertext, result.CiphertextType, originalTS, deviceID) - if err != nil { - return fmt.Errorf("failed to create decryption error message: %w", err) - } - demBytes, err := dem.Serialize() - if err != nil { - return fmt.Errorf("failed to serialize decryption error message: %w", err) - } - ptc, err := libsignalgo.PlaintextContentFromDecryptionErrorMessage(dem) - if err != nil { - return fmt.Errorf("failed to create plaintext content from decryption error message: %w", err) - } - ctm, err := libsignalgo.NewCiphertextMessage(ptc) - if err != nil { - return fmt.Errorf("failed to create ciphertext message from plaintext content: %w", err) - } - _, err = cli.sendContent(ctx, serviceID, uint64(time.Now().UnixMilli()), &signalpb.Content{ - Content: &signalpb.Content_DecryptionErrorMessage{ - DecryptionErrorMessage: demBytes, - }, - }, 0, true, result.GroupID, ctm) - if err != nil { - return fmt.Errorf("failed to send decryption error message: %w", err) - } - zerolog.Ctx(ctx).Debug(). - Stringer("sender_service_id", serviceID). - Uint("sender_device_id", deviceID). - Stringer("group_id", result.GroupID). - Msg("Sent retry receipt") - return nil -} - -func (cli *Client) handleRetryRequest( - ctx context.Context, - result DecryptionResult, - dem *libsignalgo.DecryptionErrorMessage, -) error { - destDeviceID, err := dem.GetDeviceID() - if err != nil { - return fmt.Errorf("failed to get device ID from decryption error message: %w", err) - } else if int(destDeviceID) != cli.Store.DeviceID { - zerolog.Ctx(ctx).Debug(). - Uint32("dest_device_id", destDeviceID). - Msg("Ignoring decryption error message for another device") - return nil - } - serviceID, err := result.SenderAddress.NameServiceID() - if err != nil { - return fmt.Errorf("failed to get sender name as service ID: %w", err) - } - deviceID, err := result.SenderAddress.DeviceID() - if err != nil { - return fmt.Errorf("failed to get sender device ID: %w", err) - } - ts, err := dem.GetTimestamp() - if err != nil { - return fmt.Errorf("failed to get timestamp: %w", err) - } - - cli.encryptionLock.Lock() - defer cli.encryptionLock.Unlock() - ctx = context.WithValue(ctx, contextKeyEncryptionLock, true) - var didArchiveSession bool - if ratchetKey, err := dem.GetRatchetKey(); err != nil { - return fmt.Errorf("failed to get ratchet key: %w", err) - } else if ratchetKey == nil { - // No need to archive session if no ratchet key is provided, it was probably a sender key decryption error - } else if session, err := cli.Store.ACISessionStore.LoadSession(ctx, result.SenderAddress); err != nil { - return fmt.Errorf("failed to load session for sender: %w", err) - } else if match, err := session.CurrentRatchetKeyMatches(ratchetKey); err != nil { - return fmt.Errorf("failed to check ratchet key match: %w", err) - } else if match { - err = session.ArchiveCurrentState() - if err != nil { - return fmt.Errorf("failed to archive current session state: %w", err) - } - err = cli.Store.ACISessionStore.StoreSession(ctx, result.SenderAddress, session) - if err != nil { - return fmt.Errorf("failed to store archived session: %w", err) - } - didArchiveSession = true - } - var skdmBytes []byte - groupID := types.BytesToGroupIdentifier(result.GroupID) - if groupID != "" { - ski, err := cli.Store.SenderKeyStore.GetSenderKeyInfo(ctx, groupID) - if err != nil { - return fmt.Errorf("failed to get sender key info for group %s: %w", groupID, err) - } - myAddress, err := cli.Store.ACIServiceID().Address(uint(cli.Store.DeviceID)) - if err != nil { - return fmt.Errorf("failed to get own address: %w", err) - } - if slices.Contains(ski.SharedWith[serviceID], int(deviceID)) { - skdm, err := libsignalgo.NewSenderKeyDistributionMessage(ctx, myAddress, ski.DistributionID, cli.Store.SenderKeyStore) - if err != nil { - return fmt.Errorf("failed to create sender key distribution message: %w", err) - } - skdmBytes, err = skdm.Serialize() - if err != nil { - return fmt.Errorf("failed to serialize sender key distribution message: %w", err) - } - } else { - zerolog.Ctx(ctx).Warn(). - Stringer("group_id", result.GroupID). - Stringer("sender_service_id", serviceID). - Stringer("distribution_id", ski.DistributionID). - Uint("sender_device_id", deviceID). - Ints("shared_with", ski.SharedWith[serviceID]). - Msg("Sender key distribution list doesn't contain retry receipt sender") - } - } - var retryContent *signalpb.Content - var cacheHit bool - if time.Since(time.UnixMilli(int64(ts))) < RetryRespondMaxAge { - retryContent, cacheHit = cli.sendCache.Get(sendCacheKey{ - groupID: groupID, - recipient: serviceID, - timestamp: ts, - }) - if !cacheHit { - // TODO add support for external caches - } - } - if retryContent == nil { - retryContent = &signalpb.Content{} - } - retryContent.SenderKeyDistributionMessage = skdmBytes - if !cacheHit && skdmBytes == nil { - if !didArchiveSession { - zerolog.Ctx(ctx).Debug(). - Uint64("msg_timestamp", ts). - Stringer("sender_service_id", serviceID). - Uint("sender_device_id", deviceID). - Stringer("group_id", result.GroupID). - Msg("Not responding to decryption error message") - return nil - } - retryContent.Content = &signalpb.Content_NullMessage{ - NullMessage: &signalpb.NullMessage{ - Padding: random.Bytes(rand.IntN(511) + 1), - }, - } - } - responseTimestamp := uint64(time.Now().UnixMilli()) - if cacheHit { - responseTimestamp = ts - } - zerolog.Ctx(ctx).Debug(). - Uint32("dest_device_id", destDeviceID). - Uint64("requested_msg_timestamp", ts). - Stringer("sender_service_id", serviceID). - Uint("sender_device_id", deviceID). - Stringer("group_id", result.GroupID). - Bool("did_archive_session", didArchiveSession). - Bool("found_message_in_cache", cacheHit). - Bool("including_skdm", skdmBytes != nil). - Msg("Responding to decryption error message") - _, err = cli.sendContent(ctx, serviceID, responseTimestamp, retryContent, 0, true, result.GroupID, nil) - if err != nil { - return fmt.Errorf("failed to send response: %w", err) - } - return nil -} diff --git a/pkg/signalmeow/sender_key_store.go b/pkg/signalmeow/sender_key_store.go new file mode 100644 index 0000000..e35d223 --- /dev/null +++ b/pkg/signalmeow/sender_key_store.go @@ -0,0 +1,93 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2023 Scott Weber +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package signalmeow + +import ( + "context" + "database/sql" + "errors" + "fmt" + + "github.com/google/uuid" + + "go.mau.fi/mautrix-signal/pkg/libsignalgo" +) + +var _ libsignalgo.SenderKeyStore = (*SQLStore)(nil) + +const ( + loadSenderKeyQuery = `SELECT key_record FROM signalmeow_sender_keys WHERE our_aci_uuid=$1 AND sender_uuid=$2 AND sender_device_id=$3 AND distribution_id=$4` + storeSenderKeyQuery = `INSERT INTO signalmeow_sender_keys (our_aci_uuid, sender_uuid, sender_device_id, distribution_id, key_record) VALUES ($1, $2, $3, $4, $5) ON CONFLICT (our_aci_uuid, sender_uuid, sender_device_id, distribution_id) DO UPDATE SET key_record=excluded.key_record` +) + +func scanSenderKey(row scannable) (*libsignalgo.SenderKeyRecord, error) { + var key []byte + err := row.Scan(&key) + if errors.Is(err, sql.ErrNoRows) { + return nil, nil + } else if err != nil { + return nil, err + } + return libsignalgo.DeserializeSenderKeyRecord(key) +} + +func (s *SQLStore) LoadSenderKey(sender *libsignalgo.Address, distributionID uuid.UUID, ctx context.Context) (*libsignalgo.SenderKeyRecord, error) { + distributionIdString := distributionID.String() + if distributionIdString == "" { + return nil, errors.New(fmt.Sprintf("distributionID did not parse: %v", distributionID)) + } + senderUuid, err := sender.Name() + if err != nil { + return nil, err + } + deviceId, err := sender.DeviceID() + if err != nil { + return nil, err + } + return scanSenderKey(s.db.QueryRow(loadSenderKeyQuery, s.AciUuid, senderUuid, deviceId, distributionIdString)) +} + +func (s *SQLStore) StoreSenderKey(sender *libsignalgo.Address, distributionID uuid.UUID, record *libsignalgo.SenderKeyRecord, ctx context.Context) error { + distributionIdString := distributionID.String() + if distributionIdString == "" { + return errors.New(fmt.Sprintf("distributionID did not parse: %v", distributionID)) + } + senderUuid, err := sender.Name() + if err != nil { + return err + } + deviceId, err := sender.DeviceID() + if err != nil { + return err + } + serialized, err := record.Serialize() + if err != nil { + return err + } + tx, err := s.db.BeginTx(ctx, nil) + if err != nil { + tx.Rollback() + return err + } + _, err = tx.Exec(storeSenderKeyQuery, s.AciUuid, senderUuid, deviceId, distributionIdString, serialized) + if err != nil { + _ = tx.Rollback() + return err + } + err = tx.Commit() + return err +} diff --git a/pkg/signalmeow/senderkey.go b/pkg/signalmeow/senderkey.go deleted file mode 100644 index 48a3203..0000000 --- a/pkg/signalmeow/senderkey.go +++ /dev/null @@ -1,431 +0,0 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2025 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package signalmeow - -import ( - "context" - "encoding/json" - "errors" - "fmt" - "maps" - "net/http" - "slices" - "time" - - "github.com/google/uuid" - "github.com/rs/zerolog" - "go.mau.fi/util/exslices" - "google.golang.org/protobuf/proto" - - "go.mau.fi/mautrix-signal/pkg/libsignalgo" - signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" - "go.mau.fi/mautrix-signal/pkg/signalmeow/store" - "go.mau.fi/mautrix-signal/pkg/signalmeow/types" - "go.mau.fi/mautrix-signal/pkg/signalmeow/web" -) - -const SenderKeyMaxAge = 14 * 24 * time.Hour - -type contextKey int - -const ( - contextKeyEncryptionLock contextKey = iota -) - -func (cli *Client) ResetSenderKey(ctx context.Context, groupID types.GroupIdentifier) (uuid.UUID, error) { - cli.encryptionLock.Lock() - defer cli.encryptionLock.Unlock() - info, err := cli.Store.SenderKeyStore.GetSenderKeyInfo(ctx, groupID) - if err != nil { - return uuid.Nil, fmt.Errorf("failed to get sender key info: %w", err) - } else if info == nil { - return uuid.Nil, nil - } else if myAddress, err := cli.Store.ACIServiceID().Address(uint(cli.Store.DeviceID)); err != nil { - return uuid.Nil, fmt.Errorf("failed to get own address: %w", err) - } else if err = cli.Store.SenderKeyStore.DeleteSenderKey(ctx, myAddress, info.DistributionID); err != nil { - return info.DistributionID, fmt.Errorf("failed to delete sender key: %w", err) - } else if err = cli.Store.SenderKeyStore.DeleteSenderKeyInfo(ctx, groupID); err != nil { - return info.DistributionID, fmt.Errorf("failed to delete sender key info: %w", err) - } - return info.DistributionID, nil -} - -func (cli *Client) sendToGroupWithSenderKey( - ctx context.Context, - groupID *libsignalgo.GroupIdentifier, - allRecipients []libsignalgo.ServiceID, - sec SendEndorsementCache, - content *signalpb.Content, - messageTimestamp uint64, - retries int, -) (*GroupMessageSendResult, error) { - if retries >= 3 { - return cli.sendToGroup(ctx, allRecipients, content, messageTimestamp, nil, groupID) - } - myAddress, err := cli.Store.ACIServiceID().Address(uint(cli.Store.DeviceID)) - if err != nil { - return nil, fmt.Errorf("failed to get own address: %w", err) - } - log := zerolog.Ctx(ctx) - - cli.encryptionLock.Lock() - unlocked := false - doUnlock := func() { - if !unlocked { - unlocked = true - cli.encryptionLock.Unlock() - } - } - defer doUnlock() - ctx = context.WithValue(ctx, contextKeyEncryptionLock, true) - result := &GroupMessageSendResult{ - SuccessfullySentTo: make([]SuccessfulSendResult, 0), - FailedToSendTo: make([]FailedSendResult, 0), - } - - groupIDStr := types.GroupIdentifier(groupID.String()) - deviceIDs, senderKeyRecipients, fallbackRecipients := cli.getDevicesIDs(ctx, allRecipients, sec, result) - if len(senderKeyRecipients) == 0 { - doUnlock() - log.Debug().Msg("No sender key recipients, falling back to normal send") - return cli.sendToGroup(ctx, allRecipients, content, messageTimestamp, result, groupID) - } - ski, err := cli.Store.SenderKeyStore.GetSenderKeyInfo(ctx, groupIDStr) - if err != nil { - return nil, fmt.Errorf("failed to get sender key info: %w", err) - } else if ski == nil || time.Since(ski.CreatedAt) > SenderKeyMaxAge { - if ski != nil && time.Since(ski.CreatedAt) > SenderKeyMaxAge { - log.Debug().Any("old_sender_key_info", ski).Msg("Sender key expired, creating new one") - err = cli.Store.SenderKeyStore.DeleteSenderKey(ctx, myAddress, ski.DistributionID) - if err != nil { - return nil, fmt.Errorf("failed to delete old sender key: %w", err) - } - } else { - log.Debug().Msg("No existing sender key, creating new one") - } - ski = &store.SenderKeyInfo{ - DistributionID: uuid.New(), - CreatedAt: time.Now(), - SharedWith: make(map[libsignalgo.ServiceID][]int), - } - } else { - log.Debug().Any("sender_key_info", ski).Msg("Reusing existing sender key") - } - xak, devicesAddedTo, removedDevices := diffRecipients(ski.SharedWith, deviceIDs) - if len(removedDevices) > 0 { - log.Debug(). - Any("removed_devices", removedDevices). - Msg("Resetting sender key due to recipient device changes") - devicesAddedTo = slices.Collect(maps.Keys(deviceIDs)) - err = cli.Store.SenderKeyStore.DeleteSenderKey(ctx, myAddress, ski.DistributionID) - if err != nil { - return nil, fmt.Errorf("failed to delete old sender key: %w", err) - } - } - if len(devicesAddedTo) > 0 { - log.Debug(). - Any("devices_added_to", devicesAddedTo). - Msg("Sending sender key distribution message to users with new devices") - skdm, err := libsignalgo.NewSenderKeyDistributionMessage(ctx, myAddress, ski.DistributionID, cli.Store.SenderKeyStore) - if err != nil { - return nil, fmt.Errorf("failed to create sender key distribution message: %w", err) - } - skdmBytes, err := skdm.Serialize() - if err != nil { - return nil, fmt.Errorf("failed to serialize sender key distribution message: %w", err) - } - var needsRetry bool - for _, recipient := range devicesAddedTo { - log := log.With().Str("subaction", "skdm").Stringer("recipient_id", recipient).Logger() - _, err = cli.sendContent(log.WithContext(ctx), recipient, messageTimestamp, &signalpb.Content{ - SenderKeyDistributionMessage: skdmBytes, - }, 0, true, groupID, nil) - if errors.Is(err, ErrDevicesChanged) || errors.Is(err, ErrUnregisteredUser) { - log.Warn().Err(err).Msg("Failed to send sender key distribution message due to device changes, will retry") - needsRetry = true - } else if err != nil { - log.Err(err).Msg("Failed to send sender key distribution message") - fallbackRecipients = append(fallbackRecipients, recipient) - delete(deviceIDs, recipient) - senderKeyRecipients = slices.DeleteFunc(senderKeyRecipients, func(tuple store.SessionAddressTuple) bool { - return tuple.ServiceID == recipient - }) - } else { - log.Debug().Msg("Successfully sent sender key distribution message") - ski.SharedWith[recipient] = deviceIDs[recipient].DeviceIDs - } - } - err = cli.Store.SenderKeyStore.PutSenderKeyInfo(ctx, groupIDStr, ski) - if err != nil { - return nil, fmt.Errorf("failed to store updated sender key info: %w", err) - } - if needsRetry { - doUnlock() - return cli.sendToGroupWithSenderKey(ctx, groupID, allRecipients, sec, content, messageTimestamp, retries+1) - } - } - ssCiphertext, err := cli.encryptWithSenderKey(ctx, groupID, ski.DistributionID, myAddress, senderKeyRecipients, content) - if err != nil { - return nil, err - } - for recipientID := range ski.SharedWith { - cli.addSendCache(recipientID, groupIDStr, messageTimestamp, content) - } - header := http.Header{} - header.Set("Content-Type", string(web.ContentTypeMultiRecipientMessage)) - if sec.SendEndorsement != nil { - wantedEndorsements := make([]libsignalgo.GroupSendEndorsement, 0, len(deviceIDs)) - for serviceID := range deviceIDs { - endorsement, ok := sec.MemberEndorsements[serviceID] - if !ok { - return nil, fmt.Errorf("missing group send endorsement for service ID %s", serviceID.String()) - } - wantedEndorsements = append(wantedEndorsements, endorsement) - } - combinedEndorsement, err := libsignalgo.GroupSendEndorsementCombine(wantedEndorsements...) - if err != nil { - return nil, fmt.Errorf("failed to combine group send endorsements: %w", err) - } - groupSendToken, err := sec.GetTokenWith(combinedEndorsement) - if err != nil { - return nil, fmt.Errorf("failed to create group send full token: %w", err) - } - header.Set("Group-Send-Token", groupSendToken.String()) - } else { - header.Set("Unidentified-Access-Key", xak.String()) - } - path := fmt.Sprintf( - "/v1/messages/multi_recipient?ts=%d&urgent=%t&online=false", - messageTimestamp, isUrgent(content), - ) - log.Debug(). - Any("recipients", ski.SharedWith). - Any("fallback_recipients", fallbackRecipients). - Msg("Sending multi-recipient message with sender key") - resp, err := cli.UnauthedWS.SendRequest(ctx, http.MethodPut, path, ssCiphertext, header) - switch resp.GetStatus() { - case 200: - var respData MultiRecipient200Response - err = json.Unmarshal(resp.Body, &respData) - if err != nil { - return nil, fmt.Errorf("failed to unmarshal 200 response: %w", err) - } - log.Debug(). - Any("response_data", respData). - Msg("Got successful multi-recipient send response") - for serviceID := range deviceIDs { - if slices.Contains(respData.UUIDs404, serviceID) { - err = cli.Store.ACISessionStore.RemoveAllSessionsForServiceID(ctx, serviceID) - if err != nil { - log.Err(err).Stringer("recipient_id", serviceID). - Msg("Failed to remove sessions after 404") - } - cli.Store.RecipientStore.MarkUnregistered(ctx, serviceID, true) - result.FailedToSendTo = append(result.FailedToSendTo, FailedSendResult{ - Recipient: serviceID, - Error: fmt.Errorf("multi-recipient send 404"), - }) - } else { - result.SuccessfullySentTo = append(result.SuccessfullySentTo, SuccessfulSendResult{ - Recipient: serviceID, - Unidentified: true, - }) - } - } - doUnlock() - // Send with fallback for any recipients that couldn't do sender key, plus our own sync copy - return cli.sendToGroup(ctx, fallbackRecipients, content, messageTimestamp, result, groupID) - case 401, 404: - log.Warn().Uint32("status_code", resp.GetStatus()). - Msg("Multi-recipient send failed, falling back to normal send") - doUnlock() - // Fall back to normal send for all recipients - return cli.sendToGroup(ctx, allRecipients, content, messageTimestamp, nil, groupID) - case 409, 410: - log.Warn().Uint32("status_code", resp.GetStatus()). - Msg("Multi-recipient send failed due to outdated device list, refreshing and retrying") - err = cli.handleMultiRecipient409410Response(ctx, resp) - if err != nil { - return nil, err - } - doUnlock() - // Retry recursively after fixing device lists - return cli.sendToGroupWithSenderKey(ctx, groupID, allRecipients, sec, content, messageTimestamp, retries+1) - default: - return nil, fmt.Errorf("unexpected status code %d in multi-recipient send", resp.GetStatus()) - } -} - -func (cli *Client) encryptWithSenderKey( - ctx context.Context, - groupID *libsignalgo.GroupIdentifier, - distributionID uuid.UUID, - myAddress *libsignalgo.Address, - senderKeyRecipients []store.SessionAddressTuple, - content *signalpb.Content, -) ([]byte, error) { - plaintext, err := proto.Marshal(content) - if err != nil { - return nil, fmt.Errorf("failed to marshal content: %w", err) - } - plaintext, err = addPadding(3, plaintext) - if err != nil { - return nil, fmt.Errorf("failed to add padding: %w", err) - } - ciphertext, err := libsignalgo.GroupEncrypt(ctx, plaintext, myAddress, distributionID, cli.Store.SenderKeyStore) - if err != nil { - return nil, fmt.Errorf("failed to encrypt group message: %w", err) - } - cert, err := cli.senderCertificate(ctx, false) - if err != nil { - return nil, fmt.Errorf("failed to get sender certificate: %w", err) - } - usmc, err := libsignalgo.NewUnidentifiedSenderMessageContent(ciphertext, cert, getContentHint(content), groupID) - if err != nil { - return nil, fmt.Errorf("failed to create unidentified sender message content: %w", err) - } - ssCiphertext, err := libsignalgo.SealedSenderMultiRecipientEncrypt(ctx, usmc, senderKeyRecipients, cli.Store.ACIIdentityStore) - if err != nil { - return nil, fmt.Errorf("failed to create sealed sender multi-recipient message: %w", err) - } - return ssCiphertext, nil -} - -func diffRecipients( - prevDevices map[libsignalgo.ServiceID][]int, - newDevices map[libsignalgo.ServiceID]senderKeySendMeta, -) ( - xak *libsignalgo.AccessKey, - devicesAddedTo []libsignalgo.ServiceID, - globalRemovedDevices map[libsignalgo.ServiceID][]int, -) { - collector := make(map[libsignalgo.ServiceID]uint8, max(len(prevDevices), len(newDevices))) - for key := range prevDevices { - collector[key] |= 0b01 - } - for key := range newDevices { - collector[key] |= 0b10 - } - globalRemovedDevices = make(map[libsignalgo.ServiceID][]int) - for serviceID, mask := range collector { - if mask != 0b01 { - xak = xak.Xor(newDevices[serviceID].AccessKey) - } - switch mask { - case 0b01: - // Someone left the group - globalRemovedDevices[serviceID] = prevDevices[serviceID] - case 0b10: - // Someone was added to the group - devicesAddedTo = append(devicesAddedTo, serviceID) - case 0b11: - removedDevices, addedDevices := exslices.Diff(prevDevices[serviceID], newDevices[serviceID].DeviceIDs) - if len(removedDevices) > 0 { - // Device was removed - globalRemovedDevices[serviceID] = removedDevices - } else if len(addedDevices) > 0 { - // User got new devices - devicesAddedTo = append(devicesAddedTo, serviceID) - } - } - } - return -} - -type senderKeySendMeta struct { - DeviceIDs []int - AccessKey *libsignalgo.AccessKey -} - -func (cli *Client) getDevicesIDs( - ctx context.Context, - recipients []libsignalgo.ServiceID, - sendEndorsement SendEndorsementCache, - result *GroupMessageSendResult, -) ( - map[libsignalgo.ServiceID]senderKeySendMeta, - []store.SessionAddressTuple, - []libsignalgo.ServiceID, -) { - log := zerolog.Ctx(ctx) - out := make(map[libsignalgo.ServiceID]senderKeySendMeta) - senderKeyRecipients := make([]store.SessionAddressTuple, 0, len(recipients)) - fallbackRecipients := make([]libsignalgo.ServiceID, 0) - for _, recipient := range recipients { - if recipient == cli.Store.ACIServiceID() { - // We'll send a sync copy to ourselves, not sender key and no need to include in fallback recipients either - continue - } - fallbackRecipients = append(fallbackRecipients, recipient) - if recipient.Type != libsignalgo.ServiceIDTypeACI { - continue - } - _, hasEndorsement := sendEndorsement.MemberEndorsements[recipient] - if !hasEndorsement { - continue - } - profileKey, err := cli.Store.RecipientStore.LoadProfileKey(ctx, recipient.UUID) - if err != nil { - log.Err(err).Stringer("recipient_id", recipient.UUID).Msg("Failed to get profile key") - continue - } else if profileKey == nil { - log.Debug().Stringer("recipient_id", recipient.UUID).Msg("No profile key for recipient") - continue - } - accessKey, err := profileKey.DeriveAccessKey() - if err != nil { - log.Err(err).Stringer("recipient_id", recipient.UUID).Msg("Failed to derive access key") - continue - } - sessions, err := cli.Store.ACISessionStore.AllSessionsForServiceID(ctx, recipient) - if err == nil && len(sessions) == 0 { - // No sessions, make one with prekey - err = cli.FetchAndProcessPreKey(ctx, recipient, -1) - if errors.Is(err, ErrUnregisteredUser) { - fallbackRecipients = fallbackRecipients[:len(fallbackRecipients)-1] - result.FailedToSendTo = append(result.FailedToSendTo, FailedSendResult{ - Recipient: recipient, - Error: err, - }) - log.Debug(). - Stringer("recipient_id", recipient). - Msg("Recipient is not registered, won't try to send") - continue - } else if err != nil { - log.Warn().Err(err).Stringer("recipient_id", recipient.UUID).Msg("Failed to fetch keys for recipient") - continue - } - sessions, err = cli.Store.ACISessionStore.AllSessionsForServiceID(ctx, recipient) - } - if err != nil { - log.Err(err).Stringer("recipient_id", recipient.UUID).Msg("Failed to get sessions for recipient") - continue - } else if len(sessions) == 0 { - log.Debug().Stringer("recipient_id", recipient.UUID).Msg("No sessions for recipient after fetching keys") - continue - } - fallbackRecipients = fallbackRecipients[:len(fallbackRecipients)-1] - out[recipient] = senderKeySendMeta{ - DeviceIDs: exslices.CastFunc(sessions, func(from store.SessionAddressTuple) int { - return from.DeviceID - }), - AccessKey: accessKey, - } - senderKeyRecipients = append(senderKeyRecipients, sessions...) - } - return out, senderKeyRecipients, fallbackRecipients -} diff --git a/pkg/signalmeow/sending.go b/pkg/signalmeow/sending.go index a485b54..25e3abe 100644 --- a/pkg/signalmeow/sending.go +++ b/pkg/signalmeow/sending.go @@ -22,7 +22,6 @@ import ( "encoding/json" "errors" "fmt" - "math/rand/v2" "net/http" "strconv" "strings" @@ -31,8 +30,6 @@ import ( "github.com/google/uuid" "github.com/rs/zerolog" "go.mau.fi/util/exfmt" - "go.mau.fi/util/ptr" - "go.mau.fi/util/random" "google.golang.org/protobuf/proto" "go.mau.fi/mautrix-signal/pkg/libsignalgo" @@ -43,29 +40,16 @@ import ( // Sending -func (cli *Client) senderCertificate(ctx context.Context, e164 bool) (*libsignalgo.SenderCertificate, error) { - cli.senderCertificateCache.Lock() - defer cli.senderCertificateCache.Unlock() - cached := cli.senderCertificateNoE164 - if e164 { - cached = cli.senderCertificateWithE164 - } - setCache := func(val *libsignalgo.SenderCertificate) { - if e164 { - cli.senderCertificateWithE164 = val - } else { - cli.senderCertificateNoE164 = val - } - } - if cached != nil { - expiry, err := cached.GetExpiration() +func senderCertificate(ctx context.Context, d *Device) (*libsignalgo.SenderCertificate, error) { + if d.Connection.SenderCertificate != nil { + expiry, err := d.Connection.SenderCertificate.GetExpiration() if err != nil { zerolog.Ctx(ctx).Err(err).Msg("Failed to check sender certificate expiry") } else if time.Until(expiry) < 1*exfmt.Day { zerolog.Ctx(ctx).Debug().Msg("Sender certificate expired, fetching new one") - setCache(nil) + d.Connection.SenderCertificate = nil } else { - return cached, nil + return d.Connection.SenderCertificate, nil } } @@ -74,21 +58,19 @@ func (cli *Client) senderCertificate(ctx context.Context, e164 bool) (*libsignal } var r response - var query string - if !e164 { - query = "?includeE164=false" - } - resp, err := cli.AuthedWS.SendRequest(ctx, http.MethodGet, "/v1/certificate/delivery"+query, nil, nil) + username, password := d.Data.BasicAuthCreds() + opts := &web.HTTPReqOpt{Username: &username, Password: &password} + resp, err := web.SendHTTPRequest(http.MethodGet, "/v1/certificate/delivery", opts) if err != nil { return nil, err } - err = web.DecodeWSResponseBody(ctx, &r, resp) + err = web.DecodeHTTPResponseBody(ctx, &r, resp) if err != nil { return nil, err } cert, err := libsignalgo.DeserializeSenderCertificate(r.Certificate) - setCache(cert) + d.Connection.SenderCertificate = cert return cert, err } @@ -100,7 +82,7 @@ type MyMessage struct { } type MyMessages struct { - Timestamp uint64 `json:"timestamp"` + Timestamp int64 `json:"timestamp"` Online bool `json:"online"` Urgent bool `json:"urgent"` Messages []MyMessage `json:"messages"` @@ -139,79 +121,101 @@ func addPadding(version uint32, contents []byte) ([]byte, error) { err := padBlock(&buffer, messageLength) if err != nil { - return nil, fmt.Errorf("Invalid message padding: %w", err) + return nil, errors.New(fmt.Sprintf("Invalid message padding: %v", err)) } return buffer, nil } } -func (cli *Client) buildMessagesToSend( - ctx context.Context, - recipient libsignalgo.ServiceID, - content *signalpb.Content, - unauthenticated bool, - groupID *libsignalgo.GroupIdentifier, - ctmOverride *libsignalgo.CiphertextMessage, - forceResync bool, -) ([]MyMessage, error) { - if ctx.Value(contextKeyEncryptionLock) != true { - cli.encryptionLock.Lock() - defer cli.encryptionLock.Unlock() +func checkForErrorWithSessions(err error, addresses []*libsignalgo.Address, sessionRecords []*libsignalgo.SessionRecord) error { + if err != nil { + return err + } + if addresses == nil || sessionRecords == nil { + return fmt.Errorf("Addresses or session records are nil") + } + if len(addresses) != len(sessionRecords) { + return fmt.Errorf("Mismatched number of addresses (%d) and session records (%d)", len(addresses), len(sessionRecords)) + } + if len(addresses) == 0 || len(sessionRecords) == 0 { + return fmt.Errorf("No addresses or session records") + } + return nil +} + +func howManyOtherDevicesDoWeHave(ctx context.Context, d *Device) int { + addresses, _, err := d.SessionStoreExtras.AllSessionsForUUID(d.Data.AciUuid, ctx) + if err != nil { + return 0 + } + // Filter out our deviceID + otherDevices := 0 + for _, address := range addresses { + deviceID, err := address.DeviceID() + if err != nil { + zlog.Err(err).Msg("Error getting deviceID from address") + continue + } + if deviceID != uint(d.Data.DeviceId) { + otherDevices++ + } + } + return otherDevices +} + +func buildMessagesToSend(ctx context.Context, d *Device, recipientUuid string, content *signalpb.Content, unauthenticated bool) ([]MyMessage, error) { + // We need to prevent multiple encryption operations from happening at once, or else ratchets can race + d.Connection.EncryptionMutex.Lock() + defer d.Connection.EncryptionMutex.Unlock() + + messages := []MyMessage{} + + addresses, sessionRecords, err := d.SessionStoreExtras.AllSessionsForUUID(recipientUuid, ctx) + if err == nil && (len(addresses) == 0 || len(sessionRecords) == 0) { + // No sessions, make one with prekey + FetchAndProcessPreKey(ctx, d, recipientUuid, -1) + addresses, sessionRecords, err = d.SessionStoreExtras.AllSessionsForUUID(recipientUuid, ctx) + } + err = checkForErrorWithSessions(err, addresses, sessionRecords) + if err != nil { + return nil, err } - sessions, err := cli.Store.ACISessionStore.AllSessionsForServiceID(ctx, recipient) - if err == nil && (len(sessions) == 0 || forceResync) { - // No sessions, make one with prekey - err = cli.FetchAndProcessPreKey(ctx, recipient, -1) + for i, recipientAddress := range addresses { + recipientDeviceID, err := recipientAddress.DeviceID() if err != nil { return nil, err } - sessions, err = cli.Store.ACISessionStore.AllSessionsForServiceID(ctx, recipient) - } - if err != nil { - return nil, err - } else if len(sessions) == 0 { - return nil, fmt.Errorf("no sessions found for recipient %s", recipient.String()) - } - localAddress, err := cli.Store.ACIServiceID().Address(uint(cli.Store.DeviceID)) - if err != nil { - return nil, fmt.Errorf("failed to get own address: %w", err) - } - messages := make([]MyMessage, 0, len(sessions)) - for _, tuple := range sessions { // Don't send to this device that we are sending from - if recipient == cli.Store.ACIServiceID() && tuple.DeviceID == cli.Store.DeviceID { - zerolog.Ctx(ctx).Debug(). - Int("recipient_device_id", tuple.DeviceID). - Msg("Not sending to the device I'm sending from") + if recipientUuid == d.Data.AciUuid && recipientDeviceID == uint(d.Data.DeviceId) { + zlog.Debug().Msgf("Not sending to the device I'm sending from (%v:%v)", recipientUuid, recipientDeviceID) continue } + // Build message payload serializedMessage, err := proto.Marshal(content) if err != nil { return nil, err } - paddedMessage, err := addPadding(3, serializedMessage) - if err != nil { - return nil, err + paddedMessage, err := addPadding(3, []byte(serializedMessage)) // TODO: figure out how to get actual version + sessionRecord := sessionRecords[i] + + var envelopeType int + var encryptedPayload []byte + if unauthenticated { + envelopeType, encryptedPayload, err = buildSSMessageToSend(ctx, d, recipientAddress, paddedMessage) + } else { + envelopeType, encryptedPayload, err = buildAuthedMessageToSend(ctx, d, recipientAddress, paddedMessage) } - includeE164 := groupID == nil && cli.Store.AccountRecord.GetPhoneNumberSharingMode() == signalpb.AccountRecord_EVERYBODY - envelopeType, encryptedPayload, err := cli.buildMessageToSend( - ctx, tuple.Address, localAddress, paddedMessage, getContentHint(content), ctmOverride, groupID, includeE164, unauthenticated, - ) - if err != nil { - return nil, err - } - - destinationRegistrationID, err := tuple.Record.GetRemoteRegistrationID() + destinationRegistrationID, err := sessionRecord.GetRemoteRegistrationID() if err != nil { return nil, err } outgoingMessage := MyMessage{ - Type: int(envelopeType), - DestinationDeviceID: tuple.DeviceID, + Type: envelopeType, + DestinationDeviceID: int(recipientDeviceID), DestinationRegistrationID: int(destinationRegistrationID), Content: base64.StdEncoding.EncodeToString(encryptedPayload), } @@ -221,230 +225,190 @@ func (cli *Client) buildMessagesToSend( return messages, nil } -func ctmTypeToEnvelopeType(ctmType libsignalgo.CiphertextMessageType) signalpb.Envelope_Type { - switch ctmType { - case libsignalgo.CiphertextMessageTypeWhisper: - return signalpb.Envelope_DOUBLE_RATCHET // 2 -> 1 - case libsignalgo.CiphertextMessageTypePreKey: - return signalpb.Envelope_PREKEY_MESSAGE // 3 -> 3 - case libsignalgo.CiphertextMessageTypePlaintext: - return signalpb.Envelope_PLAINTEXT_CONTENT // 8 -> 8 - default: - return signalpb.Envelope_UNKNOWN +func buildAuthedMessageToSend(ctx context.Context, d *Device, recipientAddress *libsignalgo.Address, paddedMessage []byte) (envelopeType int, encryptedPayload []byte, err error) { + cipherTextMessage, err := libsignalgo.Encrypt( + []byte(paddedMessage), + recipientAddress, + d.SessionStore, + d.IdentityStore, + libsignalgo.NewCallbackContext(ctx), + ) + encryptedPayload, err = cipherTextMessage.Serialize() + if err != nil { + return 0, nil, err } + + // OMG Signal are you serious why can't your magic numbers just align + cipherMessageType, _ := cipherTextMessage.MessageType() + if cipherMessageType == libsignalgo.CiphertextMessageTypePreKey { // 3 -> 3 + envelopeType = int(signalpb.Envelope_PREKEY_BUNDLE) + } else if cipherMessageType == libsignalgo.CiphertextMessageTypeWhisper { // 2 -> 1 + envelopeType = int(signalpb.Envelope_CIPHERTEXT) + } else { + return 0, nil, fmt.Errorf("Unknown message type: %v", cipherMessageType) + } + return envelopeType, encryptedPayload, nil } -func (cli *Client) buildMessageToSend( - ctx context.Context, - recipientAddress, localAddress *libsignalgo.Address, - paddedMessage []byte, - contentHint libsignalgo.UnidentifiedSenderMessageContentHint, - ciphertextMessage *libsignalgo.CiphertextMessage, - groupID *libsignalgo.GroupIdentifier, - includeE164, sealedSender bool, -) (envelopeType signalpb.Envelope_Type, encryptedPayload []byte, err error) { - if ciphertextMessage == nil { - ciphertextMessage, err = libsignalgo.Encrypt( - ctx, - paddedMessage, - recipientAddress, - localAddress, - cli.Store.ACISessionStore, - cli.Store.ACIIdentityStore, - ) - if err != nil { - return 0, nil, err - } - } - cipherMessageType, _ := ciphertextMessage.MessageType() - envelopeType = ctmTypeToEnvelopeType(cipherMessageType) - if !sealedSender { - encryptedPayload, err = ciphertextMessage.Serialize() - return - } - cert, err := cli.senderCertificate(ctx, includeE164) +func buildSSMessageToSend(ctx context.Context, d *Device, recipientAddress *libsignalgo.Address, paddedMessage []byte) (envelopeType int, encryptedPayload []byte, err error) { + cert, err := senderCertificate(ctx, d) if err != nil { return 0, nil, err } - usmc, err := libsignalgo.NewUnidentifiedSenderMessageContent(ciphertextMessage, cert, contentHint, groupID) - if err != nil { - return 0, nil, err - } - encryptedPayload, err = libsignalgo.SealedSenderEncrypt(ctx, usmc, recipientAddress, cli.Store.ACIIdentityStore) - envelopeType = signalpb.Envelope_UNIDENTIFIED_SENDER - return + encryptedPayload, err = libsignalgo.SealedSenderEncryptPlaintext( + []byte(paddedMessage), + recipientAddress, + cert, + d.SessionStore, + d.IdentityStore, + libsignalgo.NewCallbackContext(ctx), + ) + envelopeType = int(signalpb.Envelope_UNIDENTIFIED_SENDER) + + return envelopeType, encryptedPayload, nil } type SuccessfulSendResult struct { - Recipient libsignalgo.ServiceID - RecipientE164 *string - Unidentified bool - DestinationPNIIdentityKey *libsignalgo.IdentityKey + RecipientUuid string + Unidentified bool } type FailedSendResult struct { - Recipient libsignalgo.ServiceID - Error error + RecipientUuid string + Error error } type SendMessageResult struct { WasSuccessful bool - SuccessfulSendResult - FailedSendResult + *SuccessfulSendResult + *FailedSendResult } type GroupMessageSendResult struct { SuccessfullySentTo []SuccessfulSendResult FailedToSendTo []FailedSendResult } -type SendResult interface { - isSendResult() -} - -func (gmsr *GroupMessageSendResult) isSendResult() {} -func (smsr *SendMessageResult) isSendResult() {} - -func WrapSyncMessage(content *signalpb.SyncMessage) *signalpb.Content { - content.Padding = random.Bytes(rand.IntN(511) + 1) +func contentFromDataMessage(dataMessage *signalpb.DataMessage) *signalpb.Content { return &signalpb.Content{ - Content: &signalpb.Content_SyncMessage{SyncMessage: content}, + DataMessage: dataMessage, } } - -func syncSentMessage(sent *signalpb.SyncMessage_Sent) *signalpb.Content { - return WrapSyncMessage(&signalpb.SyncMessage{ - Content: &signalpb.SyncMessage_Sent_{ - Sent: sent, - }, - }) -} - func syncMessageFromGroupDataMessage(dataMessage *signalpb.DataMessage, results []SuccessfulSendResult) *signalpb.Content { unidentifiedStatuses := []*signalpb.SyncMessage_Sent_UnidentifiedDeliveryStatus{} for _, result := range results { unidentifiedStatuses = append(unidentifiedStatuses, &signalpb.SyncMessage_Sent_UnidentifiedDeliveryStatus{ - DestinationServiceIdBinary: result.Recipient.Bytes(), - Unidentified: &result.Unidentified, + DestinationServiceId: &result.RecipientUuid, + Unidentified: &result.Unidentified, }) } - return syncSentMessage(&signalpb.SyncMessage_Sent{ - Message: dataMessage, - Timestamp: dataMessage.Timestamp, - UnidentifiedStatus: unidentifiedStatuses, - ExpirationStartTimestamp: ptr.Ptr(uint64(time.Now().UnixMilli())), - }) + return &signalpb.Content{ + SyncMessage: &signalpb.SyncMessage{ + Sent: &signalpb.SyncMessage_Sent{ + Message: dataMessage, + Timestamp: dataMessage.Timestamp, + UnidentifiedStatus: unidentifiedStatuses, + }, + }, + } } - func syncMessageFromGroupEditMessage(editMessage *signalpb.EditMessage, results []SuccessfulSendResult) *signalpb.Content { unidentifiedStatuses := []*signalpb.SyncMessage_Sent_UnidentifiedDeliveryStatus{} for _, result := range results { unidentifiedStatuses = append(unidentifiedStatuses, &signalpb.SyncMessage_Sent_UnidentifiedDeliveryStatus{ - DestinationServiceIdBinary: result.Recipient.Bytes(), - Unidentified: &result.Unidentified, + DestinationServiceId: &result.RecipientUuid, + Unidentified: &result.Unidentified, }) } - return syncSentMessage(&signalpb.SyncMessage_Sent{ - EditMessage: editMessage, - Timestamp: editMessage.GetDataMessage().Timestamp, - UnidentifiedStatus: unidentifiedStatuses, - ExpirationStartTimestamp: ptr.Ptr(uint64(time.Now().UnixMilli())), - }) + return &signalpb.Content{ + SyncMessage: &signalpb.SyncMessage{ + Sent: &signalpb.SyncMessage_Sent{ + EditMessage: editMessage, + Timestamp: editMessage.GetDataMessage().Timestamp, + UnidentifiedStatus: unidentifiedStatuses, + }, + }, + } } func syncMessageFromSoloDataMessage(dataMessage *signalpb.DataMessage, result SuccessfulSendResult) *signalpb.Content { - return syncSentMessage(&signalpb.SyncMessage_Sent{ - Message: dataMessage, - DestinationE164: result.RecipientE164, - DestinationServiceIdBinary: result.Recipient.Bytes(), - Timestamp: dataMessage.Timestamp, - ExpirationStartTimestamp: ptr.Ptr(uint64(time.Now().UnixMilli())), - UnidentifiedStatus: []*signalpb.SyncMessage_Sent_UnidentifiedDeliveryStatus{ - { - DestinationServiceIdBinary: result.Recipient.Bytes(), - Unidentified: &result.Unidentified, - DestinationPniIdentityKey: result.DestinationPNIIdentityKey.TrySerialize(), + return &signalpb.Content{ + SyncMessage: &signalpb.SyncMessage{ + Sent: &signalpb.SyncMessage_Sent{ + Message: dataMessage, + DestinationServiceId: &result.RecipientUuid, + Timestamp: dataMessage.Timestamp, + UnidentifiedStatus: []*signalpb.SyncMessage_Sent_UnidentifiedDeliveryStatus{ + { + DestinationServiceId: &result.RecipientUuid, + Unidentified: &result.Unidentified, + }, + }, }, }, - }) + } } func syncMessageFromSoloEditMessage(editMessage *signalpb.EditMessage, result SuccessfulSendResult) *signalpb.Content { - return syncSentMessage(&signalpb.SyncMessage_Sent{ - EditMessage: editMessage, - DestinationE164: result.RecipientE164, - DestinationServiceIdBinary: result.Recipient.Bytes(), - Timestamp: editMessage.DataMessage.Timestamp, - ExpirationStartTimestamp: ptr.Ptr(uint64(time.Now().UnixMilli())), - UnidentifiedStatus: []*signalpb.SyncMessage_Sent_UnidentifiedDeliveryStatus{ - { - DestinationServiceIdBinary: result.Recipient.Bytes(), - Unidentified: &result.Unidentified, - DestinationPniIdentityKey: result.DestinationPNIIdentityKey.TrySerialize(), + return &signalpb.Content{ + SyncMessage: &signalpb.SyncMessage{ + Sent: &signalpb.SyncMessage_Sent{ + EditMessage: editMessage, + DestinationServiceId: &result.RecipientUuid, + Timestamp: editMessage.DataMessage.Timestamp, + UnidentifiedStatus: []*signalpb.SyncMessage_Sent_UnidentifiedDeliveryStatus{ + { + DestinationServiceId: &result.RecipientUuid, + Unidentified: &result.Unidentified, + }, + }, }, }, - }) + } } -func syncMessageFromReadReceiptMessage(ctx context.Context, receiptMessage *signalpb.ReceiptMessage, messageSender libsignalgo.ServiceID) *signalpb.Content { - if *receiptMessage.Type != signalpb.ReceiptMessage_READ || messageSender.Type != libsignalgo.ServiceIDTypeACI { +func syncMessageForContactRequest() *signalpb.Content { + return &signalpb.Content{ + SyncMessage: &signalpb.SyncMessage{ + Request: &signalpb.SyncMessage_Request{ + Type: signalpb.SyncMessage_Request_CONTACTS.Enum(), + }, + }, + } +} + +func syncMessageFromReadReceiptMessage(receiptMessage *signalpb.ReceiptMessage, messageSender string) *signalpb.Content { + if *receiptMessage.Type != signalpb.ReceiptMessage_READ { + zlog.Warn().Msgf("syncMessageFromReadReceiptMessage called with non-read receipt message: %v", receiptMessage.Type) return nil } read := []*signalpb.SyncMessage_Read{} for _, timestamp := range receiptMessage.Timestamp { read = append(read, &signalpb.SyncMessage_Read{ - Timestamp: proto.Uint64(timestamp), - SenderAci: proto.String(messageSender.UUID.String()), + Timestamp: ×tamp, + SenderAci: &messageSender, }) } - return WrapSyncMessage(&signalpb.SyncMessage{ - Read: read, - }) + return &signalpb.Content{ + SyncMessage: &signalpb.SyncMessage{ + Read: read, + }, + } } -func (cli *Client) SendContactSyncRequest(ctx context.Context) error { - log := zerolog.Ctx(ctx).With(). - Str("action", "send contact sync request"). - Time("last_request_time", cli.LastContactRequestTime). - Logger() - ctx = log.WithContext(ctx) +func SendContactSyncRequest(ctx context.Context, d *Device) error { + currentUnixTime := time.Now().Unix() + lastRequestTime := d.Connection.LastContactRequestTime // If we've requested in the last minute, don't request again - if time.Since(cli.LastContactRequestTime) < 60*time.Second { - log.Warn().Msg("Not sending contact sync request because we already requested it in the past minute") + if lastRequestTime != nil && currentUnixTime-*lastRequestTime < 60 { + zlog.Warn().Msgf("Not sending contact sync request, already sent %v seconds ago", currentUnixTime-*lastRequestTime) return nil } - cli.LastContactRequestTime = time.Now() - _, err := cli.sendContent(ctx, cli.Store.ACIServiceID(), uint64(time.Now().UnixMilli()), WrapSyncMessage(&signalpb.SyncMessage{ - Content: &signalpb.SyncMessage_Request_{ - Request: &signalpb.SyncMessage_Request{ - Type: signalpb.SyncMessage_Request_CONTACTS.Enum(), - }, - }, - }), 0, false, nil, nil) + groupRequest := syncMessageForContactRequest() + _, err := sendContent(ctx, d, d.Data.AciUuid, uint64(currentUnixTime), groupRequest, 0) if err != nil { - log.Err(err).Msg("Failed to send contact sync request message to myself") + zlog.Err(err).Msg("Failed to send contact sync request message to myself (%v)") return err } - return nil -} - -func (cli *Client) SendStorageMasterKeyRequest(ctx context.Context) error { - log := zerolog.Ctx(ctx).With(). - Str("action", "send key sync request"). - Logger() - ctx = log.WithContext(ctx) - - _, err := cli.sendContent(ctx, cli.Store.ACIServiceID(), uint64(time.Now().UnixMilli()), WrapSyncMessage(&signalpb.SyncMessage{ - Content: &signalpb.SyncMessage_Request_{ - Request: &signalpb.SyncMessage_Request{ - Type: signalpb.SyncMessage_Request_KEYS.Enum(), - }, - }, - }), 0, false, nil, nil) - if err != nil { - log.Err(err).Msg("Failed to send key sync request message to myself") - return err - } else { - log.Info().Msg("Sent key sync request to self") - } + d.Connection.LastContactRequestTime = ¤tUnixTime return nil } @@ -458,364 +422,185 @@ func TypingMessage(isTyping bool) *signalpb.Content { } else { action = signalpb.TypingMessage_STOPPED } + tm := &signalpb.TypingMessage{ + Timestamp: ×tamp, + Action: &action, + } return &signalpb.Content{ - Content: &signalpb.Content_TypingMessage{ - TypingMessage: &signalpb.TypingMessage{ - Timestamp: ×tamp, - Action: &action, - }, - }, + TypingMessage: tm, } } func DeliveredReceiptMessageForTimestamps(timestamps []uint64) *signalpb.Content { + rm := &signalpb.ReceiptMessage{ + Timestamp: timestamps, + Type: signalpb.ReceiptMessage_DELIVERY.Enum(), + } return &signalpb.Content{ - Content: &signalpb.Content_ReceiptMessage{ - ReceiptMessage: &signalpb.ReceiptMessage{ - Timestamp: timestamps, - Type: signalpb.ReceiptMessage_DELIVERY.Enum(), - }, - }, + ReceiptMessage: rm, } } func ReadReceptMessageForTimestamps(timestamps []uint64) *signalpb.Content { + rm := &signalpb.ReceiptMessage{ + Timestamp: timestamps, + Type: signalpb.ReceiptMessage_READ.Enum(), + } return &signalpb.Content{ - Content: &signalpb.Content_ReceiptMessage{ - ReceiptMessage: &signalpb.ReceiptMessage{ - Timestamp: timestamps, - Type: signalpb.ReceiptMessage_READ.Enum(), - }, + ReceiptMessage: rm, + } +} + +func DataMessageForReaction(reaction string, targetMessageSender uuid.UUID, targetMessageTimestamp uint64, removing bool) *signalpb.Content { + timestamp := currentMessageTimestamp() + dm := &signalpb.DataMessage{ + Timestamp: ×tamp, + RequiredProtocolVersion: proto.Uint32(uint32(signalpb.DataMessage_REACTIONS)), + Reaction: &signalpb.DataMessage_Reaction{ + Emoji: proto.String(reaction), + Remove: proto.Bool(removing), + TargetAuthorAci: proto.String(targetMessageSender.String()), + TargetSentTimestamp: proto.Uint64(targetMessageTimestamp), }, } + return wrapDataMessageInContent(dm) } -func WrapDataMessage(dm *signalpb.DataMessage) *signalpb.Content { - return &signalpb.Content{ - Content: &signalpb.Content_DataMessage{DataMessage: dm}, - } -} - -func WrapEditMessage(dm *signalpb.EditMessage) *signalpb.Content { - return &signalpb.Content{ - Content: &signalpb.Content_EditMessage{EditMessage: dm}, - } -} - -func (cli *Client) addSendCache(recipient libsignalgo.ServiceID, groupID types.GroupIdentifier, ts uint64, content *signalpb.Content) { - cli.sendCache.Push(sendCacheKey{ - recipient: recipient, - groupID: groupID, - timestamp: ts, - }, content) -} - -func (cli *Client) SendGroupUpdate(ctx context.Context, group *Group, groupContext *signalpb.GroupContextV2, groupChange *GroupChange) (*GroupMessageSendResult, error) { - log := zerolog.Ctx(ctx).With(). - Str("action", "send group change message"). - Stringer("group_id", group.GroupIdentifier). - Logger() - gidBytes, err := group.GroupIdentifier.Bytes() - if err != nil { - return nil, err - } - ctx = log.WithContext(ctx) +func DataMessageForDelete(targetMessageTimestamp uint64) *signalpb.Content { timestamp := currentMessageTimestamp() dm := &signalpb.DataMessage{ Timestamp: ×tamp, - GroupV2: groupContext, + Delete: &signalpb.DataMessage_Delete{ + TargetSentTimestamp: proto.Uint64(targetMessageTimestamp), + }, } - content := WrapDataMessage(dm) - var recipients []libsignalgo.ServiceID - for _, member := range group.Members { - serviceID := member.UserServiceID() - recipients = append(recipients, serviceID) - cli.addSendCache(serviceID, group.GroupIdentifier, timestamp, content) - } - for _, member := range group.PendingMembers { - recipients = append(recipients, member.ServiceID) - cli.addSendCache(member.ServiceID, group.GroupIdentifier, timestamp, content) - } - if groupChange != nil { - for _, member := range groupChange.AddPendingMembers { - recipients = append(recipients, member.ServiceID) - cli.addSendCache(member.ServiceID, group.GroupIdentifier, timestamp, content) - } - for _, member := range groupChange.AddMembers { - serviceID := member.UserServiceID() - recipients = append(recipients, serviceID) - cli.addSendCache(serviceID, group.GroupIdentifier, timestamp, content) - } - } - return cli.sendToGroup(ctx, recipients, content, timestamp, nil, &gidBytes) + return wrapDataMessageInContent(dm) } -const enableSenderKeySend = true +func wrapDataMessageInContent(dm *signalpb.DataMessage) *signalpb.Content { + return &signalpb.Content{ + DataMessage: dm, + } +} -func (cli *Client) SendGroupMessage(ctx context.Context, gid types.GroupIdentifier, content *signalpb.Content) (*GroupMessageSendResult, error) { - log := zerolog.Ctx(ctx).With(). - Str("action", "send group message"). - Stringer("group_id", gid). - Logger() - ctx = log.WithContext(ctx) - group, endorsement, err := cli.RetrieveGroupByID(ctx, gid, 0) +func SendGroupMessage(ctx context.Context, device *Device, gid types.GroupIdentifier, content *signalpb.Content) (*GroupMessageSendResult, error) { + group, err := RetrieveGroupByID(ctx, device, gid) if err != nil { return nil, err } + var messageTimestamp uint64 - switch content := content.Content.(type) { - case *signalpb.Content_DataMessage: + if content.GetDataMessage() != nil { messageTimestamp = content.DataMessage.GetTimestamp() content.DataMessage.GroupV2 = groupMetadataForDataMessage(*group) - case *signalpb.Content_EditMessage: + } else if content.GetEditMessage().GetDataMessage() != nil { messageTimestamp = content.EditMessage.DataMessage.GetTimestamp() content.EditMessage.DataMessage.GroupV2 = groupMetadataForDataMessage(*group) - case *signalpb.Content_TypingMessage: - messageTimestamp = content.TypingMessage.GetTimestamp() - groupIDBytes, err := group.GroupIdentifier.Bytes() - if err != nil { - return nil, err - } - content.TypingMessage.GroupId = groupIDBytes[:] } - var recipients []libsignalgo.ServiceID - for _, member := range group.Members { - recipients = append(recipients, member.UserServiceID()) - } - gidBytes, err := gid.Bytes() - if err != nil { - return nil, err - } - if enableSenderKeySend { - return cli.sendToGroupWithSenderKey(ctx, &gidBytes, recipients, ptr.Val(endorsement), content, messageTimestamp, 0) - } - return cli.sendToGroup(ctx, recipients, content, messageTimestamp, nil, &gidBytes) -} -func (cli *Client) sendToGroup( - ctx context.Context, - recipients []libsignalgo.ServiceID, - content *signalpb.Content, - messageTimestamp uint64, - result *GroupMessageSendResult, - groupID *libsignalgo.GroupIdentifier, -) (*GroupMessageSendResult, error) { - if result == nil { - result = &GroupMessageSendResult{ - SuccessfullySentTo: []SuccessfulSendResult{}, - FailedToSendTo: []FailedSendResult{}, - } + // Send to each member of the group + result := &GroupMessageSendResult{ + SuccessfullySentTo: []SuccessfulSendResult{}, + FailedToSendTo: []FailedSendResult{}, } - if content.GetTypingMessage() != nil { - // Never send typing messages via fallback path - return result, nil - } - for _, recipient := range recipients { - if recipient.Type == libsignalgo.ServiceIDTypeACI && recipient.UUID == cli.Store.ACI { + for _, member := range group.Members { + if member.UserID == device.Data.AciUuid { // Don't send normal DataMessages to ourselves continue } - log := zerolog.Ctx(ctx).With().Stringer("member", recipient).Logger() - ctx := log.WithContext(ctx) - sentUnidentified, err := cli.sendContent(ctx, recipient, messageTimestamp, content, 0, true, groupID, nil) + sentUnidentified, err := sendContent(ctx, device, member.UserID, messageTimestamp, content, 0) if err != nil { result.FailedToSendTo = append(result.FailedToSendTo, FailedSendResult{ - Recipient: recipient, - Error: err, + RecipientUuid: member.UserID, + Error: err, }) - log.Err(err).Msg("Failed to send to user") + zlog.Err(err).Msgf("Failed to send to %v", member.UserID) } else { result.SuccessfullySentTo = append(result.SuccessfullySentTo, SuccessfulSendResult{ - Recipient: recipient, - Unidentified: sentUnidentified, + RecipientUuid: member.UserID, + Unidentified: sentUnidentified, }) - log.Trace().Msg("Successfully sent to user") + zlog.Trace().Msgf("Successfully sent to %v", member.UserID) } } - cli.sendGroupSyncCopy(ctx, content, messageTimestamp, result, groupID) + // No need to send to ourselves if we don't have any other devices + if howManyOtherDevicesDoWeHave(ctx, device) > 0 { + var syncContent *signalpb.Content + if content.GetDataMessage() != nil { + syncContent = syncMessageFromGroupDataMessage(content.DataMessage, result.SuccessfullySentTo) + } else if content.GetEditMessage() != nil { + syncContent = syncMessageFromGroupEditMessage(content.EditMessage, result.SuccessfullySentTo) + } + _, selfSendErr := sendContent(ctx, device, device.Data.AciUuid, messageTimestamp, syncContent, 0) + if selfSendErr != nil { + zlog.Err(selfSendErr).Msg("Failed to send sync message to myself (%v)") + } + } if len(result.FailedToSendTo) == 0 && len(result.SuccessfullySentTo) == 0 { return result, nil // I only sent to myself } if len(result.SuccessfullySentTo) == 0 { lastError := result.FailedToSendTo[len(result.FailedToSendTo)-1].Error - return nil, fmt.Errorf("failed to send to any group members: %w", lastError) + return nil, fmt.Errorf("Failed to send to any group members: %v", lastError) } return result, nil } -func (cli *Client) sendGroupSyncCopy( - ctx context.Context, - rawContent *signalpb.Content, - messageTimestamp uint64, - result *GroupMessageSendResult, - groupID *libsignalgo.GroupIdentifier, -) { - var syncContent *signalpb.Content - switch content := rawContent.Content.(type) { - case *signalpb.Content_DataMessage: - syncContent = syncMessageFromGroupDataMessage(content.DataMessage, result.SuccessfullySentTo) - case *signalpb.Content_EditMessage: - syncContent = syncMessageFromGroupEditMessage(content.EditMessage, result.SuccessfullySentTo) - } - if syncContent != nil { - _, selfSendErr := cli.sendContent(ctx, cli.Store.ACIServiceID(), messageTimestamp, syncContent, 0, true, groupID, nil) - if selfSendErr != nil { - zerolog.Ctx(ctx).Err(selfSendErr).Msg("Failed to send sync message to myself") - } - } -} - -func (cli *Client) sendSyncCopy(ctx context.Context, rawContent *signalpb.Content, messageTS uint64, result *SuccessfulSendResult) bool { - var syncContent *signalpb.Content - switch content := rawContent.Content.(type) { - case *signalpb.Content_DataMessage: - syncContent = syncMessageFromSoloDataMessage(content.DataMessage, *result) - case *signalpb.Content_EditMessage: - syncContent = syncMessageFromSoloEditMessage(content.EditMessage, *result) - case *signalpb.Content_ReceiptMessage: - syncContent = syncMessageFromReadReceiptMessage(ctx, content.ReceiptMessage, result.Recipient) - case *signalpb.Content_SyncMessage: - syncContent = rawContent - } - if syncContent != nil { - _, selfSendErr := cli.sendContent(ctx, cli.Store.ACIServiceID(), messageTS, syncContent, 0, true, nil, nil) - if selfSendErr != nil { - zerolog.Ctx(ctx).Err(selfSendErr).Msg("Failed to send sync message to myself") - } else { - return true - } - } - return false -} - -func (cli *Client) SendMessage(ctx context.Context, recipientID libsignalgo.ServiceID, content *signalpb.Content) SendMessageResult { +func SendMessage(ctx context.Context, device *Device, recipientID string, content *signalpb.Content) SendMessageResult { // Assemble the content to send var messageTimestamp uint64 - switch realContent := content.Content.(type) { - case *signalpb.Content_DataMessage: - messageTimestamp = *realContent.DataMessage.Timestamp - case *signalpb.Content_EditMessage: - messageTimestamp = *realContent.EditMessage.DataMessage.Timestamp - case *signalpb.Content_TypingMessage: - messageTimestamp = *realContent.TypingMessage.Timestamp - case *signalpb.Content_SyncMessage, - *signalpb.Content_NullMessage, - *signalpb.Content_ReceiptMessage, - *signalpb.Content_DecryptionErrorMessage: - messageTimestamp = currentMessageTimestamp() - case *signalpb.Content_StoryMessage: - // not yet supported - default: - if content.SenderKeyDistributionMessage == nil && content.PniSignatureMessage == nil { - panic(fmt.Errorf("unsupported payload in SendMessage")) - } + if content.GetDataMessage() != nil { + messageTimestamp = *content.DataMessage.Timestamp + } else if content.GetEditMessage().GetDataMessage() != nil { + messageTimestamp = *content.EditMessage.DataMessage.Timestamp + } else { messageTimestamp = currentMessageTimestamp() } - var aci, pni uuid.UUID - if recipientID.Type == libsignalgo.ServiceIDTypeACI { - aci = recipientID.UUID - } else if recipientID.Type == libsignalgo.ServiceIDTypePNI { - pni = recipientID.UUID - } - isTypingOrReceipt := content.GetTypingMessage() != nil || content.GetReceiptMessage() != nil - recipientData, err := cli.Store.RecipientStore.LoadAndUpdateRecipient(ctx, aci, pni, func(recipientData *types.Recipient) (changed bool, err error) { - if content.GetDataMessage().GetFlags() == uint32(signalpb.DataMessage_PROFILE_KEY_UPDATE) { - recipientData.Whitelisted = ptr.Ptr(true) - } - needsPNISignature := recipientID.Type == libsignalgo.ServiceIDTypeACI && recipientData.NeedsPNISignature - if needsPNISignature && !isTypingOrReceipt && content.PniSignatureMessage == nil { - zerolog.Ctx(ctx).Debug(). - Stringer("recipient", recipientID). - Msg("Including PNI identity in message") - sig, err := cli.Store.PNIIdentityKeyPair.SignAlternateIdentity(cli.Store.ACIIdentityKeyPair.GetIdentityKey()) - if err != nil { - return false, err - } - recipientData.NeedsPNISignature = false - content.PniSignatureMessage = &signalpb.PniSignatureMessage{ - Pni: cli.Store.PNI[:], - Signature: sig, - } - return true, nil - } else if needsPNISignature && content.PniSignatureMessage != nil { - recipientData.NeedsPNISignature = false - return true, nil - } - return false, nil - }) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to get message recipient data") - } - // Treat needs PNI signature as "this is a message request" and don't send receipts/typing - if recipientData.ProbablyMessageRequest() && isTypingOrReceipt { - zerolog.Ctx(ctx).Debug().Msg("Not sending typing/receipt message to recipient as needs PNI signature flag is set") - res := SuccessfulSendResult{Recipient: recipientID} - if content.GetReceiptMessage().GetType() == signalpb.ReceiptMessage_READ { - // Still send sync messages for read receipts - cli.sendSyncCopy(ctx, content, messageTimestamp, &res) - } - return SendMessageResult{WasSuccessful: true, SuccessfulSendResult: res} - } else if content.GetTypingMessage() != nil && cli.Store.DeviceData.AccountRecord != nil && !cli.Store.DeviceData.AccountRecord.GetTypingIndicators() { - zerolog.Ctx(ctx).Debug().Msg("Not sending typing message as typing indicators are disabled") - res := SuccessfulSendResult{Recipient: recipientID} - return SendMessageResult{WasSuccessful: true, SuccessfulSendResult: res} - } else if content.GetReceiptMessage().GetType() == signalpb.ReceiptMessage_READ && cli.Store.DeviceData.AccountRecord != nil && !cli.Store.DeviceData.AccountRecord.GetReadReceipts() { - zerolog.Ctx(ctx).Debug().Msg("Not sending receipt message as read receipts are disabled") - res := SuccessfulSendResult{Recipient: recipientID} - // Still send sync messages for read receipts - cli.sendSyncCopy(ctx, content, messageTimestamp, &res) - return SendMessageResult{WasSuccessful: true, SuccessfulSendResult: res} - } - isDeliveryReceipt := content.GetReceiptMessage() != nil && content.GetReceiptMessage().GetType() == signalpb.ReceiptMessage_DELIVERY - if recipientID == cli.Store.ACIServiceID() && !isDeliveryReceipt { - res := SuccessfulSendResult{ - Recipient: recipientID, - Unidentified: false, - } - ok := cli.sendSyncCopy(ctx, content, messageTimestamp, &res) - return SendMessageResult{ - WasSuccessful: ok, - SuccessfulSendResult: res, - } - } - - cli.addSendCache(recipientID, "", messageTimestamp, content) // Send to the recipient - sentUnidentified, err := cli.sendContent(ctx, recipientID, messageTimestamp, content, 0, true, nil, nil) + sentUnidentified, err := sendContent(ctx, device, recipientID, messageTimestamp, content, 0) if err != nil { return SendMessageResult{ WasSuccessful: false, - FailedSendResult: FailedSendResult{ - Recipient: recipientID, - Error: err, + FailedSendResult: &FailedSendResult{ + RecipientUuid: recipientID, + Error: err, }, } } result := SendMessageResult{ WasSuccessful: true, - SuccessfulSendResult: SuccessfulSendResult{ - Recipient: recipientID, - Unidentified: sentUnidentified, + SuccessfulSendResult: &SuccessfulSendResult{ + RecipientUuid: recipientID, + Unidentified: sentUnidentified, }, } - if recipientID.Type == libsignalgo.ServiceIDTypePNI { - result.DestinationPNIIdentityKey, err = cli.Store.IdentityKeyStore.GetIdentityKey(ctx, recipientID) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("Failed to add PNI destination identity key to sync message") + + // TODO: don't fetch every time + // (But for now this makes sure we know about all our other devices) + // ((Actually I don't think this is necessary?)) + //FetchAndProcessPreKey(ctx, device, device.Data.AciUuid, -1) + + // If we have other devices, send Sync messages to them too + if howManyOtherDevicesDoWeHave(ctx, device) > 0 { + var syncContent *signalpb.Content + if content.GetDataMessage() != nil { + syncContent = syncMessageFromSoloDataMessage(content.DataMessage, *result.SuccessfulSendResult) + } else if content.GetEditMessage() != nil { + syncContent = syncMessageFromSoloEditMessage(content.EditMessage, *result.SuccessfulSendResult) + } else if content.GetReceiptMessage().GetType() == signalpb.ReceiptMessage_READ { + syncContent = syncMessageFromReadReceiptMessage(content.ReceiptMessage, recipientID) } - if recipientData != nil && recipientData.E164 != "" { - result.RecipientE164 = &recipientData.E164 - } else { - zerolog.Ctx(ctx).Warn().Msg("No E164 number found for PNI sync message") + if syncContent != nil { + _, selfSendErr := sendContent(ctx, device, device.Data.AciUuid, messageTimestamp, syncContent, 0) + if selfSendErr != nil { + zlog.Err(selfSendErr).Msg("Failed to send sync message to myself") + } } } - - cli.sendSyncCopy(ctx, content, messageTimestamp, &result.SuccessfulSendResult) - return result } @@ -823,150 +608,95 @@ func currentMessageTimestamp() uint64 { return uint64(time.Now().UnixMilli()) } -func isSyncMessageUrgent(content *signalpb.SyncMessage) bool { - switch content.Content.(type) { - case *signalpb.SyncMessage_Request_, - *signalpb.SyncMessage_Sent_: - return true - default: - return false - } -} - -func isUrgent(rawContent *signalpb.Content) bool { - switch content := rawContent.Content.(type) { - case *signalpb.Content_SyncMessage: - return isSyncMessageUrgent(content.SyncMessage) - case *signalpb.Content_DataMessage, - *signalpb.Content_EditMessage, - *signalpb.Content_CallMessage, - *signalpb.Content_StoryMessage: - return true - default: - return false - } -} - -func getContentHint(rawContent *signalpb.Content) libsignalgo.UnidentifiedSenderMessageContentHint { - switch rawContent.Content.(type) { - case *signalpb.Content_DataMessage, *signalpb.Content_EditMessage: - return libsignalgo.UnidentifiedSenderMessageContentHintResendable - case *signalpb.Content_TypingMessage, *signalpb.Content_ReceiptMessage: - return libsignalgo.UnidentifiedSenderMessageContentHintImplicit - default: - return libsignalgo.UnidentifiedSenderMessageContentHintDefault - } -} - -func (cli *Client) sendContent( +func sendContent( ctx context.Context, - recipient libsignalgo.ServiceID, + d *Device, + recipientUuid string, messageTimestamp uint64, content *signalpb.Content, - retryCount int, - useUnidentifiedSender bool, - groupID *libsignalgo.GroupIdentifier, - ctmOverride *libsignalgo.CiphertextMessage, + retryCount int, // For ending recursive retries ) (sentUnidentified bool, err error) { - log := zerolog.Ctx(ctx).With(). - Str("action", "send content"). - Stringer("recipient", recipient). - Uint64("timestamp", messageTimestamp). - Logger() - ctx = log.WithContext(ctx) + printContentFieldString(content, "Outgoing message") // If it's a data message, add our profile key - if content.GetDataMessage() != nil && content.GetDataMessage().ProfileKey == nil { - profileKey, err := cli.ProfileKeyForSignalID(ctx, cli.Store.ACI) + if content.DataMessage != nil { + profileKey, err := ProfileKeyForSignalID(ctx, d, d.Data.AciUuid) if err != nil { - log.Err(err).Msg("Error getting profile key, not adding to outgoing message") + zlog.Err(err).Msg("Error getting profile key, not adding to outgoing message") } else { - content.GetDataMessage().ProfileKey = profileKey.Slice() + content.DataMessage.ProfileKey = profileKey.Slice() } } - log.Trace().Any("raw_content", content).Stringer("recipient", recipient).Msg("Raw data of outgoing message") - if retryCount > 3 { - log.Error().Int("retry_count", retryCount).Msg("sendContent too many retries") - return false, fmt.Errorf("too many retries") + err := fmt.Errorf("Too many retries") + zlog.Err(err).Msgf("sendContent too many retries: %v", retryCount) + return false, err } - if recipient.Type == libsignalgo.ServiceIDTypePNI && recipient.UUID == cli.Store.PNI { - return false, fmt.Errorf("can't send to own PNI") - } else if recipient.Type == libsignalgo.ServiceIDTypeACI && recipient.UUID == cli.Store.ACI { - // Don't use unauthed websocket to send a payload to my own other devices - useUnidentifiedSender = false - } else if recipient.Type == libsignalgo.ServiceIDTypePNI { - // Can't use unidentified sender for PNIs because only ACIs have profile keys + useUnidentifiedSender := true + // Don't use unauthed websocket to send a payload to my own other devices + if recipientUuid == d.Data.AciUuid { useUnidentifiedSender = false } + profileKey, err := ProfileKeyForSignalID(ctx, d, recipientUuid) + if err != nil || profileKey == nil { + zlog.Err(err).Msg("Error getting profile key") + useUnidentifiedSender = false + // Try to self heal by requesting contact sync, though this is slow and not guaranteed to help + SendContactSyncRequest(ctx, d) + } var accessKey *libsignalgo.AccessKey - if useUnidentifiedSender { - profileKey, err := cli.ProfileKeyForSignalID(ctx, recipient.UUID) + if profileKey != nil { + accessKey, err = profileKey.DeriveAccessKey() if err != nil { - return false, fmt.Errorf("failed to get profile key: %w", err) - } else if profileKey == nil { - log.Warn().Msg("Profile key not found") - useUnidentifiedSender = false - } else if accessKey, err = profileKey.DeriveAccessKey(); err != nil { - log.Err(err).Msg("Error deriving access key") + zlog.Err(err).Msg("Error deriving access key") useUnidentifiedSender = false } } - if !useUnidentifiedSender && content.SenderKeyDistributionMessage != nil { - return false, fmt.Errorf("won't send sender key distribution message without sealed sender") - } + // TODO: JUST FOR DEBUGGING + //if content.DataMessage != nil { + // if *content.DataMessage.Body == "UNSEAL" { + // useUnidentifiedSender = false + // } + //} + // Encrypt messages var messages []MyMessage - messages, err = cli.buildMessagesToSend(ctx, recipient, content, useUnidentifiedSender, groupID, ctmOverride, false) - if errors.Is(err, libsignalgo.ErrorCodeSessionNotFound) { - log.Err(err).Msg("Got session not found error from libsignal, trying to refetch prekeys") - messages, err = cli.buildMessagesToSend(ctx, recipient, content, useUnidentifiedSender, groupID, ctmOverride, true) - } + messages, err = buildMessagesToSend(ctx, d, recipientUuid, content, useUnidentifiedSender) if err != nil { - log.Err(err).Msg("Error building messages to send") + zlog.Err(err).Msg("Error building messages to send") return false, err } outgoingMessages := MyMessages{ - Timestamp: messageTimestamp, + Timestamp: int64(messageTimestamp), Online: false, - Urgent: isUrgent(content), + Urgent: true, Messages: messages, } jsonBytes, err := json.Marshal(outgoingMessages) if err != nil { return false, err } - path := fmt.Sprintf("/v1/messages/%s", recipient) + path := fmt.Sprintf("/v1/messages/%v", recipientUuid) + request := web.CreateWSRequest(http.MethodPut, path, jsonBytes, nil, nil) var response *signalpb.WebSocketResponseMessage - header := http.Header{} - header.Set("Content-Type", string(web.ContentTypeJSON)) if useUnidentifiedSender { - log.Trace().Msg("Sending message over unidentified WS") - header.Set("Unidentified-Access-Key", accessKey.String()) - response, err = cli.UnauthedWS.SendRequest(ctx, http.MethodPut, path, jsonBytes, header) + zlog.Trace().Msgf("Sending message to %v over unidentified WS", recipientUuid) + base64AccessKey := base64.StdEncoding.EncodeToString(accessKey[:]) + request.Headers = append(request.Headers, "unidentified-access-key:"+base64AccessKey) + response, err = d.Connection.UnauthedWS.SendRequest(ctx, request) } else { - log.Trace().Msg("Sending message over authed WS") - response, err = cli.AuthedWS.SendRequest(ctx, http.MethodPut, path, jsonBytes, header) + zlog.Trace().Msgf("Sending message to %v over authed WS", recipientUuid) + response, err = d.Connection.AuthedWS.SendRequest(ctx, request) } sentUnidentified = useUnidentifiedSender if err != nil { return sentUnidentified, err } - log = log.With(). - Uint64("response_id", *response.Id). - Uint32("response_status", *response.Status). - Logger() - ctx = log.WithContext(ctx) - if json.Valid(response.GetBody()) { - log.Debug().RawJSON("response_body", response.GetBody()).Msg("DEBUG: message send response data") - } else { - log.Debug().Bytes("response_body", response.GetBody()).Msg("DEBUG: message send response data") - } - log.Trace().Msg("Received a response to a message send") + zlog.Trace().Msgf("Received a response to a message send from: %v, id: %v, code: %v", recipientUuid, *response.Id, *response.Status) retryableStatuses := []uint32{409, 410, 428, 500, 503} @@ -980,146 +710,111 @@ func (cli *Client) sendContent( } if needToRetry { - if *response.Status == 409 || *response.Status == 410 { - err = cli.handleSingleRecipient409410Response(ctx, recipient, response) - if content.SenderKeyDistributionMessage != nil { - if err == nil { - err = ErrDevicesChanged - } - return false, err - } + var err error + if *response.Status == 409 { + err = handle409(ctx, d, recipientUuid, response) + } else if *response.Status == 410 { + err = handle410(ctx, d, recipientUuid, response) } else if *response.Status == 428 { - err = cli.handle428(ctx, recipient, response) + err = handle428(ctx, d, recipientUuid, response) } if err != nil { return false, err } // Try to send again (**RECURSIVELY**) - sentUnidentified, err = cli.sendContent(ctx, recipient, messageTimestamp, content, retryCount+1, sentUnidentified, groupID, ctmOverride) + sentUnidentified, err = sendContent(ctx, d, recipientUuid, messageTimestamp, content, retryCount+1) if err != nil { - log.Err(err).Msg("2nd try sendMessage error") + zlog.Err(err).Msg("2nd try sendMessage error") return sentUnidentified, err } - } else if *response.Status == 401 && useUnidentifiedSender { - if content.SenderKeyDistributionMessage != nil { - return sentUnidentified, fmt.Errorf("unauthorized to send sender key distribution message via sealed sender") - } - log.Debug().Msg("Retrying send without sealed sender") - // Try to send again (**RECURSIVELY**) - sentUnidentified, err = cli.sendContent(ctx, recipient, messageTimestamp, content, retryCount+1, false, groupID, ctmOverride) - if err != nil { - log.Err(err).Msg("2nd try sendMessage error") - return sentUnidentified, err - } - } else if *response.Status == 404 { - err = cli.Store.ACISessionStore.RemoveAllSessionsForServiceID(ctx, recipient) - if err != nil { - log.Err(err).Msg("Failed to remove sessions after 404") - } - cli.Store.RecipientStore.MarkUnregistered(ctx, recipient, true) - return sentUnidentified, fmt.Errorf("%w (send returned 404)", ErrUnregisteredUser) } else if *response.Status != 200 { - return sentUnidentified, fmt.Errorf("unexpected status code while sending: %d", *response.Status) + err := fmt.Errorf("Unexpected status code while sending: %v", *response.Status) + zlog.Err(err).Msg("") + return sentUnidentified, err } return sentUnidentified, nil } -type SingleRecipient409410Response struct { - MissingDevices []uint `json:"missingDevices"` - ExtraDevices []uint `json:"extraDevices"` - StaleDevices []uint `json:"staleDevices"` -} - -type MultiRecipient409410Response struct { - UUID libsignalgo.ServiceID `json:"uuid"` - Devices SingleRecipient409410Response `json:"devices"` -} - -type MultiRecipient200Response struct { - UUIDs404 []libsignalgo.ServiceID `json:"uuids404"` - NeedsSync bool `json:"needsSync"` -} - -func (cli *Client) handleSingleRecipient409410Response(ctx context.Context, recipient libsignalgo.ServiceID, response *signalpb.WebSocketResponseMessage) error { - var body SingleRecipient409410Response +// A 409 means our device list was out of date, so we will fix it up +func handle409(ctx context.Context, device *Device, recipientUuid string, response *signalpb.WebSocketResponseMessage) error { + // Decode json body + var body map[string]interface{} err := json.Unmarshal(response.Body, &body) if err != nil { - return fmt.Errorf("failed to unmarshal error response body: %w", err) + zlog.Err(err).Msg("Unmarshal error") + return err } - return cli.handle409410(ctx, recipient, body) + // check for missingDevices and extraDevices + if body["missingDevices"] != nil { + missingDevices := body["missingDevices"].([]interface{}) + zlog.Debug().Msgf("missing devices found in 409 response: %v", missingDevices) + // TODO: establish session with missing devices + for _, missingDevice := range missingDevices { + FetchAndProcessPreKey(ctx, device, recipientUuid, int(missingDevice.(float64))) + } + } + if body["extraDevices"] != nil { + extraDevices := body["extraDevices"].([]interface{}) + zlog.Debug().Msgf("extra devices found in 409 response: %v", extraDevices) + for _, extraDevice := range extraDevices { + // Remove extra device from the sessionstore + recipient, err := libsignalgo.NewAddress( + recipientUuid, + uint(extraDevice.(float64)), + ) + if err != nil { + zlog.Err(err).Msg("NewAddress error") + return err + } + err = device.SessionStoreExtras.RemoveSession(recipient, ctx) + if err != nil { + zlog.Err(err).Msg("RemoveSession error") + return err + } + } + } + return err } -func (cli *Client) handleMultiRecipient409410Response(ctx context.Context, response *signalpb.WebSocketResponseMessage) error { - var body []MultiRecipient409410Response +// A 410 means we have a stale device, so get rid of it +func handle410(ctx context.Context, device *Device, recipientUuid string, response *signalpb.WebSocketResponseMessage) error { + // Decode json body + var body map[string]interface{} err := json.Unmarshal(response.Body, &body) if err != nil { - return fmt.Errorf("failed to unmarshal error response body: %w", err) + zlog.Err(err).Msg("Unmarshal error") + return err } - for _, recipientBody := range body { - err = cli.handle409410(ctx, recipientBody.UUID, recipientBody.Devices) - if err != nil { - return err + // check for staleDevices and make new sessions with them + if body["staleDevices"] != nil { + staleDevices := body["staleDevices"].([]interface{}) + zlog.Debug().Msgf("stale devices found in 410 response: %v", staleDevices) + for _, staleDevice := range staleDevices { + recipient, err := libsignalgo.NewAddress( + recipientUuid, + uint(staleDevice.(float64)), + ) + err = device.SessionStoreExtras.RemoveSession(recipient, ctx) + if err != nil { + zlog.Err(err).Msg("RemoveSession error") + return err + } + FetchAndProcessPreKey(ctx, device, recipientUuid, int(staleDevice.(float64))) } } - return nil -} - -func (cli *Client) handle409410(ctx context.Context, recipient libsignalgo.ServiceID, body SingleRecipient409410Response) error { - log := zerolog.Ctx(ctx) - if body.StaleDevices != nil { - log.Debug().Uints("stale_devices", body.StaleDevices).Msg("stale devices found in 410 response") - for _, staleDevice := range body.StaleDevices { - recipientAddr, err := recipient.Address(staleDevice) - if err != nil { - return fmt.Errorf("failed to get address for stale device %s:%d: %w", recipient, staleDevice, err) - } - err = cli.Store.ACISessionStore.RemoveSession(ctx, recipientAddr) - if err != nil { - return fmt.Errorf("failed to remove session for stale device %s:%d: %w", recipient, staleDevice, err) - } - err = cli.FetchAndProcessPreKey(ctx, recipient, int(staleDevice)) - if err != nil { - return fmt.Errorf("failed to fetch and process prekey for stale device %s:%d: %w", recipient, staleDevice, err) - } - } - } - if body.MissingDevices != nil { - log.Debug().Uints("missing_devices", body.MissingDevices).Msg("missing devices found in 409 response") - for _, missingDevice := range body.MissingDevices { - err := cli.FetchAndProcessPreKey(ctx, recipient, int(missingDevice)) - if err != nil { - return fmt.Errorf("failed to fetch and process prekey for missing device %s:%d: %w", recipient, missingDevice, err) - } - } - } - if body.ExtraDevices != nil { - log.Debug().Any("extra_devices", body.ExtraDevices).Msg("extra devices found in 409 response") - for _, extraDevice := range body.ExtraDevices { - recipientAddr, err := recipient.Address(extraDevice) - if err != nil { - return fmt.Errorf("failed to get address for extra device %s:%d: %w", recipient, extraDevice, err) - } - err = cli.Store.ACISessionStore.RemoveSession(ctx, recipientAddr) - if err != nil { - return fmt.Errorf("failed to remove session for extra device %s:%d: %w", recipient, extraDevice, err) - } - } - } - return nil + return err } // We got rate limited. // We ~~will~~ could try sending a "pushChallenge" response, but if that doesn't work we just gotta wait. // TODO: explore captcha response -func (cli *Client) handle428(ctx context.Context, recipient libsignalgo.ServiceID, response *signalpb.WebSocketResponseMessage) error { - log := zerolog.Ctx(ctx) +func handle428(ctx context.Context, device *Device, recipientUuid string, response *signalpb.WebSocketResponseMessage) error { // Decode json body - // TODO use an actual struct var body map[string]interface{} err := json.Unmarshal(response.Body, &body) if err != nil { - log.Err(err).Msg("Unmarshal error") + zlog.Err(err).Msg("Unmarshal error") return err } @@ -1134,12 +829,12 @@ func (cli *Client) handle428(ctx context.Context, recipient libsignalgo.ServiceI if key == "Retry-After" { retryAfterSeconds, err = strconv.ParseUint(value, 10, 64) if err != nil { - log.Err(err).Msg("ParseUint error") + zlog.Err(err).Msg("ParseUint error") } } } if retryAfterSeconds > 0 { - log.Warn().Uint64("retry_after_seconds", retryAfterSeconds).Msg("Got rate limited") + zlog.Warn().Msgf("Got rate limited, need to wait %v seconds", retryAfterSeconds) } // TODO: responding to a pushChallenge this way doesn't work, server just returns 422 // Luckily challenges seem rare when sending with sealed sender @@ -1170,5 +865,5 @@ func (cli *Client) handle428(ctx context.Context, recipient libsignalgo.ServiceI // } // } //} - return fmt.Errorf("got 428 error") + return nil } diff --git a/pkg/signalmeow/serviceauth.go b/pkg/signalmeow/serviceauth.go deleted file mode 100644 index 5365ded..0000000 --- a/pkg/signalmeow/serviceauth.go +++ /dev/null @@ -1,73 +0,0 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2024 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package signalmeow - -import ( - "context" - "fmt" - "net/http" - "sync" - "time" - - "go.mau.fi/mautrix-signal/pkg/signalmeow/web" -) - -type basicExpiringCredentials struct { - Username string `json:"username"` - Password string `json:"password"` - CreatedAt time.Time `json:"-"` -} - -func (bec *basicExpiringCredentials) Expired() bool { - return bec == nil || bec.CreatedAt.IsZero() || time.Since(bec.CreatedAt) > ContactDiscoveryAuthTTL -} - -func (cli *Client) getContactDiscoveryCredentials(ctx context.Context) (*basicExpiringCredentials, error) { - return cli.getCredentialsWithCache(ctx, &cli.cdAuth, &cli.cdAuthLock, "/v2/directory/auth") -} - -func (cli *Client) getStorageCredentials(ctx context.Context) (*basicExpiringCredentials, error) { - return cli.getCredentialsWithCache(ctx, &cli.storageAuth, &cli.storageAuthLock, "/v1/storage/auth") -} - -func (cli *Client) getCredentialsWithCache(ctx context.Context, cache **basicExpiringCredentials, lock *sync.Mutex, path string) (*basicExpiringCredentials, error) { - lock.Lock() - defer lock.Unlock() - if (*cache).Expired() { - newCreds, err := cli.getCredentialsFromServer(ctx, path) - if err != nil { - return nil, err - } - *cache = newCreds - } - return *cache, nil -} - -func (cli *Client) getCredentialsFromServer(ctx context.Context, path string) (*basicExpiringCredentials, error) { - resp, err := cli.AuthedWS.SendRequest(ctx, http.MethodGet, path, nil, nil) - if err != nil { - return nil, err - } - - var auth basicExpiringCredentials - auth.CreatedAt = time.Now() - err = web.DecodeWSResponseBody(ctx, &auth, resp) - if err != nil { - return nil, fmt.Errorf("failed to decode response: %w", err) - } - return &auth, nil -} diff --git a/pkg/signalmeow/session_store.go b/pkg/signalmeow/session_store.go new file mode 100644 index 0000000..09783fd --- /dev/null +++ b/pkg/signalmeow/session_store.go @@ -0,0 +1,138 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2023 Scott Weber +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package signalmeow + +import ( + "context" + "database/sql" + "errors" + + "go.mau.fi/mautrix-signal/pkg/libsignalgo" +) + +var _ libsignalgo.SessionStore = (*SQLStore)(nil) +var _ SessionStoreExtras = (*SQLStore)(nil) + +const ( + loadSessionQuery = `SELECT their_device_id, record FROM signalmeow_sessions WHERE our_aci_uuid=$1 AND their_aci_uuid=$2 AND their_device_id=$3` + storeSessionQuery = `INSERT INTO signalmeow_sessions (our_aci_uuid, their_aci_uuid, their_device_id, record) VALUES ($1, $2, $3, $4) ON CONFLICT (our_aci_uuid, their_aci_uuid, their_device_id) DO UPDATE SET record=excluded.record` + allSessionsQuery = `SELECT their_device_id, record FROM signalmeow_sessions WHERE our_aci_uuid=$1 AND their_aci_uuid=$2` + removeSessionQuery = `DELETE FROM signalmeow_sessions WHERE our_aci_uuid=$1 AND their_aci_uuid=$2 AND their_device_id=$3` +) + +type SessionStoreExtras interface { + // AllSessionsForUUID returns all sessions for the given UUID. + AllSessionsForUUID(theirUuid string, ctx context.Context) ([]*libsignalgo.Address, []*libsignalgo.SessionRecord, error) + // RemoveSession removes the session for the given address. + RemoveSession(address *libsignalgo.Address, ctx context.Context) error + // RemoveAllSessions removes all sessions for our ACI UUID + RemoveAllSessions(ctx context.Context) error +} + +func scanRecord(row scannable) (int, *libsignalgo.SessionRecord, error) { + var record []byte + var deviceId int + err := row.Scan(&deviceId, &record) + if errors.Is(err, sql.ErrNoRows) { + return 0, nil, nil + } else if err != nil { + return 0, nil, err + } + sessionRecord, err := libsignalgo.DeserializeSessionRecord(record) + return deviceId, sessionRecord, err +} + +func (s *SQLStore) RemoveSession(address *libsignalgo.Address, ctx context.Context) error { + theirUuid, err := address.Name() + if err != nil { + return err + } + deviceId, err := address.DeviceID() + if err != nil { + return err + } + _, err = s.db.Exec(removeSessionQuery, s.AciUuid, theirUuid, deviceId) + return err +} + +func (s *SQLStore) AllSessionsForUUID(theirUuid string, ctx context.Context) ([]*libsignalgo.Address, []*libsignalgo.SessionRecord, error) { + rows, err := s.db.Query(allSessionsQuery, s.AciUuid, theirUuid) + if err != nil { + return nil, nil, err + } + defer rows.Close() + var records []*libsignalgo.SessionRecord + var addresses []*libsignalgo.Address + for rows.Next() { + deviceId, record, err := scanRecord(rows) + if err != nil { + return nil, nil, err + } + records = append(records, record) + address, err := libsignalgo.NewAddress(theirUuid, uint(deviceId)) + if err != nil { + return nil, nil, err + } + addresses = append(addresses, address) + } + return addresses, records, nil +} + +func (s *SQLStore) LoadSession(address *libsignalgo.Address, ctx context.Context) (*libsignalgo.SessionRecord, error) { + theirUuid, err := address.Name() + if err != nil { + return nil, err + } + deviceId, err := address.DeviceID() + if err != nil { + return nil, err + } + _, record, err := scanRecord(s.db.QueryRow(loadSessionQuery, s.AciUuid, theirUuid, deviceId)) + return record, err +} + +func (s *SQLStore) StoreSession(address *libsignalgo.Address, record *libsignalgo.SessionRecord, ctx context.Context) error { + theirUuid, err := address.Name() + if err != nil { + return err + } + deviceId, err := address.DeviceID() + if err != nil { + return err + } + serialized, err := record.Serialize() + if err != nil { + return err + } + tx, err := s.db.BeginTx(ctx, nil) + if err != nil { + tx.Rollback() + return err + } + _, err = tx.Exec(storeSessionQuery, s.AciUuid, theirUuid, deviceId, serialized) + if err != nil { + _ = tx.Rollback() + return err + } + err = tx.Commit() + return err +} + +func (s *SQLStore) RemoveAllSessions(ctx context.Context) error { + _, err := s.db.Exec("DELETE FROM signalmeow_sessions WHERE our_aci_uuid=$1", s.AciUuid) + return err +} diff --git a/pkg/signalmeow/sticker.go b/pkg/signalmeow/sticker.go deleted file mode 100644 index 2759d18..0000000 --- a/pkg/signalmeow/sticker.go +++ /dev/null @@ -1,251 +0,0 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2026 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package signalmeow - -import ( - "bytes" - "context" - "crypto/hkdf" - "crypto/sha256" - "encoding/hex" - "errors" - "fmt" - "io" - "mime/multipart" - "net/http" - "net/textproto" - "sync" - - "go.mau.fi/util/exerrors" - "go.mau.fi/util/random" - "golang.org/x/sync/semaphore" - "google.golang.org/protobuf/proto" - - signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" - "go.mau.fi/mautrix-signal/pkg/signalmeow/web" -) - -func DownloadStickerPackManifest(ctx context.Context, packID, packKey []byte) (*signalpb.Pack, error) { - if len(packID) != 16 { - return nil, fmt.Errorf("invalid pack ID length: %d", len(packID)) - } - resp, err := downloadStickerData(ctx, fmt.Sprintf("/stickers/%x/manifest.proto", packID), packKey) - if err != nil { - return nil, err - } - var pack signalpb.Pack - err = proto.Unmarshal(resp, &pack) - if err != nil { - return nil, fmt.Errorf("failed to unmarshal decrypted manifest: %w", err) - } - return &pack, nil -} - -func DownloadStickerPackItem(ctx context.Context, packID, packKey []byte, stickerID uint32) ([]byte, error) { - if len(packID) != 16 { - return nil, fmt.Errorf("invalid pack ID length: %d", len(packID)) - } - return downloadStickerData(ctx, fmt.Sprintf("/stickers/%x/full/%d", packID, stickerID), packKey) -} - -func downloadStickerData(ctx context.Context, path string, packKey []byte) ([]byte, error) { - if len(packKey) != 32 { - return nil, fmt.Errorf("invalid pack key length: %d", len(packKey)) - } - var body, decrypted []byte - resp, err := web.SendHTTPRequest(ctx, web.CDN1Hostname, http.MethodGet, path, nil) - defer web.CloseBody(resp) - if err != nil { - return nil, fmt.Errorf("failed to make request: %w", err) - } else if resp.StatusCode != http.StatusOK { - return nil, fmt.Errorf("unexpected status code %d", resp.StatusCode) - } else if body, err = io.ReadAll(resp.Body); err != nil { - return nil, fmt.Errorf("failed to read response: %w", err) - } else if decrypted, err = decryptSticker(packKey, body); err != nil { - return nil, fmt.Errorf("failed to decrypt response: %w", err) - } else { - return decrypted, nil - } -} - -type stickerUploadAttributes struct { - ACL string `json:"acl"` - Algorithm string `json:"algorithm"` - Credential string `json:"credential"` - Date string `json:"date"` - ID int `json:"id"` - Key string `json:"key"` - Policy string `json:"policy"` - Signature string `json:"signature"` -} - -func (sua *stickerUploadAttributes) makeFormBody(encryptedData []byte) (*web.HTTPReqOpt, error) { - var buf bytes.Buffer - writer := multipart.NewWriter(&buf) - var closed bool - // This isn't necessary in practice, just do it to avoid linter warnings - defer func() { - if !closed { - _ = writer.Close() - } - }() - fields := map[string]string{ - "key": sua.Key, - "acl": sua.ACL, - "policy": sua.Policy, - "x-amz-algorithm": sua.Algorithm, - "x-amz-credential": sua.Credential, - "x-amz-date": sua.Date, - "Content-Type": "application/octet-stream", - } - for key, value := range fields { - err := writer.WriteField(key, value) - if err != nil { - return nil, fmt.Errorf("failed to write multipart field %s: %w", key, err) - } - } - filePart, err := writer.CreatePart(textproto.MIMEHeader{ - "Content-Type": []string{"application/octet-stream"}, - "Content-Disposition": []string{`form-data; name="file"`}, - }) - if err != nil { - return nil, fmt.Errorf("failed to create multipart file part: %w", err) - } - _, err = filePart.Write(encryptedData) - if err != nil { - return nil, fmt.Errorf("failed to write file data to multipart body: %w", err) - } - err = writer.Close() - if err != nil { - return nil, fmt.Errorf("failed to close multipart writer: %w", err) - } - closed = true - return &web.HTTPReqOpt{ - Body: buf.Bytes(), - ContentType: web.ContentType(writer.FormDataContentType()), - }, nil -} - -func (sua *stickerUploadAttributes) upload(ctx context.Context, packKey, fileData []byte) error { - encryptedData, err := macAndAESEncrypt(fileData, deriveStickerPackKey(packKey)) - if err != nil { - return fmt.Errorf("failed to encrypt sticker data: %w", err) - } - req, err := sua.makeFormBody(encryptedData) - if err != nil { - return fmt.Errorf("failed to prepare request: %w", err) - } - resp, err := web.SendHTTPRequest(ctx, web.CDN1Hostname, http.MethodPost, "/", req) - if err != nil { - return err - } - _ = resp.Body.Close() - if resp.StatusCode < 200 || resp.StatusCode >= 300 { - return fmt.Errorf("unexpected status code %d", resp.StatusCode) - } - return nil -} - -func (sua *stickerUploadAttributes) uploadAsync( - ctx context.Context, - packKey []byte, - getFileData func(context.Context) ([]byte, error), - sema *semaphore.Weighted, - done func(), - onError func(error), -) { - defer done() - err := sema.Acquire(ctx, 1) - if err != nil { - return - } - defer sema.Release(1) - fileData, err := getFileData(ctx) - if err == nil { - err = sua.upload(ctx, packKey, fileData) - } - if err != nil { - onError(err) - } -} - -type stickerPackUploadAttributes struct { - PackID string `json:"packId"` - Manifest *stickerUploadAttributes `json:"manifest"` - Stickers []*stickerUploadAttributes `json:"stickers"` -} - -var StickerUploadParallelism = 4 - -func (cli *Client) UploadStickerPack(ctx context.Context, pack *signalpb.Pack, stickerData []func(context.Context) ([]byte, error)) (packID, packKey []byte, err error) { - for i, sticker := range pack.Stickers { - if sticker.GetId() >= uint32(len(stickerData)) { - return nil, nil, fmt.Errorf("sticker ID %d at index %d is out of bounds, only %d sticker blobs provided", sticker.GetId(), i, len(stickerData)) - } - } - marshaledPack, err := proto.Marshal(pack) - if err != nil { - return nil, nil, fmt.Errorf("failed to marshal pack: %w", err) - } - packKey = random.Bytes(32) - resp, err := cli.AuthedWS.SendRequest(ctx, http.MethodGet, fmt.Sprintf("/v1/sticker/pack/form/%d", len(stickerData)), nil, nil) - if err != nil { - return nil, nil, fmt.Errorf("failed to get upload form: %w", err) - } - var packAttributes stickerPackUploadAttributes - err = web.DecodeWSResponseBody(ctx, &packAttributes, resp) - if err != nil { - return nil, nil, fmt.Errorf("failed to decode pack attributes: %w", err) - } - if len(packAttributes.Stickers) != len(stickerData) { - return nil, nil, fmt.Errorf("expected %d sticker upload attribute sets, got %d", len(stickerData), len(packAttributes.Stickers)) - } - packID, err = hex.DecodeString(packAttributes.PackID) - if err != nil { - return nil, nil, fmt.Errorf("invalid pack ID in response: %w", err) - } - err = packAttributes.Manifest.upload(ctx, packKey, marshaledPack) - if err != nil { - return nil, nil, fmt.Errorf("failed to upload manifest: %w", err) - } - var wg sync.WaitGroup - wg.Add(len(packAttributes.Stickers)) - sema := semaphore.NewWeighted(int64(StickerUploadParallelism)) - var errorList []error - var errorLock sync.Mutex - for i, attrs := range packAttributes.Stickers { - go attrs.uploadAsync(ctx, packKey, stickerData[i], sema, wg.Done, func(err error) { - errorLock.Lock() - errorList = append(errorList, fmt.Errorf("failed to upload sticker #%d: %w", i+1, err)) - errorLock.Unlock() - }) - } - wg.Wait() - err = ctx.Err() - if err == nil { - err = errors.Join(errorList...) - } - return -} - -func decryptSticker(packKey, ciphertext []byte) ([]byte, error) { - return macAndAESDecrypt(ciphertext, deriveStickerPackKey(packKey)) -} - -func deriveStickerPackKey(key []byte) []byte { - return exerrors.Must(hkdf.Key(sha256.New, key, make([]byte, 32), "Sticker Pack", 2*32)) -} diff --git a/pkg/signalmeow/storageservice.go b/pkg/signalmeow/storageservice.go deleted file mode 100644 index 899c54b..0000000 --- a/pkg/signalmeow/storageservice.go +++ /dev/null @@ -1,381 +0,0 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2024 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package signalmeow - -import ( - "context" - "crypto/hmac" - "crypto/sha256" - "encoding/base64" - "fmt" - "io" - "net/http" - "slices" - "strings" - - "github.com/google/uuid" - "github.com/rs/zerolog" - "go.mau.fi/util/exerrors" - "go.mau.fi/util/ptr" - "golang.org/x/crypto/hkdf" - "golang.org/x/exp/maps" - "google.golang.org/protobuf/proto" - - "go.mau.fi/mautrix-signal/pkg/libsignalgo" - "go.mau.fi/mautrix-signal/pkg/signalmeow/events" - signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" - "go.mau.fi/mautrix-signal/pkg/signalmeow/types" - "go.mau.fi/mautrix-signal/pkg/signalmeow/web" -) - -func (cli *Client) SyncStorage(ctx context.Context) { - log := cli.Log.With().Str("action", "sync storage").Logger() - ctx = log.WithContext(ctx) - // TODO only fetch changed entries - update, err := cli.FetchStorage(ctx, cli.Store.MasterKey, 0, nil) - if err != nil { - log.Err(err).Msg("Failed to fetch storage") - return - } - err = cli.Store.DoContactTxn(ctx, func(ctx context.Context) error { - return cli.processStorageInTxn(ctx, update) - }) - if err != nil { - log.Err(err).Msg("Failed to process storage update") - } -} - -func (cli *Client) processStorageInTxn(ctx context.Context, update *StorageUpdate) error { - log := zerolog.Ctx(ctx) - var changedContacts []*types.Recipient - for _, record := range update.NewRecords { - switch data := record.StorageRecord.GetRecord().(type) { - case *signalpb.StorageRecord_Contact: - log.Trace().Any("contact_record", data.Contact).Msg("Handling contact record") - aci, _ := ParseStringOrBinaryUUID(data.Contact.Aci, data.Contact.AciBinary) - pni, _ := ParseStringOrBinaryUUID(data.Contact.Pni, data.Contact.PniBinary) - if aci == uuid.Nil && pni == uuid.Nil { - log.Warn(). - Str("raw_aci", data.Contact.Aci). - Str("raw_pni", data.Contact.Pni). - Hex("raw_aci_binary", data.Contact.AciBinary). - Hex("raw_pni_binary", data.Contact.PniBinary). - Str("raw_e164", data.Contact.E164). - Msg("Storage service has contact record with no ACI or PNI") - continue - } - contact := data.Contact - topLevelChanged := false - recipient, err := cli.Store.RecipientStore.LoadAndUpdateRecipient(ctx, aci, pni, func(recipient *types.Recipient) (changed bool, err error) { - if len(contact.ProfileKey) == libsignalgo.ProfileKeyLength { - newProfileKey := libsignalgo.ProfileKey(contact.ProfileKey) - changed = changed || recipient.Profile.Key != newProfileKey - recipient.Profile.Key = newProfileKey - } - if recipient.Profile.Name == "" && (contact.GivenName != "" || contact.FamilyName != "") { - changed = true - recipient.Profile.Name = strings.TrimSpace(fmt.Sprintf("%s %s", contact.GivenName, contact.FamilyName)) - } - if contact.SystemGivenName != "" || contact.SystemFamilyName != "" { - changed = true - recipient.ContactName = strings.TrimSpace(fmt.Sprintf("%s %s", contact.SystemGivenName, contact.SystemFamilyName)) - } - newNickname := "" - if contact.Nickname != nil { - newNickname = strings.TrimSpace(fmt.Sprintf("%s %s", contact.Nickname.Given, contact.Nickname.Family)) - } - if recipient.Nickname != newNickname { - changed = true - recipient.Nickname = newNickname - } - if contact.E164 != "" { - changed = changed || recipient.E164 != contact.E164 - recipient.E164 = contact.E164 - } - if contact.Blocked != recipient.Blocked { - changed = true - recipient.Blocked = contact.Blocked - } - if !ptr.Val(recipient.Whitelisted) { - changed = true - recipient.Whitelisted = &contact.Whitelisted - } - topLevelChanged = changed - return - }) - if err != nil { - return fmt.Errorf("failed to update contact %s/%s: %w", aci, pni, err) - } - if topLevelChanged { - changedContacts = append(changedContacts, recipient) - } - case *signalpb.StorageRecord_GroupV2: - if len(data.GroupV2.MasterKey) != libsignalgo.GroupMasterKeyLength { - log.Warn().Msg("Invalid group master key length") - continue - } - masterKey := libsignalgo.GroupMasterKey(data.GroupV2.MasterKey) - groupID, err := cli.StoreMasterKey(ctx, masterKeyFromBytes(masterKey)) - if err != nil { - return fmt.Errorf("failed to store group master key for %s: %w", groupID, err) - } - log.Debug().Stringer("group_id", groupID).Msg("Stored group master key from storage service") - case *signalpb.StorageRecord_Account: - log.Trace().Any("account_record", data.Account).Msg("Found account record") - cli.Store.AccountRecord = data.Account - err := cli.Store.DeviceStore.PutDevice(ctx, &cli.Store.DeviceData) - if err != nil { - return fmt.Errorf("failed to save device after receiving account record: %w", err) - } - log.Debug().Msg("Saved device after receiving account record") - case *signalpb.StorageRecord_GroupV1, *signalpb.StorageRecord_StoryDistributionList: - // irrelevant data - default: - log.Warn().Type("type", data).Str("item_id", record.StorageID).Msg("Unknown storage record type") - } - } - if len(changedContacts) > 0 { - go cli.handleEvent(&events.ContactList{ - Contacts: changedContacts, - IsFromDB: true, - }) - } - return nil -} - -type StorageUpdate struct { - Version uint64 - NewRecords []*DecryptedStorageRecord - RemovedRecords []string - MissingRecords []string -} - -func (cli *Client) FetchStorage(ctx context.Context, masterKey []byte, currentVersion uint64, existingKeys []string) (*StorageUpdate, error) { - storageKey := deriveStorageServiceKey(masterKey) - manifest, err := cli.fetchStorageManifest(ctx, storageKey, currentVersion) - if err != nil { - return nil, err - } else if manifest == nil { - return nil, nil - } - removedKeys := make([]string, 0) - newKeys := manifestRecordToMap(manifest.GetIdentifiers()) - slices.Sort(existingKeys) - existingKeys = slices.Compact(existingKeys) - for _, key := range existingKeys { - _, isStillThere := newKeys[key] - if isStillThere { - delete(newKeys, key) - } else { - removedKeys = append(removedKeys, key) - } - delete(newKeys, key) - } - newRecords, missingKeys, err := cli.fetchStorageRecords(ctx, storageKey, manifest.GetRecordIkm(), newKeys) - if err != nil { - return nil, err - } - return &StorageUpdate{ - Version: manifest.GetVersion(), - NewRecords: newRecords, - RemovedRecords: removedKeys, - MissingRecords: missingKeys, - }, nil -} - -func manifestRecordToMap(manifest []*signalpb.ManifestRecord_Identifier) map[string]signalpb.ManifestRecord_Identifier_Type { - manifestMap := make(map[string]signalpb.ManifestRecord_Identifier_Type, len(manifest)) - for _, item := range manifest { - manifestMap[base64.StdEncoding.EncodeToString(item.GetRaw())] = item.GetType() - } - return manifestMap -} - -func deriveStorageServiceKey(masterKey []byte) []byte { - h := hmac.New(sha256.New, masterKey) - h.Write([]byte("Storage Service Encryption")) - return h.Sum(nil) -} - -func deriveStorageManifestKey(storageKey []byte, version uint64) []byte { - h := hmac.New(sha256.New, storageKey) - exerrors.Must(fmt.Fprintf(h, "Manifest_%d", version)) - return h.Sum(nil) -} - -const storageServiceItemKeyInfoPrefix = "20240801_SIGNAL_STORAGE_SERVICE_ITEM_" -const storageServiceItemKeyLen = 32 - -func deriveStorageItemKey(storageKey, recordIKM, rawItemID []byte, b64ItemID string) []byte { - if recordIKM == nil { - h := hmac.New(sha256.New, storageKey) - exerrors.Must(fmt.Fprintf(h, "Item_%s", b64ItemID)) - return h.Sum(nil) - } else { - h := hkdf.New(sha256.New, recordIKM, []byte{}, append([]byte(storageServiceItemKeyInfoPrefix), rawItemID...)) - out := make([]byte, storageServiceItemKeyLen) - exerrors.Must(io.ReadFull(h, out)) - return out - } -} - -// MaxReadStorageRecords is the maximum number of storage records to fetch at once -// from https://github.com/signalapp/Signal-Desktop/blob/v6.44.0/ts/services/storageConstants.ts -const MaxReadStorageRecords = 2500 - -type DecryptedStorageRecord struct { - ItemType signalpb.ManifestRecord_Identifier_Type - StorageID string - StorageRecord *signalpb.StorageRecord -} - -func (cli *Client) fetchStorageManifest(ctx context.Context, storageKey []byte, greaterThanVersion uint64) (*signalpb.ManifestRecord, error) { - storageCreds, err := cli.getStorageCredentials(ctx) - if err != nil { - return nil, fmt.Errorf("failed to fetch credentials: %w", err) - } - path := "/v1/storage/manifest" - if greaterThanVersion > 0 { - path += fmt.Sprintf("/version/%d", greaterThanVersion) - } - var encryptedManifest signalpb.StorageManifest - var manifestRecord signalpb.ManifestRecord - resp, err := web.SendHTTPRequest(ctx, web.StorageHostname, http.MethodGet, path, &web.HTTPReqOpt{ - Username: &storageCreds.Username, - Password: &storageCreds.Password, - ContentType: web.ContentTypeProtobuf, - }) - defer web.CloseBody(resp) - if err != nil { - return nil, fmt.Errorf("failed to fetch storage manifest: %w", err) - } else if resp.StatusCode == http.StatusNoContent { - // Already up to date - return nil, nil - } else if resp.StatusCode != http.StatusOK { - return nil, fmt.Errorf("unexpected status code %d fetching storage manifest", resp.StatusCode) - } else if body, err := io.ReadAll(resp.Body); err != nil { - return nil, fmt.Errorf("failed to read storage manifest response: %w", err) - } else if err = proto.Unmarshal(body, &encryptedManifest); err != nil { - return nil, fmt.Errorf("failed to unmarshal encrypted storage manifest: %w", err) - } else if decryptedManifestBytes, err := decryptBytes(deriveStorageManifestKey(storageKey, encryptedManifest.GetVersion()), encryptedManifest.GetValue()); err != nil { - return nil, fmt.Errorf("failed to decrypt storage manifest: %w", err) - } else if err = proto.Unmarshal(decryptedManifestBytes, &manifestRecord); err != nil { - return nil, fmt.Errorf("failed to unmarshal decrypted manifest record: %w", err) - } else { - return &manifestRecord, nil - } -} - -func (cli *Client) fetchStorageRecords( - ctx context.Context, - storageKey []byte, - recordIKM []byte, - inputRecords map[string]signalpb.ManifestRecord_Identifier_Type, -) ([]*DecryptedStorageRecord, []string, error) { - recordKeys := make([][]byte, 0, len(inputRecords)) - for key := range inputRecords { - decoded, err := base64.StdEncoding.DecodeString(key) - if err != nil { - return nil, nil, fmt.Errorf("failed to decode storage key %s: %w", key, err) - } - recordKeys = append(recordKeys, decoded) - } - items := make([]*signalpb.StorageItem, 0, len(inputRecords)) - for i := 0; i < len(recordKeys); i += MaxReadStorageRecords { - end := i + MaxReadStorageRecords - if len(recordKeys) < end { - end = len(recordKeys) - } - keyChunk := recordKeys[i:end] - itemChunk, err := cli.fetchStorageItemsChunk(ctx, keyChunk) - if err != nil { - return nil, nil, err - } - items = append(items, itemChunk...) - } - records := make([]*DecryptedStorageRecord, 0, len(items)) - log := zerolog.Ctx(ctx) - for i, encryptedItem := range items { - base64Key := base64.StdEncoding.EncodeToString(encryptedItem.GetKey()) - itemType, ok := inputRecords[base64Key] - if !ok { - log.Warn().Int("item_index", i).Str("item_key", base64Key).Msg("Received unexpected storage item") - continue - } - itemKey := deriveStorageItemKey(storageKey, recordIKM, encryptedItem.GetKey(), base64Key) - decryptedItemBytes, err := decryptBytes(itemKey, encryptedItem.GetValue()) - if err != nil { - log.Warn().Err(err). - Stringer("item_type", itemType). - Int("item_index", i). - Str("item_key", base64Key). - Msg("Failed to decrypt storage item") - continue - } - var decryptedItem signalpb.StorageRecord - err = proto.Unmarshal(decryptedItemBytes, &decryptedItem) - if err != nil { - logEvt := log.Warn().Err(err). - Stringer("item_type", itemType). - Int("item_index", i). - Str("item_key", base64Key) - if log.GetLevel() == zerolog.TraceLevel { - logEvt.Str("item_data", base64.StdEncoding.EncodeToString(decryptedItemBytes)) - } - logEvt.Msg("Failed to unmarshal storage item") - continue - } - delete(inputRecords, base64Key) - records = append(records, &DecryptedStorageRecord{ - ItemType: itemType, - StorageID: base64Key, - StorageRecord: &decryptedItem, - }) - } - missingKeys := maps.Keys(inputRecords) - return records, missingKeys, nil -} - -func (cli *Client) fetchStorageItemsChunk(ctx context.Context, recordKeys [][]byte) ([]*signalpb.StorageItem, error) { - storageCreds, err := cli.getStorageCredentials(ctx) - if err != nil { - return nil, fmt.Errorf("failed to fetch credentials: %w", err) - } - body, err := proto.Marshal(&signalpb.ReadOperation{ReadKey: recordKeys}) - if err != nil { - return nil, fmt.Errorf("failed to marshal read operation: %w", err) - } - var storageItems signalpb.StorageItems - resp, err := web.SendHTTPRequest(ctx, web.StorageHostname, http.MethodPut, "/v1/storage/read", &web.HTTPReqOpt{ - Username: &storageCreds.Username, - Password: &storageCreds.Password, - Body: body, - ContentType: web.ContentTypeProtobuf, - }) - defer web.CloseBody(resp) - if err != nil { - return nil, fmt.Errorf("failed to fetch storage records: %w", err) - } else if resp.StatusCode != http.StatusOK { - return nil, fmt.Errorf("unexpected status code %d fetching storage records", resp.StatusCode) - } else if body, err = io.ReadAll(resp.Body); err != nil { - return nil, fmt.Errorf("failed to read storage manifest response: %w", err) - } else if err = proto.Unmarshal(body, &storageItems); err != nil { - return nil, fmt.Errorf("failed to unmarshal encrypted storage manifest: %w", err) - } else { - return storageItems.GetItems(), nil - } -} diff --git a/pkg/signalmeow/store.go b/pkg/signalmeow/store.go new file mode 100644 index 0000000..3b28a76 --- /dev/null +++ b/pkg/signalmeow/store.go @@ -0,0 +1,261 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2023 Scott Weber +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package signalmeow + +import ( + "context" + "database/sql" + "errors" + "fmt" + + "go.mau.fi/util/dbutil" + + "go.mau.fi/mautrix-signal/pkg/libsignalgo" + "go.mau.fi/mautrix-signal/pkg/signalmeow/upgrades" +) + +var _ DeviceStore = (*StoreContainer)(nil) + +type DeviceStore interface { + PutDevice(dd *DeviceData) error + DeviceByAci(aciUuid string) (*Device, error) +} + +// StoreContainer is a wrapper for a SQL database that can contain multiple signalmeow sessions. +type StoreContainer struct { + db *dbutil.Database +} + +// Device is a wrapper for a signalmeow session, including device data, +// and interfaces for operating on the DB within the session. +type Device struct { + Data DeviceData + Connection DeviceConnection + + // NOTE: when adding a new store interface, make sure to assing it below + // (search for "innerStore" further down in this file) + + // libsignalgo store interfaces + PreKeyStore libsignalgo.PreKeyStore + SignedPreKeyStore libsignalgo.SignedPreKeyStore + KyberPreKeyStore libsignalgo.KyberPreKeyStore + IdentityStore libsignalgo.IdentityKeyStore + SessionStore libsignalgo.SessionStore + SenderKeyStore libsignalgo.SenderKeyStore + + // internal store interfaces + PreKeyStoreExtras PreKeyStoreExtras + SessionStoreExtras SessionStoreExtras + ProfileKeyStore ProfileKeyStore + GroupStore GroupStore + ContactStore ContactStore + DeviceStore DeviceStore +} + +func NewStore(db *dbutil.Database, log dbutil.DatabaseLogger) *StoreContainer { + return &StoreContainer{db: db.Child("signalmeow_version", upgrades.Table, log)} +} + +const getAllDevicesQuery = ` +SELECT + aci_uuid, aci_identity_key_pair, registration_id, + pni_uuid, pni_identity_key_pair, pni_registration_id, + device_id, number, password +FROM signalmeow_device +` + +const getDeviceQuery = getAllDevicesQuery + " WHERE aci_uuid=$1" + +type scannable interface { + Scan(dest ...interface{}) error +} + +func (c *StoreContainer) Upgrade() error { + return c.db.Upgrade() +} + +func (c *StoreContainer) scanDevice(row scannable) (*Device, error) { + var device Device + deviceData := &device.Data + var aciIdentityKeyPair, pniIdentityKeyPair []byte + + err := row.Scan( + &deviceData.AciUuid, &aciIdentityKeyPair, &deviceData.RegistrationId, + &deviceData.PniUuid, &pniIdentityKeyPair, &deviceData.PniRegistrationId, + &deviceData.DeviceId, &deviceData.Number, &deviceData.Password, + ) + deviceData.AciIdentityKeyPair, err = libsignalgo.DeserializeIdentityKeyPair(aciIdentityKeyPair) + deviceData.PniIdentityKeyPair, err = libsignalgo.DeserializeIdentityKeyPair(pniIdentityKeyPair) + if err != nil { + return nil, fmt.Errorf("failed to scan session: %w", err) + } + + innerStore := newSQLStore(c, deviceData.AciUuid) + // Assign innerStore to all the interfaces + device.PreKeyStore = innerStore + device.PreKeyStoreExtras = innerStore + device.SignedPreKeyStore = innerStore + device.KyberPreKeyStore = innerStore + device.IdentityStore = innerStore + device.SessionStore = innerStore + device.SessionStoreExtras = innerStore + device.ProfileKeyStore = innerStore + device.SenderKeyStore = innerStore + device.GroupStore = innerStore + device.ContactStore = innerStore + device.DeviceStore = innerStore + + return &device, nil +} + +// GetAllDevices finds all the devices in the database. +func (c *StoreContainer) GetAllDevices() ([]*Device, error) { + rows, err := c.db.Query(getAllDevicesQuery) + if err != nil { + return nil, fmt.Errorf("failed to query sessions: %w", err) + } + defer rows.Close() + sessions := make([]*Device, 0) + for rows.Next() { + sess, scanErr := c.scanDevice(rows) + if scanErr != nil { + return sessions, scanErr + } + sessions = append(sessions, sess) + } + return sessions, nil +} + +// GetDevice finds the device with the specified ACI UUID in the database. +// If the device is not found, nil is returned instead. +func (c *StoreContainer) DeviceByAci(aciUuid string) (*Device, error) { + sess, err := c.scanDevice(c.db.QueryRow(getDeviceQuery, aciUuid)) + if errors.Is(err, sql.ErrNoRows) { + return nil, nil + } + return sess, err +} + +const ( + insertDeviceQuery = ` + INSERT INTO signalmeow_device ( + aci_uuid, aci_identity_key_pair, registration_id, + pni_uuid, pni_identity_key_pair, pni_registration_id, + device_id, number, password + ) + VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) + ON CONFLICT (aci_uuid) DO UPDATE SET + aci_identity_key_pair=excluded.aci_identity_key_pair, + registration_id=excluded.registration_id, + pni_uuid=excluded.pni_uuid, + pni_identity_key_pair=excluded.pni_identity_key_pair, + pni_registration_id=excluded.pni_registration_id, + device_id=excluded.device_id, + number=excluded.number, + password=excluded.password + ` + deleteDeviceQuery = `DELETE FROM signalmeow_device WHERE aci_uuid=$1` +) + +// ErrDeviceIDMustBeSet is the error returned by PutDevice if you try to save a device before knowing its ACI UUID. +var ErrDeviceIDMustBeSet = errors.New("device aci_uuid must be known before accessing database") + +// PutDevice stores the given device in this database. +func (c *StoreContainer) PutDevice(device *DeviceData) error { + if device.AciUuid == "" { + return ErrDeviceIDMustBeSet + } + aciIdentityKeyPair, err := device.AciIdentityKeyPair.Serialize() + pniIdentityKeyPair, err := device.PniIdentityKeyPair.Serialize() + if err != nil { + zlog.Err(err).Msg("failed to serialize identity key pair") + return err + } + _, err = c.db.Exec(insertDeviceQuery, + device.AciUuid, aciIdentityKeyPair, device.RegistrationId, + device.PniUuid, pniIdentityKeyPair, device.PniRegistrationId, + device.DeviceId, device.Number, device.Password, + ) + if err != nil { + zlog.Err(err).Msg("failed to insert device") + } + return err +} + +// DeleteDevice deletes the given device from this database +func (c *StoreContainer) DeleteDevice(device *DeviceData) error { + if device.AciUuid == "" { + return ErrDeviceIDMustBeSet + } + _, err := c.db.Exec(deleteDeviceQuery, device.AciUuid) + return err +} + +func (d *Device) ClearDeviceKeys() error { + // We need to clear out keys associated with the Signal device that no longer has valid credentials + if d == nil { + zlog.Warn().Msg("ClearDeviceKeys called with nil device") + return nil + } + err := d.PreKeyStoreExtras.DeleteAllPreKeys() + err = d.SessionStoreExtras.RemoveAllSessions(context.Background()) + return err +} + +func (d *Device) IsDeviceLoggedIn() bool { + return d != nil && + d.Data.AciUuid != "" && + d.Data.DeviceId != 0 && + d.Data.Password != "" +} + +func (d *Device) ClearKeysAndDisconnect() error { + // Essentially logout, clearing sessions and keys, and disconnecting websockets + // but don't clear ACI UUID or profile keys or contacts, or anything else that + // we can reuse if we reassociate with the same Signal account. + // To fully "logout" delete the device from the database. + clearErr := d.ClearDeviceKeys() + d.Data.Password = "" + saveDeviceErr := d.DeviceStore.PutDevice(&d.Data) + stopLoopErr := StopReceiveLoops(d) + + if clearErr != nil { + return clearErr + } + if saveDeviceErr != nil { + return saveDeviceErr + } + return stopLoopErr +} + +// +// Implementing "Store" interfaces +// + +// SQLStore is basically a StoreContainer with an ACI UUID attached to it, +// reperesenting a store for a single user +type SQLStore struct { + *StoreContainer + AciUuid string +} + +func newSQLStore(container *StoreContainer, aciUuid string) *SQLStore { + return &SQLStore{ + StoreContainer: container, + AciUuid: aciUuid, + } +} diff --git a/pkg/signalmeow/store/backup_store.go b/pkg/signalmeow/store/backup_store.go deleted file mode 100644 index e99b110..0000000 --- a/pkg/signalmeow/store/backup_store.go +++ /dev/null @@ -1,341 +0,0 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2025 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package store - -import ( - "context" - "database/sql" - "encoding/base64" - "errors" - "fmt" - "strings" - "time" - - "github.com/google/uuid" - "github.com/rs/zerolog" - "go.mau.fi/util/dbutil" - "go.mau.fi/util/ptr" - "google.golang.org/protobuf/proto" - - "go.mau.fi/mautrix-signal/pkg/libsignalgo" - "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf/backuppb" - "go.mau.fi/mautrix-signal/pkg/signalmeow/types" -) - -type BackupChat struct { - *backuppb.Chat - TotalMessages int - LatestMessageID uint64 -} - -type BackupStore interface { - AddBackupRecipient(ctx context.Context, recipient *backuppb.Recipient) error - AddBackupChat(ctx context.Context, chat *backuppb.Chat) error - AddBackupChatItem(ctx context.Context, item *backuppb.ChatItem) error - RecalculateChatCounts(ctx context.Context) error - ClearBackup(ctx context.Context) error - - GetBackupRecipient(ctx context.Context, recipientID uint64) (*backuppb.Recipient, error) - GetBackupChatByUserID(ctx context.Context, userID libsignalgo.ServiceID) (*BackupChat, error) - GetBackupChatByGroupID(ctx context.Context, groupID types.GroupIdentifier) (*BackupChat, error) - GetBackupChats(ctx context.Context) ([]*BackupChat, error) - GetBackupChatItems(ctx context.Context, chatID uint64, anchor time.Time, forward bool, limit int) ([]*backuppb.ChatItem, error) - DeleteBackupChat(ctx context.Context, chatID uint64) error - DeleteBackupChatItems(ctx context.Context, chatID uint64, minTime time.Time) error -} - -var _ BackupStore = (*sqlStore)(nil) - -const ( - addBackupRecipientQuery = ` - INSERT INTO signalmeow_backup_recipient (account_id, recipient_id, aci_uuid, pni_uuid, group_master_key, data) - VALUES ($1, $2, $3, $4, $5, $6) - ` - addBackupChatQuery = ` - INSERT INTO signalmeow_backup_chat (account_id, chat_id, recipient_id, data) - VALUES ($1, $2, $3, $4) - ` - addBackupChatItemQuery = ` - INSERT INTO signalmeow_backup_message (account_id, chat_id, sender_id, message_id, data) - VALUES ($1, $2, $3, $4, $5) - ON CONFLICT DO NOTHING - ` - - getBackupRecipientQuery = ` - SELECT data FROM signalmeow_backup_recipient WHERE account_id=$1 AND recipient_id=$2 - ` - getBackupChatByACIQuery = ` - SELECT chat.data, chat.latest_message_id, chat.total_message_count FROM signalmeow_backup_recipient rcp - INNER JOIN signalmeow_backup_chat chat ON rcp.account_id=chat.account_id AND rcp.recipient_id=chat.recipient_id - WHERE rcp.account_id=$1 AND rcp.aci_uuid=$2 - ` - getBackupChatByPNIQuery = ` - SELECT chat.data, chat.latest_message_id, chat.total_message_count FROM signalmeow_backup_recipient rcp - INNER JOIN signalmeow_backup_chat chat ON rcp.account_id=chat.account_id AND rcp.recipient_id=chat.recipient_id - WHERE rcp.account_id=$1 AND rcp.pni_uuid=$2 - ` - getBackupChatByGroupIDQuery = ` - SELECT chat.data, chat.latest_message_id, chat.total_message_count FROM signalmeow_groups g - INNER JOIN signalmeow_backup_recipient rcp ON g.account_id=rcp.account_id AND g.master_key=rcp.group_master_key - INNER JOIN signalmeow_backup_chat chat ON rcp.account_id=chat.account_id AND rcp.recipient_id=chat.recipient_id - WHERE g.account_id=$1 AND g.group_identifier=$2 - ` - getAllBackupChatsQuery = ` - SELECT data, latest_message_id, total_message_count - FROM signalmeow_backup_chat - WHERE account_id=$1 - ` - getBackupChatItemsQuery = ` - SELECT data - FROM signalmeow_backup_message - WHERE account_id=$1 AND chat_id=$2 AND message_id > $3 AND message_id < $4 - ORDER BY message_id DESC - LIMIT $5 - ` - deleteBackupChatQuery = ` - DELETE FROM signalmeow_backup_chat WHERE account_id=$1 AND chat_id=$2 - ` - deleteBackupChatItemsQuery = ` - DELETE FROM signalmeow_backup_message WHERE account_id=$1 AND chat_id=$2 AND message_id >= $3 - ` - recalculateChatCountsQuery = ` - UPDATE signalmeow_backup_chat - SET latest_message_id = ( - SELECT message_id - FROM signalmeow_backup_message - WHERE account_id=signalmeow_backup_chat.account_id AND chat_id=signalmeow_backup_chat.chat_id - ORDER BY message_id DESC - LIMIT 1 - ), - total_message_count = ( - SELECT COUNT(*) - FROM signalmeow_backup_message - WHERE account_id=signalmeow_backup_chat.account_id AND chat_id=signalmeow_backup_chat.chat_id - ) - WHERE account_id=$1 - ` -) - -func tryCastUUID(b []byte) uuid.UUID { - if len(b) == 16 { - return uuid.UUID(b) - } - return uuid.Nil -} - -func (s *sqlStore) AddBackupRecipient(ctx context.Context, recipient *backuppb.Recipient) error { - recipientData, err := proto.Marshal(recipient) - if err != nil { - return fmt.Errorf("failed to marshal recipient %d: %w", recipient.Id, err) - } - var aci, pni uuid.UUID - var groupMasterKey types.SerializedGroupMasterKey - switch dest := recipient.Destination.(type) { - case *backuppb.Recipient_Contact: - aci = tryCastUUID(dest.Contact.Aci) - pni = tryCastUUID(dest.Contact.Pni) - // TODO save identity key + trust level - if aci != uuid.Nil || pni != uuid.Nil { - _, err := s.LoadAndUpdateRecipient(ctx, aci, pni, func(recipient *types.Recipient) (changed bool, err error) { - oldRecipient := ptr.Clone(recipient) - if dest.Contact.E164 != nil { - recipient.E164 = fmt.Sprintf("+%d", *dest.Contact.E164) - } - if len(dest.Contact.ProfileKey) == libsignalgo.ProfileKeyLength { - recipient.Profile.Key = libsignalgo.ProfileKey(dest.Contact.ProfileKey) - } - if dest.Contact.ProfileGivenName != nil || dest.Contact.ProfileFamilyName != nil { - recipient.Profile.Name = strings.TrimSpace(fmt.Sprintf("%s %s", dest.Contact.GetProfileGivenName(), dest.Contact.GetProfileFamilyName())) - } - if dest.Contact.ProfileSharing && !ptr.Val(recipient.Whitelisted) { - recipient.Whitelisted = ptr.Ptr(true) - changed = true - } - recipient.Blocked = dest.Contact.Blocked - changed = changed || - oldRecipient.E164 != recipient.E164 || - oldRecipient.Profile.Key != recipient.Profile.Key || - oldRecipient.Profile.Name != recipient.Profile.Name || - oldRecipient.Blocked != recipient.Blocked - return - }) - if err != nil { - return fmt.Errorf("failed to save info for recipient %d: %w", recipient.Id, err) - } - } else if dest.Contact.GetRegistered() != nil { - zerolog.Ctx(ctx).Warn(). - Uint64("recipient_id", recipient.Id). - Any("entry", dest.Contact). - Msg("Both ACI and PNI are invalid for registered contact recipient") - } - if aci != uuid.Nil { - s.MarkUnregistered(ctx, libsignalgo.NewACIServiceID(aci), dest.Contact.GetNotRegistered() != nil) - } - case *backuppb.Recipient_Group: - groupMasterKey = types.SerializedGroupMasterKey(base64.StdEncoding.EncodeToString(dest.Group.MasterKey)) - if len(dest.Group.MasterKey) == libsignalgo.GroupMasterKeyLength { - gid, err := libsignalgo.GroupMasterKey(dest.Group.MasterKey).GroupIdentifier() - if err != nil { - zerolog.Ctx(ctx).Err(err). - Uint64("recipient_id", recipient.Id). - Msg("Failed to get group identifier from master key") - } else if err = s.StoreMasterKey(ctx, types.BytesToGroupIdentifier(gid), groupMasterKey); err != nil { - return fmt.Errorf("failed to save group master key for recipient %d: %w", recipient.Id, err) - } - } else { - zerolog.Ctx(ctx).Warn(). - Uint64("recipient_id", recipient.Id). - Msg("Invalid group master key length") - } - case *backuppb.Recipient_Self: - aci = s.AccountID - default: - } - _, err = s.db.Exec(ctx, addBackupRecipientQuery, s.AccountID, recipient.Id, ptr.NonZero(aci), ptr.NonZero(pni), ptr.NonZero(groupMasterKey), recipientData) - if err != nil { - return fmt.Errorf("failed to add backup recipient %d: %w", recipient.Id, err) - } - return nil -} - -func (s *sqlStore) AddBackupChat(ctx context.Context, chat *backuppb.Chat) error { - chatData, err := proto.Marshal(chat) - if err != nil { - return fmt.Errorf("failed to marshal chat %d: %w", chat.Id, err) - } - _, err = s.db.Exec(ctx, addBackupChatQuery, s.AccountID, chat.Id, chat.RecipientId, chatData) - if err != nil { - return fmt.Errorf("failed to add backup chat %d: %w", chat.Id, err) - } - return nil -} - -func (s *sqlStore) AddBackupChatItem(ctx context.Context, item *backuppb.ChatItem) error { - itemData, err := proto.Marshal(item) - if err != nil { - return fmt.Errorf("failed to marshal chat item %d: %w", item.DateSent, err) - } - _, err = s.db.Exec(ctx, addBackupChatItemQuery, s.AccountID, item.ChatId, item.AuthorId, item.DateSent, itemData) - if err != nil { - return fmt.Errorf("failed to add backup chat item %d: %w", item.DateSent, err) - } - return nil -} - -func (s *sqlStore) ClearBackup(ctx context.Context) error { - _, err := s.db.Exec(ctx, "DELETE FROM signalmeow_backup_message WHERE account_id=$1", s.AccountID) - if err != nil { - return err - } - _, err = s.db.Exec(ctx, "DELETE FROM signalmeow_backup_chat WHERE account_id=$1", s.AccountID) - if err != nil { - return err - } - _, err = s.db.Exec(ctx, "DELETE FROM signalmeow_backup_recipient WHERE account_id=$1", s.AccountID) - return err -} - -func scanProto[T proto.Message](row dbutil.Scannable) (val T, err error) { - var data []byte - err = row.Scan(&data) - if err != nil { - if errors.Is(err, sql.ErrNoRows) { - err = nil - } - return - } - val = val.ProtoReflect().New().Interface().(T) - err = proto.Unmarshal(data, val) - return -} - -func scanChat(row dbutil.Scannable) (*BackupChat, error) { - var data []byte - var latestMessageID, totalMessageCount sql.NullInt64 - err := row.Scan(&data, &latestMessageID, &totalMessageCount) - if err != nil { - if errors.Is(err, sql.ErrNoRows) { - return nil, nil - } - return nil, err - } - var chat backuppb.Chat - err = proto.Unmarshal(data, &chat) - if err != nil { - return nil, err - } - return &BackupChat{ - Chat: &chat, - TotalMessages: int(totalMessageCount.Int64), - LatestMessageID: uint64(latestMessageID.Int64), - }, nil -} - -var chatScanner = dbutil.ConvertRowFn[*BackupChat](scanChat) -var messageScanner = dbutil.ConvertRowFn[*backuppb.ChatItem](scanProto[*backuppb.ChatItem]) - -func (s *sqlStore) GetBackupRecipient(ctx context.Context, recipientID uint64) (*backuppb.Recipient, error) { - return scanProto[*backuppb.Recipient](s.db.QueryRow(ctx, getBackupRecipientQuery, s.AccountID, recipientID)) -} - -func (s *sqlStore) GetBackupChatByUserID(ctx context.Context, userID libsignalgo.ServiceID) (*BackupChat, error) { - query := getBackupChatByACIQuery - if userID.Type == libsignalgo.ServiceIDTypePNI { - query = getBackupChatByPNIQuery - } - return scanChat(s.db.QueryRow(ctx, query, s.AccountID, userID.UUID)) -} - -func (s *sqlStore) GetBackupChatByGroupID(ctx context.Context, groupID types.GroupIdentifier) (*BackupChat, error) { - return scanChat(s.db.QueryRow(ctx, getBackupChatByGroupIDQuery, s.AccountID, groupID)) -} - -func (s *sqlStore) GetBackupChats(ctx context.Context) ([]*BackupChat, error) { - return chatScanner.NewRowIter(s.db.Query(ctx, getAllBackupChatsQuery, s.AccountID)).AsList() -} - -func (s *sqlStore) GetBackupChatItems(ctx context.Context, chatID uint64, anchor time.Time, forward bool, limit int) ([]*backuppb.ChatItem, error) { - var minTS, maxTS int64 - if anchor.IsZero() { - maxTS = time.Now().Add(24 * time.Hour).UnixMilli() - } else if forward { - minTS = anchor.UnixMilli() - maxTS = time.Now().Add(24 * time.Hour).UnixMilli() - } else { - maxTS = anchor.UnixMilli() - } - return messageScanner.NewRowIter(s.db.Query(ctx, getBackupChatItemsQuery, s.AccountID, chatID, minTS, maxTS, limit)).AsList() -} - -func (s *sqlStore) DeleteBackupChatItems(ctx context.Context, chatID uint64, minTime time.Time) error { - anchorTS := minTime.UnixMilli() - if minTime.IsZero() { - anchorTS = 0 - } - _, err := s.db.Exec(ctx, deleteBackupChatItemsQuery, s.AccountID, chatID, anchorTS) - return err -} - -func (s *sqlStore) DeleteBackupChat(ctx context.Context, chatID uint64) error { - _, err := s.db.Exec(ctx, deleteBackupChatQuery, s.AccountID, chatID) - return err -} - -func (s *sqlStore) RecalculateChatCounts(ctx context.Context) error { - _, err := s.db.Exec(ctx, recalculateChatCountsQuery, s.AccountID) - return err -} diff --git a/pkg/signalmeow/store/container.go b/pkg/signalmeow/store/container.go deleted file mode 100644 index e6335e5..0000000 --- a/pkg/signalmeow/store/container.go +++ /dev/null @@ -1,225 +0,0 @@ -package store - -import ( - "context" - "database/sql" - "errors" - "fmt" - - "github.com/google/uuid" - "github.com/rs/zerolog" - "go.mau.fi/util/dbutil" - "google.golang.org/protobuf/proto" - - "go.mau.fi/mautrix-signal/pkg/libsignalgo" - signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" - "go.mau.fi/mautrix-signal/pkg/signalmeow/store/upgrades" -) - -var _ DeviceStore = (*Container)(nil) - -type DeviceStore interface { - PutDevice(ctx context.Context, dd *DeviceData) error - DeviceByACI(ctx context.Context, aci uuid.UUID) (*Device, error) - DeviceByPNI(ctx context.Context, pni uuid.UUID) (*Device, error) -} - -// Container is a wrapper for a SQL database that can contain multiple signalmeow sessions. -type Container struct { - db *dbutil.Database -} - -func NewStore(db *dbutil.Database, log dbutil.DatabaseLogger) *Container { - return &Container{db: db.Child("signalmeow_version", upgrades.Table, log)} -} - -const getAllDevicesQuery = ` -SELECT - aci_uuid, aci_identity_key_pair, registration_id, - pni_uuid, pni_identity_key_pair, pni_registration_id, - device_id, number, password, master_key, account_record, - account_entropy_pool, ephemeral_backup_key, media_root_backup_key -FROM signalmeow_device -` - -const getDeviceQuery = getAllDevicesQuery + " WHERE aci_uuid=$1" -const deviceByPNIQuery = getAllDevicesQuery + "WHERE pni_uuid=$1" - -func (c *Container) Upgrade(ctx context.Context) error { - return c.db.Upgrade(ctx) -} - -func (c *Container) scanDevice(row dbutil.Scannable) (*Device, error) { - var device Device - var accountEntropyPool sql.NullString - var aciIdentityKeyPair, pniIdentityKeyPair, accountRecordBytes, ephemeralBackupKey, mediaRootBackupKey []byte - - err := row.Scan( - &device.ACI, &aciIdentityKeyPair, &device.ACIRegistrationID, - &device.PNI, &pniIdentityKeyPair, &device.PNIRegistrationID, - &device.DeviceID, &device.Number, &device.Password, &device.MasterKey, &accountRecordBytes, - &accountEntropyPool, &ephemeralBackupKey, &mediaRootBackupKey, - ) - if err != nil { - return nil, fmt.Errorf("failed to scan session: %w", err) - } - device.ACIIdentityKeyPair, err = libsignalgo.DeserializeIdentityKeyPair(aciIdentityKeyPair) - if err != nil { - return nil, fmt.Errorf("failed to deserialize ACI identity key pair: %w", err) - } - device.PNIIdentityKeyPair, err = libsignalgo.DeserializeIdentityKeyPair(pniIdentityKeyPair) - if err != nil { - return nil, fmt.Errorf("failed to deserialize PNI identity key pair: %w", err) - } - - if len(device.MasterKey) == 0 { - device.MasterKey = nil - } - if len(accountRecordBytes) > 0 { - device.AccountRecord = &signalpb.AccountRecord{} - err = proto.Unmarshal(accountRecordBytes, device.AccountRecord) - if err != nil { - return nil, fmt.Errorf("failed to unmarshal account record: %w", err) - } - } - device.AccountEntropyPool = libsignalgo.AccountEntropyPool(accountEntropyPool.String) - device.EphemeralBackupKey = libsignalgo.BytesToBackupKey(ephemeralBackupKey) - device.MediaRootBackupKey = libsignalgo.BytesToBackupKey(mediaRootBackupKey) - baseStore := &sqlStore{Container: c, AccountID: device.ACI, blockCache: make(map[uuid.UUID]bool)} - aciStore := &scopedSQLStore{Container: c, AccountID: device.ACI, ServiceID: device.ACIServiceID()} - pniStore := &scopedSQLStore{Container: c, AccountID: device.ACI, ServiceID: device.PNIServiceID()} - device.ACIPreKeyStore = aciStore - device.PNIPreKeyStore = pniStore - device.ACISessionStore = aciStore - device.PNISessionStore = pniStore - device.ACIIdentityStore = &sqlIdentityStore{ - sqlStore: baseStore, - OwnKeyPair: device.ACIIdentityKeyPair, - LocalRegistrationID: uint32(device.ACIRegistrationID), - } - device.PNIIdentityStore = &sqlIdentityStore{ - sqlStore: baseStore, - OwnKeyPair: device.PNIIdentityKeyPair, - LocalRegistrationID: uint32(device.PNIRegistrationID), - } - device.IdentityKeyStore = baseStore - device.SenderKeyStore = baseStore - device.GroupStore = baseStore - device.RecipientStore = baseStore - device.DeviceStore = baseStore - device.BackupStore = baseStore - device.EventBuffer = baseStore - device.sqlStore = baseStore - device.db = c.db - return &device, nil -} - -// GetAllDevices finds all the devices in the database. -func (c *Container) GetAllDevices(ctx context.Context) ([]*Device, error) { - rows, err := c.db.Query(ctx, getAllDevicesQuery) - if err != nil { - return nil, fmt.Errorf("failed to query sessions: %w", err) - } - defer rows.Close() - sessions := make([]*Device, 0) - for rows.Next() { - sess, scanErr := c.scanDevice(rows) - if scanErr != nil { - return sessions, scanErr - } - sessions = append(sessions, sess) - } - return sessions, nil -} - -// GetDevice finds the device with the specified ACI UUID in the database. -// If the device is not found, nil is returned instead. -func (c *Container) DeviceByACI(ctx context.Context, aci uuid.UUID) (*Device, error) { - sess, err := c.scanDevice(c.db.QueryRow(ctx, getDeviceQuery, aci)) - if errors.Is(err, sql.ErrNoRows) { - return nil, nil - } - return sess, err -} - -func (c *Container) DeviceByPNI(ctx context.Context, pni uuid.UUID) (*Device, error) { - sess, err := c.scanDevice(c.db.QueryRow(ctx, deviceByPNIQuery, pni)) - if errors.Is(err, sql.ErrNoRows) { - return nil, nil - } - return sess, err -} - -const ( - insertDeviceQuery = ` - INSERT INTO signalmeow_device ( - aci_uuid, aci_identity_key_pair, registration_id, - pni_uuid, pni_identity_key_pair, pni_registration_id, - device_id, number, password, master_key, account_record, - account_entropy_pool, ephemeral_backup_key, media_root_backup_key - ) - VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14) - ON CONFLICT (aci_uuid) DO UPDATE SET - aci_identity_key_pair=excluded.aci_identity_key_pair, - registration_id=excluded.registration_id, - pni_uuid=excluded.pni_uuid, - pni_identity_key_pair=excluded.pni_identity_key_pair, - pni_registration_id=excluded.pni_registration_id, - device_id=excluded.device_id, - number=excluded.number, - password=excluded.password, - master_key=excluded.master_key, - account_record=excluded.account_record, - account_entropy_pool=excluded.account_entropy_pool, - ephemeral_backup_key=excluded.ephemeral_backup_key, - media_root_backup_key=excluded.media_root_backup_key - ` - deleteDeviceQuery = `DELETE FROM signalmeow_device WHERE aci_uuid=$1` -) - -// ErrDeviceIDMustBeSet is the error returned by PutDevice if you try to save a device before knowing its ACI UUID. -var ErrDeviceIDMustBeSet = errors.New("device aci_uuid must be known before accessing database") - -// PutDevice stores the given device in this database. -func (c *Container) PutDevice(ctx context.Context, device *DeviceData) error { - if device.ACI == uuid.Nil { - return ErrDeviceIDMustBeSet - } - aciIdentityKeyPair, err := device.ACIIdentityKeyPair.Serialize() - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("failed to serialize aci identity key pair") - return err - } - pniIdentityKeyPair, err := device.PNIIdentityKeyPair.Serialize() - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("failed to serialize pni identity key pair") - return err - } - var accountRecordBytes []byte - if device.AccountRecord != nil { - accountRecordBytes, err = proto.Marshal(device.AccountRecord) - if err != nil { - return fmt.Errorf("failed to marshal account record: %w", err) - } - } - _, err = c.db.Exec(ctx, insertDeviceQuery, - device.ACI, aciIdentityKeyPair, device.ACIRegistrationID, - device.PNI, pniIdentityKeyPair, device.PNIRegistrationID, - device.DeviceID, device.Number, device.Password, device.MasterKey, - accountRecordBytes, device.AccountEntropyPool, - device.EphemeralBackupKey.Slice(), device.MediaRootBackupKey.Slice(), - ) - if err != nil { - zerolog.Ctx(ctx).Err(err).Msg("failed to insert device") - } - return err -} - -// DeleteDevice deletes the given device from this database -func (c *Container) DeleteDevice(ctx context.Context, device *DeviceData) error { - if device.ACI == uuid.Nil { - return ErrDeviceIDMustBeSet - } - _, err := c.db.Exec(ctx, deleteDeviceQuery, device.ACI) - return err -} diff --git a/pkg/signalmeow/store/device.go b/pkg/signalmeow/store/device.go deleted file mode 100644 index e72c04f..0000000 --- a/pkg/signalmeow/store/device.go +++ /dev/null @@ -1,161 +0,0 @@ -package store - -import ( - "context" - "fmt" - "sync" - - "github.com/google/uuid" - "github.com/rs/zerolog" - "go.mau.fi/util/dbutil" - - "go.mau.fi/mautrix-signal/pkg/libsignalgo" - signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" -) - -type sqlStore struct { - *Container - AccountID uuid.UUID - - contactLock sync.Mutex - - blockCacheLock sync.RWMutex - blockCache map[uuid.UUID]bool -} - -type scopedSQLStore struct { - *Container - AccountID uuid.UUID - ServiceID libsignalgo.ServiceID -} - -type DeviceData struct { - ACIIdentityKeyPair *libsignalgo.IdentityKeyPair - PNIIdentityKeyPair *libsignalgo.IdentityKeyPair - ACIRegistrationID int - PNIRegistrationID int - ACI uuid.UUID - PNI uuid.UUID - DeviceID int - Number string - Password string - MasterKey []byte - AccountRecord *signalpb.AccountRecord - AccountEntropyPool libsignalgo.AccountEntropyPool - EphemeralBackupKey *libsignalgo.BackupKey - MediaRootBackupKey *libsignalgo.BackupKey -} - -func (d *DeviceData) ACIServiceID() libsignalgo.ServiceID { - return libsignalgo.NewACIServiceID(d.ACI) -} - -func (d *DeviceData) PNIServiceID() libsignalgo.ServiceID { - return libsignalgo.NewPNIServiceID(d.PNI) -} - -func (d *DeviceData) BasicAuthCreds() (string, string) { - username := fmt.Sprintf("%s.%d", d.ACI, d.DeviceID) - password := d.Password - return username, password -} - -// Device is a wrapper for a signalmeow session, including device data, -// and interfaces for operating on the DB within the session. -type Device struct { - DeviceData - - // NOTE: when adding a new store interface, make sure to assing it below - // (search for "innerStore" further down in this file) - - // libsignalgo store interfaces - ACIPreKeyStore PreKeyStore - PNIPreKeyStore PreKeyStore - ACISessionStore SessionStore - PNISessionStore SessionStore - ACIIdentityStore libsignalgo.IdentityKeyStore - PNIIdentityStore libsignalgo.IdentityKeyStore - IdentityKeyStore IdentityKeyStore - SenderKeyStore SenderKeyStore - - GroupStore GroupStore - RecipientStore RecipientStore - DeviceStore DeviceStore - BackupStore BackupStore - EventBuffer EventBuffer - - sqlStore *sqlStore - db *dbutil.Database -} - -type contextKey int64 - -const ( - contextKeyContactLock contextKey = 1 -) - -func (d *Device) DoContactTxn(ctx context.Context, fn func(context.Context) error) error { - d.sqlStore.contactLock.Lock() - defer d.sqlStore.contactLock.Unlock() - ctx = context.WithValue(ctx, dbutil.ContextKeyDoTxnCallerSkip, 1) - ctx = context.WithValue(ctx, contextKeyContactLock, true) - return d.db.DoTxn(ctx, nil, fn) -} - -func (d *Device) DoDecryptionTxn(ctx context.Context, fn func(context.Context) error) error { - ctx = context.WithValue(ctx, dbutil.ContextKeyDoTxnCallerSkip, 2) - return d.db.DoTxn(ctx, nil, fn) -} - -func (d *Device) ClearDeviceKeys(ctx context.Context) error { - // We need to clear out keys associated with the Signal device that no longer has valid credentials - if d == nil { - zerolog.Ctx(ctx).Warn().Msg("ClearDeviceKeys called with nil device") - return nil - } - err := d.ACIPreKeyStore.DeleteAllPreKeys(ctx) - if err != nil { - return err - } - err = d.ACISessionStore.RemoveAllSessions(ctx) - return err -} - -func (d *Device) IsDeviceLoggedIn() bool { - return d != nil && - d.ACI != uuid.Nil && - d.DeviceID != 0 && - d.Password != "" -} - -func (d *Device) ClearPassword(ctx context.Context) error { - d.Password = "" - return d.DeviceStore.PutDevice(ctx, &d.DeviceData) -} - -func (d *Device) PreKeyStore(serviceID libsignalgo.ServiceID) PreKeyStore { - if serviceID == d.ACIServiceID() { - return d.ACIPreKeyStore - } else if serviceID == d.PNIServiceID() { - return d.PNIPreKeyStore - } - return nil -} - -func (d *Device) SessionStore(serviceID libsignalgo.ServiceID) SessionStore { - if serviceID == d.ACIServiceID() { - return d.ACISessionStore - } else if serviceID == d.PNIServiceID() { - return d.PNISessionStore - } - return nil -} - -func (d *Device) IdentityStore(serviceID libsignalgo.ServiceID) libsignalgo.IdentityKeyStore { - if serviceID == d.ACIServiceID() { - return d.ACIIdentityStore - } else if serviceID == d.PNIServiceID() { - return d.PNIIdentityStore - } - return nil -} diff --git a/pkg/signalmeow/store/event_buffer.go b/pkg/signalmeow/store/event_buffer.go deleted file mode 100644 index 6b8d6cf..0000000 --- a/pkg/signalmeow/store/event_buffer.go +++ /dev/null @@ -1,79 +0,0 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2025 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package store - -import ( - "context" - "database/sql" - "errors" - "time" -) - -type BufferedEvent struct { - Plaintext []byte - ServerTimestamp uint64 - InsertTimestamp int64 -} - -type EventBuffer interface { - GetBufferedEvent(ctx context.Context, ciphertextHash [32]byte) (*BufferedEvent, error) - PutBufferedEvent(ctx context.Context, ciphertextHash [32]byte, plaintext []byte, serverTimestamp uint64) error - ClearBufferedEventPlaintext(ctx context.Context, ciphertextHash [32]byte) error - DeleteBufferedEventsOlderThan(ctx context.Context, maxTS time.Time) error -} - -var _ EventBuffer = (*sqlStore)(nil) - -const ( - getBufferedEventQuery = ` - SELECT plaintext, server_timestamp, insert_timestamp - FROM signalmeow_event_buffer - WHERE account_id=$1 AND ciphertext_hash=$2 - ` - putBufferedEventQuery = ` - INSERT INTO signalmeow_event_buffer (account_id, ciphertext_hash, plaintext, server_timestamp, insert_timestamp) - VALUES ($1, $2, $3, $4, $5) - ` - clearBufferedEventPlaintextQuery = `UPDATE signalmeow_event_buffer SET plaintext=NULL WHERE account_id=$1 AND ciphertext_hash=$2` - deleteOldBufferedEventsQuery = `DELETE FROM signalmeow_event_buffer WHERE account_id=$1 AND insert_timestamp<$2 AND plaintext IS NULL` -) - -func (s *sqlStore) GetBufferedEvent(ctx context.Context, ciphertextHash [32]byte) (*BufferedEvent, error) { - var evt BufferedEvent - err := s.db.QueryRow(ctx, getBufferedEventQuery, s.AccountID, ciphertextHash[:]).Scan(&evt.Plaintext, &evt.ServerTimestamp, &evt.InsertTimestamp) - if errors.Is(err, sql.ErrNoRows) { - return nil, nil - } else if err != nil { - return nil, err - } - return &evt, nil -} - -func (s *sqlStore) PutBufferedEvent(ctx context.Context, ciphertextHash [32]byte, plaintext []byte, serverTimestamp uint64) error { - _, err := s.db.Exec(ctx, putBufferedEventQuery, s.AccountID, ciphertextHash[:], plaintext, serverTimestamp, time.Now().UnixMilli()) - return err -} - -func (s *sqlStore) ClearBufferedEventPlaintext(ctx context.Context, ciphertextHash [32]byte) error { - _, err := s.db.Exec(ctx, clearBufferedEventPlaintextQuery, s.AccountID, ciphertextHash[:]) - return err -} - -func (s *sqlStore) DeleteBufferedEventsOlderThan(ctx context.Context, maxTS time.Time) error { - _, err := s.db.Exec(ctx, deleteOldBufferedEventsQuery, s.AccountID, maxTS.UnixMilli()) - return err -} diff --git a/pkg/signalmeow/store/group_store.go b/pkg/signalmeow/store/group_store.go deleted file mode 100644 index 39b4684..0000000 --- a/pkg/signalmeow/store/group_store.go +++ /dev/null @@ -1,75 +0,0 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2023 Scott Weber -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package store - -import ( - "context" - "database/sql" - "errors" - - "go.mau.fi/util/dbutil" - - "go.mau.fi/mautrix-signal/pkg/signalmeow/types" -) - -var _ GroupStore = (*sqlStore)(nil) - -type dbGroup struct { - OurAciUuid string - GroupIdentifier types.GroupIdentifier - GroupMasterKey types.SerializedGroupMasterKey -} - -type GroupStore interface { - MasterKeyFromGroupIdentifier(ctx context.Context, groupID types.GroupIdentifier) (types.SerializedGroupMasterKey, error) - StoreMasterKey(ctx context.Context, groupID types.GroupIdentifier, key types.SerializedGroupMasterKey) error -} - -const ( - getGroupByIDQuery = `SELECT account_id, group_identifier, master_key FROM signalmeow_groups WHERE account_id=$1 AND group_identifier=$2` - upsertGroupMasterKeyQuery = ` - INSERT INTO signalmeow_groups (account_id, group_identifier, master_key) - VALUES ($1, $2, $3) - ON CONFLICT (account_id, group_identifier) DO UPDATE - SET master_key = excluded.master_key; - ` -) - -func scanGroup(row dbutil.Scannable) (*dbGroup, error) { - var g dbGroup - err := row.Scan(&g.OurAciUuid, &g.GroupIdentifier, &g.GroupMasterKey) - if errors.Is(err, sql.ErrNoRows) { - return nil, nil - } else if err != nil { - return nil, err - } - return &g, nil -} - -func (s *sqlStore) MasterKeyFromGroupIdentifier(ctx context.Context, groupID types.GroupIdentifier) (types.SerializedGroupMasterKey, error) { - g, err := scanGroup(s.db.QueryRow(ctx, getGroupByIDQuery, s.AccountID, groupID)) - if g == nil { - return "", err - } else { - return g.GroupMasterKey, nil - } -} - -func (s *sqlStore) StoreMasterKey(ctx context.Context, groupID types.GroupIdentifier, key types.SerializedGroupMasterKey) error { - _, err := s.db.Exec(ctx, upsertGroupMasterKeyQuery, s.AccountID, groupID, key) - return err -} diff --git a/pkg/signalmeow/store/identity_store.go b/pkg/signalmeow/store/identity_store.go deleted file mode 100644 index 3b2435d..0000000 --- a/pkg/signalmeow/store/identity_store.go +++ /dev/null @@ -1,121 +0,0 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2023 Scott Weber -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package store - -import ( - "context" - "database/sql" - "errors" - "fmt" - - "go.mau.fi/util/dbutil" - - "go.mau.fi/mautrix-signal/pkg/libsignalgo" -) - -type sqlIdentityStore struct { - *sqlStore - - OwnKeyPair *libsignalgo.IdentityKeyPair - LocalRegistrationID uint32 -} - -type IdentityKeyStore interface { - SaveIdentityKey(ctx context.Context, theirServiceID libsignalgo.ServiceID, identityKey *libsignalgo.IdentityKey) (bool, error) - GetIdentityKey(ctx context.Context, theirServiceID libsignalgo.ServiceID) (*libsignalgo.IdentityKey, error) - IsTrustedIdentity(ctx context.Context, theirServiceID libsignalgo.ServiceID, identityKey *libsignalgo.IdentityKey, direction libsignalgo.SignalDirection) (bool, error) -} - -var _ libsignalgo.IdentityKeyStore = (*sqlIdentityStore)(nil) -var _ IdentityKeyStore = (*sqlStore)(nil) - -const ( - insertIdentityKeyQuery = ` - INSERT INTO signalmeow_identity_keys (account_id, their_service_id, key, trust_level) - VALUES ($1, $2, $3, $4) - ON CONFLICT (account_id, their_service_id) DO UPDATE - SET key=excluded.key, trust_level=excluded.trust_level - ` - getIdentityKeyTrustLevelQuery = ` - SELECT trust_level FROM signalmeow_identity_keys - WHERE account_id=$1 AND their_service_id=$2 - ` - getIdentityKeyQuery = ` - SELECT key FROM signalmeow_identity_keys - WHERE account_id=$1 AND their_service_id=$2 - ` -) - -func (s *sqlIdentityStore) GetIdentityKeyPair(ctx context.Context) (*libsignalgo.IdentityKeyPair, error) { - return s.OwnKeyPair, nil -} - -func (s *sqlIdentityStore) GetLocalRegistrationID(ctx context.Context) (uint32, error) { - return s.LocalRegistrationID, nil -} - -func scanIdentityKey(row dbutil.Scannable) (*libsignalgo.IdentityKey, error) { - return scanRecord(row, libsignalgo.DeserializeIdentityKey) -} - -func (s *sqlStore) SaveIdentityKey(ctx context.Context, theirServiceID libsignalgo.ServiceID, identityKey *libsignalgo.IdentityKey) (bool, error) { - trustLevel := "TRUSTED_UNVERIFIED" // TODO: this should be hard coded here - serialized, err := identityKey.Serialize() - if err != nil { - return false, fmt.Errorf("failed to serialize identity key: %w", err) - } - oldKey, err := scanIdentityKey(s.db.QueryRow(ctx, getIdentityKeyQuery, s.AccountID, theirServiceID)) - if err != nil { - return false, fmt.Errorf("failed to get old identity key: %w", err) - } - var replacing bool - if oldKey != nil { - equal, err := oldKey.Equal(identityKey) - if err != nil { - return false, fmt.Errorf("failed to compare new and old identity keys: %w", err) - } - // We are replacing the old key if the old key exists, and it is not equal to the new key - replacing = !equal - } - _, err = s.db.Exec(ctx, insertIdentityKeyQuery, s.AccountID, theirServiceID, serialized, trustLevel) - if err != nil { - return replacing, fmt.Errorf("failed to insert new identity key: %w", err) - } - return replacing, err -} - -func (s *sqlStore) IsTrustedIdentity(ctx context.Context, theirServiceID libsignalgo.ServiceID, identityKey *libsignalgo.IdentityKey, direction libsignalgo.SignalDirection) (bool, error) { - // TODO: this should check direction, and probably some other stuff (though whisperfish is pretty basic) - var trustLevel string - err := s.db.QueryRow(ctx, getIdentityKeyTrustLevelQuery, s.AccountID, theirServiceID).Scan(&trustLevel) - if errors.Is(err, sql.ErrNoRows) { - // If no rows, they are a new identity, so trust by default - return true, nil - } else if err != nil { - return false, fmt.Errorf("failed to get trust level from database: %w", err) - } - trusted := trustLevel == "TRUSTED_UNVERIFIED" || trustLevel == "TRUSTED_VERIFIED" - return trusted, nil -} - -func (s *sqlStore) GetIdentityKey(ctx context.Context, theirServiceID libsignalgo.ServiceID) (*libsignalgo.IdentityKey, error) { - key, err := scanIdentityKey(s.db.QueryRow(ctx, getIdentityKeyQuery, s.AccountID, theirServiceID)) - if err != nil { - return nil, fmt.Errorf("failed to get identity key from database: %w", err) - } - return key, err -} diff --git a/pkg/signalmeow/store/prekey_store.go b/pkg/signalmeow/store/prekey_store.go deleted file mode 100644 index 37bca7e..0000000 --- a/pkg/signalmeow/store/prekey_store.go +++ /dev/null @@ -1,233 +0,0 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2023 Scott Weber -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package store - -import ( - "context" - "database/sql" - "errors" - "fmt" - - "go.mau.fi/util/dbutil" - - "go.mau.fi/mautrix-signal/pkg/libsignalgo" -) - -var _ PreKeyStore = (*scopedSQLStore)(nil) - -type ServiceScopedStore interface { - GetServiceID() libsignalgo.ServiceID -} - -type PreKeyStore interface { - libsignalgo.PreKeyStore - libsignalgo.SignedPreKeyStore - libsignalgo.KyberPreKeyStore - ServiceScopedStore - - StoreLastResortKyberPreKey(ctx context.Context, preKeyID uint32, record *libsignalgo.KyberPreKeyRecord) error - RemoveSignedPreKey(ctx context.Context, preKeyID uint32) error - RemoveKyberPreKey(ctx context.Context, preKeyID uint32) error - GetNextPreKeyID(ctx context.Context) (count, max uint32, err error) - GetNextKyberPreKeyID(ctx context.Context) (count, max uint32, err error) - IsKyberPreKeyLastResort(ctx context.Context, preKeyID uint32) (bool, error) - AllPreKeys(ctx context.Context) ([]*libsignalgo.PreKeyRecord, error) - AllNormalKyberPreKeys(ctx context.Context) ([]*libsignalgo.KyberPreKeyRecord, error) - DeleteAllPreKeys(ctx context.Context) error -} - -const ( - getAllPreKeysQuery = `SELECT key_pair FROM signalmeow_pre_keys WHERE account_id=$1 AND service_id=$2 AND is_signed=$3` - getPreKeyQuery = `SELECT key_pair FROM signalmeow_pre_keys WHERE account_id=$1 AND service_id=$2 AND key_id=$3 AND is_signed=$4` - insertPreKeyQuery = `INSERT INTO signalmeow_pre_keys (account_id, service_id, key_id, is_signed, key_pair) VALUES ($1, $2, $3, $4, $5)` - deletePreKeyQuery = `DELETE FROM signalmeow_pre_keys WHERE account_id=$1 AND service_id=$2 AND key_id=$3 AND is_signed=$4` - getLastPreKeyIDQuery = `SELECT COUNT(*), COALESCE(MAX(key_id), 0) FROM signalmeow_pre_keys WHERE account_id=$1 AND service_id=$2 AND is_signed=$3` - - getAllKyberPreKeysQuery = `SELECT key_pair FROM signalmeow_kyber_pre_keys WHERE account_id=$1 AND service_id=$2 AND is_last_resort=false` - getKyberPreKeyQuery = `SELECT key_pair FROM signalmeow_kyber_pre_keys WHERE account_id=$1 AND service_id=$2 AND key_id=$3` - insertKyberPreKeyQuery = `INSERT INTO signalmeow_kyber_pre_keys (account_id, service_id, key_id, key_pair, is_last_resort) VALUES ($1, $2, $3, $4, $5)` - deleteKyberPreKeyQuery = `DELETE FROM signalmeow_kyber_pre_keys WHERE account_id=$1 AND service_id=$2 AND key_id=$3` - getLastKyberPreKeyIDQuery = `SELECT COUNT(*), COALESCE(MAX(key_id), 0) FROM signalmeow_kyber_pre_keys WHERE account_id=$1 AND service_id=$2` - isLastResortQuery = `SELECT is_last_resort FROM signalmeow_kyber_pre_keys WHERE account_id=$1 AND service_id=$2 AND key_id=$3` -) - -func scanRecord[T any](row dbutil.Scannable, deserializer func([]byte) (*T, error)) (*T, error) { - record, err := dbutil.ScanSingleColumn[[]byte](row) - if errors.Is(err, sql.ErrNoRows) { - return nil, nil - } else if err != nil { - return nil, err - } - return deserializer(record) -} - -func scanPreKey(row dbutil.Scannable) (*libsignalgo.PreKeyRecord, error) { - return scanRecord(row, libsignalgo.DeserializePreKeyRecord) -} - -func scanSignedPreKey(row dbutil.Scannable) (*libsignalgo.SignedPreKeyRecord, error) { - return scanRecord(row, libsignalgo.DeserializeSignedPreKeyRecord) -} - -func scanKyberPreKey(row dbutil.Scannable) (*libsignalgo.KyberPreKeyRecord, error) { - return scanRecord(row, libsignalgo.DeserializeKyberPreKeyRecord) -} - -func (s *scopedSQLStore) GetServiceID() libsignalgo.ServiceID { - return s.ServiceID -} - -func (s *scopedSQLStore) LoadPreKey(ctx context.Context, preKeyID uint32) (*libsignalgo.PreKeyRecord, error) { - return scanPreKey(s.db.QueryRow(ctx, getPreKeyQuery, s.AccountID, s.ServiceID, preKeyID, false)) -} - -func (s *scopedSQLStore) LoadSignedPreKey(ctx context.Context, preKeyID uint32) (*libsignalgo.SignedPreKeyRecord, error) { - return scanSignedPreKey(s.db.QueryRow(ctx, getPreKeyQuery, s.AccountID, s.ServiceID, preKeyID, true)) -} - -func (s *scopedSQLStore) LoadKyberPreKey(ctx context.Context, preKeyID uint32) (*libsignalgo.KyberPreKeyRecord, error) { - return scanKyberPreKey(s.db.QueryRow(ctx, getKyberPreKeyQuery, s.AccountID, s.ServiceID, preKeyID)) -} - -func (s *scopedSQLStore) StorePreKey(ctx context.Context, preKeyID uint32, preKey *libsignalgo.PreKeyRecord) error { - id, err := preKey.GetID() - if err != nil { - return fmt.Errorf("failed to get prekey ID: %w", err) - } else if preKeyID > 0 && id != preKeyID { - return fmt.Errorf("prekey ID mismatch: expected %d, got %d", preKeyID, id) - } - serialized, err := preKey.Serialize() - if err != nil { - return fmt.Errorf("failed to serialize prekey: %w", err) - } - _, err = s.db.Exec(ctx, insertPreKeyQuery, s.AccountID, s.ServiceID, id, false, serialized) - return err -} - -func (s *scopedSQLStore) StoreSignedPreKey(ctx context.Context, preKeyID uint32, preKey *libsignalgo.SignedPreKeyRecord) error { - id, err := preKey.GetID() - if err != nil { - return fmt.Errorf("failed to get signed prekey ID: %w", err) - } else if preKeyID > 0 && id != preKeyID { - return fmt.Errorf("prekey ID mismatch: expected %d, got %d", preKeyID, id) - } - serialized, err := preKey.Serialize() - if err != nil { - return fmt.Errorf("failed to serialize signed prekey: %w", err) - } - _, err = s.db.Exec(ctx, insertPreKeyQuery, s.AccountID, s.ServiceID, id, true, serialized) - return err -} - -func (s *scopedSQLStore) StoreKyberPreKey(ctx context.Context, preKeyID uint32, kyberPreKeyRecord *libsignalgo.KyberPreKeyRecord) error { - return s.storeKyberPreKey(ctx, preKeyID, kyberPreKeyRecord, false) -} - -func (s *scopedSQLStore) StoreLastResortKyberPreKey(ctx context.Context, preKeyID uint32, kyberPreKeyRecord *libsignalgo.KyberPreKeyRecord) error { - return s.storeKyberPreKey(ctx, preKeyID, kyberPreKeyRecord, true) -} - -func (s *scopedSQLStore) storeKyberPreKey(ctx context.Context, preKeyID uint32, kyberPreKeyRecord *libsignalgo.KyberPreKeyRecord, lastResort bool) error { - id, err := kyberPreKeyRecord.GetID() - if err != nil { - return fmt.Errorf("failed to get kyber prekey record ID: %w", err) - } else if preKeyID > 0 && id != preKeyID { - return fmt.Errorf("prekey ID mismatch: expected %d, got %d", preKeyID, id) - } - serialized, err := kyberPreKeyRecord.Serialize() - if err != nil { - return fmt.Errorf("failed to serialize kyber prekey record: %w", err) - } - _, err = s.db.Exec(ctx, insertKyberPreKeyQuery, s.AccountID, s.ServiceID, id, serialized, lastResort) - return err -} - -func (s *scopedSQLStore) RemovePreKey(ctx context.Context, preKeyID uint32) error { - _, err := s.db.Exec(ctx, deletePreKeyQuery, s.AccountID, s.ServiceID, preKeyID, false) - return err -} - -func (s *scopedSQLStore) RemoveSignedPreKey(ctx context.Context, preKeyID uint32) error { - _, err := s.db.Exec(ctx, deletePreKeyQuery, s.AccountID, s.ServiceID, preKeyID, true) - return err -} - -func (s *scopedSQLStore) RemoveKyberPreKey(ctx context.Context, preKeyID uint32) error { - _, err := s.db.Exec(ctx, deleteKyberPreKeyQuery, s.AccountID, s.ServiceID, preKeyID) - return err -} - -func (s *scopedSQLStore) MarkKyberPreKeyUsed(ctx context.Context, id uint32) error { - isLastResort, err := s.IsKyberPreKeyLastResort(ctx, id) - if err != nil { - return err - } - if !isLastResort { - return s.RemoveKyberPreKey(ctx, id) - } - return nil -} - -func (s *scopedSQLStore) GetNextPreKeyID(ctx context.Context) (count, next uint32, err error) { - err = s.db.QueryRow(ctx, getLastPreKeyIDQuery, s.AccountID, s.ServiceID, false).Scan(&count, &next) - if err != nil { - err = fmt.Errorf("failed to query next prekey ID: %w", err) - } - next++ - return -} - -func (s *scopedSQLStore) GetNextKyberPreKeyID(ctx context.Context) (count, next uint32, err error) { - err = s.db.QueryRow(ctx, getLastKyberPreKeyIDQuery, s.AccountID, s.ServiceID).Scan(&count, &next) - if err != nil { - err = fmt.Errorf("failed to query next kyber prekey ID: %w", err) - } - next++ - return -} - -func (s *scopedSQLStore) IsKyberPreKeyLastResort(ctx context.Context, preKeyID uint32) (bool, error) { - var isLastResort bool - err := s.db.QueryRow(ctx, isLastResortQuery, s.AccountID, s.ServiceID, preKeyID).Scan(&isLastResort) - if err != nil { - return false, err - } - return isLastResort, nil -} - -func (s *scopedSQLStore) DeleteAllPreKeys(ctx context.Context) error { - return s.db.DoTxn(ctx, nil, func(ctx context.Context) error { - _, err := s.db.Exec(ctx, "DELETE FROM signalmeow_pre_keys WHERE account_id=$1", s.AccountID) - if err != nil { - return err - } - _, err = s.db.Exec(ctx, "DELETE FROM signalmeow_kyber_pre_keys WHERE account_id=$1", s.AccountID) - return err - }) -} - -func (s *scopedSQLStore) AllPreKeys(ctx context.Context) ([]*libsignalgo.PreKeyRecord, error) { - return dbutil.ConvertRowFn[*libsignalgo.PreKeyRecord](scanPreKey). - NewRowIter(s.db.Query(ctx, getAllPreKeysQuery, s.AccountID, s.ServiceID, false)). - AsList() -} - -func (s *scopedSQLStore) AllNormalKyberPreKeys(ctx context.Context) ([]*libsignalgo.KyberPreKeyRecord, error) { - return dbutil.ConvertRowFn[*libsignalgo.KyberPreKeyRecord](scanKyberPreKey). - NewRowIter(s.db.Query(ctx, getAllKyberPreKeysQuery, s.AccountID, s.ServiceID)). - AsList() -} diff --git a/pkg/signalmeow/store/profile_key_store.go b/pkg/signalmeow/store/profile_key_store.go deleted file mode 100644 index 02fd3e6..0000000 --- a/pkg/signalmeow/store/profile_key_store.go +++ /dev/null @@ -1,52 +0,0 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2024 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package store - -import ( - "context" - - "github.com/google/uuid" - "go.mau.fi/util/dbutil" - - "go.mau.fi/mautrix-signal/pkg/libsignalgo" -) - -const ( - loadProfileKeyQuery = `SELECT profile_key FROM signalmeow_recipients WHERE account_id=$1 AND aci_uuid=$2` - storeProfileKeyQuery = ` - INSERT INTO signalmeow_recipients (account_id, aci_uuid, profile_key) - VALUES ($1, $2, $3) - ON CONFLICT (account_id, aci_uuid) DO UPDATE SET profile_key=excluded.profile_key - ` -) - -func scanProfileKey(row dbutil.Scannable) (*libsignalgo.ProfileKey, error) { - return scanRecord(row, libsignalgo.DeserializeProfileKey) -} - -func (s *sqlStore) LoadProfileKey(ctx context.Context, theirACI uuid.UUID) (*libsignalgo.ProfileKey, error) { - return scanProfileKey(s.db.QueryRow(ctx, loadProfileKeyQuery, s.AccountID, theirACI)) -} - -func (s *sqlStore) MyProfileKey(ctx context.Context) (*libsignalgo.ProfileKey, error) { - return scanProfileKey(s.db.QueryRow(ctx, loadProfileKeyQuery, s.AccountID, s.AccountID)) -} - -func (s *sqlStore) StoreProfileKey(ctx context.Context, theirACI uuid.UUID, key libsignalgo.ProfileKey) error { - _, err := s.db.Exec(ctx, storeProfileKeyQuery, s.AccountID, theirACI, key.Slice()) - return err -} diff --git a/pkg/signalmeow/store/recipient_store.go b/pkg/signalmeow/store/recipient_store.go deleted file mode 100644 index 5f328be..0000000 --- a/pkg/signalmeow/store/recipient_store.go +++ /dev/null @@ -1,429 +0,0 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2023 Scott Weber -// Copyright (C) 2024 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package store - -import ( - "context" - "database/sql" - "errors" - "fmt" - "time" - - "github.com/google/uuid" - "github.com/rs/zerolog" - "go.mau.fi/util/dbutil" - - "go.mau.fi/mautrix-signal/pkg/libsignalgo" - "go.mau.fi/mautrix-signal/pkg/signalmeow/types" -) - -type RecipientStore interface { - LoadProfileKey(ctx context.Context, theirACI uuid.UUID) (*libsignalgo.ProfileKey, error) - StoreProfileKey(ctx context.Context, theirACI uuid.UUID, key libsignalgo.ProfileKey) error - MyProfileKey(ctx context.Context) (*libsignalgo.ProfileKey, error) - - LoadAndUpdateRecipient(ctx context.Context, aci, pni uuid.UUID, updater RecipientUpdaterFunc) (*types.Recipient, error) - IsBlocked(ctx context.Context, aci uuid.UUID) (bool, error) - LoadRecipientByE164(ctx context.Context, e164 string) (*types.Recipient, error) - StoreRecipient(ctx context.Context, recipient *types.Recipient) error - UpdateRecipientE164(ctx context.Context, aci, pni uuid.UUID, e164 string) (*types.Recipient, error) - - IsUnregistered(ctx context.Context, serviceID libsignalgo.ServiceID) bool - MarkUnregistered(ctx context.Context, serviceID libsignalgo.ServiceID, unregistered bool) - - LoadAllContacts(ctx context.Context) ([]*types.Recipient, error) -} - -var _ RecipientStore = (*sqlStore)(nil) - -const ( - getAllRecipientsQuery = ` - SELECT - aci_uuid, - pni_uuid, - e164_number, - contact_name, - contact_avatar_hash, - nickname, - profile_key, - profile_name, - profile_about, - profile_about_emoji, - profile_avatar_path, - profile_fetched_at, - needs_pni_signature, - blocked, - whitelisted - FROM signalmeow_recipients - WHERE account_id = $1 - ` - getAllRecipientsWithNameOrPhoneQuery = getAllRecipientsQuery + `AND (contact_name <> '' OR profile_name <> '' OR e164_number <> '')` - getRecipientByACIQuery = getAllRecipientsQuery + `AND aci_uuid = $2` - getRecipientByPNIQuery = getAllRecipientsQuery + `AND pni_uuid = $2` - getRecipientByACIOrPNIQuery = getAllRecipientsQuery + `AND (($2<>'00000000-0000-0000-0000-000000000000' AND aci_uuid = $2) OR ($3<>'00000000-0000-0000-0000-000000000000' AND pni_uuid = $3))` - getRecipientByPhoneQuery = getAllRecipientsQuery + `AND e164_number = $2` - deleteRecipientByPNIQuery = `DELETE FROM signalmeow_recipients WHERE account_id = $1 AND pni_uuid = $2` - upsertACIRecipientQuery = ` - INSERT INTO signalmeow_recipients ( - account_id, - aci_uuid, - pni_uuid, - e164_number, - contact_name, - contact_avatar_hash, - nickname, - profile_key, - profile_name, - profile_about, - profile_about_emoji, - profile_avatar_path, - profile_fetched_at, - needs_pni_signature, - blocked, - whitelisted - ) - VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16) - ON CONFLICT (account_id, aci_uuid) DO UPDATE SET - pni_uuid = excluded.pni_uuid, - e164_number = excluded.e164_number, - contact_name = excluded.contact_name, - contact_avatar_hash = excluded.contact_avatar_hash, - nickname = excluded.nickname, - profile_key = excluded.profile_key, - profile_name = excluded.profile_name, - profile_about = excluded.profile_about, - profile_about_emoji = excluded.profile_about_emoji, - profile_avatar_path = excluded.profile_avatar_path, - profile_fetched_at = excluded.profile_fetched_at, - needs_pni_signature = excluded.needs_pni_signature, - blocked = excluded.blocked, - whitelisted = excluded.whitelisted - ` - upsertPNIRecipientQuery = ` - INSERT INTO signalmeow_recipients ( - account_id, - pni_uuid, - e164_number, - contact_name, - contact_avatar_hash - ) - VALUES ($1, $2, $3, $4, $5) - ON CONFLICT (account_id, pni_uuid) DO UPDATE SET - e164_number = excluded.e164_number, - contact_name = excluded.contact_name, - contact_avatar_hash = excluded.contact_avatar_hash - ` -) - -func scanRecipient(row dbutil.Scannable) (*types.Recipient, error) { - var recipient types.Recipient - var aci, pni uuid.NullUUID - var profileKey []byte - var profileFetchedAt sql.NullInt64 - err := row.Scan( - &aci, - &pni, - &recipient.E164, - &recipient.ContactName, - &recipient.ContactAvatar.Hash, - &recipient.Nickname, - &profileKey, - &recipient.Profile.Name, - &recipient.Profile.About, - &recipient.Profile.AboutEmoji, - &recipient.Profile.AvatarPath, - &profileFetchedAt, - &recipient.NeedsPNISignature, - &recipient.Blocked, - &recipient.Whitelisted, - ) - if errors.Is(err, sql.ErrNoRows) { - return nil, nil - } else if err != nil { - return nil, err - } - recipient.ACI = aci.UUID - recipient.PNI = pni.UUID - if profileFetchedAt.Valid { - recipient.Profile.FetchedAt = time.UnixMilli(profileFetchedAt.Int64) - } - if len(profileKey) == libsignalgo.ProfileKeyLength { - recipient.Profile.Key = libsignalgo.ProfileKey(profileKey) - } - return &recipient, err -} - -func (s *sqlStore) LoadRecipientByACI(ctx context.Context, theirUUID uuid.UUID) (*types.Recipient, error) { - return scanRecipient(s.db.QueryRow(ctx, getRecipientByACIQuery, s.AccountID, theirUUID)) -} - -func (s *sqlStore) LoadRecipientByPNI(ctx context.Context, theirUUID uuid.UUID) (*types.Recipient, error) { - return scanRecipient(s.db.QueryRow(ctx, getRecipientByPNIQuery, s.AccountID, theirUUID)) -} - -type RecipientUpdaterFunc func(recipient *types.Recipient) (changed bool, err error) - -func (s *sqlStore) mergeRecipients(ctx context.Context, first, second *types.Recipient, updater RecipientUpdaterFunc) (*types.Recipient, error) { - if first.ACI == uuid.Nil { - first, second = second, first - } - first.PNI = second.PNI - zerolog.Ctx(ctx).Debug(). - Stringer("aci", first.ACI). - Stringer("pni", first.PNI). - Msg("Merging recipient entries in database") - if second.E164 != "" { - first.E164 = second.E164 - } - if first.ContactName == "" { - first.ContactName = second.ContactName - } - if first.ContactAvatar.Hash == "" { - first.ContactAvatar = second.ContactAvatar - } - _, err := updater(first) - if err != nil { - return first, fmt.Errorf("failed to run updater function: %w", err) - } - err = s.DeleteRecipientByPNI(ctx, first.PNI) - if err != nil { - return first, fmt.Errorf("failed to delete duplicate PNI row: %w", err) - } - err = s.StoreRecipient(ctx, first) - if err != nil { - return first, fmt.Errorf("failed to store merged row: %w", err) - } - return first, nil -} - -func (s *sqlStore) LoadAndUpdateRecipient(ctx context.Context, aci, pni uuid.UUID, updater RecipientUpdaterFunc) (outRecipient *types.Recipient, outErr error) { - if aci == uuid.Nil && pni == uuid.Nil { - return nil, fmt.Errorf("no ACI or PNI provided in LoadAndUpdateRecipient call") - } - if updater == nil { - updater = func(recipient *types.Recipient) (bool, error) { - return false, nil - } - } - defer func() { - if outRecipient != nil && outRecipient.ACI != uuid.Nil && outErr == nil { - s.blockCacheLock.Lock() - s.blockCache[outRecipient.ACI] = outRecipient.Blocked - s.blockCacheLock.Unlock() - } - }() - if ctx.Value(contextKeyContactLock) == nil { - s.contactLock.Lock() - defer s.contactLock.Unlock() - } - outErr = s.db.DoTxn(ctx, nil, func(ctx context.Context) error { - var entries []*types.Recipient - var err error - if aci != uuid.Nil && pni != uuid.Nil { - query := getRecipientByACIOrPNIQuery - if s.db.Dialect == dbutil.Postgres { - query += " FOR UPDATE" - } - entries, err = dbutil.ConvertRowFn[*types.Recipient](scanRecipient). - NewRowIter(s.db.Query(ctx, query, s.AccountID, aci, pni)). - AsList() - } else if aci != uuid.Nil { - var entry *types.Recipient - entry, err = s.LoadRecipientByACI(ctx, aci) - if entry != nil { - entries = []*types.Recipient{entry} - } - } else if pni != uuid.Nil { - var entry *types.Recipient - entry, err = s.LoadRecipientByPNI(ctx, pni) - if entry != nil { - entries = []*types.Recipient{entry} - } - } else { - panic("impossible case") - } - if err != nil { - return err - } else if len(entries) > 2 { - return fmt.Errorf("got more than two recipient rows for ACI %s and PNI %s", aci, pni) - } else if len(entries) < 2 { - if len(entries) == 0 { - outRecipient = &types.Recipient{ - ACI: aci, - PNI: pni, - } - } else { - outRecipient = entries[0] - } - changed, err := updater(outRecipient) - if err != nil { - return fmt.Errorf("failed to run updater function: %w", err) - } - // SQL only supports one ON CONFLICT clause, which means StoreRecipient will key on the ACI if it's present. - // If we're adding an ACI to a PNI row, just delete the PNI row first to avoid conflicts on the PNI key. - if outRecipient.PNI != uuid.Nil && outRecipient.ACI == uuid.Nil && aci != uuid.Nil { - zerolog.Ctx(ctx).Debug(). - Stringer("aci", outRecipient.ACI). - Stringer("pni", outRecipient.PNI). - Msg("Deleting old PNI-only row before inserting row with both IDs") - err = s.DeleteRecipientByPNI(ctx, outRecipient.PNI) - if err != nil { - return fmt.Errorf("failed to delete old PNI row: %w", err) - } - } - if outRecipient.PNI == uuid.Nil && pni != uuid.Nil { - outRecipient.PNI = pni - changed = true - } - if outRecipient.ACI == uuid.Nil && aci != uuid.Nil { - outRecipient.ACI = aci - changed = true - } - if changed || len(entries) == 0 { - zerolog.Ctx(ctx).Trace(). - Stringer("aci", outRecipient.ACI). - Stringer("pni", outRecipient.PNI). - Msg("Saving recipient row") - err = s.StoreRecipient(ctx, outRecipient) - if err != nil { - return fmt.Errorf("failed to store updated recipient row: %w", err) - } - } - return nil - } else if outRecipient, err = s.mergeRecipients(ctx, entries[0], entries[1], updater); err != nil { - return fmt.Errorf("failed to merge recipient rows for ACI %s and PNI %s: %w", aci, pni, err) - } else { - return nil - } - }) - return -} - -func (s *sqlStore) IsBlocked(ctx context.Context, aci uuid.UUID) (bool, error) { - s.blockCacheLock.RLock() - cachedVal, ok := s.blockCache[aci] - s.blockCacheLock.RUnlock() - if ok { - return cachedVal, nil - } - recipient, err := s.LoadAndUpdateRecipient(ctx, aci, uuid.Nil, nil) - if err != nil { - return false, err - } - return recipient.Blocked, nil -} - -func (s *sqlStore) UpdateRecipientE164(ctx context.Context, aci, pni uuid.UUID, e164 string) (*types.Recipient, error) { - return s.LoadAndUpdateRecipient(ctx, aci, pni, func(recipient *types.Recipient) (bool, error) { - if recipient.E164 != e164 { - recipient.E164 = e164 - return true, nil - } - return false, nil - }) -} -func (s *sqlStore) LoadRecipientByE164(ctx context.Context, e164 string) (*types.Recipient, error) { - return scanRecipient(s.db.QueryRow(ctx, getRecipientByPhoneQuery, s.AccountID, e164)) -} - -func (s *sqlStore) LoadAllContacts(ctx context.Context) ([]*types.Recipient, error) { - rows, err := s.db.Query(ctx, getAllRecipientsWithNameOrPhoneQuery, s.AccountID) - return dbutil.NewRowIterWithError(rows, scanRecipient, err).AsList() -} - -func (s *sqlStore) DeleteRecipientByPNI(ctx context.Context, pni uuid.UUID) error { - _, err := s.db.Exec(ctx, deleteRecipientByPNIQuery, s.AccountID, pni) - return err -} - -func nullableUUID(u uuid.UUID) uuid.NullUUID { - return uuid.NullUUID{UUID: u, Valid: u != uuid.Nil} -} - -func (s *sqlStore) StoreRecipient(ctx context.Context, recipient *types.Recipient) (err error) { - if recipient.ACI != uuid.Nil { - _, err = s.db.Exec( - ctx, - upsertACIRecipientQuery, - s.AccountID, - recipient.ACI, - nullableUUID(recipient.PNI), - recipient.E164, - recipient.ContactName, - recipient.ContactAvatar.Hash, - recipient.Nickname, - recipient.Profile.Key.Slice(), - recipient.Profile.Name, - recipient.Profile.About, - recipient.Profile.AboutEmoji, - recipient.Profile.AvatarPath, - dbutil.UnixMilliPtr(recipient.Profile.FetchedAt), - recipient.NeedsPNISignature, - recipient.Blocked, - recipient.Whitelisted, - ) - s.blockCacheLock.Lock() - s.blockCache[recipient.ACI] = recipient.Blocked - s.blockCacheLock.Unlock() - } else if recipient.PNI != uuid.Nil { - _, err = s.db.Exec( - ctx, - upsertPNIRecipientQuery, - s.AccountID, - recipient.PNI, - recipient.E164, - recipient.ContactName, - recipient.ContactAvatar.Hash, - ) - } else { - err = fmt.Errorf("no ACI or PNI provided in StoreRecipient call") - } - return -} - -const ( - isUnregisteredQuery = `SELECT 1 FROM signalmeow_unregistered_users WHERE aci_uuid=$1` - markUnregisteredQuery = `INSERT INTO signalmeow_unregistered_users (aci_uuid) VALUES ($1) ON CONFLICT (aci_uuid) DO NOTHING` - markRegisteredQuery = `DELETE FROM signalmeow_unregistered_users WHERE aci_uuid=$1` -) - -func (s *sqlStore) IsUnregistered(ctx context.Context, serviceID libsignalgo.ServiceID) (unregistered bool) { - if serviceID.Type != libsignalgo.ServiceIDTypeACI { - return - } - _ = s.db.QueryRow(ctx, isUnregisteredQuery, serviceID.UUID).Scan(&unregistered) - return -} - -func (s *sqlStore) MarkUnregistered(ctx context.Context, serviceID libsignalgo.ServiceID, unregistered bool) { - if serviceID.Type != libsignalgo.ServiceIDTypeACI { - return - } - var err error - if unregistered { - _, err = s.db.Exec(ctx, markUnregisteredQuery, serviceID.UUID) - } else { - _, err = s.db.Exec(ctx, markRegisteredQuery, serviceID.UUID) - } - if err != nil { - zerolog.Ctx(ctx).Err(err). - Stringer("service_id", serviceID). - Bool("unregistered", unregistered). - Msg("Failed to mark recipient as unregistered") - } -} diff --git a/pkg/signalmeow/store/sender_key_store.go b/pkg/signalmeow/store/sender_key_store.go deleted file mode 100644 index 1334066..0000000 --- a/pkg/signalmeow/store/sender_key_store.go +++ /dev/null @@ -1,147 +0,0 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2023 Scott Weber -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package store - -import ( - "context" - "database/sql" - "errors" - "fmt" - "time" - - "github.com/google/uuid" - "go.mau.fi/util/dbutil" - - "go.mau.fi/mautrix-signal/pkg/libsignalgo" - "go.mau.fi/mautrix-signal/pkg/signalmeow/types" -) - -type SenderKeyStore interface { - libsignalgo.SenderKeyStore - DeleteSenderKey(ctx context.Context, address *libsignalgo.Address, distributionID uuid.UUID) error - GetSenderKeyInfo(ctx context.Context, groupID types.GroupIdentifier) (*SenderKeyInfo, error) - DeleteSenderKeyInfo(ctx context.Context, groupID types.GroupIdentifier) error - PutSenderKeyInfo(ctx context.Context, groupID types.GroupIdentifier, info *SenderKeyInfo) error -} - -var _ SenderKeyStore = (*sqlStore)(nil) - -const ( - loadSenderKeyQuery = `SELECT key_record FROM signalmeow_sender_keys WHERE account_id=$1 AND sender_uuid=$2 AND sender_device_id=$3 AND distribution_id=$4` - storeSenderKeyQuery = `INSERT INTO signalmeow_sender_keys (account_id, sender_uuid, sender_device_id, distribution_id, key_record) VALUES ($1, $2, $3, $4, $5) ON CONFLICT (account_id, sender_uuid, sender_device_id, distribution_id) DO UPDATE SET key_record=excluded.key_record` - deleteSenderKeyQuery = `DELETE FROM signalmeow_sender_keys WHERE account_id=$1 AND sender_uuid=$2 AND sender_device_id=$3 AND distribution_id=$4` - - getSenderKeyInfoQuery = ` - SELECT distribution_id, shared_with - FROM signalmeow_outbound_sender_key_info - WHERE account_id=$1 AND group_id=$2 - ` - putSenderKeyInfoQuery = ` - INSERT INTO signalmeow_outbound_sender_key_info (account_id, group_id, distribution_id, shared_with) - VALUES ($1, $2, $3, $4) - ON CONFLICT (account_id, group_id) DO UPDATE - SET distribution_id=excluded.distribution_id, shared_with=excluded.shared_with - ` - deleteSenderKeyInfoQuery = ` - DELETE FROM signalmeow_outbound_sender_key_info - WHERE account_id=$1 AND group_id=$2 - ` -) - -func scanSenderKey(row dbutil.Scannable) (*libsignalgo.SenderKeyRecord, error) { - var key []byte - err := row.Scan(&key) - if errors.Is(err, sql.ErrNoRows) { - return nil, nil - } else if err != nil { - return nil, err - } - return libsignalgo.DeserializeSenderKeyRecord(key) -} - -func (s *sqlStore) LoadSenderKey(ctx context.Context, sender *libsignalgo.Address, distributionID uuid.UUID) (*libsignalgo.SenderKeyRecord, error) { - senderUUID, err := sender.Name() - if err != nil { - return nil, fmt.Errorf("failed to get sender UUID: %w", err) - } - deviceID, err := sender.DeviceID() - if err != nil { - return nil, fmt.Errorf("failed to get sender device ID: %w", err) - } - return scanSenderKey(s.db.QueryRow(ctx, loadSenderKeyQuery, s.AccountID, senderUUID, deviceID, distributionID)) -} - -func (s *sqlStore) StoreSenderKey(ctx context.Context, sender *libsignalgo.Address, distributionID uuid.UUID, record *libsignalgo.SenderKeyRecord) error { - senderUUID, err := sender.Name() - if err != nil { - return fmt.Errorf("failed to get sender UUID: %w", err) - } - deviceID, err := sender.DeviceID() - if err != nil { - return fmt.Errorf("failed to get sender device ID: %w", err) - } - serialized, err := record.Serialize() - if err != nil { - return fmt.Errorf("failed to serialize sender key: %w", err) - } - _, err = s.db.Exec(ctx, storeSenderKeyQuery, s.AccountID, senderUUID, deviceID, distributionID, serialized) - return err -} - -func (s *sqlStore) DeleteSenderKey(ctx context.Context, sender *libsignalgo.Address, distributionID uuid.UUID) error { - senderUUID, err := sender.Name() - if err != nil { - return fmt.Errorf("failed to get sender UUID: %w", err) - } - deviceID, err := sender.DeviceID() - if err != nil { - return fmt.Errorf("failed to get sender device ID: %w", err) - } - _, err = s.db.Exec(ctx, deleteSenderKeyQuery, s.AccountID, senderUUID, deviceID, distributionID) - return err -} - -type SenderKeyInfo struct { - DistributionID uuid.UUID `json:"distribution_id"` - SharedWith map[libsignalgo.ServiceID][]int `json:"shared_with"` - CreatedAt time.Time `json:"created_at"` -} - -func scanSenderKeyInfo(row dbutil.Scannable) (*SenderKeyInfo, error) { - var ski SenderKeyInfo - err := row.Scan(&ski.DistributionID, dbutil.JSON{Data: &ski}) - if errors.Is(err, sql.ErrNoRows) { - return nil, nil - } else if err != nil { - return nil, err - } - return &ski, nil -} - -func (s *sqlStore) GetSenderKeyInfo(ctx context.Context, groupID types.GroupIdentifier) (*SenderKeyInfo, error) { - return scanSenderKeyInfo(s.db.QueryRow(ctx, getSenderKeyInfoQuery, s.AccountID, groupID)) -} - -func (s *sqlStore) PutSenderKeyInfo(ctx context.Context, groupID types.GroupIdentifier, info *SenderKeyInfo) error { - _, err := s.db.Exec(ctx, putSenderKeyInfoQuery, s.AccountID, groupID, info.DistributionID, dbutil.JSON{Data: info}) - return err -} - -func (s *sqlStore) DeleteSenderKeyInfo(ctx context.Context, groupID types.GroupIdentifier) error { - _, err := s.db.Exec(ctx, deleteSenderKeyInfoQuery, s.AccountID, groupID) - return err -} diff --git a/pkg/signalmeow/store/session_store.go b/pkg/signalmeow/store/session_store.go deleted file mode 100644 index 3956714..0000000 --- a/pkg/signalmeow/store/session_store.go +++ /dev/null @@ -1,137 +0,0 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2023 Scott Weber -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package store - -import ( - "context" - "database/sql" - "errors" - "fmt" - - "go.mau.fi/util/dbutil" - - "go.mau.fi/mautrix-signal/pkg/libsignalgo" -) - -var _ SessionStore = (*scopedSQLStore)(nil) - -const ( - loadSessionQuery = `SELECT their_service_id, their_device_id, record FROM signalmeow_sessions WHERE account_id=$1 AND service_id=$2 AND their_service_id=$3 AND their_device_id=$4` - storeSessionQuery = ` - INSERT INTO signalmeow_sessions (account_id, service_id, their_service_id, their_device_id, record) - VALUES ($1, $2, $3, $4, $5) - ON CONFLICT (account_id, service_id, their_service_id, their_device_id) DO UPDATE SET record=excluded.record - ` - allSessionsQuery = `SELECT their_service_id, their_device_id, record FROM signalmeow_sessions WHERE account_id=$1 AND service_id=$2 AND their_service_id=$3` - removeSessionQuery = `DELETE FROM signalmeow_sessions WHERE account_id=$1 AND service_id=$2 AND their_service_id=$3 AND their_device_id=$4` - removeSessionsForRecipientQuery = "DELETE FROM signalmeow_sessions WHERE account_id=$1 AND their_service_id=$2" - deleteAllSessionsQuery = "DELETE FROM signalmeow_sessions WHERE account_id=$1" -) - -type SessionAddressTuple = libsignalgo.SessionAddressTuple - -type SessionStore interface { - libsignalgo.SessionStore - ServiceScopedStore - - // AllSessionsForServiceID returns all sessions for the given service ID. - AllSessionsForServiceID(ctx context.Context, theirID libsignalgo.ServiceID) ([]SessionAddressTuple, error) - // RemoveSession removes the session for the given address. - RemoveSession(ctx context.Context, address *libsignalgo.Address) error - RemoveAllSessionsForServiceID(ctx context.Context, theirID libsignalgo.ServiceID) error - // RemoveAllSessions removes all sessions for our ACI UUID - RemoveAllSessions(ctx context.Context) error -} - -func scanSessionRecord(row dbutil.Scannable) (tuple SessionAddressTuple, err error) { - var rawServiceID string - var rawRecord []byte - err = row.Scan(&rawServiceID, &tuple.DeviceID, &rawRecord) - if errors.Is(err, sql.ErrNoRows) { - err = nil - } else if err != nil { - // return error as-is - } else if tuple.Record, err = libsignalgo.DeserializeSessionRecord(rawRecord); err != nil { - err = fmt.Errorf("failed to deserialize session record: %w", err) - } else if tuple.ServiceID, err = libsignalgo.ServiceIDFromString(rawServiceID); err != nil { - err = fmt.Errorf("failed to parse service ID: %w", err) - } else if tuple.Address, err = tuple.ServiceID.Address(uint(tuple.DeviceID)); err != nil { - err = fmt.Errorf("failed to construct address: %w", err) - } - return -} - -func (s *scopedSQLStore) RemoveSession(ctx context.Context, address *libsignalgo.Address) error { - theirServiceID, err := address.Name() - if err != nil { - return fmt.Errorf("failed to get their service ID: %w", err) - } - deviceID, err := address.DeviceID() - if err != nil { - return fmt.Errorf("failed to get their device ID: %w", err) - } - _, err = s.db.Exec(ctx, removeSessionQuery, s.AccountID, s.ServiceID, theirServiceID, deviceID) - return err -} - -func (s *scopedSQLStore) AllSessionsForServiceID(ctx context.Context, theirID libsignalgo.ServiceID) ([]SessionAddressTuple, error) { - rows, err := s.db.Query(ctx, allSessionsQuery, s.AccountID, s.ServiceID, theirID) - if err != nil { - return nil, err - } - return dbutil.NewRowIterWithError(rows, scanSessionRecord, err).AsList() -} - -func (s *scopedSQLStore) RemoveAllSessionsForServiceID(ctx context.Context, theirID libsignalgo.ServiceID) error { - _, err := s.db.Exec(ctx, removeSessionsForRecipientQuery, s.AccountID, theirID) - return err -} - -func (s *scopedSQLStore) LoadSession(ctx context.Context, address *libsignalgo.Address) (*libsignalgo.SessionRecord, error) { - theirServiceID, err := address.Name() - if err != nil { - return nil, fmt.Errorf("failed to get their service ID: %w", err) - } - deviceID, err := address.DeviceID() - if err != nil { - return nil, fmt.Errorf("failed to get their device ID: %w", err) - } - tuple, err := scanSessionRecord(s.db.QueryRow(ctx, loadSessionQuery, s.AccountID, s.ServiceID, theirServiceID, deviceID)) - return tuple.Record, err -} - -func (s *scopedSQLStore) StoreSession(ctx context.Context, address *libsignalgo.Address, record *libsignalgo.SessionRecord) error { - theirServiceID, err := address.Name() - if err != nil { - return fmt.Errorf("failed to get their service ID: %w", err) - } - deviceID, err := address.DeviceID() - if err != nil { - return fmt.Errorf("failed to get their device ID: %w", err) - } - serialized, err := record.Serialize() - if err != nil { - return fmt.Errorf("failed to serialize session record: %w", err) - } - _, err = s.db.Exec(ctx, storeSessionQuery, s.AccountID, s.ServiceID, theirServiceID, deviceID, serialized) - return err -} - -func (s *scopedSQLStore) RemoveAllSessions(ctx context.Context) error { - _, err := s.db.Exec(ctx, deleteAllSessionsQuery, s.AccountID) - return err -} diff --git a/pkg/signalmeow/store/upgrades/00-latest.sql b/pkg/signalmeow/store/upgrades/00-latest.sql deleted file mode 100644 index fbb44ad..0000000 --- a/pkg/signalmeow/store/upgrades/00-latest.sql +++ /dev/null @@ -1,196 +0,0 @@ --- v0 -> v27 (compatible with v13+): Latest revision -CREATE TABLE signalmeow_device ( - aci_uuid TEXT PRIMARY KEY, - - aci_identity_key_pair bytea NOT NULL, - registration_id INTEGER NOT NULL CHECK ( registration_id >= 0 AND registration_id < 4294967296 ), - - pni_uuid TEXT NOT NULL, - pni_identity_key_pair bytea NOT NULL, - pni_registration_id INTEGER NOT NULL CHECK ( pni_registration_id >= 0 AND pni_registration_id < 4294967296 ), - - device_id INTEGER NOT NULL, - number TEXT NOT NULL DEFAULT '', - password TEXT NOT NULL DEFAULT '', - - master_key bytea, - account_record bytea, - account_entropy_pool TEXT, - ephemeral_backup_key bytea, - media_root_backup_key bytea -); - -CREATE TABLE signalmeow_pre_keys ( - account_id TEXT NOT NULL, - service_id TEXT NOT NULL, - key_id INTEGER NOT NULL, - is_signed BOOLEAN NOT NULL, - key_pair bytea NOT NULL, - - PRIMARY KEY (account_id, service_id, key_id, is_signed), - FOREIGN KEY (account_id) REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE -); - -CREATE TABLE signalmeow_kyber_pre_keys ( - account_id TEXT NOT NULL, - service_id TEXT NOT NULL, - key_id INTEGER NOT NULL, - key_pair bytea NOT NULL, - is_last_resort BOOLEAN NOT NULL, - - PRIMARY KEY (account_id, service_id, key_id), - FOREIGN KEY (account_id) REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE -); - -CREATE TABLE signalmeow_identity_keys ( - account_id TEXT NOT NULL, - their_service_id TEXT NOT NULL, - key bytea NOT NULL, - trust_level TEXT NOT NULL, - - PRIMARY KEY (account_id, their_service_id), - FOREIGN KEY (account_id) REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE -); - -CREATE TABLE signalmeow_sessions ( - account_id TEXT NOT NULL, - service_id TEXT NOT NULL, - their_service_id TEXT NOT NULL, - their_device_id INTEGER NOT NULL, - record bytea NOT NULL, - - PRIMARY KEY (account_id, service_id, their_service_id, their_device_id), - FOREIGN KEY (account_id) REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE -); - -CREATE TABLE signalmeow_event_buffer ( - account_id TEXT NOT NULL, - ciphertext_hash bytea NOT NULL, - plaintext bytea, - server_timestamp BIGINT NOT NULL, - insert_timestamp BIGINT NOT NULL, - - PRIMARY KEY (account_id, ciphertext_hash), - FOREIGN KEY (account_id) REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE -); - -CREATE TABLE signalmeow_profile_keys ( - account_id TEXT NOT NULL, - their_aci_uuid TEXT NOT NULL, - key bytea NOT NULL, - - PRIMARY KEY (account_id, their_aci_uuid), - FOREIGN KEY (account_id) REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE -); - -CREATE TABLE signalmeow_sender_keys ( - account_id TEXT NOT NULL, - sender_uuid TEXT NOT NULL, -- note: this may actually be a service id - sender_device_id INTEGER NOT NULL, - distribution_id TEXT NOT NULL, - key_record bytea NOT NULL, - - PRIMARY KEY (account_id, sender_uuid, sender_device_id, distribution_id), - FOREIGN KEY (account_id) REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE -); - -CREATE TABLE signalmeow_outbound_sender_key_info ( - account_id TEXT NOT NULL, - group_id TEXT NOT NULL, - distribution_id TEXT NOT NULL, - shared_with jsonb NOT NULL, - - PRIMARY KEY (account_id, group_id), - CONSTRAINT signalmeow_outbound_sender_key_info_device_fkey - FOREIGN KEY (account_id) REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE -); - -CREATE TABLE signalmeow_groups ( - account_id TEXT NOT NULL, - group_identifier TEXT NOT NULL, - master_key TEXT NOT NULL, - - PRIMARY KEY (account_id, group_identifier), - CONSTRAINT signalmeow_groups_device_fkey - FOREIGN KEY (account_id) REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE -); - -CREATE TABLE signalmeow_recipients ( - account_id TEXT NOT NULL, - aci_uuid TEXT, - pni_uuid TEXT, - e164_number TEXT NOT NULL DEFAULT '', - contact_name TEXT NOT NULL DEFAULT '', - contact_avatar_hash TEXT NOT NULL DEFAULT '', - nickname TEXT NOT NULL DEFAULT '', - profile_key bytea, - profile_name TEXT NOT NULL DEFAULT '', - profile_about TEXT NOT NULL DEFAULT '', - profile_about_emoji TEXT NOT NULL DEFAULT '', - profile_avatar_path TEXT NOT NULL DEFAULT '', - profile_fetched_at BIGINT, - needs_pni_signature BOOLEAN NOT NULL DEFAULT false, - blocked BOOLEAN NOT NULL DEFAULT false, - whitelisted BOOLEAN, - - CONSTRAINT signalmeow_contacts_account_id_fkey FOREIGN KEY (account_id) REFERENCES signalmeow_device (aci_uuid) - ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT signalmeow_contacts_aci_unique UNIQUE (account_id, aci_uuid), - CONSTRAINT signalmeow_contacts_pni_unique UNIQUE (account_id, pni_uuid) -); - -CREATE TABLE signalmeow_unregistered_users ( - aci_uuid uuid PRIMARY KEY -); - -CREATE TABLE signalmeow_backup_recipient ( - account_id TEXT NOT NULL, - recipient_id BIGINT NOT NULL, - - aci_uuid TEXT, - pni_uuid TEXT, - - group_master_key TEXT, - - data bytea NOT NULL, - - PRIMARY KEY (account_id, recipient_id), - CONSTRAINT signalmeow_backup_recipient_device_fkey FOREIGN KEY (account_id) - REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE -); -CREATE INDEX signalmeow_backup_recipient_group_idx ON signalmeow_backup_recipient (account_id, group_master_key); -CREATE INDEX signalmeow_backup_recipient_aci_idx ON signalmeow_backup_recipient (account_id, aci_uuid); - -CREATE TABLE signalmeow_backup_chat ( - account_id TEXT NOT NULL, - chat_id BIGINT NOT NULL, - recipient_id BIGINT NOT NULL, - data bytea NOT NULL, - - latest_message_id BIGINT, - total_message_count INTEGER, - - PRIMARY KEY (account_id, chat_id), - CONSTRAINT signalmeow_backup_chat_device_fkey FOREIGN KEY (account_id) - REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT signalmeow_backup_chat_recipient_fkey FOREIGN KEY (account_id, recipient_id) - REFERENCES signalmeow_backup_recipient (account_id, recipient_id) ON DELETE CASCADE ON UPDATE CASCADE -); -CREATE INDEX signalmeow_backup_chat_recipient_id_idx ON signalmeow_backup_chat (account_id, recipient_id); - -CREATE TABLE signalmeow_backup_message ( - account_id TEXT NOT NULL, - chat_id BIGINT NOT NULL, - sender_id BIGINT NOT NULL, - message_id BIGINT NOT NULL, - data bytea NOT NULL, - - PRIMARY KEY (account_id, sender_id, message_id), - CONSTRAINT signalmeow_backup_message_chat_fkey FOREIGN KEY (account_id, chat_id) - REFERENCES signalmeow_backup_chat (account_id, chat_id) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT signalmeow_backup_message_sender_fkey FOREIGN KEY (account_id, sender_id) - REFERENCES signalmeow_backup_recipient (account_id, recipient_id) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT signalmeow_backup_message_device_fkey FOREIGN KEY (account_id) - REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE -); -CREATE INDEX signalmeow_backup_message_chat_id_idx ON signalmeow_backup_message (account_id, chat_id); diff --git a/pkg/signalmeow/store/upgrades/06-profile-avatar-path.sql b/pkg/signalmeow/store/upgrades/06-profile-avatar-path.sql deleted file mode 100644 index 27fccb2..0000000 --- a/pkg/signalmeow/store/upgrades/06-profile-avatar-path.sql +++ /dev/null @@ -1,2 +0,0 @@ --- v6 (compatible with v5+): Save profile avatar path -ALTER TABLE signalmeow_contacts ADD COLUMN profile_avatar_path TEXT NOT NULL DEFAULT ''; diff --git a/pkg/signalmeow/store/upgrades/08-profile-fetch-time.sql b/pkg/signalmeow/store/upgrades/08-profile-fetch-time.sql deleted file mode 100644 index 414245c..0000000 --- a/pkg/signalmeow/store/upgrades/08-profile-fetch-time.sql +++ /dev/null @@ -1,11 +0,0 @@ --- v6 -> v8: Add profile_fetched_at and make other columns not null -ALTER TABLE signalmeow_contacts DROP COLUMN profile_avatar_hash; -ALTER TABLE signalmeow_contacts ADD COLUMN profile_fetched_at BIGINT; --- only: postgres until "end only" -ALTER TABLE signalmeow_contacts ALTER COLUMN e164_number SET NOT NULL; -ALTER TABLE signalmeow_contacts ALTER COLUMN contact_name SET NOT NULL; -ALTER TABLE signalmeow_contacts ALTER COLUMN contact_avatar_hash SET NOT NULL; -ALTER TABLE signalmeow_contacts ALTER COLUMN profile_name SET NOT NULL; -ALTER TABLE signalmeow_contacts ALTER COLUMN profile_about SET NOT NULL; -ALTER TABLE signalmeow_contacts ALTER COLUMN profile_about_emoji SET NOT NULL; --- end only postgres diff --git a/pkg/signalmeow/store/upgrades/08-resync-schema-449.sql b/pkg/signalmeow/store/upgrades/08-resync-schema-449.sql deleted file mode 100644 index 95af775..0000000 --- a/pkg/signalmeow/store/upgrades/08-resync-schema-449.sql +++ /dev/null @@ -1,12 +0,0 @@ --- v7 -> v8: Migration from https://github.com/mautrix/signal/pull/449 to match the new v8 upgrade -ALTER TABLE signalmeow_contacts DROP COLUMN profile_avatar_hash; -ALTER TABLE signalmeow_contacts RENAME COLUMN profile_fetch_ts TO profile_fetched_at; -ALTER TABLE signalmeow_contacts ALTER COLUMN profile_fetched_at DROP DEFAULT; -ALTER TABLE signalmeow_contacts ALTER COLUMN profile_fetched_at DROP NOT NULL; -UPDATE signalmeow_contacts SET profile_fetched_at = NULL WHERE profile_fetched_at <= 0; -ALTER TABLE signalmeow_contacts ALTER COLUMN e164_number SET NOT NULL; -ALTER TABLE signalmeow_contacts ALTER COLUMN contact_name SET NOT NULL; -ALTER TABLE signalmeow_contacts ALTER COLUMN contact_avatar_hash SET NOT NULL; -ALTER TABLE signalmeow_contacts ALTER COLUMN profile_name SET NOT NULL; -ALTER TABLE signalmeow_contacts ALTER COLUMN profile_about SET NOT NULL; -ALTER TABLE signalmeow_contacts ALTER COLUMN profile_about_emoji SET NOT NULL; diff --git a/pkg/signalmeow/store/upgrades/09-pni-sending.sql b/pkg/signalmeow/store/upgrades/09-pni-sending.sql deleted file mode 100644 index d3c1cb4..0000000 --- a/pkg/signalmeow/store/upgrades/09-pni-sending.sql +++ /dev/null @@ -1,3 +0,0 @@ --- v9: Add support for sending to PNIs -ALTER TABLE signalmeow_sessions RENAME COLUMN their_aci_uuid TO their_service_id; -ALTER TABLE signalmeow_identity_keys RENAME COLUMN their_aci_uuid TO their_service_id; diff --git a/pkg/signalmeow/store/upgrades/10-prekey-store-service-id.postgres.sql b/pkg/signalmeow/store/upgrades/10-prekey-store-service-id.postgres.sql deleted file mode 100644 index c4d913d..0000000 --- a/pkg/signalmeow/store/upgrades/10-prekey-store-service-id.postgres.sql +++ /dev/null @@ -1,31 +0,0 @@ --- v10: Change prekey store to use service IDs instead of UUID kind column -ALTER TABLE signalmeow_pre_keys ADD COLUMN service_id TEXT; -UPDATE signalmeow_pre_keys SET service_id=aci_uuid WHERE uuid_kind='aci'; -UPDATE signalmeow_pre_keys SET service_id='PNI:' || ( - SELECT pni_uuid FROM signalmeow_device WHERE signalmeow_device.aci_uuid=signalmeow_pre_keys.aci_uuid -) WHERE uuid_kind='pni'; -ALTER TABLE signalmeow_pre_keys ALTER COLUMN service_id SET NOT NULL; -ALTER TABLE signalmeow_pre_keys DROP CONSTRAINT signalmeow_pre_keys_pkey; -ALTER TABLE signalmeow_pre_keys DROP COLUMN uuid_kind; -ALTER TABLE signalmeow_pre_keys RENAME COLUMN aci_uuid TO account_id; -ALTER TABLE signalmeow_pre_keys ADD PRIMARY KEY (account_id, service_id, is_signed, key_id); - -ALTER TABLE signalmeow_pre_keys DROP COLUMN uploaded; - -ALTER TABLE signalmeow_kyber_pre_keys ADD COLUMN service_id TEXT; -UPDATE signalmeow_kyber_pre_keys SET service_id=aci_uuid WHERE uuid_kind='aci'; -UPDATE signalmeow_kyber_pre_keys SET service_id='PNI:' || ( - SELECT pni_uuid FROM signalmeow_device WHERE signalmeow_device.aci_uuid=signalmeow_kyber_pre_keys.aci_uuid -) WHERE uuid_kind='pni'; -ALTER TABLE signalmeow_kyber_pre_keys ALTER COLUMN service_id SET NOT NULL; -ALTER TABLE signalmeow_kyber_pre_keys DROP CONSTRAINT signalmeow_kyber_pre_keys_pkey; -ALTER TABLE signalmeow_kyber_pre_keys DROP COLUMN uuid_kind; -ALTER TABLE signalmeow_kyber_pre_keys RENAME COLUMN aci_uuid TO account_id; -ALTER TABLE signalmeow_kyber_pre_keys ADD PRIMARY KEY (account_id, service_id, key_id); - -ALTER TABLE signalmeow_sessions ADD COLUMN service_id TEXT; -UPDATE signalmeow_sessions SET service_id=our_aci_uuid; -- there are no PNI sessions yet -ALTER TABLE signalmeow_sessions ALTER COLUMN service_id SET NOT NULL; -ALTER TABLE signalmeow_sessions DROP CONSTRAINT signalmeow_sessions_pkey; -ALTER TABLE signalmeow_sessions RENAME COLUMN our_aci_uuid TO account_id; -ALTER TABLE signalmeow_sessions ADD PRIMARY KEY (account_id, service_id, their_service_id, their_device_id); diff --git a/pkg/signalmeow/store/upgrades/10-prekey-store-service-id.sqlite.sql b/pkg/signalmeow/store/upgrades/10-prekey-store-service-id.sqlite.sql deleted file mode 100644 index 25b2824..0000000 --- a/pkg/signalmeow/store/upgrades/10-prekey-store-service-id.sqlite.sql +++ /dev/null @@ -1,59 +0,0 @@ --- v10: Change prekey store to use service IDs instead of UUID kind column -CREATE TABLE new_signalmeow_pre_keys ( - account_id TEXT NOT NULL, - service_id TEXT NOT NULL, - key_id INTEGER NOT NULL, - is_signed BOOLEAN NOT NULL, - key_pair bytea NOT NULL, - - PRIMARY KEY (account_id, service_id, is_signed, key_id), - FOREIGN KEY (account_id) REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE -); - -INSERT INTO new_signalmeow_pre_keys (account_id, service_id, key_id, is_signed, key_pair) -SELECT aci_uuid, CASE WHEN uuid_kind='pni' THEN 'PNI:'||( - SELECT pni_uuid FROM signalmeow_device WHERE signalmeow_device.aci_uuid=signalmeow_pre_keys.aci_uuid -) ELSE aci_uuid END, key_id, is_signed, key_pair -FROM signalmeow_pre_keys; - -DROP TABLE signalmeow_pre_keys; -ALTER TABLE new_signalmeow_pre_keys RENAME TO signalmeow_pre_keys; - - -CREATE TABLE new_signalmeow_kyber_pre_keys ( - account_id TEXT NOT NULL, - service_id TEXT NOT NULL, - key_id INTEGER NOT NULL, - key_pair bytea NOT NULL, - is_last_resort BOOLEAN NOT NULL, - - PRIMARY KEY (account_id, service_id, key_id), - FOREIGN KEY (account_id) REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE -); - -INSERT INTO new_signalmeow_kyber_pre_keys (account_id, service_id, key_id, key_pair, is_last_resort) -SELECT aci_uuid, CASE WHEN uuid_kind='pni' THEN 'PNI:'||( - SELECT pni_uuid FROM signalmeow_device WHERE signalmeow_device.aci_uuid=signalmeow_kyber_pre_keys.aci_uuid -) ELSE aci_uuid END, key_id, key_pair, is_last_resort -FROM signalmeow_kyber_pre_keys; - -DROP TABLE signalmeow_kyber_pre_keys; -ALTER TABLE new_signalmeow_kyber_pre_keys RENAME TO signalmeow_kyber_pre_keys; - - -CREATE TABLE new_signalmeow_sessions ( - account_id TEXT NOT NULL, - service_id TEXT NOT NULL, - their_service_id TEXT NOT NULL, - their_device_id INTEGER NOT NULL, - record bytea NOT NULL, - - PRIMARY KEY (account_id, service_id, their_service_id, their_device_id), - FOREIGN KEY (account_id) REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE -); -INSERT INTO new_signalmeow_sessions (account_id, service_id, their_service_id, their_device_id, record) -SELECT our_aci_uuid, our_aci_uuid, their_service_id, their_device_id, record -FROM signalmeow_sessions; - -DROP TABLE signalmeow_sessions; -ALTER TABLE new_signalmeow_sessions RENAME TO signalmeow_sessions; diff --git a/pkg/signalmeow/store/upgrades/11-aci-to-account-id.sql b/pkg/signalmeow/store/upgrades/11-aci-to-account-id.sql deleted file mode 100644 index 88974a6..0000000 --- a/pkg/signalmeow/store/upgrades/11-aci-to-account-id.sql +++ /dev/null @@ -1,6 +0,0 @@ --- v11: Rename our_aci_uuid columns to account_id -ALTER TABLE signalmeow_identity_keys RENAME COLUMN our_aci_uuid TO account_id; -ALTER TABLE signalmeow_profile_keys RENAME COLUMN our_aci_uuid TO account_id; -ALTER TABLE signalmeow_sender_keys RENAME COLUMN our_aci_uuid TO account_id; -ALTER TABLE signalmeow_groups RENAME COLUMN our_aci_uuid TO account_id; -ALTER TABLE signalmeow_contacts RENAME COLUMN our_aci_uuid TO account_id; diff --git a/pkg/signalmeow/store/upgrades/12-drop-identity-key-device-id.postgres.sql b/pkg/signalmeow/store/upgrades/12-drop-identity-key-device-id.postgres.sql deleted file mode 100644 index 8625f12..0000000 --- a/pkg/signalmeow/store/upgrades/12-drop-identity-key-device-id.postgres.sql +++ /dev/null @@ -1,5 +0,0 @@ --- v12: Drop their_device_id column in signalmeow_identity_keys table -DELETE FROM signalmeow_identity_keys WHERE their_device_id<>1; -ALTER TABLE signalmeow_identity_keys DROP CONSTRAINT signalmeow_identity_keys_pkey; -ALTER TABLE signalmeow_identity_keys DROP COLUMN their_device_id; -ALTER TABLE signalmeow_identity_keys ADD PRIMARY KEY (account_id, their_service_id); diff --git a/pkg/signalmeow/store/upgrades/12-drop-identity-key-device-id.sqlite.sql b/pkg/signalmeow/store/upgrades/12-drop-identity-key-device-id.sqlite.sql deleted file mode 100644 index 396862f..0000000 --- a/pkg/signalmeow/store/upgrades/12-drop-identity-key-device-id.sqlite.sql +++ /dev/null @@ -1,19 +0,0 @@ --- v12: Drop their_device_id column in signalmeow_identity_keys table -CREATE TABLE new_signalmeow_identity_keys ( - account_id TEXT NOT NULL, - their_service_id TEXT NOT NULL, - key bytea NOT NULL, - trust_level TEXT NOT NULL, - - PRIMARY KEY (account_id, their_service_id), - FOREIGN KEY (account_id) REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE -); - -INSERT INTO new_signalmeow_identity_keys (account_id, their_service_id, key, trust_level) -SELECT account_id, their_service_id, key, trust_level -FROM signalmeow_identity_keys -WHERE their_device_id=1; - -DROP TABLE signalmeow_identity_keys; - -ALTER TABLE new_signalmeow_identity_keys RENAME TO signalmeow_identity_keys; diff --git a/pkg/signalmeow/store/upgrades/13-recipients-table.postgres.sql b/pkg/signalmeow/store/upgrades/13-recipients-table.postgres.sql deleted file mode 100644 index 181807c..0000000 --- a/pkg/signalmeow/store/upgrades/13-recipients-table.postgres.sql +++ /dev/null @@ -1,22 +0,0 @@ --- v13: Add PNIs to recipient table and merge profile keys -ALTER TABLE signalmeow_contacts DROP CONSTRAINT signalmeow_contacts_pkey; -ALTER TABLE signalmeow_contacts RENAME TO signalmeow_recipients; -ALTER TABLE signalmeow_recipients ADD COLUMN pni_uuid TEXT; -ALTER TABLE signalmeow_recipients ALTER COLUMN aci_uuid DROP NOT NULL; -ALTER TABLE signalmeow_recipients ADD CONSTRAINT signalmeow_contacts_aci_unique UNIQUE (account_id, aci_uuid); -ALTER TABLE signalmeow_recipients ADD CONSTRAINT signalmeow_contacts_pni_unique UNIQUE (account_id, pni_uuid); - -ALTER TABLE signalmeow_recipients ALTER COLUMN e164_number SET DEFAULT ''; -ALTER TABLE signalmeow_recipients ALTER COLUMN contact_name SET DEFAULT ''; -ALTER TABLE signalmeow_recipients ALTER COLUMN contact_avatar_hash SET DEFAULT ''; -ALTER TABLE signalmeow_recipients ALTER COLUMN profile_name SET DEFAULT ''; -ALTER TABLE signalmeow_recipients ALTER COLUMN profile_about SET DEFAULT ''; -ALTER TABLE signalmeow_recipients ALTER COLUMN profile_about_emoji SET DEFAULT ''; -ALTER TABLE signalmeow_recipients ALTER COLUMN profile_avatar_path SET DEFAULT ''; - -INSERT INTO signalmeow_recipients (account_id, aci_uuid, profile_key) -SELECT account_id, their_aci_uuid, key -FROM signalmeow_profile_keys -ON CONFLICT (account_id, aci_uuid) DO UPDATE SET profile_key=excluded.profile_key; - -DROP TABLE signalmeow_profile_keys; diff --git a/pkg/signalmeow/store/upgrades/13-recipients-table.sqlite.sql b/pkg/signalmeow/store/upgrades/13-recipients-table.sqlite.sql deleted file mode 100644 index 4060685..0000000 --- a/pkg/signalmeow/store/upgrades/13-recipients-table.sqlite.sql +++ /dev/null @@ -1,37 +0,0 @@ --- v13: Add PNIs to recipient table and merge profile keys -CREATE TABLE signalmeow_recipients ( - account_id TEXT NOT NULL, - aci_uuid TEXT, - pni_uuid TEXT, - e164_number TEXT NOT NULL DEFAULT '', - contact_name TEXT NOT NULL DEFAULT '', - contact_avatar_hash TEXT NOT NULL DEFAULT '', - profile_key bytea, - profile_name TEXT NOT NULL DEFAULT '', - profile_about TEXT NOT NULL DEFAULT '', - profile_about_emoji TEXT NOT NULL DEFAULT '', - profile_avatar_path TEXT NOT NULL DEFAULT '', - profile_fetched_at BIGINT, - - CONSTRAINT signalmeow_contacts_account_id_fkey FOREIGN KEY (account_id) REFERENCES signalmeow_device (aci_uuid) - ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT signalmeow_contacts_aci_unique UNIQUE (account_id, aci_uuid), - CONSTRAINT signalmeow_contacts_pni_unique UNIQUE (account_id, pni_uuid) -); - -INSERT INTO signalmeow_recipients ( - account_id, aci_uuid, e164_number, contact_name, contact_avatar_hash, profile_key, profile_name, - profile_about, profile_about_emoji, profile_avatar_path, profile_fetched_at -) -SELECT account_id, aci_uuid, e164_number, contact_name, contact_avatar_hash, profile_key, profile_name, - profile_about, profile_about_emoji, profile_avatar_path, profile_fetched_at -FROM signalmeow_contacts; - -INSERT INTO signalmeow_recipients (account_id, aci_uuid, profile_key) -SELECT account_id, their_aci_uuid, key -FROM signalmeow_profile_keys -WHERE true -- https://sqlite.org/lang_upsert.html#parsing_ambiguity -ON CONFLICT (account_id, aci_uuid) DO UPDATE SET profile_key=excluded.profile_key; - -DROP TABLE signalmeow_contacts; -DROP TABLE signalmeow_profile_keys; diff --git a/pkg/signalmeow/store/upgrades/14-save-storage-master-key.sql b/pkg/signalmeow/store/upgrades/14-save-storage-master-key.sql deleted file mode 100644 index 6c75ed1..0000000 --- a/pkg/signalmeow/store/upgrades/14-save-storage-master-key.sql +++ /dev/null @@ -1,2 +0,0 @@ --- v14 (compatible with v13+): Save storage master key for devices -ALTER TABLE signalmeow_device ADD COLUMN master_key bytea; diff --git a/pkg/signalmeow/store/upgrades/15-needs-pni-signature.sql b/pkg/signalmeow/store/upgrades/15-needs-pni-signature.sql deleted file mode 100644 index 26d854a..0000000 --- a/pkg/signalmeow/store/upgrades/15-needs-pni-signature.sql +++ /dev/null @@ -1,2 +0,0 @@ --- v15 (compatible with v13+): Store flag for recipients who need a PNI signature -ALTER TABLE signalmeow_recipients ADD COLUMN needs_pni_signature boolean DEFAULT false; diff --git a/pkg/signalmeow/store/upgrades/16-remove-extra-prekeys.go b/pkg/signalmeow/store/upgrades/16-remove-extra-prekeys.go deleted file mode 100644 index 5046abf..0000000 --- a/pkg/signalmeow/store/upgrades/16-remove-extra-prekeys.go +++ /dev/null @@ -1,81 +0,0 @@ -// mautrix-signal - A Matrix-signal puppeting bridge. -// Copyright (C) 2024 Tulir Asokan -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package upgrades - -import ( - "context" - "fmt" - - "github.com/rs/zerolog" - "go.mau.fi/util/dbutil" -) - -type PreKeyCounts struct { - AccountID string - ServiceID string - Count int - MaxID int -} - -func scanPreKeyCounts(row dbutil.Scannable) (*PreKeyCounts, error) { - var pkc PreKeyCounts - return dbutil.ValueOrErr(&pkc, row.Scan(&pkc.AccountID, &pkc.ServiceID, &pkc.Count, &pkc.MaxID)) -} - -func deleteExtraPrekeys(ctx context.Context, db *dbutil.Database, selectQuery, deleteQuery string) error { - preKeys, err := dbutil.ConvertRowFn[*PreKeyCounts](scanPreKeyCounts).NewRowIter(db.Query(ctx, selectQuery)).AsList() - if err != nil { - return fmt.Errorf("failed to query prekey counts: %w", err) - } - for _, pkc := range preKeys { - if pkc.Count > 250 { - zerolog.Ctx(ctx).Debug(). - Str("account_id", pkc.AccountID). - Str("service_id", pkc.ServiceID). - Int("max_id", pkc.MaxID). - Int("count", pkc.Count). - Msg("Too many prekeys, deleting all") - _, err = db.Exec(ctx, deleteQuery, pkc.AccountID, pkc.ServiceID, pkc.MaxID-95) - if err != nil { - return fmt.Errorf("failed to delete extra prekeys for %s/%s: %w", pkc.AccountID, pkc.ServiceID, err) - } - } - } - return nil -} - -func init() { - Table.Register(-1, 16, 13, "Remove extra prekeys", dbutil.TxnModeOn, func(ctx context.Context, db *dbutil.Database) error { - err := deleteExtraPrekeys(ctx, db, ` - SELECT account_id, service_id, COUNT(*), MAX(key_id) FROM signalmeow_pre_keys WHERE is_signed=false GROUP BY 1, 2 - `, ` - DELETE FROM signalmeow_pre_keys WHERE account_id=$1 AND service_id=$2 AND is_signed=false AND key_id<$3 - `) - if err != nil { - return fmt.Errorf("failed to process EC: %w", err) - } - err = deleteExtraPrekeys(ctx, db, ` - SELECT account_id, service_id, COUNT(*), MAX(key_id) FROM signalmeow_kyber_pre_keys WHERE is_last_resort=false GROUP BY 1, 2 - `, ` - DELETE FROM signalmeow_kyber_pre_keys WHERE account_id=$1 AND service_id=$2 AND is_last_resort=false AND key_id<$3 - `) - if err != nil { - return fmt.Errorf("failed to process kyber: %w", err) - } - return nil - }) -} diff --git a/pkg/signalmeow/store/upgrades/17-store-account-record.sql b/pkg/signalmeow/store/upgrades/17-store-account-record.sql deleted file mode 100644 index 6d8b0db..0000000 --- a/pkg/signalmeow/store/upgrades/17-store-account-record.sql +++ /dev/null @@ -1,2 +0,0 @@ --- v17 (compatible with v13+): Store account config -ALTER TABLE signalmeow_device ADD COLUMN account_record bytea; diff --git a/pkg/signalmeow/store/upgrades/18-store-backup-keys.sql b/pkg/signalmeow/store/upgrades/18-store-backup-keys.sql deleted file mode 100644 index e478324..0000000 --- a/pkg/signalmeow/store/upgrades/18-store-backup-keys.sql +++ /dev/null @@ -1,4 +0,0 @@ --- v18 (compatible with v13+): Store account entropy pool and ephemeral backup keys -ALTER TABLE signalmeow_device ADD COLUMN account_entropy_pool TEXT; -ALTER TABLE signalmeow_device ADD COLUMN ephemeral_backup_key bytea; -ALTER TABLE signalmeow_device ADD COLUMN media_root_backup_key bytea; diff --git a/pkg/signalmeow/store/upgrades/19-store-backup-data.sql b/pkg/signalmeow/store/upgrades/19-store-backup-data.sql deleted file mode 100644 index 6354ef8..0000000 --- a/pkg/signalmeow/store/upgrades/19-store-backup-data.sql +++ /dev/null @@ -1,52 +0,0 @@ --- v19 (compatible with v13+): Add tables for caching parsed backup data -CREATE TABLE signalmeow_backup_recipient ( - account_id TEXT NOT NULL, - recipient_id BIGINT NOT NULL, - - aci_uuid TEXT, - pni_uuid TEXT, - - group_master_key TEXT, - - data bytea NOT NULL, - - PRIMARY KEY (account_id, recipient_id), - CONSTRAINT signalmeow_backup_recipient_device_fkey FOREIGN KEY (account_id) - REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE -); -CREATE INDEX signalmeow_backup_recipient_group_idx ON signalmeow_backup_recipient (account_id, group_master_key); -CREATE INDEX signalmeow_backup_recipient_aci_idx ON signalmeow_backup_recipient (account_id, aci_uuid); - -CREATE TABLE signalmeow_backup_chat ( - account_id TEXT NOT NULL, - chat_id BIGINT NOT NULL, - recipient_id BIGINT NOT NULL, - data bytea NOT NULL, - - latest_message_id BIGINT, - total_message_count INTEGER, - - PRIMARY KEY (account_id, chat_id), - CONSTRAINT signalmeow_backup_chat_device_fkey FOREIGN KEY (account_id) - REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT signalmeow_backup_chat_recipient_fkey FOREIGN KEY (account_id, recipient_id) - REFERENCES signalmeow_backup_recipient (account_id, recipient_id) ON DELETE CASCADE ON UPDATE CASCADE -); -CREATE INDEX signalmeow_backup_chat_recipient_id_idx ON signalmeow_backup_chat (account_id, recipient_id); - -CREATE TABLE signalmeow_backup_message ( - account_id TEXT NOT NULL, - chat_id BIGINT NOT NULL, - sender_id BIGINT NOT NULL, - message_id BIGINT NOT NULL, - data bytea NOT NULL, - - PRIMARY KEY (account_id, sender_id, message_id), - CONSTRAINT signalmeow_backup_message_chat_fkey FOREIGN KEY (account_id, chat_id) - REFERENCES signalmeow_backup_chat (account_id, chat_id) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT signalmeow_backup_message_sender_fkey FOREIGN KEY (account_id, sender_id) - REFERENCES signalmeow_backup_recipient (account_id, recipient_id) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT signalmeow_backup_message_device_fkey FOREIGN KEY (account_id) - REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE -); -CREATE INDEX signalmeow_backup_message_chat_id_idx ON signalmeow_backup_message (account_id, chat_id); diff --git a/pkg/signalmeow/store/upgrades/21-event-buffer.sql b/pkg/signalmeow/store/upgrades/21-event-buffer.sql deleted file mode 100644 index bfc289a..0000000 --- a/pkg/signalmeow/store/upgrades/21-event-buffer.sql +++ /dev/null @@ -1,11 +0,0 @@ --- v21 (compatible with v13+): Add event buffer -CREATE TABLE signalmeow_event_buffer ( - account_id TEXT NOT NULL, - ciphertext_hash bytea NOT NULL, - plaintext bytea, - server_timestamp BIGINT NOT NULL, - insert_timestamp BIGINT NOT NULL, - - PRIMARY KEY (account_id, ciphertext_hash), - FOREIGN KEY (account_id) REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE -); diff --git a/pkg/signalmeow/store/upgrades/22-recipient-nickname.sql b/pkg/signalmeow/store/upgrades/22-recipient-nickname.sql deleted file mode 100644 index 437cb33..0000000 --- a/pkg/signalmeow/store/upgrades/22-recipient-nickname.sql +++ /dev/null @@ -1,2 +0,0 @@ --- v22 (compatible with v13+): Store Signal-specific nickname of contacts -ALTER TABLE signalmeow_recipients ADD COLUMN nickname TEXT NOT NULL DEFAULT ''; diff --git a/pkg/signalmeow/store/upgrades/23-recipient-blocked.sql b/pkg/signalmeow/store/upgrades/23-recipient-blocked.sql deleted file mode 100644 index 3a9654a..0000000 --- a/pkg/signalmeow/store/upgrades/23-recipient-blocked.sql +++ /dev/null @@ -1,2 +0,0 @@ --- v23 (compatible with v13+): Store block status for recipients -ALTER TABLE signalmeow_recipients ADD COLUMN blocked BOOLEAN NOT NULL DEFAULT false; diff --git a/pkg/signalmeow/store/upgrades/24-outbound-sender-keys.sql b/pkg/signalmeow/store/upgrades/24-outbound-sender-keys.sql deleted file mode 100644 index 4f02389..0000000 --- a/pkg/signalmeow/store/upgrades/24-outbound-sender-keys.sql +++ /dev/null @@ -1,9 +0,0 @@ --- v24 (compatible with v13+): Store outbound sender keys for groups -CREATE TABLE IF NOT EXISTS signalmeow_outbound_sender_key_info ( - account_id TEXT NOT NULL, - group_id TEXT NOT NULL, - distribution_id TEXT NOT NULL, - shared_with jsonb NOT NULL, - - PRIMARY KEY (account_id, group_id) -); diff --git a/pkg/signalmeow/store/upgrades/25-unregistered-user-cache.sql b/pkg/signalmeow/store/upgrades/25-unregistered-user-cache.sql deleted file mode 100644 index 04a5233..0000000 --- a/pkg/signalmeow/store/upgrades/25-unregistered-user-cache.sql +++ /dev/null @@ -1,4 +0,0 @@ --- v25 (compatible with v13+): Cache unregistered users -CREATE TABLE signalmeow_unregistered_users ( - aci_uuid uuid PRIMARY KEY -); diff --git a/pkg/signalmeow/store/upgrades/26-recipient-whitelisted.sql b/pkg/signalmeow/store/upgrades/26-recipient-whitelisted.sql deleted file mode 100644 index c61bf33..0000000 --- a/pkg/signalmeow/store/upgrades/26-recipient-whitelisted.sql +++ /dev/null @@ -1,2 +0,0 @@ --- v26 (compatible with v13+): Store whitelisted status for recipients -ALTER TABLE signalmeow_recipients ADD COLUMN whitelisted BOOLEAN; diff --git a/pkg/signalmeow/store/upgrades/27-sender-key-info-foreign-key.postgres.sql b/pkg/signalmeow/store/upgrades/27-sender-key-info-foreign-key.postgres.sql deleted file mode 100644 index e9c0ee5..0000000 --- a/pkg/signalmeow/store/upgrades/27-sender-key-info-foreign-key.postgres.sql +++ /dev/null @@ -1,10 +0,0 @@ --- v27 (compatible with v13+): Add missing foreign key for outbound sender key info and groups -DELETE FROM signalmeow_outbound_sender_key_info -WHERE NOT EXISTS(SELECT 1 FROM signalmeow_device WHERE aci_uuid=account_id); -ALTER TABLE signalmeow_outbound_sender_key_info ADD CONSTRAINT signalmeow_outbound_sender_key_info_device_fkey - FOREIGN KEY (account_id) REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE; - -DELETE FROM signalmeow_groups -WHERE NOT EXISTS(SELECT 1 FROM signalmeow_device WHERE aci_uuid=account_id); -ALTER TABLE signalmeow_groups ADD CONSTRAINT signalmeow_groups_device_fkey - FOREIGN KEY (account_id) REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/pkg/signalmeow/store/upgrades/27-sender-key-info-foreign-key.sqlite.sql b/pkg/signalmeow/store/upgrades/27-sender-key-info-foreign-key.sqlite.sql deleted file mode 100644 index b6017ba..0000000 --- a/pkg/signalmeow/store/upgrades/27-sender-key-info-foreign-key.sqlite.sql +++ /dev/null @@ -1,32 +0,0 @@ --- v27 (compatible with v13+): Add missing foreign key for outbound sender key info and groups - -CREATE TABLE new_signalmeow_outbound_sender_key_info ( - account_id TEXT NOT NULL, - group_id TEXT NOT NULL, - distribution_id TEXT NOT NULL, - shared_with jsonb NOT NULL, - - PRIMARY KEY (account_id, group_id), - CONSTRAINT signalmeow_outbound_sender_key_info_device_fkey - FOREIGN KEY (account_id) REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE -); -INSERT INTO new_signalmeow_outbound_sender_key_info -SELECT * FROM signalmeow_outbound_sender_key_info -WHERE EXISTS(SELECT 1 FROM signalmeow_device WHERE aci_uuid=account_id); -DROP TABLE signalmeow_outbound_sender_key_info; -ALTER TABLE new_signalmeow_outbound_sender_key_info RENAME TO signalmeow_outbound_sender_key_info; - -CREATE TABLE new_signalmeow_groups ( - account_id TEXT NOT NULL, - group_identifier TEXT NOT NULL, - master_key TEXT NOT NULL, - - PRIMARY KEY (account_id, group_identifier), - CONSTRAINT signalmeow_groups_device_fkey - FOREIGN KEY (account_id) REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE -); -INSERT INTO new_signalmeow_groups -SELECT * FROM signalmeow_groups -WHERE EXISTS(SELECT 1 FROM signalmeow_device WHERE aci_uuid=account_id); -DROP TABLE signalmeow_groups; -ALTER TABLE new_signalmeow_groups RENAME TO signalmeow_groups; diff --git a/pkg/signalmeow/types.go b/pkg/signalmeow/types.go index ba8da3f..9849d6a 100644 --- a/pkg/signalmeow/types.go +++ b/pkg/signalmeow/types.go @@ -16,20 +16,21 @@ package signalmeow -import ( - "github.com/google/uuid" +const ( + UUID_KIND_ACI = "aci" + UUID_KIND_PNI = "pni" ) +type UUIDKind string + type GroupCredentials struct { Credentials []GroupCredential `json:"credentials"` - PNI uuid.UUID `json:"pni"` + Pni string `json:"pni"` } - type GroupCredential struct { Credential []byte RedemptionTime int64 } - type GroupExternalCredential struct { Token []byte `json:"token"` } diff --git a/pkg/signalmeow/types/contact.go b/pkg/signalmeow/types/contact.go index 889dd3e..856a0e3 100644 --- a/pkg/signalmeow/types/contact.go +++ b/pkg/signalmeow/types/contact.go @@ -17,50 +17,24 @@ package types import ( - "time" - "github.com/google/uuid" - - "go.mau.fi/mautrix-signal/pkg/libsignalgo" ) -type Profile struct { - Name string - About string - AboutEmoji string - AvatarPath string - Key libsignalgo.ProfileKey - FetchedAt time.Time - Credential []byte -} - -func (p *Profile) Equals(other *Profile) bool { - return p.Name == other.Name && - p.About == other.About && - p.AboutEmoji == other.AboutEmoji && - p.AvatarPath == other.AvatarPath && - p.Key == other.Key -} - -// The Recipient struct combines information from two sources: +// The Contact struct combines information from two sources: // - A Signal "contact": contact info harvested from our user's phone's contact list // - A Signal "profile": contact info entered by the target user when registering for Signal -type Recipient struct { - ACI uuid.UUID - PNI uuid.UUID - E164 string - ContactName string - ContactAvatar ContactAvatar - Nickname string - Profile Profile - - NeedsPNISignature bool - Blocked bool - Whitelisted *bool -} - -func (r *Recipient) ProbablyMessageRequest() bool { - return r != nil && (r.NeedsPNISignature || (r.Whitelisted != nil && !*r.Whitelisted)) +// Users of this Contact struct should prioritize "contact" information, but fall back +// to "profile" information if the contact information is not available. +type Contact struct { + UUID uuid.UUID + E164 string + ContactName string + ContactAvatarHash string + ProfileKey []byte + ProfileName string + ProfileAbout string + ProfileAboutEmoji string + ProfileAvatarHash string } type ContactAvatar struct { diff --git a/pkg/signalmeow/types/identifer.go b/pkg/signalmeow/types/identifer.go index f1c02dc..00554bf 100644 --- a/pkg/signalmeow/types/identifer.go +++ b/pkg/signalmeow/types/identifer.go @@ -25,17 +25,13 @@ import ( type GroupIdentifier string -func BytesToGroupIdentifier(raw *libsignalgo.GroupIdentifier) GroupIdentifier { - return GroupIdentifier(raw.String()) -} - func (gid GroupIdentifier) String() string { return string(gid) } func (gid GroupIdentifier) Bytes() (raw libsignalgo.GroupIdentifier, err error) { var decoded []byte - decoded, err = base64.StdEncoding.DecodeString(string(gid)) + decoded, err = base64.RawStdEncoding.DecodeString(string(gid)) if err == nil { if len(decoded) != 32 { err = fmt.Errorf("invalid group identifier length") @@ -45,7 +41,3 @@ func (gid GroupIdentifier) Bytes() (raw libsignalgo.GroupIdentifier, err error) } return } - -// This is just base64 encoded group master key -type SerializedGroupMasterKey string -type SerializedInviteLinkPassword string diff --git a/pkg/signalmeow/upgrades/00-latest.sql b/pkg/signalmeow/upgrades/00-latest.sql new file mode 100644 index 0000000..ed7c674 --- /dev/null +++ b/pkg/signalmeow/upgrades/00-latest.sql @@ -0,0 +1,103 @@ +-- v0 -> v5: Latest revision +CREATE TABLE signalmeow_device ( + aci_uuid TEXT PRIMARY KEY, + + aci_identity_key_pair bytea NOT NULL, + registration_id INTEGER NOT NULL CHECK ( registration_id >= 0 AND registration_id < 4294967296 ), + + pni_uuid TEXT NOT NULL, + pni_identity_key_pair bytea NOT NULL, + pni_registration_id INTEGER NOT NULL CHECK ( pni_registration_id >= 0 AND pni_registration_id < 4294967296 ), + + device_id INTEGER NOT NULL, + number TEXT NOT NULL DEFAULT '', + password TEXT NOT NULL DEFAULT '' +); + +CREATE TABLE signalmeow_pre_keys ( + aci_uuid TEXT NOT NULL, + key_id INTEGER NOT NULL, + uuid_kind TEXT NOT NULL, + is_signed BOOLEAN NOT NULL, + key_pair bytea NOT NULL, + uploaded BOOLEAN NOT NULL, + + PRIMARY KEY (aci_uuid, uuid_kind, is_signed, key_id), + FOREIGN KEY (aci_uuid) REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE +); + +CREATE TABLE signalmeow_identity_keys ( + our_aci_uuid TEXT NOT NULL, + their_aci_uuid TEXT NOT NULL, + their_device_id INTEGER NOT NULL, + key bytea NOT NULL, + trust_level TEXT NOT NULL, + + PRIMARY KEY (our_aci_uuid, their_aci_uuid, their_device_id), + FOREIGN KEY (our_aci_uuid) REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE +); + +CREATE TABLE signalmeow_sessions ( + our_aci_uuid TEXT NOT NULL, + their_aci_uuid TEXT NOT NULL, + their_device_id INTEGER NOT NULL, + record bytea NOT NULL, + + PRIMARY KEY (our_aci_uuid, their_aci_uuid, their_device_id), + FOREIGN KEY (our_aci_uuid) REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE +); + +CREATE TABLE signalmeow_profile_keys ( + our_aci_uuid TEXT NOT NULL, + their_aci_uuid TEXT NOT NULL, + key bytea NOT NULL, + + PRIMARY KEY (our_aci_uuid, their_aci_uuid), + FOREIGN KEY (our_aci_uuid) REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE +); + +CREATE TABLE signalmeow_sender_keys ( + our_aci_uuid TEXT NOT NULL, + sender_uuid TEXT NOT NULL, + sender_device_id INTEGER NOT NULL, + distribution_id TEXT NOT NULL, + key_record bytea NOT NULL, + + PRIMARY KEY (our_aci_uuid, sender_uuid, sender_device_id, distribution_id), + FOREIGN KEY (our_aci_uuid) REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE +); + +CREATE TABLE signalmeow_groups ( + our_aci_uuid TEXT NOT NULL, + group_identifier TEXT NOT NULL, + master_key TEXT NOT NULL, + + PRIMARY KEY (our_aci_uuid, group_identifier) +); + +CREATE TABLE signalmeow_contacts ( + our_aci_uuid TEXT NOT NULL, + aci_uuid TEXT NOT NULL, + e164_number TEXT, + contact_name TEXT, + contact_avatar_hash TEXT, + profile_key bytea, + profile_name TEXT, + profile_about TEXT, + profile_about_emoji TEXT, + profile_avatar_hash TEXT, + + PRIMARY KEY (our_aci_uuid, aci_uuid), + FOREIGN KEY (our_aci_uuid) REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE +); + +CREATE TABLE signalmeow_kyber_pre_keys ( + aci_uuid TEXT NOT NULL, + key_id INTEGER NOT NULL, + uuid_kind TEXT NOT NULL, + key_pair bytea NOT NULL, + is_last_resort BOOLEAN NOT NULL, + + PRIMARY KEY (aci_uuid, uuid_kind, key_id), + FOREIGN KEY (aci_uuid) REFERENCES signalmeow_device (aci_uuid) ON DELETE CASCADE ON UPDATE CASCADE +); diff --git a/pkg/signalmeow/store/upgrades/02-groups.sql b/pkg/signalmeow/upgrades/02-groups.sql similarity index 100% rename from pkg/signalmeow/store/upgrades/02-groups.sql rename to pkg/signalmeow/upgrades/02-groups.sql diff --git a/pkg/signalmeow/store/upgrades/03-contacts.sql b/pkg/signalmeow/upgrades/03-contacts.sql similarity index 100% rename from pkg/signalmeow/store/upgrades/03-contacts.sql rename to pkg/signalmeow/upgrades/03-contacts.sql diff --git a/pkg/signalmeow/store/upgrades/04-kyber-prekeys.sql b/pkg/signalmeow/upgrades/04-kyber-prekeys.sql similarity index 100% rename from pkg/signalmeow/store/upgrades/04-kyber-prekeys.sql rename to pkg/signalmeow/upgrades/04-kyber-prekeys.sql diff --git a/pkg/signalmeow/store/upgrades/05-postgres-profile-key.sql b/pkg/signalmeow/upgrades/05-postgres-profile-key.sql similarity index 100% rename from pkg/signalmeow/store/upgrades/05-postgres-profile-key.sql rename to pkg/signalmeow/upgrades/05-postgres-profile-key.sql diff --git a/pkg/signalmeow/store/upgrades/upgrades.go b/pkg/signalmeow/upgrades/upgrades.go similarity index 100% rename from pkg/signalmeow/store/upgrades/upgrades.go rename to pkg/signalmeow/upgrades/upgrades.go diff --git a/pkg/signalmeow/web/signalwebsocket.go b/pkg/signalmeow/web/signalwebsocket.go index a2153a1..e092a5e 100644 --- a/pkg/signalmeow/web/signalwebsocket.go +++ b/pkg/signalmeow/web/signalwebsocket.go @@ -19,55 +19,46 @@ package web import ( "context" "encoding/base64" - "encoding/json" "errors" "fmt" "net/http" - "net/url" "strings" - "sync" - "sync/atomic" "time" - "github.com/coder/websocket" "github.com/rs/zerolog" - "go.mau.fi/util/exsync" + "nhooyr.io/websocket" signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" "go.mau.fi/mautrix-signal/pkg/signalmeow/wspb" ) -var WebsocketPingInterval = 30 * time.Second -var WebsocketPingTimeout = 20 * time.Second -var WebsocketPingTimeoutLimit = 5 - const WebsocketProvisioningPath = "/v1/websocket/provisioning/" const WebsocketPath = "/v1/websocket/" type SimpleResponse struct { - Status int - WriteCallback func(time.Time) + Status int } type RequestHandlerFunc func(context.Context, *signalpb.WebSocketRequestMessage) (*SimpleResponse, error) type SignalWebsocket struct { - ws atomic.Pointer[websocket.Conn] - basicAuth *url.Userinfo + ws *websocket.Conn + path string + basicAuth *string sendChannel chan SignalWebsocketSendMessage statusChannel chan SignalWebsocketConnectionStatus - closeLock sync.RWMutex - closeEvt *exsync.Event - closeCalled atomic.Bool - cancel atomic.Pointer[context.CancelFunc] - cancelConn atomic.Pointer[context.CancelCauseFunc] } -func NewSignalWebsocket(basicAuth *url.Userinfo) *SignalWebsocket { +func NewSignalWebsocket(path string, username *string, password *string) *SignalWebsocket { + var basicAuth *string + if username != nil && password != nil { + b := base64.StdEncoding.EncodeToString([]byte(*username + ":" + *password)) + basicAuth = &b + } return &SignalWebsocket{ + path: path, basicAuth: basicAuth, sendChannel: make(chan SignalWebsocketSendMessage), statusChannel: make(chan SignalWebsocketConnectionStatus), - closeEvt: exsync.NewEvent(), } } @@ -79,7 +70,6 @@ const ( SignalWebsocketConnectionEventDisconnected SignalWebsocketConnectionEventLoggedOut SignalWebsocketConnectionEventError - SignalWebsocketConnectionEventFatalError SignalWebsocketConnectionEventCleanShutdown ) @@ -90,7 +80,6 @@ var signalWebsocketConnectionEventNames = map[SignalWebsocketConnectionEvent]str SignalWebsocketConnectionEventDisconnected: "SignalWebsocketConnectionEventDisconnected", SignalWebsocketConnectionEventLoggedOut: "SignalWebsocketConnectionEventLoggedOut", SignalWebsocketConnectionEventError: "SignalWebsocketConnectionEventError", - SignalWebsocketConnectionEventFatalError: "SignalWebsocketConnectionEventFatalError", SignalWebsocketConnectionEventCleanShutdown: "SignalWebsocketConnectionEventCleanShutdown", } @@ -105,105 +94,50 @@ type SignalWebsocketConnectionStatus struct { } func (s *SignalWebsocket) IsConnected() bool { - return s.ws.Load() != nil + return s.ws != nil } -func (s *SignalWebsocket) Close() (err error) { - if s == nil { - return nil +func (s *SignalWebsocket) Close() error { + defer func() { + if s != nil { + s.ws = nil + } + }() + if s != nil && s.ws != nil { + return s.ws.Close(websocket.StatusNormalClosure, "") } - - s.closeCalled.Store(true) - if ws := s.ws.Swap(nil); ws != nil { - err = ws.Close(websocket.StatusNormalClosure, "") - } - if cancelLoop := s.cancel.Swap(nil); cancelLoop != nil { - (*cancelLoop)() - } - <-s.closeEvt.GetChan() - return err + return nil } -func (s *SignalWebsocket) Connect(ctx context.Context, requestHandler RequestHandlerFunc) chan SignalWebsocketConnectionStatus { +func (s *SignalWebsocket) Connect(ctx context.Context, requestHandler *RequestHandlerFunc) chan SignalWebsocketConnectionStatus { go s.connectLoop(ctx, requestHandler) return s.statusChannel } -func (s *SignalWebsocket) pushStatus(ctx context.Context, status SignalWebsocketConnectionEvent, err error) { - select { - case s.statusChannel <- SignalWebsocketConnectionStatus{ - Event: status, - Err: err, - }: - case <-ctx.Done(): - return - case <-time.After(5 * time.Second): - zerolog.Ctx(ctx).Error().Msg("Status channel didn't accept status") - } -} - -func (s *SignalWebsocket) pushOutgoing(ctx context.Context, send SignalWebsocketSendMessage) error { - if ctx.Err() != nil { - return ctx.Err() - } - s.closeLock.RLock() - defer s.closeLock.RUnlock() - if s.sendChannel == nil { - return errors.New("connection is not open") - } - select { - case s.sendChannel <- send: - return nil - case <-ctx.Done(): - return ctx.Err() - case <-s.closeEvt.GetChan(): - return errors.New("connection closed before send could be queued") - } -} - -var ErrForcedReconnect = errors.New("forced reconnect") - -func (s *SignalWebsocket) ForceReconnect() { - if s == nil { - return - } - cancelFn := s.cancelConn.Load() - if cancelFn == nil { - return - } - (*cancelFn)(ErrForcedReconnect) -} - func (s *SignalWebsocket) connectLoop( ctx context.Context, - requestHandler RequestHandlerFunc, + requestHandler *RequestHandlerFunc, ) { log := zerolog.Ctx(ctx).With(). Str("loop", "signal_websocket_connect_loop"). Logger() ctx, cancel := context.WithCancel(ctx) - s.cancel.Store(&cancel) - incomingRequestChan := make(chan *signalpb.WebSocketRequestMessage, 256) + incomingRequestChan := make(chan *signalpb.WebSocketRequestMessage, 10000) defer func() { - s.closeEvt.Set() - cancel() - - s.closeLock.Lock() - defer s.closeLock.Unlock() close(incomingRequestChan) close(s.statusChannel) close(s.sendChannel) incomingRequestChan = nil s.statusChannel = nil s.sendChannel = nil + cancel() }() - const initialBackoff = 10 * time.Second const backoffIncrement = 5 * time.Second const maxBackoff = 60 * time.Second - if s.ws.Load() != nil { + if s.ws != nil { panic("Already connected") } @@ -229,20 +163,17 @@ func (s *SignalWebsocket) connectLoop( } // Handle the request with the request handler function - response, err := requestHandler(ctx, request) + response, err := (*requestHandler)(ctx, request) if err != nil { - log.Err(err).Uint64("request_id", request.GetId()).Msg("Error handling request") - } else if response != nil { - err = s.pushOutgoing(ctx, SignalWebsocketSendMessage{ + log.Err(err).Msg("Error handling request") + continue + } + if response != nil && s.sendChannel != nil { + s.sendChannel <- SignalWebsocketSendMessage{ RequestMessage: request, ResponseMessage: response, - }) - if err != nil { - log.Err(err).Uint64("request_id", request.GetId()).Msg("Error queuing response message") } - } else { - log.Warn().Uint64("request_id", request.GetId()).Msg("Request handler didn't return a response nor an error") } } } @@ -250,57 +181,53 @@ func (s *SignalWebsocket) connectLoop( // Main connection loop - if there's a problem with anything just // kill everything (including the websocket) and build it all up again - backoff := initialBackoff + backoff := backoffIncrement retrying := false errorCount := 0 - isFirstConnect := true - wsURL := (&url.URL{ - Scheme: "wss", - Host: APIHostname, - Path: WebsocketPath, - User: s.basicAuth, - }).String() for { if retrying { if backoff > maxBackoff { backoff = maxBackoff } log.Warn().Dur("backoff", backoff).Msg("Failed to connect, waiting to retry...") - select { - case <-time.After(backoff): - case <-ctx.Done(): - } + time.Sleep(backoff) backoff += backoffIncrement - } else if !isFirstConnect && s.basicAuth != nil { - select { - case <-time.After(initialBackoff): - case <-ctx.Done(): - } } if ctx.Err() != nil { log.Info().Msg("ctx done, stopping connection loop") return } - isFirstConnect = false - ws, resp, err := OpenWebsocket(ctx, wsURL) + ws, resp, err := OpenWebsocket(ctx, s.path) if resp != nil { if resp.StatusCode != 101 { // Server didn't want to open websocket if resp.StatusCode >= 500 { // We can try again if it's a 5xx - s.pushStatus(ctx, SignalWebsocketConnectionEventDisconnected, fmt.Errorf("5xx opening websocket: %v", resp.Status)) + s.statusChannel <- SignalWebsocketConnectionStatus{ + Event: SignalWebsocketConnectionEventDisconnected, + Err: fmt.Errorf("5xx opening websocket: %v", resp.Status), + } } else if resp.StatusCode == 403 { // We are logged out, so we should stop trying to reconnect - s.pushStatus(ctx, SignalWebsocketConnectionEventLoggedOut, fmt.Errorf("403 opening websocket, we are logged out")) + s.statusChannel <- SignalWebsocketConnectionStatus{ + Event: SignalWebsocketConnectionEventLoggedOut, + Err: fmt.Errorf("403 opening websocket, we are logged out"), + } return // NOT RETRYING, KILLING THE CONNECTION LOOP } else if resp.StatusCode > 0 && resp.StatusCode < 500 { // Unexpected status code - s.pushStatus(ctx, SignalWebsocketConnectionEventFatalError, fmt.Errorf("unexpected status opening websocket: %v", resp.Status)) + s.statusChannel <- SignalWebsocketConnectionStatus{ + Event: SignalWebsocketConnectionEventError, + Err: fmt.Errorf("Bad status opening websocket: %v", resp.Status), + } return // NOT RETRYING, KILLING THE CONNECTION LOOP } else { // Something is very wrong - s.pushStatus(ctx, SignalWebsocketConnectionEventError, fmt.Errorf("unexpected error opening websocket: %v", resp.Status)) + s.statusChannel <- SignalWebsocketConnectionStatus{ + Event: SignalWebsocketConnectionEventError, + Err: fmt.Errorf("Unexpected error opening websocket: %v", resp.Status), + } } // Retry the connection retrying = true @@ -310,46 +237,45 @@ func (s *SignalWebsocket) connectLoop( if err != nil { // Unexpected error opening websocket if backoff < maxBackoff { - s.pushStatus(ctx, SignalWebsocketConnectionEventDisconnected, fmt.Errorf("transient error opening websocket: %w", err)) + s.statusChannel <- SignalWebsocketConnectionStatus{ + Event: SignalWebsocketConnectionEventDisconnected, + Err: fmt.Errorf("hopefully transient error opening websocket: %w", err), + } } else { - s.pushStatus(ctx, SignalWebsocketConnectionEventError, fmt.Errorf("continuing error opening websocket: %w", err)) + s.statusChannel <- SignalWebsocketConnectionStatus{ + Event: SignalWebsocketConnectionEventError, + Err: fmt.Errorf("continuing error opening websocket: %w", err), + } } retrying = true continue } // Succssfully connected - s.pushStatus(ctx, SignalWebsocketConnectionEventConnected, nil) - s.ws.Store(ws) + s.statusChannel <- SignalWebsocketConnectionStatus{ + Event: SignalWebsocketConnectionEventConnected, + } + s.ws = ws retrying = false - backoff = initialBackoff + backoff = backoffIncrement - responseChannels := exsync.NewMap[uint64, chan *signalpb.WebSocketResponseMessage]() + responseChannels := make(map[uint64]chan *signalpb.WebSocketResponseMessage) loopCtx, loopCancel := context.WithCancelCause(ctx) - s.cancelConn.Store(&loopCancel) - var wg sync.WaitGroup - wg.Add(3) // Read loop (for reading incoming reqeusts and responses to outgoing requests) go func() { - defer wg.Done() - err := readLoop(loopCtx, ws, incomingRequestChan, responseChannels) + err := readLoop(loopCtx, ws, incomingRequestChan, &responseChannels) // Don't want to put an err into loopCancel if we don't have one if err != nil { err = fmt.Errorf("error in readLoop: %w", err) } - if s.closeCalled.Load() { - // Exit during Close() so cancel the reconnect loop as well - cancel() - } loopCancel(err) log.Info().Msg("readLoop exited") }() // Write loop (for sending outgoing requests and responses to incoming requests) go func() { - defer wg.Done() - err := writeLoop(loopCtx, ws, s.sendChannel, responseChannels) + err := writeLoop(loopCtx, ws, s.sendChannel, &responseChannels) // Don't want to put an err into loopCancel if we don't have one if err != nil { err = fmt.Errorf("error in writeLoop: %w", err) @@ -360,34 +286,18 @@ func (s *SignalWebsocket) connectLoop( // Ping loop (send a keepalive Ping every 30s) go func() { - defer wg.Done() - ticker := time.NewTicker(WebsocketPingInterval) + ticker := time.NewTicker(30 * time.Second) defer ticker.Stop() - pingTimeoutCount := 0 for { select { case <-ticker.C: - pingCtx, cancel := context.WithTimeout(loopCtx, WebsocketPingTimeout) - err := ws.Ping(pingCtx) - cancel() + err := ws.Ping(loopCtx) if err != nil { - pingTimeoutCount++ - log.Err(err).Msg("Failed to send ping") - if pingTimeoutCount >= WebsocketPingTimeoutLimit { - log.Warn().Msg("Ping timeout count exceeded, closing websocket") - err = ws.Close(websocket.StatusNormalClosure, "Ping timeout") - if err != nil { - log.Err(err).Msg("Error closing websocket after ping timeout") - } - return - } - } else if pingTimeoutCount > 0 { - pingTimeoutCount = 0 - log.Debug().Msg("Recovered from ping error") - } else { - log.Trace().Msg("Sent keepalive") + loopCancel(fmt.Errorf("error sending keepalive: %w", err)) + return } + log.Info().Msg("Sent keepalive") case <-loopCtx.Done(): return } @@ -395,29 +305,49 @@ func (s *SignalWebsocket) connectLoop( }() // Wait for read or write or ping loop to exit (which means there was an error) - log.Debug().Msg("Finished preparing connection, waiting for loop context to finish") - <-loopCtx.Done() - ctxCauseErr := context.Cause(loopCtx) - log.Debug().AnErr("ctx_cause_err", ctxCauseErr).Msg("Read or write loop exited") - if ctxCauseErr == nil || errors.Is(ctxCauseErr, context.Canceled) { - s.pushStatus(ctx, SignalWebsocketConnectionEventCleanShutdown, nil) - } else { - errorCount++ - s.pushStatus(ctx, SignalWebsocketConnectionEventDisconnected, ctxCauseErr) - if errors.Is(ctxCauseErr, ErrForcedReconnect) { - // Skip the delay for forced reconnects - // TODO should the delay be lowered globally? - isFirstConnect = true + log.Info().Msg("Waiting for read or write loop to exit") + select { + case <-loopCtx.Done(): + log.Info().Msg("received loopCtx done") + if context.Cause(loopCtx) != nil { + err := context.Cause(loopCtx) + if err != nil && err != context.Canceled { + log.Err(err).Msg("loopCtx error") + errorCount++ + } + } + if context.Cause(loopCtx) != nil && context.Cause(loopCtx) == context.Canceled { + s.statusChannel <- SignalWebsocketConnectionStatus{ + Event: SignalWebsocketConnectionEventCleanShutdown, + } + } else { + s.statusChannel <- SignalWebsocketConnectionStatus{ + Event: SignalWebsocketConnectionEventDisconnected, + Err: err, + } + } + case <-ctx.Done(): + log.Info().AnErr("ctx_err", ctx.Err()).AnErr("ctx_cause", context.Cause(ctx)).Msg("received ctx done") + if context.Cause(ctx) != nil && context.Cause(ctx) == context.Canceled { + s.statusChannel <- SignalWebsocketConnectionStatus{ + Event: SignalWebsocketConnectionEventCleanShutdown, + } + return + } else { + s.statusChannel <- SignalWebsocketConnectionStatus{ + Event: SignalWebsocketConnectionEventDisconnected, + Err: err, + } } } + log.Info().Msg("Read or write loop exited") // Clean up - ws.Close(websocket.StatusGoingAway, "Going away") - for _, responseChannel := range responseChannels.SwapData(nil) { + ws.Close(200, "Done") + for _, responseChannel := range responseChannels { close(responseChannel) } loopCancel(nil) - wg.Wait() log.Debug().Msg("Finished websocket cleanup") if errorCount > 500 { // Something is really wrong, we better panic. @@ -432,7 +362,7 @@ func readLoop( ctx context.Context, ws *websocket.Conn, incomingRequestChan chan *signalpb.WebSocketRequestMessage, - responseChannels *exsync.Map[uint64, chan *signalpb.WebSocketResponseMessage], + responseChannels *(map[uint64]chan *signalpb.WebSocketResponseMessage), ) error { log := zerolog.Ctx(ctx).With(). Str("loop", "signal_websocket_read_loop"). @@ -447,19 +377,20 @@ func readLoop( if err != nil { if err == context.Canceled { log.Info().Msg("readLoop context canceled") - } else if websocket.CloseStatus(err) == websocket.StatusNormalClosure { + } + if strings.Contains(err.Error(), "StatusNormalClosure") { log.Info().Msg("readLoop received StatusNormalClosure") return nil } return fmt.Errorf("error reading message: %w", err) } if msg.Type == nil { - return errors.New("received message with no type") + return errors.New("Received message with no type") } else if *msg.Type == signalpb.WebSocketMessage_REQUEST { if msg.Request == nil { - return errors.New("received request message with no request") + return errors.New("Received request message with no request") } - log.Trace(). + log.Debug(). Uint64("request_id", *msg.Request.Id). Str("request_verb", *msg.Request.Verb). Str("request_path", *msg.Request.Path). @@ -472,32 +403,27 @@ func readLoop( if msg.Response.Id == nil { log.Fatal().Msg("Received response with no id") } - responseChannel, ok := responseChannels.Pop(*msg.Response.Id) + responseChannel, ok := (*responseChannels)[*msg.Response.Id] if !ok { log.Warn(). Uint64("response_id", *msg.Response.Id). Msg("Received response with unknown id") continue } - logEvt := log.Debug(). - Uint64("response_id", msg.Response.GetId()). - Uint32("response_status", msg.Response.GetStatus()). - Str("response_message", msg.Response.GetMessage()) - if log.GetLevel() == zerolog.TraceLevel || len(msg.Response.Body) < 256 { - logEvt.Strs("response_headers", msg.Response.Headers) - if json.Valid(msg.Response.Body) { - logEvt.RawJSON("response_body", msg.Response.Body) - } else { - logEvt.Str("response_body", base64.StdEncoding.EncodeToString(msg.Response.Body)) - } - } - logEvt.Msg("Received WS response") + log.Debug(). + Uint64("response_id", *msg.Response.Id). + Uint32("response_status", *msg.Response.Status). + Msg("Received WS response") responseChannel <- msg.Response + delete(*responseChannels, *msg.Response.Id) + log.Debug(). + Uint64("response_id", *msg.Response.Id). + Msg("Deleted response channel for ID") close(responseChannel) } else if *msg.Type == signalpb.WebSocketMessage_UNKNOWN { - return fmt.Errorf("received message with unknown type: %v", *msg.Type) + return fmt.Errorf("Received message with unknown type: %v", *msg.Type) } else { - return fmt.Errorf("received message with actually unknown type: %v", *msg.Type) + return fmt.Errorf("Received message with actually unknown type: %v", *msg.Type) } } } @@ -516,7 +442,7 @@ func writeLoop( ctx context.Context, ws *websocket.Conn, sendChannel chan SignalWebsocketSendMessage, - responseChannels *exsync.Map[uint64, chan *signalpb.WebSocketResponseMessage], + responseChannels *(map[uint64]chan *signalpb.WebSocketResponseMessage), ) error { log := zerolog.Ctx(ctx).With(). Str("loop", "signal_websocket_write_loop"). @@ -530,7 +456,7 @@ func writeLoop( return nil case request, ok := <-sendChannel: if !ok { - return errors.New("send channel closed") + return errors.New("Send channel closed") } if request.RequestMessage != nil && request.ResponseChannel != nil { msgType := signalpb.WebSocketMessage_REQUEST @@ -539,23 +465,27 @@ func writeLoop( Request: request.RequestMessage, } request.RequestMessage.Id = &i - responseChannels.Set(i, request.ResponseChannel) - if !request.RequestTime.IsZero() { + (*responseChannels)[i] = request.ResponseChannel + path := *request.RequestMessage.Path + if len(path) > 30 { + path = path[:40] + } + if request.RequestTime != (time.Time{}) { elapsed := time.Since(request.RequestTime) if elapsed > 1*time.Minute { - return fmt.Errorf("request too old (%v), not sending", elapsed) + return fmt.Errorf("Took too long, not sending (elapsed: %v)", elapsed) } else if elapsed > 10*time.Second { log.Warn(). Uint64("request_id", i). Str("request_verb", *request.RequestMessage.Verb). - Str("request_path", *request.RequestMessage.Path). + Str("request_path", path). Dur("elapsed", elapsed). Msg("Sending WS request") } else { log.Debug(). Uint64("request_id", i). Str("request_verb", *request.RequestMessage.Verb). - Str("request_path", *request.RequestMessage.Path). + Str("request_path", path). Dur("elapsed", elapsed). Msg("Sending WS request") } @@ -568,21 +498,17 @@ func writeLoop( return fmt.Errorf("error writing request message: %w", err) } } else if request.RequestMessage != nil && request.ResponseMessage != nil { - message := CreateWSResponse(ctx, *request.RequestMessage.Id, request.ResponseMessage.Status) + message := CreateWSResponse(*request.RequestMessage.Id, request.ResponseMessage.Status) log.Debug(). Uint64("request_id", *request.RequestMessage.Id). Int("response_status", request.ResponseMessage.Status). Msg("Sending WS response") - writeStartTime := time.Now() err := wspb.Write(ctx, ws, message) if err != nil { return fmt.Errorf("error writing response message: %w", err) } - if request.ResponseMessage.WriteCallback != nil { - request.ResponseMessage.WriteCallback(writeStartTime) - } } else { - return fmt.Errorf("invalid request: %+v", request) + return fmt.Errorf("Invalid request: %+v", request) } } } @@ -590,33 +516,10 @@ func writeLoop( func (s *SignalWebsocket) SendRequest( ctx context.Context, - method, - path string, - body []byte, - headers http.Header, + request *signalpb.WebSocketRequestMessage, ) (*signalpb.WebSocketResponseMessage, error) { - if s == nil { - return nil, errors.New("websocket is nil") - } - headerArray := make([]string, len(headers)) - var hasContentType bool - for key, values := range headers { - if strings.ToLower(key) == "content-type" { - hasContentType = true - } - for _, value := range values { - headerArray = append(headerArray, fmt.Sprintf("%s:%s", strings.ToLower(key), value)) - } - } - if !hasContentType && body != nil { - headerArray = append(headerArray, "content-type:application/json") - } - return s.sendRequestInternal(ctx, &signalpb.WebSocketRequestMessage{ - Verb: &method, - Path: &path, - Body: body, - Headers: headerArray, - }, time.Now(), 0) + startTime := time.Now() + return s.sendRequestInternal(ctx, request, startTime, 0) } func (s *SignalWebsocket) sendRequestInternal( @@ -626,28 +529,27 @@ func (s *SignalWebsocket) sendRequestInternal( retryCount int, ) (*signalpb.WebSocketResponseMessage, error) { if s.basicAuth != nil { - request.Headers = append(request.Headers, "authorization:Basic "+s.basicAuth.String()) + request.Headers = append(request.Headers, "authorization:Basic "+*s.basicAuth) } responseChannel := make(chan *signalpb.WebSocketResponseMessage, 1) - err := s.pushOutgoing(ctx, SignalWebsocketSendMessage{ + if s.sendChannel == nil { + return nil, errors.New("Send channel not initialized") + } + s.sendChannel <- SignalWebsocketSendMessage{ RequestMessage: request, ResponseChannel: responseChannel, RequestTime: startTime, - }) - if err != nil { - return nil, err } response := <-responseChannel - isSelfDelete := request.GetVerb() == http.MethodDelete && strings.HasPrefix(request.GetPath(), "/v1/devices/") - if response == nil && !isSelfDelete { + if response == nil { // If out of retries, return error no matter what if retryCount >= 3 { // TODO: I think error isn't getting passed in this context (as it's not the one in writeLoop) if ctx.Err() != nil { return nil, fmt.Errorf("retried 3 times, giving up: %w", ctx.Err()) } else { - return nil, errors.New("retried 3 times, giving up") + return nil, errors.New("Retried 3 times, giving up") } } if ctx.Err() != nil { @@ -662,24 +564,22 @@ func (s *SignalWebsocket) sendRequestInternal( return response, nil } -func OpenWebsocket(ctx context.Context, url string) (*websocket.Conn, *http.Response, error) { +func OpenWebsocket(ctx context.Context, path string) (*websocket.Conn, *http.Response, error) { opt := &websocket.DialOptions{ - HTTPClient: SignalHTTPClient, - HTTPHeader: make(http.Header, 2), + HTTPClient: signalHTTPClient, } - opt.HTTPHeader.Set("User-Agent", UserAgent) - opt.HTTPHeader.Set("X-Signal-Agent", SignalAgent) - ws, resp, err := websocket.Dial(ctx, url, opt) + urlStr := "wss://" + UrlHost + path + ws, resp, err := websocket.Dial(ctx, urlStr, opt) if ws != nil { ws.SetReadLimit(1 << 20) // Increase read limit to 1MB from default of 32KB } return ws, resp, err } -func CreateWSResponse(ctx context.Context, id uint64, status int) *signalpb.WebSocketMessage { +func CreateWSResponse(id uint64, status int) *signalpb.WebSocketMessage { if status != 200 && status != 400 { // TODO support more responses to Signal? Are there more? - zerolog.Ctx(ctx).Fatal().Int("status", status).Msg("Error creating response. Non 200/400 not supported yet.") + zlog.Fatal().Int("status", status).Msg("Error creating response. Non 200/400 not supported yet.") return nil } msg_type := signalpb.WebSocketMessage_RESPONSE diff --git a/pkg/signalmeow/web/web.go b/pkg/signalmeow/web/web.go index f211b77..d9790a6 100644 --- a/pkg/signalmeow/web/web.go +++ b/pkg/signalmeow/web/web.go @@ -26,44 +26,44 @@ import ( "fmt" "io" "net/http" - "runtime" - "strings" - "time" + "net/url" + "os" "github.com/rs/zerolog" - - "go.mau.fi/mautrix-signal/pkg/libsignalgo" - signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" ) -var BaseUserAgent = "libsignal/" + libsignalgo.Version + " go/" + strings.TrimPrefix(runtime.Version(), "go") -var UserAgent = "signalmeow/0.1.0 " + BaseUserAgent -var SignalAgent = "MAU" +const proxyUrlStr = "" // Set this to proxy requests +const caCertPath = "" // Set this to trust a self-signed cert (ie. for mitmproxy) const ( - APIHostname = "chat.signal.org" - StorageHostname = "storage.signal.org" - CDN1Hostname = "cdn.signal.org" - CDN2Hostname = "cdn2.signal.org" - CDN3Hostname = "cdn3.signal.org" + UrlHost = "chat.signal.org" + StorageUrlHost = "storage.signal.org" + CDNUrlHost = "cdn.signal.org" + CDN2UrlHost = "cdn2.signal.org" ) var CDNHosts = []string{ - CDN1Hostname, - CDN1Hostname, - CDN2Hostname, - CDN3Hostname, + CDNUrlHost, + CDNUrlHost, + CDN2UrlHost, +} + +// logging +var zlog zerolog.Logger = zerolog.New(zerolog.ConsoleWriter{}).With().Timestamp().Logger() + +func SetLogger(l zerolog.Logger) { + zlog = l } //go:embed signal-root.crt.der var signalRootCertBytes []byte -var SignalCertPool = x509.NewCertPool() -var SignalTLSConfig = &tls.Config{RootCAs: SignalCertPool} var signalTransport = &http.Transport{ ForceAttemptHTTP2: true, - TLSClientConfig: SignalTLSConfig, + TLSClientConfig: &tls.Config{ + RootCAs: x509.NewCertPool(), + }, } -var SignalHTTPClient = &http.Client{ +var signalHTTPClient = &http.Client{ Transport: signalTransport, } @@ -72,17 +72,30 @@ func init() { if err != nil { panic(err) } - SignalCertPool.AddCert(cert) + signalTransport.TLSClientConfig.RootCAs.AddCert(cert) + + if proxyUrlStr != "" { + proxyURL, err := url.Parse(proxyUrlStr) + if err != nil { + panic(err) + } + signalTransport.Proxy = http.ProxyURL(proxyURL) + } + if caCertPath != "" { + caCert, err := os.ReadFile(caCertPath) + if err != nil { + panic(err) + } + signalTransport.TLSClientConfig.RootCAs.AppendCertsFromPEM(caCert) + } } type ContentType string const ( - ContentTypeJSON ContentType = "application/json" - ContentTypeProtobuf ContentType = "application/x-protobuf" - ContentTypeOctetStream ContentType = "application/octet-stream" - ContentTypeOffsetOctetStream ContentType = "application/offset+octet-stream" - ContentTypeMultiRecipientMessage ContentType = "application/vnd.signal-messenger.mrm" + ContentTypeJSON ContentType = "application/json" + ContentTypeProtobuf ContentType = "application/x-protobuf" + ContentTypeOctetStream ContentType = "application/octet-stream" ) type HTTPReqOpt struct { @@ -90,34 +103,32 @@ type HTTPReqOpt struct { Username *string Password *string ContentType ContentType + Host string Headers map[string]string OverrideURL string // Override the full URL, if set ignores path and Host } var httpReqCounter = 0 -func SendHTTPRequest(ctx context.Context, host, method, path string, opt *HTTPReqOpt) (*http.Response, error) { +func SendHTTPRequest(method string, path string, opt *HTTPReqOpt) (*http.Response, error) { // Set defaults if opt == nil { opt = &HTTPReqOpt{} } + if opt.Host == "" { + opt.Host = UrlHost + } if len(path) > 0 && path[0] != '/' { path = "/" + path } - urlStr := "https://" + host + path + urlStr := "https://" + opt.Host + path if opt.OverrideURL != "" { urlStr = opt.OverrideURL } - log := zerolog.Ctx(ctx).With(). - Str("action", "send HTTP request"). - Str("method", method). - Str("url", urlStr). - Logger() - ctx = log.WithContext(ctx) - req, err := http.NewRequestWithContext(ctx, method, urlStr, bytes.NewReader(opt.Body)) + req, err := http.NewRequest(method, urlStr, bytes.NewBuffer(opt.Body)) if err != nil { - log.Err(err).Msg("Error creating request") + zlog.Err(err).Msg("Error creating request") return nil, err } if opt.Headers != nil { @@ -130,56 +141,33 @@ func SendHTTPRequest(ctx context.Context, host, method, path string, opt *HTTPRe } else { req.Header.Set("Content-Type", string(ContentTypeJSON)) } - req.ContentLength = int64(len(opt.Body)) req.Header.Set("Content-Length", fmt.Sprintf("%d", len(opt.Body))) - req.Header.Set("User-Agent", UserAgent) - req.Header.Set("X-Signal-Agent", SignalAgent) + // TODO: figure out what user agent to use + //req.Header.Set("User-Agent", "SignalBridge/0.1") + //req.Header.Set("X-Signal-Agent", "SignalBridge/0.1") if opt.Username != nil && opt.Password != nil { req.SetBasicAuth(*opt.Username, *opt.Password) } httpReqCounter++ - log = log.With().Int("request_number", httpReqCounter).Logger() + log := zlog.With(). + Int("request_number", httpReqCounter). + Str("method", method). + Str("url", urlStr). + Logger() log.Trace().Msg("Sending HTTP request") - start := time.Now() - resp, err := SignalHTTPClient.Do(req) - dur := time.Since(start) + resp, err := signalHTTPClient.Do(req) if err != nil { - log.Err(err).Dur("duration", dur).Msg("Error sending request") + log.Err(err).Msg("Error sending request") return nil, err } - log.Debug().Int("status_code", resp.StatusCode).Dur("duration", dur).Msg("Received HTTP response") + log.Debug().Int("status_code", resp.StatusCode).Msg("received HTTP response") return resp, nil } -func CloseBody(resp *http.Response) { - if resp != nil && resp.Body != nil { - _ = resp.Body.Close() - } -} - -func DecodeWSResponseBody(ctx context.Context, out any, resp *signalpb.WebSocketResponseMessage) error { - if resp == nil { - return nil - } - if resp.GetStatus() < 200 || resp.GetStatus() >= 300 { - zerolog.Ctx(ctx).Warn(). - Bytes("body", resp.Body). - Str("resp_message", resp.GetMessage()). - Strs("headers", resp.Headers). - Uint32("status_code", resp.GetStatus()). - Msg("Unexpected status code") - return fmt.Errorf("unexpected response status %d", resp.GetStatus()) - } - if out == nil { - return nil - } - return json.Unmarshal(resp.Body, &out) -} - // DecodeHTTPResponseBody checks status code, reads an http.Response's Body and decodes it into the provided interface. func DecodeHTTPResponseBody(ctx context.Context, out any, resp *http.Response) error { - defer CloseBody(resp) + defer resp.Body.Close() // Check if status code indicates success if resp.StatusCode < 200 || resp.StatusCode >= 300 { @@ -200,33 +188,32 @@ func DecodeHTTPResponseBody(ctx context.Context, out any, resp *http.Response) e return nil } -func GetAttachment(ctx context.Context, path string, cdnNumber uint32) (*http.Response, error) { +// Download an attachment from the CDN +func GetAttachment(ctx context.Context, path string, cdnNumber uint32, opt *HTTPReqOpt) (*http.Response, error) { log := zerolog.Ctx(ctx).With(). Str("action", "get_attachment"). Str("path", path). Uint32("cdn_number", cdnNumber). Logger() - var host string - if int(cdnNumber) > len(CDNHosts) { - log.Warn().Msg("Invalid CDN index") - host = CDN1Hostname - } else { - host = CDNHosts[cdnNumber] + if opt == nil { + opt = &HTTPReqOpt{} } - if cdnNumber == 0 { - // This is basically a fallback if cdnNumber is not set, - // but it also seems to be the right host if cdnNumber == 0 - host = CDNHosts[0] - } else if cdnNumber > 0 && int(cdnNumber) <= len(CDNHosts) { - // Pull CDN hosts from array (cdnNumber is 1-indexed, but we have a placeholder host at index 0) - // (the 1-indexed is just an assumption, other clients seem to only explicitly handle cdnNumber == 0 and 2) - host = CDNHosts[cdnNumber] - } else { - host = CDNHosts[0] - log.Warn().Msg("Invalid CDN index") + if opt.Host == "" { + if cdnNumber == 0 { + // This is basically a fallback if cdnNumber is not set + // but it also seems to be the right host if cdnNumber == 0 + opt.Host = CDNHosts[0] + } else if cdnNumber > 0 && int(cdnNumber) <= len(CDNHosts) { + // Pull CDN hosts from array (cdnNumber is 1-indexed, but we have a placeholder host at index 0) + // (the 1-indexed is just an assumption, other clients seem to only explicitly handle cdnNumber == 0 and 2) + opt.Host = CDNHosts[cdnNumber] + } else { + opt.Host = CDNHosts[0] + log.Warn().Msg("Invalid CDN index") + } } - log.Debug().Str("host", host).Msg("getting attachment") - urlStr := "https://" + host + path + log.Debug().Str("host", opt.Host).Msg("getting attachment") + urlStr := "https://" + opt.Host + path req, err := http.NewRequest(http.MethodGet, urlStr, nil) if err != nil { return nil, err @@ -235,7 +222,6 @@ func GetAttachment(ctx context.Context, path string, cdnNumber uint32) (*http.Re //const SERVICE_REFLECTOR_HOST = "europe-west1-signal-cdn-reflector.cloudfunctions.net" //req.Header.Add("Host", SERVICE_REFLECTOR_HOST) req.Header.Add("Content-Type", "application/octet-stream") - req.Header.Set("User-Agent", UserAgent) httpReqCounter++ log = log.With(). @@ -244,14 +230,14 @@ func GetAttachment(ctx context.Context, path string, cdnNumber uint32) (*http.Re Logger() log.Debug().Msg("Sending Attachment HTTP request") - resp, err := SignalHTTPClient.Do(req) + resp, err := signalHTTPClient.Do(req) if err != nil { return nil, err } - log.Debug(). - Int("status_code", resp.StatusCode). - Int64("content_length", resp.ContentLength). - Msg("Received Attachment HTTP response") + log.Debug().Msg("Received Attachment HTTP response") return resp, err } + +// Upload an attachment to the CDN +//func PutAttachment( diff --git a/pkg/signalmeow/wspb/wspb.go b/pkg/signalmeow/wspb/wspb.go index 2c2ccd8..c58628f 100644 --- a/pkg/signalmeow/wspb/wspb.go +++ b/pkg/signalmeow/wspb/wspb.go @@ -8,8 +8,8 @@ import ( "fmt" "sync" - "github.com/coder/websocket" "google.golang.org/protobuf/proto" + "nhooyr.io/websocket" ) // Read reads a protobuf message from c into v. diff --git a/portal.go b/portal.go new file mode 100644 index 0000000..72248ab --- /dev/null +++ b/portal.go @@ -0,0 +1,1653 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2023 Scott Weber, Tulir Asokan +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package main + +import ( + "bytes" + "context" + "errors" + "fmt" + "image" + "reflect" + "strings" + "sync" + "time" + + "github.com/google/uuid" + "github.com/rs/zerolog" + "go.mau.fi/util/jsontime" + "go.mau.fi/util/variationselector" + "google.golang.org/protobuf/proto" + "maunium.net/go/mautrix" + "maunium.net/go/mautrix/appservice" + "maunium.net/go/mautrix/bridge" + "maunium.net/go/mautrix/bridge/bridgeconfig" + "maunium.net/go/mautrix/bridge/status" + "maunium.net/go/mautrix/crypto/attachment" + "maunium.net/go/mautrix/event" + "maunium.net/go/mautrix/id" + + "go.mau.fi/mautrix-signal/database" + "go.mau.fi/mautrix-signal/msgconv" + "go.mau.fi/mautrix-signal/msgconv/matrixfmt" + "go.mau.fi/mautrix-signal/msgconv/signalfmt" + "go.mau.fi/mautrix-signal/pkg/signalmeow" + "go.mau.fi/mautrix-signal/pkg/signalmeow/events" + signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" + "go.mau.fi/mautrix-signal/pkg/signalmeow/types" +) + +type portalSignalMessage struct { + evt *events.ChatEvent + user *User +} + +type portalMatrixMessage struct { + evt *event.Event + user *User +} + +type Portal struct { + *database.Portal + + MsgConv *msgconv.MessageConverter + + bridge *SignalBridge + log zerolog.Logger + + roomCreateLock sync.Mutex + encryptLock sync.Mutex + + signalMessages chan portalSignalMessage + matrixMessages chan portalMatrixMessage + + currentlyTyping []id.UserID + currentlyTypingLock sync.Mutex + + latestReadTimestamp uint64 // Cache the latest read timestamp to avoid unnecessary read receipts + + relayUser *User +} + +const recentMessageBufferSize = 32 + +func init() { + event.TypeMap[event.StateBridge] = reflect.TypeOf(CustomBridgeInfoContent{}) + event.TypeMap[event.StateHalfShotBridge] = reflect.TypeOf(CustomBridgeInfoContent{}) +} + +// ** Interfaces that Portal implements ** + +var _ bridge.Portal = (*Portal)(nil) + +var _ bridge.ReadReceiptHandlingPortal = (*Portal)(nil) +var _ bridge.TypingPortal = (*Portal)(nil) +var _ bridge.DisappearingPortal = (*Portal)(nil) + +//var _ bridge.MembershipHandlingPortal = (*Portal)(nil) +//var _ bridge.MetaHandlingPortal = (*Portal)(nil) + +// ** bridge.Portal Interface ** + +func (portal *Portal) IsEncrypted() bool { + return portal.Encrypted +} + +func (portal *Portal) MarkEncrypted() { + portal.Encrypted = true + err := portal.Update(context.TODO()) + if err != nil { + portal.log.Err(err).Msg("Failed to update portal in database after marking as encrypted") + } +} + +func (portal *Portal) ReceiveMatrixEvent(user bridge.User, evt *event.Event) { + if user.GetPermissionLevel() >= bridgeconfig.PermissionLevelUser || portal.HasRelaybot() { + portal.matrixMessages <- portalMatrixMessage{user: user.(*User), evt: evt} + } +} + +func (portal *Portal) GetRelayUser() *User { + if !portal.HasRelaybot() { + return nil + } else if portal.relayUser == nil { + portal.relayUser = portal.bridge.GetUserByMXID(portal.RelayUserID) + } + return portal.relayUser +} + +func isUUID(s string) bool { + if _, uuidErr := uuid.Parse(s); uuidErr == nil { + return true + } + return false +} + +func (portal *Portal) IsPrivateChat() bool { + // If ChatID is a UUID, it's a private chat, otherwise it's base64 and a group chat + return isUUID(portal.ChatID) +} + +func (portal *Portal) MainIntent() *appservice.IntentAPI { + if portal.IsPrivateChat() { + return portal.bridge.GetPuppetBySignalID(portal.UserID()).DefaultIntent() + } + + return portal.bridge.Bot +} + +type CustomBridgeInfoContent struct { + event.BridgeEventContent + RoomType string `json:"com.beeper.room_type,omitempty"` +} + +func (portal *Portal) getBridgeInfo() (string, CustomBridgeInfoContent) { + bridgeInfo := event.BridgeEventContent{ + BridgeBot: portal.bridge.Bot.UserID, + Creator: portal.MainIntent().UserID, + Protocol: event.BridgeInfoSection{ + ID: "signal", + DisplayName: "Signal", + AvatarURL: portal.bridge.Config.AppService.Bot.ParsedAvatar.CUString(), + ExternalURL: "https://signal.org/", + }, + Channel: event.BridgeInfoSection{ + ID: portal.ChatID, + DisplayName: portal.Name, + AvatarURL: portal.AvatarURL.CUString(), + }, + } + var bridgeInfoStateKey string + bridgeInfoStateKey = fmt.Sprintf("fi.mau.signal://signal/%s", portal.ChatID) + bridgeInfo.Channel.ExternalURL = fmt.Sprintf("https://signal.me/#p/%s", portal.ChatID) + var roomType string + if portal.IsPrivateChat() { + roomType = "dm" + } + return bridgeInfoStateKey, CustomBridgeInfoContent{bridgeInfo, roomType} +} + +func (portal *Portal) UpdateBridgeInfo() { + if len(portal.MXID) == 0 { + portal.log.Debug().Msg("Not updating bridge info: no Matrix room created") + return + } + portal.log.Debug().Msg("Updating bridge info...") + stateKey, content := portal.getBridgeInfo() + _, err := portal.MainIntent().SendStateEvent(portal.MXID, event.StateBridge, stateKey, content) + if err != nil { + portal.log.Warn().Err(err).Msg("Failed to update m.bridge") + } + // TODO remove this once https://github.com/matrix-org/matrix-doc/pull/2346 is in spec + _, err = portal.MainIntent().SendStateEvent(portal.MXID, event.StateHalfShotBridge, stateKey, content) + if err != nil { + portal.log.Warn().Err(err).Msg("Failed to update uk.half-shot.bridge") + } +} + +// ** bridge.ChildOverride methods (for SignalBridge in main.go) ** + +func (br *SignalBridge) GetAllPortalsWithMXID() []*Portal { + portals, err := br.dbPortalsToPortals(br.DB.Portal.GetAllWithMXID(context.TODO())) + if err != nil { + br.ZLog.Err(err).Msg("Failed to get all portals with mxid") + return nil + } + return portals +} + +func (br *SignalBridge) GetAllIPortals() (iportals []bridge.Portal) { + portals, err := br.dbPortalsToPortals(br.DB.Portal.GetAllWithMXID(context.TODO())) + if err != nil { + br.ZLog.Err(err).Msg("Failed to get all portals with mxid") + return nil + } + iportals = make([]bridge.Portal, len(portals)) + for i, portal := range portals { + iportals[i] = portal + } + return iportals +} + +func (br *SignalBridge) dbPortalsToPortals(dbPortals []*database.Portal, err error) ([]*Portal, error) { + if err != nil { + return nil, err + } + br.portalsLock.Lock() + defer br.portalsLock.Unlock() + + output := make([]*Portal, len(dbPortals)) + for index, dbPortal := range dbPortals { + if dbPortal == nil { + continue + } + + portal, ok := br.portalsByID[dbPortal.PortalKey] + if !ok { + portal = br.loadPortal(context.TODO(), dbPortal, nil) + } + + output[index] = portal + } + + return output, nil +} + +// ** Portal Creation and Message Handling ** + +var signalFormatParams *signalfmt.FormatParams +var matrixFormatParams *matrixfmt.HTMLParser + +func (br *SignalBridge) NewPortal(dbPortal *database.Portal) *Portal { + portal := &Portal{ + Portal: dbPortal, + bridge: br, + log: br.ZLog.With().Str("chat_id", dbPortal.ChatID).Logger(), + + signalMessages: make(chan portalSignalMessage, br.Config.Bridge.PortalMessageBuffer), + matrixMessages: make(chan portalMatrixMessage, br.Config.Bridge.PortalMessageBuffer), + } + portal.MsgConv = &msgconv.MessageConverter{ + PortalMethods: portal, + SignalFmtParams: signalFormatParams, + MatrixFmtParams: matrixFormatParams, + ConvertVoiceMessages: true, + MaxFileSize: br.MediaConfig.UploadSize, + } + go portal.messageLoop() + + return portal +} + +func (portal *Portal) messageLoop() { + for { + select { + case msg := <-portal.matrixMessages: + portal.handleMatrixMessages(msg) + case msg := <-portal.signalMessages: + portal.handleSignalMessage(msg) + } + } +} + +func (portal *Portal) handleMatrixMessages(msg portalMatrixMessage) { + // If we have no SignalDevice, the bridge isn't logged in properly, + // so send BAD_CREDENTIALS so the user knows + if !msg.user.SignalDevice.IsDeviceLoggedIn() && !portal.HasRelaybot() { + go portal.sendMessageMetrics(msg.evt, errUserNotLoggedIn, "Ignoring", nil) + msg.user.BridgeState.Send(status.BridgeState{StateEvent: status.StateBadCredentials, Message: "You have been logged out of Signal, please reconnect"}) + return + } + log := portal.log.With(). + Str("action", "handle matrix event"). + Str("event_id", msg.evt.ID.String()). + Str("event_type", msg.evt.Type.String()). + Logger() + ctx := log.WithContext(context.TODO()) + + switch msg.evt.Type { + case event.EventMessage, event.EventSticker: + portal.handleMatrixMessage(ctx, msg.user, msg.evt) + case event.EventRedaction: + portal.handleMatrixRedaction(ctx, msg.user, msg.evt) + case event.EventReaction: + portal.handleMatrixReaction(ctx, msg.user, msg.evt) + default: + log.Warn().Str("type", msg.evt.Type.String()).Msg("Unhandled matrix message type") + } +} + +func (portal *Portal) handleMatrixMessage(ctx context.Context, sender *User, evt *event.Event) { + log := zerolog.Ctx(ctx) + evtTS := time.UnixMilli(evt.Timestamp) + timings := messageTimings{ + initReceive: evt.Mautrix.ReceivedAt.Sub(evtTS), + decrypt: evt.Mautrix.DecryptionDuration, + totalReceive: time.Since(evtTS), + } + implicitRRStart := time.Now() + // TODO send read receipt for previous messages + timings.implicitRR = time.Since(implicitRRStart) + start := time.Now() + + messageAge := timings.totalReceive + ms := metricSender{portal: portal, timings: &timings} + log.Debug(). + Str("sender", evt.Sender.String()). + Dur("age", messageAge). + Msg("Received message") + + errorAfter := portal.bridge.Config.Bridge.MessageHandlingTimeout.ErrorAfter + deadline := portal.bridge.Config.Bridge.MessageHandlingTimeout.Deadline + isScheduled, _ := evt.Content.Raw["com.beeper.scheduled"].(bool) + if isScheduled { + log.Debug().Msg("Message is a scheduled message, extending handling timeouts") + errorAfter *= 10 + deadline *= 10 + } + + if errorAfter > 0 { + remainingTime := errorAfter - messageAge + if remainingTime < 0 { + go ms.sendMessageMetrics(evt, errTimeoutBeforeHandling, "Timeout handling", true) + return + } else if remainingTime < 1*time.Second { + log.Warn(). + Dur("remaining_time", remainingTime). + Dur("max_timeout", errorAfter). + Msg("Message was delayed before reaching the bridge") + } + go func() { + time.Sleep(remainingTime) + ms.sendMessageMetrics(evt, errMessageTakingLong, "Timeout handling", false) + }() + } + + if deadline > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, deadline) + defer cancel() + } + + timings.preproc = time.Since(start) + start = time.Now() + + content, ok := evt.Content.Parsed.(*event.MessageEventContent) + if !ok { + log.Error().Type("content_type", content).Msg("Unexpected parsed content type") + go ms.sendMessageMetrics(evt, fmt.Errorf("%w %T", errUnexpectedParsedContentType, evt.Content.Parsed), "Error converting", true) + return + } + + realSenderMXID := sender.MXID + isRelay := false + if !sender.IsLoggedIn() { + if !portal.HasRelaybot() { + go ms.sendMessageMetrics(evt, errUserNotLoggedIn, "Error converting", true) + return + } + sender = portal.GetRelayUser() + if !sender.IsLoggedIn() { + go ms.sendMessageMetrics(evt, errRelaybotNotLoggedIn, "Error converting", true) + return + } + isRelay = true + } + + var editTargetMsg *database.Message + if editTarget := content.RelatesTo.GetReplaceID(); editTarget != "" { + var err error + editTargetMsg, err = portal.bridge.DB.Message.GetByMXID(ctx, editTarget) + if err != nil { + log.Err(err).Str("edit_target_mxid", editTarget.String()).Msg("Failed to get edit target message") + go ms.sendMessageMetrics(evt, errFailedToGetEditTarget, "Error converting", true) + return + } else if editTargetMsg == nil { + log.Err(err).Str("edit_target_mxid", editTarget.String()).Msg("Edit target message not found") + go ms.sendMessageMetrics(evt, errEditUnknownTarget, "Error converting", true) + return + } else if editTargetMsg.Sender != sender.SignalID { + go ms.sendMessageMetrics(evt, errEditDifferentSender, "Error converting", true) + return + } + if content.NewContent != nil { + content = content.NewContent + evt.Content.Parsed = content + } + } + + relaybotFormatted := isRelay && portal.addRelaybotFormat(realSenderMXID, evt, content) + if content.MsgType == event.MsgNotice && !portal.bridge.Config.Bridge.BridgeNotices { + go ms.sendMessageMetrics(evt, errMNoticeDisabled, "Error converting", true) + return + } + ctx = context.WithValue(ctx, msgconvContextKeyClient, sender.SignalDevice) + msg, err := portal.MsgConv.ToSignal(ctx, evt, content, relaybotFormatted) + if err != nil { + log.Err(err).Msg("Failed to convert message") + go ms.sendMessageMetrics(evt, err, "Error converting", true) + return + } + var wrappedMsg *signalpb.Content + if editTargetMsg == nil { + wrappedMsg = &signalpb.Content{ + DataMessage: msg, + } + } else { + wrappedMsg = &signalpb.Content{ + EditMessage: &signalpb.EditMessage{ + TargetSentTimestamp: proto.Uint64(editTargetMsg.Timestamp), + DataMessage: msg, + }, + } + } + + timings.convert = time.Since(start) + start = time.Now() + + err = portal.sendSignalMessage(ctx, wrappedMsg, sender, evt.ID) + + timings.totalSend = time.Since(start) + go ms.sendMessageMetrics(evt, err, "Error sending", true) + if err == nil { + if editTargetMsg != nil { + err = editTargetMsg.SetTimestamp(ctx, msg.GetTimestamp()) + if err != nil { + log.Err(err).Msg("Failed to update message timestamp in database after editing") + } + } else { + portal.storeMessageInDB(ctx, evt.ID, sender.SignalID, msg.GetTimestamp(), 0) + if portal.ExpirationTime > 0 { + portal.addDisappearingMessage(ctx, evt.ID, uint32(portal.ExpirationTime), true) + } + } + } +} + +func (portal *Portal) handleMatrixRedaction(ctx context.Context, sender *User, evt *event.Event) { + log := zerolog.Ctx(ctx) + // Find the original signal message based on eventID + dbMessage, err := portal.bridge.DB.Message.GetByMXID(ctx, evt.Redacts) + if err != nil { + log.Err(err).Msg("Failed to get redaction target message") + } + // Might be a reaction redaction, find the original message for the reaction + dbReaction, err := portal.bridge.DB.Reaction.GetByMXID(ctx, evt.Redacts) + if err != nil { + log.Err(err).Msg("Failed to get redaction target reaction") + } + + if !sender.IsLoggedIn() { + sender = portal.GetRelayUser() + } + + if dbMessage != nil { + if dbMessage.Sender != sender.SignalID { + portal.sendMessageStatusCheckpointFailed(evt, errRedactionTargetSentBySomeoneElse) + return + } + msg := signalmeow.DataMessageForDelete(dbMessage.Timestamp) + err = portal.sendSignalMessage(ctx, msg, sender, evt.ID) + if err != nil { + portal.sendMessageStatusCheckpointFailed(evt, err) + log.Err(err).Msg("Failed to send message redaction to Signal") + return + } + err = dbMessage.Delete(ctx) + if err != nil { + log.Err(err).Msg("Failed to delete redacted message from database") + } else if otherParts, err := portal.bridge.DB.Message.GetAllPartsBySignalID(ctx, dbMessage.Sender, dbMessage.Timestamp, portal.Receiver); err != nil { + log.Err(err).Msg("Failed to get other parts of redacted message from database") + } else if len(otherParts) > 0 { + // If there are other parts of the message, send a redaction for each of them + for _, otherPart := range otherParts { + _, err = portal.MainIntent().RedactEvent(portal.MXID, otherPart.MXID, mautrix.ReqRedact{ + Reason: "Other part of Signal message redacted", + TxnID: "mxsg_partredact_" + otherPart.MXID.String(), + }) + if err != nil { + log.Err(err). + Str("part_event_id", otherPart.MXID.String()). + Int("part_index", otherPart.PartIndex). + Msg("Failed to redact other part of redacted message") + } + err = otherPart.Delete(ctx) + if err != nil { + log.Err(err). + Str("part_event_id", otherPart.MXID.String()). + Int("part_index", otherPart.PartIndex). + Msg("Failed to delete other part of redacted message from database") + } + } + } + portal.sendMessageStatusCheckpointSuccess(evt) + } else if dbReaction != nil { + if dbReaction.Author != sender.SignalID { + portal.sendMessageStatusCheckpointFailed(evt, errUnreactTargetSentBySomeoneElse) + return + } + msg := signalmeow.DataMessageForReaction(dbReaction.Emoji, dbReaction.MsgAuthor, dbReaction.MsgTimestamp, true) + err = portal.sendSignalMessage(ctx, msg, sender, evt.ID) + if err != nil { + portal.sendMessageStatusCheckpointFailed(evt, err) + log.Err(err).Msg("Failed to send reaction redaction to Signal") + return + } + err = dbReaction.Delete(ctx) + if err != nil { + log.Err(err).Msg("Failed to delete redacted reaction from database") + } + portal.sendMessageStatusCheckpointSuccess(evt) + } else { + portal.sendMessageStatusCheckpointFailed(evt, errRedactionTargetNotFound) + } +} + +func (portal *Portal) handleMatrixReaction(ctx context.Context, sender *User, evt *event.Event) { + log := zerolog.Ctx(ctx) + if !sender.IsLoggedIn() { + log.Error().Msg("Cannot relay reaction from non-logged-in user. Ignoring") + return + } + // Find the original signal message based on eventID + relatedEventID := evt.Content.AsReaction().RelatesTo.EventID + targetMsg, err := portal.bridge.DB.Message.GetByMXID(ctx, relatedEventID) + if err != nil { + portal.sendMessageStatusCheckpointFailed(evt, err) + log.Err(err).Msg("Failed to get reaction target message") + return + } else if targetMsg == nil { + portal.sendMessageStatusCheckpointFailed(evt, errReactionTargetNotFound) + log.Warn().Msg("Reaction target message not found") + return + } + emoji := evt.Content.AsReaction().RelatesTo.Key + signalEmoji := variationselector.FullyQualify(emoji) // Signal seems to require fully qualified emojis + msg := signalmeow.DataMessageForReaction(signalEmoji, targetMsg.Sender, targetMsg.Timestamp, false) + err = portal.sendSignalMessage(ctx, msg, sender, evt.ID) + if err != nil { + portal.sendMessageStatusCheckpointFailed(evt, err) + portal.log.Error().Msgf("Failed to send reaction %s", evt.ID) + return + } + + // Signal only allows one reaction from each user + // Check if there's an existing reaction in the database for this sender and redact/delete it + dbReaction, err := portal.bridge.DB.Reaction.GetBySignalID( + ctx, + targetMsg.Sender, + targetMsg.Timestamp, + sender.SignalID, + portal.Receiver, + ) + if err != nil { + log.Err(err).Msg("Failed to get existing reaction from database") + } else if dbReaction != nil { + log.Debug().Str("existing_event_id", dbReaction.MXID.String()).Msg("Redacting existing reaction after sending new one") + _, err = portal.MainIntent().RedactEvent(portal.MXID, dbReaction.MXID) + if err != nil { + log.Err(err).Msg("Failed to redact existing reaction") + } + } + if dbReaction != nil { + dbReaction.MXID = evt.ID + dbReaction.Emoji = signalEmoji + err = dbReaction.Update(ctx) + if err != nil { + log.Err(err).Msg("Failed to update reaction in database") + } + } else { + dbReaction = portal.bridge.DB.Reaction.New() + dbReaction.MXID = evt.ID + dbReaction.RoomID = portal.MXID + dbReaction.SignalChatID = portal.ChatID + dbReaction.SignalReceiver = portal.Receiver + dbReaction.Author = sender.SignalID + dbReaction.MsgAuthor = targetMsg.Sender + dbReaction.MsgTimestamp = targetMsg.Timestamp + dbReaction.Emoji = signalEmoji + err = dbReaction.Insert(ctx) + if err != nil { + log.Err(err).Msg("Failed to insert reaction to database") + } + } + + portal.sendMessageStatusCheckpointSuccess(evt) +} + +func (portal *Portal) sendSignalMessage(ctx context.Context, msg *signalpb.Content, sender *User, evtID id.EventID) error { + log := zerolog.Ctx(ctx).With(). + Str("action", "send_signal_message"). + Str("event_id", evtID.String()). + Str("portal_chat_id", portal.ChatID). + Logger() + ctx = log.WithContext(ctx) + + log.Debug().Msg("Sending event to Signal") + + // Check to see if portal.ChatID is a standard UUID (with dashes) + var err error + if _, uuidErr := uuid.Parse(portal.ChatID); uuidErr == nil { + // this is a 1:1 chat + result := signalmeow.SendMessage(ctx, sender.SignalDevice, portal.ChatID, msg) + if !result.WasSuccessful { + err = result.FailedSendResult.Error + log.Err(err).Msg("Error sending event to Signal") + } + } else { + // this is a group chat + groupID := types.GroupIdentifier(portal.ChatID) + result, err := signalmeow.SendGroupMessage(ctx, sender.SignalDevice, groupID, msg) + if err != nil { + // check the start of the error string, see if it starts with "No group master key found for group identifier" + if strings.HasPrefix(err.Error(), "No group master key found for group identifier") { + portal.MainIntent().SendNotice(portal.MXID, "Missing group encryption key. Please ask a group member to send a message in this chat, then retry sending.") + } + log.Err(err).Msg("Error sending event to Signal group") + return err + } + totalRecipients := len(result.FailedToSendTo) + len(result.SuccessfullySentTo) + log = log.With(). + Int("total_recipients", totalRecipients). + Int("failed_to_send_to_count", len(result.FailedToSendTo)). + Int("successfully_sent_to_count", len(result.SuccessfullySentTo)). + Logger() + if len(result.FailedToSendTo) > 0 { + log.Error().Msg("Failed to send event to some members of Signal group") + } + if len(result.SuccessfullySentTo) == 0 && len(result.FailedToSendTo) == 0 { + log.Debug().Msg("No successes or failures - Probably sent to myself") + } else if len(result.SuccessfullySentTo) == 0 { + log.Error().Msg("Failed to send event to all members of Signal group") + err = errors.New("failed to send to any members of Signal group") + } else if len(result.SuccessfullySentTo) < totalRecipients { + log.Warn().Msg("Only sent event to some members of Signal group") + } else { + log.Debug().Msgf("Sent event to all members of Signal group") + } + } + return err +} + +func (portal *Portal) sendMessageStatusCheckpointSuccess(evt *event.Event) { + portal.sendDeliveryReceipt(evt.ID) + portal.bridge.SendMessageSuccessCheckpoint(evt, status.MsgStepRemote, 0) + + var deliveredTo *[]id.UserID + if portal.IsPrivateChat() { + deliveredTo = &[]id.UserID{} + } + portal.sendStatusEvent(evt.ID, "", nil, deliveredTo) +} + +func (portal *Portal) sendMessageStatusCheckpointFailed(evt *event.Event, err error) { + portal.sendDeliveryReceipt(evt.ID) + portal.bridge.SendMessageErrorCheckpoint(evt, status.MsgStepRemote, err, true, 0) + portal.sendStatusEvent(evt.ID, "", err, nil) +} + +type msgconvContextKey int + +const ( + msgconvContextKeyIntent msgconvContextKey = iota + msgconvContextKeyClient +) + +func (portal *Portal) UploadMatrixMedia(ctx context.Context, data []byte, fileName, contentType string) (id.ContentURIString, error) { + intent := ctx.Value(msgconvContextKeyIntent).(*appservice.IntentAPI) + req := mautrix.ReqUploadMedia{ + ContentBytes: data, + ContentType: contentType, + FileName: fileName, + } + if portal.bridge.Config.Homeserver.AsyncMedia { + uploaded, err := intent.UploadAsync(req) + if err != nil { + return "", err + } + return uploaded.ContentURI.CUString(), nil + } else { + uploaded, err := intent.UploadMedia(req) + if err != nil { + return "", err + } + return uploaded.ContentURI.CUString(), nil + } +} + +func (portal *Portal) DownloadMatrixMedia(ctx context.Context, uriString id.ContentURIString) ([]byte, error) { + parsedURI, err := uriString.Parse() + if err != nil { + return nil, fmt.Errorf("malformed content URI: %w", err) + } + return portal.MainIntent().DownloadBytesContext(ctx, parsedURI) +} + +func (portal *Portal) GetData(ctx context.Context) *database.Portal { + return portal.Portal +} + +func (portal *Portal) GetClient(ctx context.Context) *signalmeow.Device { + return ctx.Value(msgconvContextKeyClient).(*signalmeow.Device) +} + +func (portal *Portal) GetMatrixReply(ctx context.Context, msg *signalpb.DataMessage_Quote) (replyTo id.EventID, replyTargetSender id.UserID) { + if msg == nil { + return + } + log := zerolog.Ctx(ctx).With(). + Str("reply_target_author", msg.GetAuthorAci()). + Uint64("reply_target_ts", msg.GetId()). + Logger() + if senderUUID, err := uuid.Parse(msg.GetAuthorAci()); err != nil { + log.Err(err).Msg("Failed to parse sender UUID in Signal quote") + } else if message, err := portal.bridge.DB.Message.GetBySignalID(ctx, senderUUID, msg.GetId(), 0, portal.Receiver); err != nil { + log.Err(err).Msg("Failed to get reply target message from database") + } else if message == nil { + log.Warn().Msg("Reply target message not found") + } else { + replyTo = message.MXID + targetUser := portal.bridge.GetUserBySignalID(message.Sender) + if targetUser != nil { + replyTargetSender = targetUser.MXID + } else { + replyTargetSender = portal.bridge.FormatPuppetMXID(message.Sender) + } + } + return +} + +func (portal *Portal) GetSignalReply(ctx context.Context, content *event.MessageEventContent) *signalpb.DataMessage_Quote { + replyToID := content.RelatesTo.GetReplyTo() + if len(replyToID) == 0 { + return nil + } + replyToMsg, err := portal.bridge.DB.Message.GetByMXID(ctx, replyToID) + if err != nil { + zerolog.Ctx(ctx).Err(err). + Str("reply_to_mxid", replyToID.String()). + Msg("Failed to get reply target message from database") + } else if replyToMsg == nil { + zerolog.Ctx(ctx).Warn(). + Str("reply_to_mxid", replyToID.String()). + Msg("Reply target message not found") + } else { + return &signalpb.DataMessage_Quote{ + Id: proto.Uint64(replyToMsg.Timestamp), + AuthorAci: proto.String(replyToMsg.Sender.String()), + Type: signalpb.DataMessage_Quote_NORMAL.Enum(), + + // This is a hack to make Signal iOS and desktop render replies to file messages. + // Unfortunately it also makes Signal Desktop show a file icon on replies to text messages. + // TODO store file or text flag in database and fill this field only when replying to file messages. + Attachments: make([]*signalpb.DataMessage_Quote_QuotedAttachment, 0), + } + } + return nil +} + +func (portal *Portal) handleSignalMessage(portalMessage portalSignalMessage) { + sender := portal.bridge.GetPuppetBySignalID(portalMessage.evt.Info.Sender) + if sender == nil { + portal.log.Warn(). + Str("sender_uuid", portalMessage.evt.Info.Sender.String()). + Msg("Couldn't get puppet for message") + return + } + switch typedEvt := portalMessage.evt.Event.(type) { + case *signalpb.DataMessage: + portal.handleSignalDataMessage(portalMessage.user, sender, typedEvt) + case *signalpb.TypingMessage: + portal.handleSignalTypingMessage(sender, typedEvt) + case *signalpb.EditMessage: + portal.handleSignalEditMessage(sender, typedEvt.GetTargetSentTimestamp(), typedEvt.GetDataMessage()) + default: + portal.log.Error(). + Type("data_type", typedEvt). + Msg("Invalid inner event type inside ChatEvent") + } +} + +func (portal *Portal) handleSignalDataMessage(source *User, sender *Puppet, msg *signalpb.DataMessage) { + // FIXME hacky + updatePuppetWithSignalContact(context.TODO(), source, sender, nil) + + switch { + case msgconv.CanConvertSignal(msg): + portal.handleSignalNormalDataMessage(source, sender, msg) + case msg.Reaction != nil: + portal.handleSignalReaction(sender, msg.Reaction, msg.GetTimestamp()) + case msg.Delete != nil: + portal.handleSignalDelete(sender, msg.Delete, msg.GetTimestamp()) + case msg.StoryContext != nil, msg.GroupCallUpdate != nil: + // ignore + default: + portal.log.Warn(). + Str("action", "handle signal message"). + Str("sender_uuid", sender.SignalID.String()). + Uint64("msg_ts", msg.GetTimestamp()). + Msg("Unrecognized content in message") + } +} + +func (portal *Portal) handleSignalReaction(sender *Puppet, react *signalpb.DataMessage_Reaction, ts uint64) { + log := portal.log.With(). + Str("action", "handle signal reaction"). + Str("sender_uuid", sender.SignalID.String()). + Uint64("target_msg_ts", react.GetTargetSentTimestamp()). + Str("target_msg_sender", react.GetTargetAuthorAci()). + Bool("remove", react.GetRemove()). + Logger() + ctx := log.WithContext(context.TODO()) + targetSenderUUID, err := uuid.Parse(react.GetTargetAuthorAci()) + if err != nil { + log.Err(err).Msg("Failed to parse target message sender UUID") + return + } + targetMsg, err := portal.bridge.DB.Message.GetBySignalID(ctx, targetSenderUUID, react.GetTargetSentTimestamp(), 0, portal.Receiver) + if err != nil { + log.Err(err).Msg("Failed to get target message from database") + return + } else if targetMsg == nil { + log.Warn().Msg("Target message not found") + return + } + existingReaction, err := portal.bridge.DB.Reaction.GetBySignalID(ctx, targetMsg.Sender, targetMsg.Timestamp, sender.SignalID, portal.Receiver) + if err != nil { + log.Err(err).Msg("Failed to get existing reaction from database") + return + } + intent := sender.IntentFor(portal) + if existingReaction != nil { + _, err = intent.RedactEvent(portal.MXID, existingReaction.MXID, mautrix.ReqRedact{ + TxnID: "mxsg_unreact_" + existingReaction.MXID.String(), + }) + if err != nil { + log.Err(err).Msg("Failed to redact reaction") + } + if react.GetRemove() { + err = existingReaction.Delete(ctx) + if err != nil { + log.Err(err).Msg("Failed to remove reaction from database after redacting") + } + return + } + } else if react.GetRemove() { + log.Warn().Msg("Existing reaction for removal not found") + return + } + // Create a new message event with the reaction + content := &event.ReactionEventContent{ + RelatesTo: event.RelatesTo{ + Type: event.RelAnnotation, + Key: variationselector.Add(react.GetEmoji()), + EventID: targetMsg.MXID, + }, + } + resp, err := portal.sendMatrixEvent(intent, event.EventReaction, content, nil, int64(ts)) + if err != nil { + log.Err(err).Msg("Failed to send reaction") + return + } + if existingReaction == nil { + dbReaction := portal.bridge.DB.Reaction.New() + dbReaction.MXID = resp.EventID + dbReaction.RoomID = portal.MXID + dbReaction.SignalChatID = portal.ChatID + dbReaction.SignalReceiver = portal.Receiver + dbReaction.Author = sender.SignalID + dbReaction.MsgAuthor = targetMsg.Sender + dbReaction.MsgTimestamp = targetMsg.Timestamp + dbReaction.Emoji = react.GetEmoji() + err = dbReaction.Insert(ctx) + if err != nil { + log.Err(err).Msg("Failed to insert reaction to database") + } + } else { + existingReaction.Emoji = react.GetEmoji() + existingReaction.MXID = resp.EventID + err = existingReaction.Update(ctx) + if err != nil { + log.Err(err).Msg("Failed to update reaction in database") + } + } +} + +func (portal *Portal) handleSignalDelete(sender *Puppet, delete *signalpb.DataMessage_Delete, ts uint64) { + log := portal.log.With(). + Str("action", "handle signal delete"). + Str("sender_uuid", sender.SignalID.String()). + Uint64("target_msg_ts", delete.GetTargetSentTimestamp()). + Uint64("delete_ts", ts). + Logger() + ctx := log.WithContext(context.TODO()) + targetMsg, err := portal.bridge.DB.Message.GetAllPartsBySignalID(ctx, sender.SignalID, delete.GetTargetSentTimestamp(), portal.Receiver) + if err != nil { + log.Err(err).Msg("Failed to get target message from database") + return + } else if len(targetMsg) == 0 { + log.Warn().Msg("Target message not found") + return + } + intent := sender.IntentFor(portal) + for _, part := range targetMsg { + _, err = intent.RedactEvent(portal.MXID, part.MXID, mautrix.ReqRedact{ + TxnID: "mxsg_delete_" + part.MXID.String(), + }) + if err != nil { + log.Err(err). + Int("part_index", part.PartIndex). + Str("event_id", part.MXID.String()). + Msg("Failed to redact message") + } + err = part.Delete(ctx) + if err != nil { + log.Err(err). + Int("part_index", part.PartIndex). + Msg("Failed to delete message from database") + } + } +} + +func (portal *Portal) handleSignalNormalDataMessage(source *User, sender *Puppet, msg *signalpb.DataMessage) { + log := portal.log.With(). + Str("action", "handle signal message"). + Str("sender_uuid", sender.SignalID.String()). + Uint64("msg_ts", msg.GetTimestamp()). + Logger() + ctx := log.WithContext(context.TODO()) + if portal.MXID == "" { + log.Debug().Msg("Creating Matrix room from incoming message") + if err := portal.CreateMatrixRoom(source, nil); err != nil { + log.Error().Err(err).Msg("Failed to create portal room") + return + } + // FIXME hacky + ensureGroupPuppetsAreJoinedToPortal(context.Background(), source, portal) + signalmeow.SendContactSyncRequest(context.TODO(), source.SignalDevice) + } + + existingMessage, err := portal.bridge.DB.Message.GetBySignalID(ctx, sender.SignalID, msg.GetTimestamp(), 0, portal.Receiver) + if err != nil { + log.Err(err).Msg("Failed to check if message was already bridged") + return + } else if existingMessage != nil { + log.Debug().Msg("Ignoring duplicate message") + return + } + + intent := sender.IntentFor(portal) + ctx = context.WithValue(ctx, msgconvContextKeyIntent, intent) + converted := portal.MsgConv.ToMatrix(ctx, msg) + if portal.bridge.Config.Bridge.CaptionInMessage { + converted.MergeCaption() + } + for i, part := range converted.Parts { + resp, err := portal.sendMatrixEvent(intent, part.Type, part.Content, part.Extra, int64(converted.Timestamp)) + if err != nil { + log.Err(err).Int("part_index", i).Msg("Failed to send message to Matrix") + continue + } + portal.storeMessageInDB(ctx, resp.EventID, sender.SignalID, converted.Timestamp, i) + if converted.DisappearIn != 0 { + portal.addDisappearingMessage(ctx, resp.EventID, converted.DisappearIn, sender.SignalID == source.SignalID) + } + } +} + +func (portal *Portal) handleSignalEditMessage(sender *Puppet, timestamp uint64, msg *signalpb.DataMessage) { + log := portal.log.With(). + Str("action", "handle signal edit"). + Str("sender_uuid", sender.SignalID.String()). + Uint64("target_msg_ts", timestamp). + Uint64("edit_msg_ts", msg.GetTimestamp()). + Logger() + if portal.MXID == "" { + log.Debug().Msg("Dropping edit message in chat with no portal") + return + } + ctx := log.WithContext(context.TODO()) + targetMessage, err := portal.bridge.DB.Message.GetAllPartsBySignalID(ctx, sender.SignalID, timestamp, portal.Receiver) + if err != nil { + log.Err(err).Msg("Failed to get target message") + return + } else if len(targetMessage) == 0 { + log.Debug().Msg("Target message not found (edit may have been already handled)") + return + } + + intent := sender.IntentFor(portal) + ctx = context.WithValue(ctx, msgconvContextKeyIntent, intent) + converted := portal.MsgConv.ToMatrix(ctx, msg) + if portal.bridge.Config.Bridge.CaptionInMessage { + converted.MergeCaption() + } + if len(converted.Parts) != len(targetMessage) { + log.Error(). + Int("target_parts", len(targetMessage)). + Int("new_parts", len(converted.Parts)). + Msg("Mismatched number of parts in edit") + return + } + for i, part := range converted.Parts { + part.Content.SetEdit(targetMessage[i].MXID) + if part.Extra != nil { + part.Extra = map[string]any{ + "m.new_content": part.Extra, + } + } + _, err = portal.sendMatrixEvent(intent, part.Type, part.Content, part.Extra, int64(converted.Timestamp)) + if err != nil { + log.Err(err).Int("part_index", i).Msg("Failed to send edit to Matrix") + } + } + err = targetMessage[0].SetTimestamp(ctx, msg.GetTimestamp()) + if err != nil { + log.Err(err).Msg("Failed to update message edit timestamp in database") + } +} + +const SignalTypingTimeout = 15 * time.Second + +func (portal *Portal) handleSignalTypingMessage(sender *Puppet, msg *signalpb.TypingMessage) { + if portal.MXID == "" { + portal.log.Debug().Msg("Dropping typing message in chat with no portal") + return + } + intent := sender.IntentFor(portal) + // Don't bridge double puppeted typing notifications to avoid echoing + if intent.IsCustomPuppet { + return + } + var err error + switch msg.GetAction() { + case signalpb.TypingMessage_STARTED: + _, err = intent.UserTyping(portal.MXID, true, SignalTypingTimeout) + case signalpb.TypingMessage_STOPPED: + _, err = intent.UserTyping(portal.MXID, false, 0) + } + if err != nil { + portal.log.Err(err). + Str("user_id", sender.SignalID.String()). + Msg("Failed to handle Signal typing notification") + } +} + +func (portal *Portal) storeMessageInDB(ctx context.Context, eventID id.EventID, senderSignalID uuid.UUID, timestamp uint64, partIndex int) { + dbMessage := portal.bridge.DB.Message.New() + dbMessage.MXID = eventID + dbMessage.RoomID = portal.MXID + dbMessage.Sender = senderSignalID + dbMessage.Timestamp = timestamp + dbMessage.PartIndex = partIndex + dbMessage.SignalChatID = portal.ChatID + dbMessage.SignalReceiver = portal.Receiver + err := dbMessage.Insert(ctx) + if err != nil { + portal.log.Err(err).Msg("Failed to insert message into database") + } +} + +func (portal *Portal) addDisappearingMessage(ctx context.Context, eventID id.EventID, expireInSeconds uint32, startTimerNow bool) { + portal.bridge.disappearingMessagesManager.AddDisappearingMessage(ctx, eventID, portal.MXID, time.Duration(expireInSeconds)*time.Second, startTimerNow) +} + +func (portal *Portal) MarkDelivered(msg *database.Message) { + if !portal.IsPrivateChat() { + return + } + portal.bridge.SendRawMessageCheckpoint(&status.MessageCheckpoint{ + EventID: msg.MXID, + RoomID: portal.MXID, + Step: status.MsgStepRemote, + Timestamp: jsontime.UnixMilliNow(), + Status: status.MsgStatusDelivered, + ReportedBy: status.MsgReportedByBridge, + }) + portal.sendStatusEvent(msg.MXID, "", nil, &[]id.UserID{portal.MainIntent().UserID}) +} + +type customReadReceipt struct { + Timestamp int64 `json:"ts,omitempty"` + DoublePuppetSource string `json:"fi.mau.double_puppet_source,omitempty"` +} + +type customReadMarkers struct { + mautrix.ReqSetReadMarkers + ReadExtra customReadReceipt `json:"com.beeper.read.extra"` + FullyReadExtra customReadReceipt `json:"com.beeper.fully_read.extra"` +} + +func (portal *Portal) SendReadReceipt(sender *Puppet, msg *database.Message) error { + intent := sender.IntentFor(portal) + if intent.IsCustomPuppet { + extra := customReadReceipt{DoublePuppetSource: portal.bridge.Name} + return intent.SetReadMarkers(portal.MXID, &customReadMarkers{ + ReqSetReadMarkers: mautrix.ReqSetReadMarkers{ + Read: msg.MXID, + FullyRead: msg.MXID, + }, + ReadExtra: extra, + FullyReadExtra: extra, + }) + } else { + return intent.MarkRead(portal.MXID, msg.MXID) + } +} + +func typingDiff(prev, new []id.UserID) (started, stopped []id.UserID) { +OuterNew: + for _, userID := range new { + for _, previousUserID := range prev { + if userID == previousUserID { + continue OuterNew + } + } + started = append(started, userID) + } +OuterPrev: + for _, userID := range prev { + for _, previousUserID := range new { + if userID == previousUserID { + continue OuterPrev + } + } + stopped = append(stopped, userID) + } + return +} + +func (portal *Portal) setTyping(userIDs []id.UserID, isTyping bool) { + for _, userID := range userIDs { + user := portal.bridge.GetUserByMXID(userID) + if user == nil || !user.IsLoggedIn() { + continue + } + + // Check to see if portal.ChatID is a standard UUID (with dashes) + // Note: not handling sending to a group right now, since that will + // require SenderKey sending to not be terrible + var err error + if _, uuidErr := uuid.Parse(portal.ChatID); uuidErr == nil { + // this is a 1:1 chat + portal.log.Debug().Msgf("Sending Typing event to Signal %s", portal.ChatID) + ctx := context.Background() + typingMessage := signalmeow.TypingMessage(isTyping) + result := signalmeow.SendMessage(ctx, user.SignalDevice, portal.ChatID, typingMessage) + if !result.WasSuccessful { + err = result.FailedSendResult.Error + portal.log.Err(err).Msg("Error sending event to Signal") + } + } + } +} + +// mautrix-go TypingPortal interface +func (portal *Portal) HandleMatrixTyping(newTyping []id.UserID) { + portal.currentlyTypingLock.Lock() + defer portal.currentlyTypingLock.Unlock() + startedTyping, stoppedTyping := typingDiff(portal.currentlyTyping, newTyping) + portal.currentlyTyping = newTyping + portal.setTyping(startedTyping, true) + portal.setTyping(stoppedTyping, false) +} + +// mautrix-go ReadReceiptHandlingPortal interface +func (portal *Portal) HandleMatrixReadReceipt(sender bridge.User, eventID id.EventID, receipt event.ReadReceipt) { + log := portal.log.With(). + Str("action", "handle matrix read receipt"). + Str("event_id", eventID.String()). + Str("sender", sender.GetMXID().String()). + Logger() + log.Debug().Msg("Received read receipt") + portal.ScheduleDisappearing() + + // Find event in the DB + dbMessage, err := portal.bridge.DB.Message.GetByMXID(context.TODO(), eventID) + if err != nil { + log.Err(err).Msg("Failed to get read receipt target message") + return + } else if dbMessage == nil { + log.Debug().Msg("Read receipt target message not found") + return + } + // TODO find all messages that haven't been marked as read by the user + msg := signalmeow.ReadReceptMessageForTimestamps([]uint64{dbMessage.Timestamp}) + receiptDestination := dbMessage.Sender + receiptSender := sender.(*User) + + // Don't use portal.sendSignalMessage because we're sending this straight to + // who sent the original message, not the portal's ChatID + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + result := signalmeow.SendMessage(ctx, receiptSender.SignalDevice, receiptDestination.String(), msg) + if !result.WasSuccessful { + log.Err(result.FailedSendResult.Error). + Str("receipt_destination", receiptDestination.String()). + Msg("Failed to send read receipt to Signal") + } else { + log.Debug().Str("receipt_destination", receiptDestination.String()).Msg("Sent read receipt to Signal") + } +} + +func (portal *Portal) sendMainIntentMessage(content *event.MessageEventContent) (*mautrix.RespSendEvent, error) { + return portal.sendMatrixEvent(portal.MainIntent(), event.EventMessage, content, nil, 0) +} + +func (portal *Portal) encrypt(intent *appservice.IntentAPI, content *event.Content, eventType event.Type) (event.Type, error) { + if !portal.Encrypted || portal.bridge.Crypto == nil { + return eventType, nil + } + intent.AddDoublePuppetValue(content) + // TODO maybe the locking should be inside mautrix-go? + portal.encryptLock.Lock() + defer portal.encryptLock.Unlock() + err := portal.bridge.Crypto.Encrypt(portal.MXID, eventType, content) + if err != nil { + return eventType, fmt.Errorf("failed to encrypt event: %w", err) + } + return event.EventEncrypted, nil +} + +func (portal *Portal) encryptFileInPlace(data []byte, mimeType string) (string, *event.EncryptedFileInfo) { + if !portal.Encrypted { + return mimeType, nil + } + + file := &event.EncryptedFileInfo{ + EncryptedFile: *attachment.NewEncryptedFile(), + URL: "", + } + file.EncryptInPlace(data) + return "application/octet-stream", file +} + +func (portal *Portal) uploadMediaToMatrix(intent *appservice.IntentAPI, data []byte, content *event.MessageEventContent) error { + uploadMimeType, file := portal.encryptFileInPlace(data, content.Info.MimeType) + + req := mautrix.ReqUploadMedia{ + ContentBytes: data, + ContentType: uploadMimeType, + } + var mxc id.ContentURI + if portal.bridge.Config.Homeserver.AsyncMedia { + uploaded, err := intent.UploadAsync(req) + if err != nil { + return err + } + mxc = uploaded.ContentURI + } else { + uploaded, err := intent.UploadMedia(req) + if err != nil { + return err + } + mxc = uploaded.ContentURI + } + + if file != nil { + file.URL = mxc.CUString() + content.File = file + } else { + content.URL = mxc.CUString() + } + + content.Info.Size = len(data) + if content.Info.Width == 0 && content.Info.Height == 0 && strings.HasPrefix(content.Info.MimeType, "image/") { + cfg, _, _ := image.DecodeConfig(bytes.NewReader(data)) + content.Info.Width, content.Info.Height = cfg.Width, cfg.Height + } + + // This is a hack for bad clients like Element iOS that require a thumbnail (https://github.com/vector-im/element-ios/issues/4004) + if strings.HasPrefix(content.Info.MimeType, "image/") && content.Info.ThumbnailInfo == nil { + infoCopy := *content.Info + content.Info.ThumbnailInfo = &infoCopy + if content.File != nil { + content.Info.ThumbnailFile = file + } else { + content.Info.ThumbnailURL = content.URL + } + } + return nil +} + +func (portal *Portal) sendMatrixEvent(intent *appservice.IntentAPI, eventType event.Type, content any, extraContent map[string]any, timestamp int64) (*mautrix.RespSendEvent, error) { + wrappedContent := event.Content{Parsed: content, Raw: extraContent} + if eventType != event.EventReaction { + var err error + eventType, err = portal.encrypt(intent, &wrappedContent, eventType) + if err != nil { + return nil, err + } + } + + _, _ = intent.UserTyping(portal.MXID, false, 0) + return intent.SendMassagedMessageEvent(portal.MXID, eventType, &wrappedContent, timestamp) +} + +func (portal *Portal) getEncryptionEventContent() (evt *event.EncryptionEventContent) { + evt = &event.EncryptionEventContent{Algorithm: id.AlgorithmMegolmV1} + if rot := portal.bridge.Config.Bridge.Encryption.Rotation; rot.EnableCustom { + evt.RotationPeriodMillis = rot.Milliseconds + evt.RotationPeriodMessages = rot.Messages + } + return +} + +func (portal *Portal) shouldSetDMRoomMetadata() bool { + return !portal.IsPrivateChat() || + portal.bridge.Config.Bridge.PrivateChatPortalMeta == "always" || + (portal.IsEncrypted() && portal.bridge.Config.Bridge.PrivateChatPortalMeta != "never") +} + +func (portal *Portal) ensureUserInvited(user *User) bool { + return user.ensureInvited(portal.MainIntent(), portal.MXID, portal.IsPrivateChat()) +} + +func (portal *Portal) CreateMatrixRoom(user *User, meta *any) error { + portal.roomCreateLock.Lock() + defer portal.roomCreateLock.Unlock() + if portal.MXID != "" { + portal.log.Debug().Msg("Not creating room: already exists") + return nil + } + portal.log.Debug().Msg("Creating matrix room") + + intent := portal.MainIntent() + + if err := intent.EnsureRegistered(); err != nil { + portal.log.Error().Err(err).Msg("failed to ensure registered") + return err + } + + bridgeInfoStateKey, bridgeInfo := portal.getBridgeInfo() + initialState := []*event.Event{{ + Type: event.StateBridge, + Content: event.Content{Parsed: bridgeInfo}, + StateKey: &bridgeInfoStateKey, + }, { + // TODO remove this once https://github.com/matrix-org/matrix-doc/pull/2346 is in spec + Type: event.StateHalfShotBridge, + Content: event.Content{Parsed: bridgeInfo}, + StateKey: &bridgeInfoStateKey, + }} + + if !portal.AvatarURL.IsEmpty() { + initialState = append(initialState, &event.Event{ + Type: event.StateRoomAvatar, + Content: event.Content{Parsed: &event.RoomAvatarEventContent{ + URL: portal.AvatarURL, + }}, + }) + } + + creationContent := make(map[string]interface{}) + if !portal.bridge.Config.Bridge.FederateRooms { + creationContent["m.federate"] = false + } + + var invite []id.UserID + + if portal.bridge.Config.Bridge.Encryption.Default { + initialState = append(initialState, &event.Event{ + Type: event.StateEncryption, + Content: event.Content{ + Parsed: portal.getEncryptionEventContent(), + }, + }) + portal.Encrypted = true + + if portal.IsPrivateChat() { + invite = append(invite, portal.bridge.Bot.UserID) + } + } + + // FIXME slightly hacky + user.syncPortalInfo(portal) + + resp, err := intent.CreateRoom(&mautrix.ReqCreateRoom{ + Visibility: "private", + Name: portal.Name, + Topic: portal.Topic, + Invite: invite, + Preset: "private_chat", + IsDirect: portal.IsPrivateChat(), + InitialState: initialState, + CreationContent: creationContent, + }) + if err != nil { + portal.log.Warn().Err(err).Msg("failed to create room") + return err + } + + portal.NameSet = true + //portal.TopicSet = true + portal.AvatarSet = !portal.AvatarURL.IsEmpty() + portal.MXID = resp.RoomID + portal.bridge.portalsLock.Lock() + portal.bridge.portalsByMXID[portal.MXID] = portal + portal.bridge.portalsLock.Unlock() + err = portal.Update(context.TODO()) + if err != nil { + portal.log.Err(err).Msg("Failed to save created portal mxid") + } + portal.log.Info().Msgf("Created matrix room %s", portal.MXID) + + if portal.Encrypted && portal.IsPrivateChat() { + err = portal.bridge.Bot.EnsureJoined(portal.MXID, appservice.EnsureJoinedParams{BotOverride: portal.MainIntent().Client}) + if err != nil { + portal.log.Error().Err(err).Msg("Failed to ensure bridge bot is joined to private chat portal") + } + } + + user.ensureInvited(portal.MainIntent(), portal.MXID, portal.IsPrivateChat()) + user.syncChatDoublePuppetDetails(portal, true) + go portal.addToPersonalSpace(portal.log.WithContext(context.TODO()), user) + + //portal.syncParticipants(user, channel.Recipients) + + if portal.IsPrivateChat() { + portal.log.Debug().Msgf("Portal is private chat, updating direct chats: %s", portal.MXID) + puppet := user.bridge.GetPuppetBySignalID(portal.Receiver) + if puppet == nil { + portal.log.Error().Msgf("Failed to find puppet for portal receiver %s", portal.Receiver) + return nil + } + + chats := map[id.UserID][]id.RoomID{puppet.MXID: {portal.MXID}} + user.UpdateDirectChats(chats) + } + + return nil +} + +func (portal *Portal) UpdateInfo(user *User, meta *any) *any { + return nil +} + +// ** Portal loading and fetching ** +var ( + portalCreationDummyEvent = event.Type{Type: "fi.mau.dummy.portal_created", Class: event.MessageEventType} +) + +func (br *SignalBridge) loadPortal(ctx context.Context, dbPortal *database.Portal, key *database.PortalKey) *Portal { + if dbPortal == nil { + if key == nil { + return nil + } + + dbPortal = br.DB.Portal.New() + dbPortal.PortalKey = *key + err := dbPortal.Insert(ctx) + if err != nil { + br.ZLog.Err(err).Msg("Failed to insert new portal") + return nil + } + } + + portal := br.NewPortal(dbPortal) + + br.portalsByID[portal.PortalKey] = portal + if portal.MXID != "" { + br.portalsByMXID[portal.MXID] = portal + } + + return portal +} + +func (br *SignalBridge) GetPortalByMXID(mxid id.RoomID) *Portal { + br.portalsLock.Lock() + defer br.portalsLock.Unlock() + + portal, ok := br.portalsByMXID[mxid] + if !ok { + dbPortal, err := br.DB.Portal.GetByMXID(context.TODO(), mxid) + if err != nil { + br.ZLog.Err(err).Msg("Failed to get portal from database") + return nil + } + return br.loadPortal(context.TODO(), dbPortal, nil) + } + + return portal +} + +func (br *SignalBridge) GetPortalByChatID(key database.PortalKey) *Portal { + br.portalsLock.Lock() + defer br.portalsLock.Unlock() + // If this PortalKey is for a group, Receiver should be empty + if key.UserID() == uuid.Nil { + key.Receiver = uuid.Nil + } + portal, ok := br.portalsByID[key] + if !ok { + dbPortal, err := br.DB.Portal.GetByChatID(context.TODO(), key) + if err != nil { + br.ZLog.Err(err).Msg("Failed to get portal from database") + return nil + } + return br.loadPortal(context.TODO(), dbPortal, &key) + } + return portal +} + +func (portal *Portal) getBridgeInfoStateKey() string { + return fmt.Sprintf("net.maunium.signal://signal/%s", portal.ChatID) +} + +// ** DisappearingPortal interface ** +func (portal *Portal) ScheduleDisappearing() { + portal.bridge.disappearingMessagesManager.ScheduleDisappearingForRoom(context.TODO(), portal.MXID) +} + +func (portal *Portal) addToPersonalSpace(ctx context.Context, user *User) bool { + spaceID := user.GetSpaceRoom() + if len(spaceID) == 0 || user.IsInSpace(ctx, portal.PortalKey) { + return false + } + _, err := portal.bridge.Bot.SendStateEvent(spaceID, event.StateSpaceChild, portal.MXID.String(), &event.SpaceChildEventContent{ + Via: []string{portal.bridge.Config.Homeserver.Domain}, + }) + if err != nil { + zerolog.Ctx(ctx).Err(err). + Str("user_id", user.MXID.String()). + Str("space_id", spaceID.String()). + Msg("Failed to add room to user's personal filtering space") + return false + } else { + zerolog.Ctx(ctx).Debug(). + Str("user_id", user.MXID.String()). + Str("space_id", spaceID.String()). + Msg("Added room to user's personal filtering space") + user.MarkInSpace(ctx, portal.PortalKey) + return true + } +} + +func (portal *Portal) HasRelaybot() bool { + return portal.bridge.Config.Bridge.Relay.Enabled && len(portal.RelayUserID) > 0 +} + +func (portal *Portal) addRelaybotFormat(userID id.UserID, evt *event.Event, content *event.MessageEventContent) bool { + member := portal.MainIntent().Member(portal.MXID, userID) + if member == nil { + member = &event.MemberEventContent{} + } + // Stickers can't have captions, so force them into images when relaying + if evt.Type == event.EventSticker { + content.MsgType = event.MsgImage + evt.Type = event.EventMessage + } + content.EnsureHasHTML() + data, err := portal.bridge.Config.Bridge.Relay.FormatMessage(content, userID, *member) + if err != nil { + portal.log.Err(err).Msg("Failed to apply relaybot format") + } + content.FormattedBody = data + // Force FileName field so the formatted body is used as a caption + if content.FileName == "" { + content.FileName = content.Body + } + return true +} + +func (portal *Portal) Delete() { + err := portal.Portal.Delete(context.TODO()) + if err != nil { + portal.log.Err(err).Msg("Failed to delete portal from db") + } + portal.bridge.portalsLock.Lock() + delete(portal.bridge.portalsByID, portal.PortalKey) + if len(portal.MXID) > 0 { + delete(portal.bridge.portalsByMXID, portal.MXID) + } + if portal.Receiver == uuid.Nil { + portal.bridge.usersLock.Lock() + for _, user := range portal.bridge.usersBySignalID { + user.RemoveInSpaceCache(portal.PortalKey) + } + portal.bridge.usersLock.Unlock() + } else { + user := portal.bridge.GetUserBySignalID(portal.Receiver) + if user != nil { + user.RemoveInSpaceCache(portal.PortalKey) + } + } + portal.bridge.portalsLock.Unlock() +} + +func (portal *Portal) Cleanup(puppetsOnly bool) { + portal.bridge.CleanupRoom(&portal.log, portal.MainIntent(), portal.MXID, puppetsOnly) +} + +func (br *SignalBridge) CleanupRoom(log *zerolog.Logger, intent *appservice.IntentAPI, mxid id.RoomID, puppetsOnly bool) { + if len(mxid) == 0 { + return + } + if br.SpecVersions.Supports(mautrix.BeeperFeatureRoomYeeting) { + err := intent.BeeperDeleteRoom(mxid) + if err == nil || errors.Is(err, mautrix.MNotFound) { + return + } + log.Warn().Err(err).Msg("Failed to delete room using beeper yeet endpoint, falling back to normal behavior") + } + members, err := intent.JoinedMembers(mxid) + if err != nil { + log.Err(err).Msg("Failed to get portal members for cleanup") + return + } + for member := range members.Joined { + if member == intent.UserID { + continue + } + puppet := br.GetPuppetByMXID(member) + if puppet != nil { + _, err = puppet.DefaultIntent().LeaveRoom(mxid) + if err != nil { + log.Err(err).Msg("Failed to leave as puppet while cleaning up portal") + } + } else if !puppetsOnly { + _, err = intent.KickUser(mxid, &mautrix.ReqKickUser{UserID: member, Reason: "Deleting portal"}) + if err != nil { + log.Err(err).Msg("Failed to kick user while cleaning up portal") + } + } + } + _, err = intent.LeaveRoom(mxid) + if err != nil { + log.Err(err).Msg("Failed to leave room while cleaning up portal") + } +} diff --git a/provisioning.go b/provisioning.go new file mode 100644 index 0000000..10a3487 --- /dev/null +++ b/provisioning.go @@ -0,0 +1,647 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2023 Scott Weber +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package main + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "net/http" + _ "net/http/pprof" + "strconv" + "strings" + "sync" + "time" + + "github.com/beeper/libserv/pkg/requestlog" + "github.com/google/uuid" + "github.com/gorilla/mux" + "github.com/rs/zerolog" + "github.com/rs/zerolog/hlog" + "maunium.net/go/mautrix" + "maunium.net/go/mautrix/id" + + "go.mau.fi/mautrix-signal/pkg/signalmeow" +) + +type provisioningContextKey int + +const ( + provisioningUserKey provisioningContextKey = iota +) + +type provisioningHandle struct { + id int + context context.Context + cancel context.CancelFunc + channel <-chan signalmeow.ProvisioningResponse +} + +type ProvisioningAPI struct { + bridge *SignalBridge + log zerolog.Logger + provisioningHandles []*provisioningHandle + provisioningUsers map[string]int + provisioningMutexes map[string]*sync.Mutex +} + +func (prov *ProvisioningAPI) Init() { + prov.log.Debug().Str("prefix", prov.bridge.Config.Bridge.Provisioning.Prefix).Msg("Enabling provisioning API") + prov.provisioningUsers = make(map[string]int) + prov.provisioningMutexes = make(map[string]*sync.Mutex) + r := prov.bridge.AS.Router.PathPrefix(prov.bridge.Config.Bridge.Provisioning.Prefix).Subrouter() + r.Use(hlog.NewHandler(prov.log)) + r.Use(requestlog.AccessLogger(true)) + r.Use(prov.AuthMiddleware) + r.HandleFunc("/v2/link/new", prov.LinkNew).Methods(http.MethodPost) + r.HandleFunc("/v2/link/wait/scan", prov.LinkWaitForScan).Methods(http.MethodPost) + r.HandleFunc("/v2/link/wait/account", prov.LinkWaitForAccount).Methods(http.MethodPost) + r.HandleFunc("/v2/logout", prov.Logout).Methods(http.MethodPost) + r.HandleFunc("/v2/resolve_identifier/{phonenum}", prov.ResolveIdentifier).Methods(http.MethodGet) + r.HandleFunc("/v2/pm/{phonenum}", prov.StartPM).Methods(http.MethodPost) + + if prov.bridge.Config.Bridge.Provisioning.DebugEndpoints { + prov.log.Debug().Msg("Enabling debug API at /debug") + r := prov.bridge.AS.Router.PathPrefix("/debug").Subrouter() + r.Use(prov.AuthMiddleware) + r.PathPrefix("/pprof").Handler(http.DefaultServeMux) + } +} + +func jsonResponse(w http.ResponseWriter, status int, response any) { + w.Header().Add("Content-Type", "application/json") + w.WriteHeader(status) + _ = json.NewEncoder(w).Encode(response) +} + +func (prov *ProvisioningAPI) AuthMiddleware(h http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + auth := strings.TrimPrefix(r.Header.Get("Authorization"), "Bearer ") + if auth != prov.bridge.Config.Bridge.Provisioning.SharedSecret { + zerolog.Ctx(r.Context()).Warn().Msg("Authentication token does not match shared secret") + jsonResponse(w, http.StatusForbidden, &mautrix.RespError{ + Err: "Authentication token does not match shared secret", + ErrCode: mautrix.MForbidden.ErrCode, + }) + return + } + userID := r.URL.Query().Get("user_id") + user := prov.bridge.GetUserByMXID(id.UserID(userID)) + h.ServeHTTP(w, r.WithContext(context.WithValue(r.Context(), provisioningUserKey, user))) + }) +} + +type Error struct { + Success bool `json:"success"` + Error string `json:"error"` + ErrCode string `json:"errcode"` +} + +type Response struct { + Success bool `json:"success"` + Status string `json:"status"` + + // For response in LinkNew + SessionID string `json:"session_id,omitempty"` + URI string `json:"uri,omitempty"` + + // For response in LinkWaitForAccount + UUID string `json:"uuid,omitempty"` + Number string `json:"number,omitempty"` + + // For response in ResolveIdentifier + *ResolveIdentifierResponse +} + +// ** Start New Chat ** // + +type ResolveIdentifierResponse struct { + RoomID id.RoomID `json:"room_id"` + ChatID ResolveIdentifierResponseChatID `json:"chat_id"` + JustCreated bool `json:"just_created"` + OtherUser ResolveIdentifierResponseOtherUser `json:"other_user"` +} + +type ResolveIdentifierResponseChatID struct { + UUID string `json:"uuid"` + Number string `json:"number"` +} + +type ResolveIdentifierResponseOtherUser struct { + MXID string `json:"mxid"` + DisplayName string `json:"displayname"` + AvatarURL string `json:"avatar_url"` +} + +func (prov *ProvisioningAPI) resolveIdentifier(user *User, phoneNum string) (int, *ResolveIdentifierResponse, error) { + if !strings.HasPrefix(phoneNum, "+") { + phoneNum = "+" + phoneNum + } + if user.SignalDevice == nil { + return http.StatusUnauthorized, nil, fmt.Errorf("Not currently connected to Signal") + } + contact, err := user.SignalDevice.ContactByE164(phoneNum) + if err != nil { + return http.StatusInternalServerError, nil, fmt.Errorf("Error looking up number in local contact list: %w", err) + } + if contact == nil { + return http.StatusNotFound, nil, fmt.Errorf("The bridge does not have the Signal ID for the number %s", phoneNum) + } + + portal := user.GetPortalByChatID(contact.UUID.String()) + puppet := prov.bridge.GetPuppetBySignalID(contact.UUID) + + return http.StatusOK, &ResolveIdentifierResponse{ + RoomID: portal.MXID, + ChatID: ResolveIdentifierResponseChatID{ + UUID: contact.UUID.String(), + Number: phoneNum, + }, + OtherUser: ResolveIdentifierResponseOtherUser{ + MXID: puppet.MXID.String(), + DisplayName: puppet.Name, + AvatarURL: puppet.AvatarURL.String(), + }, + }, nil +} + +func (prov *ProvisioningAPI) ResolveIdentifier(w http.ResponseWriter, r *http.Request) { + user := r.Context().Value(provisioningUserKey).(*User) + phoneNum, _ := mux.Vars(r)["phonenum"] + + log := prov.log.With(). + Str("action", "resolve_identifier"). + Str("user_id", user.MXID.String()). + Str("phone_num", phoneNum). + Logger() + log.Debug().Msg("resolving identifier") + + status, resp, err := prov.resolveIdentifier(user, phoneNum) + if err != nil { + errCode := "M_INTERNAL" + if status == http.StatusNotFound { + log.Debug().Msg("contact not found") + errCode = "M_NOT_FOUND" + } else { + log.Err(err).Msg("error looking up contact") + } + jsonResponse(w, status, Error{ + Success: false, + Error: err.Error(), + ErrCode: errCode, + }) + return + } + jsonResponse(w, status, Response{ + Success: true, + Status: "ok", + ResolveIdentifierResponse: resp, + }) +} + +func (prov *ProvisioningAPI) StartPM(w http.ResponseWriter, r *http.Request) { + user := r.Context().Value(provisioningUserKey).(*User) + phoneNum, _ := mux.Vars(r)["phonenum"] + + log := prov.log.With(). + Str("action", "start_pm"). + Str("user_id", user.MXID.String()). + Str("phone_num", phoneNum). + Logger() + log.Debug().Msg("starting private message") + + status, resp, err := prov.resolveIdentifier(user, phoneNum) + if err != nil { + errCode := "M_INTERNAL" + if status == http.StatusNotFound { + log.Debug().Msg("contact not found") + errCode = "M_NOT_FOUND" + } else { + log.Err(err).Msg("error looking up contact") + } + jsonResponse(w, status, Error{ + Success: false, + Error: err.Error(), + ErrCode: errCode, + }) + return + } + + portal := user.GetPortalByChatID(resp.ChatID.UUID) + if portal.MXID == "" { + if err := portal.CreateMatrixRoom(user, nil); err != nil { + log.Err(err).Msg("error looking up contact") + jsonResponse(w, http.StatusInternalServerError, Error{ + Success: false, + Error: "Error creating Matrix room", + ErrCode: "M_INTERNAL", + }) + return + } + resp.JustCreated = true + resp.RoomID = portal.MXID + } + if resp.JustCreated { + status = http.StatusCreated + } + + jsonResponse(w, status, Response{ + Success: true, + Status: "ok", + ResolveIdentifierResponse: resp, + }) +} + +// ** Provisioning session creation and management ** // + +func (prov *ProvisioningAPI) mutexForUser(user *User) *sync.Mutex { + if _, ok := prov.provisioningMutexes[user.MXID.String()]; !ok { + prov.provisioningMutexes[user.MXID.String()] = &sync.Mutex{} + } + return prov.provisioningMutexes[user.MXID.String()] +} + +func (prov *ProvisioningAPI) newOrExistingSession(user *User) (newSessionLoggedIn bool, handle *provisioningHandle, err error) { + prov.mutexForUser(user).Lock() + defer prov.mutexForUser(user).Unlock() + + if existingSessionID, ok := prov.provisioningUsers[user.MXID.String()]; ok { + provisioningHandle := prov.provisioningHandles[existingSessionID] + return false, provisioningHandle, nil + } + + provChan, err := user.Login() + if err != nil { + return false, nil, fmt.Errorf("Error logging in: %w", err) + } + provisioningCtx, cancel := context.WithCancel(context.Background()) + handle = &provisioningHandle{ + context: provisioningCtx, + cancel: cancel, + channel: provChan, + } + prov.provisioningHandles = append(prov.provisioningHandles, handle) + handle.id = len(prov.provisioningHandles) - 1 + prov.provisioningUsers[user.MXID.String()] = handle.id + return true, handle, nil +} + +func (prov *ProvisioningAPI) existingSession(user *User) (handle *provisioningHandle) { + prov.mutexForUser(user).Lock() + defer prov.mutexForUser(user).Unlock() + + if existingSessionID, ok := prov.provisioningUsers[user.MXID.String()]; ok { + provisioningHandle := prov.provisioningHandles[existingSessionID] + return provisioningHandle + } + return nil +} + +func (prov *ProvisioningAPI) clearSession(ctx context.Context, user *User) { + log := zerolog.Ctx(ctx).With().Str("function", "clearSession").Logger() + prov.mutexForUser(user).Lock() + defer prov.mutexForUser(user).Unlock() + + if existingSessionID, ok := prov.provisioningUsers[user.MXID.String()]; ok { + log.Debug().Int("existing_session_id", existingSessionID).Msg("clearing existing session") + if existingSessionID >= len(prov.provisioningHandles) { + log.Warn().Msg("session does not exist") + return + } + if prov.provisioningHandles[existingSessionID].cancel != nil { + prov.provisioningHandles[existingSessionID].cancel() + } + prov.provisioningHandles[existingSessionID] = nil + delete(prov.provisioningUsers, user.MXID.String()) + } else { + prov.log.Debug().Msg("no session found") + } +} + +// ** Provisioning API Helpers ** // + +func (prov *ProvisioningAPI) loginOrSendError(ctx context.Context, w http.ResponseWriter, user *User) (*provisioningHandle, error) { + newSessionLoggedIn, handle, err := prov.newOrExistingSession(user) + if err != nil { + return nil, err + } + if !newSessionLoggedIn { + zerolog.Ctx(ctx).Debug(). + Int("existing_provisioning_handle", handle.id). + Msg("user already has pending provisioning request, cancelling") + prov.clearSession(ctx, user) + newSessionLoggedIn, handle, err = prov.newOrExistingSession(user) + if err != nil { + return nil, fmt.Errorf("error logging in after cancelling existing session: %w", err) + } + } + return handle, nil +} + +func (prov *ProvisioningAPI) checkSessionAndReturnHandle(ctx context.Context, w http.ResponseWriter, currentSession int) *provisioningHandle { + log := zerolog.Ctx(ctx).With().Str("function", "checkSessionAndReturnHandle").Logger() + user := ctx.Value(provisioningUserKey).(*User) + handle := prov.existingSession(user) + if handle == nil { + log.Warn().Msg("no session found") + jsonResponse(w, http.StatusNotFound, Error{ + Success: false, + Error: "No session found", + ErrCode: "M_NOT_FOUND", + }) + return nil + } + if handle.id != currentSession { + log.Warn(). + Int("handle_id", handle.id). + Int("current_session", currentSession). + Msg("session_id does not match user's session_id") + jsonResponse(w, http.StatusBadRequest, Error{ + Success: false, + Error: "session_id does not match user's session_id", + ErrCode: "M_BAD_JSON", + }) + return nil + } + return handle +} + +// ** Provisioning API ** // + +func (prov *ProvisioningAPI) LinkNew(w http.ResponseWriter, r *http.Request) { + user := r.Context().Value(provisioningUserKey).(*User) + log := prov.log.With(). + Str("action", "link_new"). + Str("user_id", user.MXID.String()). + Logger() + ctx := log.WithContext(r.Context()) + log.Debug().Msg("starting login") + + handle, err := prov.loginOrSendError(ctx, w, user) + if err != nil { + jsonResponse(w, http.StatusInternalServerError, Error{ + Success: false, + Error: err.Error(), + ErrCode: "M_INTERNAL", + }) + return + } + + log = log.With().Int("session_id", handle.id).Logger() + log.Debug().Msg("waiting for provisioning response") + + select { + case resp := <-handle.channel: + if resp.Err != nil || resp.State == signalmeow.StateProvisioningError { + log.Err(resp.Err).Msg("Error getting provisioning URL") + jsonResponse(w, http.StatusInternalServerError, Error{ + Success: false, + Error: resp.Err.Error(), + ErrCode: "M_INTERNAL", + }) + return + } + if resp.State != signalmeow.StateProvisioningURLReceived { + log.Err(resp.Err).Str("state", resp.State.String()).Msg("unexpected state") + jsonResponse(w, http.StatusInternalServerError, Error{ + Success: false, + Error: fmt.Sprintf("Unexpected state %s", resp.State.String()), + ErrCode: "M_INTERNAL", + }) + return + } + + log.Debug().Str("provisioning_url", resp.ProvisioningUrl).Msg("provisioning URL received") + jsonResponse(w, http.StatusOK, Response{ + Success: true, + Status: "provisioning_url_received", + SessionID: fmt.Sprintf("%d", handle.id), + URI: resp.ProvisioningUrl, + }) + case <-time.After(30 * time.Second): + log.Warn().Msg("Timeout waiting for provisioning response (new)") + jsonResponse(w, http.StatusGatewayTimeout, Error{ + Success: false, + Error: "Timeout waiting for provisioning response (new)", + ErrCode: "M_TIMEOUT", + }) + } +} + +type LinkWaitForScanRequest struct { + SessionID string `json:"session_id"` +} + +func (prov *ProvisioningAPI) LinkWaitForScan(w http.ResponseWriter, r *http.Request) { + user := r.Context().Value(provisioningUserKey).(*User) + + var body LinkWaitForScanRequest + err := json.NewDecoder(r.Body).Decode(&body) + if err != nil { + jsonResponse(w, http.StatusBadRequest, Error{ + Success: false, + Error: "Error decoding JSON body", + ErrCode: "M_BAD_JSON", + }) + return + } + sessionID, err := strconv.Atoi(body.SessionID) + if err != nil { + jsonResponse(w, http.StatusBadRequest, Error{ + Success: false, + Error: "Error decoding session ID in JSON body", + ErrCode: "M_BAD_JSON", + }) + return + } + + log := prov.log.With(). + Str("action", "link_wait_for_scan"). + Str("user_id", user.MXID.String()). + Str("session_id", body.SessionID). + Logger() + ctx := log.WithContext(r.Context()) + log.Debug().Msg("waiting for scan") + + handle := prov.checkSessionAndReturnHandle(ctx, w, sessionID) + if handle == nil { + return + } + + select { + case resp := <-handle.channel: + if resp.Err != nil || resp.State == signalmeow.StateProvisioningError { + log.Err(resp.Err).Msg("Error waiting for scan") + // If context was cancelled be chill + if errors.Is(resp.Err, context.Canceled) { + log.Debug().Msg("Context cancelled waiting for scan") + return + } + // If we error waiting for the scan, treat it as a normal error not 5xx + // so that the client will retry quietly. Also, it's really not an internal + // error, sitting with a WS open waiting for a scan is inherently flaky. + jsonResponse(w, http.StatusBadRequest, Error{ + Success: false, + Error: resp.Err.Error(), + ErrCode: "M_INTERNAL", + }) + return + } + if resp.State != signalmeow.StateProvisioningDataReceived { + log.Err(resp.Err).Str("state", resp.State.String()).Msg("unexpected state") + jsonResponse(w, http.StatusInternalServerError, Error{ + Success: false, + Error: fmt.Sprintf("Unexpected state %s", resp.State.String()), + ErrCode: "M_INTERNAL", + }) + return + } + log.Debug().Msg("provisioning data received") + jsonResponse(w, http.StatusOK, Response{ + Success: true, + Status: "provisioning_data_received", + }) + + // Update user with SignalID + if resp.ProvisioningData.AciUuid != "" { + user.SignalID, err = uuid.Parse(resp.ProvisioningData.AciUuid) + // TODO handle err + user.SignalUsername = resp.ProvisioningData.Number + err = user.Update(r.Context()) + if err != nil { + prov.log.Err(err).Msg("Failed to save user after login") + } + } + return + case <-time.After(45 * time.Second): + log.Warn().Msg("Timeout waiting for provisioning response (scan)") + // Using 400 here to match the old bridge + jsonResponse(w, http.StatusBadRequest, Error{ + Success: false, + Error: "Timeout waiting for QR code scan", + ErrCode: "M_BAD_REQUEST", + }) + return + } +} + +type LinkWaitForAccountRequest struct { + SessionID string `json:"session_id"` + DeviceName string `json:"device_name"` // TODO this seems to not be used anywhere +} + +func (prov *ProvisioningAPI) LinkWaitForAccount(w http.ResponseWriter, r *http.Request) { + user := r.Context().Value(provisioningUserKey).(*User) + + var body LinkWaitForAccountRequest + err := json.NewDecoder(r.Body).Decode(&body) + if err != nil { + jsonResponse(w, http.StatusBadRequest, Error{ + Success: false, + Error: "Error decoding JSON body", + ErrCode: "M_BAD_JSON", + }) + return + } + sessionID, err := strconv.Atoi(body.SessionID) + if err != nil { + jsonResponse(w, http.StatusBadRequest, Error{ + Success: false, + Error: "Error decoding session ID in JSON body", + ErrCode: "M_BAD_JSON", + }) + return + } + deviceName := body.DeviceName + + log := prov.log.With(). + Str("action", "link_wait_for_account"). + Str("user_id", user.MXID.String()). + Int("session_id", sessionID). + Str("device_name", deviceName). + Logger() + ctx := log.WithContext(r.Context()) + log.Debug().Msg("waiting for account") + + handle := prov.checkSessionAndReturnHandle(ctx, w, sessionID) + if handle == nil { + return + } + + select { + case resp := <-handle.channel: + if resp.Err != nil || resp.State == signalmeow.StateProvisioningError { + log.Err(resp.Err).Msg("Error waiting for account") + jsonResponse(w, http.StatusInternalServerError, Error{ + Success: false, + Error: resp.Err.Error(), + ErrCode: "M_INTERNAL", + }) + return + } + if resp.State != signalmeow.StateProvisioningPreKeysRegistered { + log.Err(resp.Err).Str("state", resp.State.String()).Msg("unexpected state") + jsonResponse(w, http.StatusInternalServerError, Error{ + Success: false, + Error: fmt.Sprintf("Unexpected state %s", resp.State.String()), + ErrCode: "M_INTERNAL", + }) + return + } + + log.Debug().Msg("prekeys registered") + jsonResponse(w, http.StatusOK, Response{ + Success: true, + Status: "prekeys_registered", + UUID: user.SignalID.String(), + Number: user.SignalUsername, + }) + + // Connect to Signal!! + user.Connect() + return + case <-time.After(30 * time.Second): + log.Warn().Msg("Timeout waiting for provisioning response (account)") + jsonResponse(w, http.StatusGatewayTimeout, Error{ + Success: false, + Error: "Timeout waiting for provisioning response (account)", + ErrCode: "M_TIMEOUT", + }) + return + } +} + +func (prov *ProvisioningAPI) Logout(w http.ResponseWriter, r *http.Request) { + user := r.Context().Value(provisioningUserKey).(*User) + log := prov.log.With(). + Str("action", "logout"). + Str("user_id", user.MXID.String()). + Logger() + ctx := log.WithContext(r.Context()) + log.Debug().Msg("Logout called (but not logging out)") + + prov.clearSession(ctx, user) + + // For now do nothing - we need this API to return 200 to be compatible with + // the old Signal bridge, which needed a call to Logout before allowing LinkNew + // to be called, but we don't actually want to logout, we want to allow a reconnect. + jsonResponse(w, http.StatusOK, Response{ + Success: true, + Status: "logged_out", + }) +} diff --git a/puppet.go b/puppet.go new file mode 100644 index 0000000..45cc79a --- /dev/null +++ b/puppet.go @@ -0,0 +1,268 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2023 Scott Weber +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package main + +import ( + "context" + "fmt" + "regexp" + "sync" + + "github.com/google/uuid" + "github.com/rs/zerolog" + "maunium.net/go/mautrix/appservice" + "maunium.net/go/mautrix/bridge" + "maunium.net/go/mautrix/id" + + "go.mau.fi/mautrix-signal/database" +) + +type Puppet struct { + *database.Puppet + + bridge *SignalBridge + log zerolog.Logger + + MXID id.UserID + + customIntent *appservice.IntentAPI + customUser *User + + syncLock sync.Mutex +} + +var userIDRegex *regexp.Regexp + +var _ bridge.Ghost = (*Puppet)(nil) +var _ bridge.GhostWithProfile = (*Puppet)(nil) + +// ** bridge.Ghost methods ** +func (puppet *Puppet) GetMXID() id.UserID { + return puppet.MXID +} + +func (puppet *Puppet) DefaultIntent() *appservice.IntentAPI { + return puppet.bridge.AS.Intent(puppet.MXID) +} + +func (puppet *Puppet) CustomIntent() *appservice.IntentAPI { + if puppet == nil { + return nil + } + return puppet.customIntent +} + +func (puppet *Puppet) IntentFor(portal *Portal) *appservice.IntentAPI { + if puppet != nil { + if puppet.customIntent == nil || portal.UserID() == puppet.SignalID { + return puppet.DefaultIntent() + } + return puppet.customIntent + } + return nil +} + +// ** bridge.GhostWithProfile methods ** +func (puppet *Puppet) GetDisplayname() string { + return puppet.Name +} + +func (puppet *Puppet) GetAvatarURL() id.ContentURI { + return puppet.AvatarURL +} + +// ** Puppet creation and fetching methods ** +func (br *SignalBridge) NewPuppet(dbPuppet *database.Puppet) *Puppet { + return &Puppet{ + Puppet: dbPuppet, + bridge: br, + log: br.ZLog.With().Str("signal_user_id", dbPuppet.SignalID.String()).Logger(), + + MXID: br.FormatPuppetMXID(dbPuppet.SignalID), + } +} + +func (br *SignalBridge) ParsePuppetMXID(mxid id.UserID) (uuid.UUID, bool) { + if userIDRegex == nil { + pattern := fmt.Sprintf( + "^@%s:%s$", + // The "SignalID" portion of the MXID is a (lowercase) UUID + br.Config.Bridge.FormatUsername("([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})"), + br.Config.Homeserver.Domain, + ) + br.ZLog.Debug().Str("pattern", pattern).Msg("Compiling userIDRegex") + + userIDRegex = regexp.MustCompile(pattern) + } + + match := userIDRegex.FindStringSubmatch(string(mxid)) + if len(match) == 2 { + parsed, err := uuid.Parse(match[1]) + if err != nil { + return uuid.Nil, false + } + return parsed, true + } + + return uuid.Nil, false +} + +func (br *SignalBridge) GetPuppetByMXID(mxid id.UserID) *Puppet { + signalID, ok := br.ParsePuppetMXID(mxid) + if !ok { + return nil + } + + return br.GetPuppetBySignalID(signalID) +} + +func (br *SignalBridge) GetPuppetBySignalIDString(id string) *Puppet { + parsed, err := uuid.Parse(id) + if err != nil { + return nil + } + return br.GetPuppetBySignalID(parsed) +} + +func (br *SignalBridge) GetPuppetBySignalID(id uuid.UUID) *Puppet { + br.puppetsLock.Lock() + defer br.puppetsLock.Unlock() + + if id == uuid.Nil { + br.ZLog.Warn().Msg("Trying to get puppet with empty signal_user_id") + return nil + } + + puppet, ok := br.puppets[id] + if !ok { + dbPuppet, err := br.DB.Puppet.GetBySignalID(context.TODO(), id) + if err != nil { + br.ZLog.Err(err).Msg("Failed to get puppet from database") + return nil + } else if dbPuppet == nil { + br.ZLog.Info().Str("signal_user_id", id.String()).Msg("Puppet not found in database, creating new entry") + dbPuppet = br.DB.Puppet.New() + dbPuppet.SignalID = id + //dbPuppet.Number = + err = dbPuppet.Insert(context.TODO()) + if err != nil { + br.ZLog.Error().Err(err).Str("signal_user_id", id.String()).Msg("Error creating new puppet") + return nil + } + } + puppet = br.NewPuppet(dbPuppet) + br.puppets[puppet.SignalID] = puppet + if puppet.CustomMXID != "" { + br.puppetsByCustomMXID[puppet.CustomMXID] = puppet + } + if puppet.Number != "" { + br.puppetsByNumber[puppet.Number] = puppet + } + } + return puppet +} + +func (br *SignalBridge) GetPuppetByNumber(number string) *Puppet { + br.puppetsLock.Lock() + defer br.puppetsLock.Unlock() + + puppet, ok := br.puppetsByNumber[number] + if !ok { + dbPuppet, err := br.DB.Puppet.GetByNumber(context.TODO(), number) + if err != nil { + br.ZLog.Err(err).Msg("Failed to get puppet from database") + return nil + } else if dbPuppet == nil { + return nil + } + + puppet = br.NewPuppet(dbPuppet) + br.puppets[puppet.SignalID] = puppet + if puppet.CustomMXID != "" { + br.puppetsByCustomMXID[puppet.CustomMXID] = puppet + } + if puppet.Number != "" { + br.puppetsByNumber[puppet.Number] = puppet + } + } + return puppet +} + +func (br *SignalBridge) GetPuppetByCustomMXID(mxid id.UserID) *Puppet { + br.puppetsLock.Lock() + defer br.puppetsLock.Unlock() + + puppet, ok := br.puppetsByCustomMXID[mxid] + if !ok { + dbPuppet, err := br.DB.Puppet.GetByCustomMXID(context.TODO(), mxid) + if err != nil { + br.ZLog.Err(err).Msg("Failed to get puppet from database") + return nil + } else if dbPuppet == nil { + return nil + } + + puppet = br.NewPuppet(dbPuppet) + br.puppets[puppet.SignalID] = puppet + br.puppetsByCustomMXID[puppet.CustomMXID] = puppet + if puppet.Number != "" { + br.puppetsByNumber[puppet.Number] = puppet + } + } + return puppet +} + +func (br *SignalBridge) GetAllPuppetsWithCustomMXID() []*Puppet { + puppets, err := br.DB.Puppet.GetAllWithCustomMXID(context.TODO()) + if err != nil { + br.ZLog.Error().Err(err).Msg("Failed to get all puppets with custom MXID") + return nil + } + return br.dbPuppetsToPuppets(puppets) +} + +func (br *SignalBridge) FormatPuppetMXID(u uuid.UUID) id.UserID { + return id.NewUserID( + br.Config.Bridge.FormatUsername(u.String()), + br.Config.Homeserver.Domain, + ) +} + +func (br *SignalBridge) dbPuppetsToPuppets(dbPuppets []*database.Puppet) []*Puppet { + br.puppetsLock.Lock() + defer br.puppetsLock.Unlock() + + output := make([]*Puppet, len(dbPuppets)) + for index, dbPuppet := range dbPuppets { + if dbPuppet == nil { + continue + } + puppet, ok := br.puppets[dbPuppet.SignalID] + if !ok { + puppet = br.NewPuppet(dbPuppet) + br.puppets[dbPuppet.SignalID] = puppet + if dbPuppet.Number != "" { + br.puppetsByNumber[dbPuppet.Number] = puppet + } + if dbPuppet.CustomMXID != "" { + br.puppetsByCustomMXID[dbPuppet.CustomMXID] = puppet + } + } + output[index] = puppet + } + return output +} diff --git a/user.go b/user.go new file mode 100644 index 0000000..ec30d76 --- /dev/null +++ b/user.go @@ -0,0 +1,1081 @@ +// mautrix-signal - A Matrix-signal puppeting bridge. +// Copyright (C) 2023 Scott Weber +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package main + +import ( + "context" + "crypto/sha256" + "encoding/hex" + "errors" + "net/http" + "strings" + "sync" + "time" + + "github.com/google/uuid" + "github.com/rs/zerolog" + "golang.org/x/exp/maps" + "maunium.net/go/mautrix" + "maunium.net/go/mautrix/appservice" + "maunium.net/go/mautrix/bridge" + "maunium.net/go/mautrix/bridge/bridgeconfig" + "maunium.net/go/mautrix/bridge/status" + "maunium.net/go/mautrix/event" + "maunium.net/go/mautrix/id" + + "go.mau.fi/mautrix-signal/database" + "go.mau.fi/mautrix-signal/pkg/signalmeow" + "go.mau.fi/mautrix-signal/pkg/signalmeow/events" + signalpb "go.mau.fi/mautrix-signal/pkg/signalmeow/protobuf" + "go.mau.fi/mautrix-signal/pkg/signalmeow/types" +) + +var ( + ErrNotConnected = errors.New("not connected") + ErrNotLoggedIn = errors.New("not logged in") +) + +type User struct { + *database.User + + sync.Mutex + + bridge *SignalBridge + log zerolog.Logger + + Admin bool + PermissionLevel bridgeconfig.PermissionLevel + + SignalDevice *signalmeow.Device + + BridgeState *bridge.BridgeStateQueue + bridgeStateLock sync.Mutex + + spaceMembershipChecked bool + spaceCreateLock sync.Mutex +} + +var _ bridge.User = (*User)(nil) +var _ status.BridgeStateFiller = (*User)(nil) + +// ** bridge.User Interface ** + +func (user *User) GetPermissionLevel() bridgeconfig.PermissionLevel { + return user.PermissionLevel +} + +func (user *User) IsLoggedIn() bool { + user.Lock() + defer user.Unlock() + + return user.SignalDevice.IsDeviceLoggedIn() +} + +func (user *User) GetManagementRoomID() id.RoomID { + return user.ManagementRoom +} + +func (user *User) SetManagementRoom(roomID id.RoomID) { + user.bridge.managementRoomsLock.Lock() + defer user.bridge.managementRoomsLock.Unlock() + + existing, ok := user.bridge.managementRooms[roomID] + if ok { + existing.ManagementRoom = "" + err := existing.Update(context.TODO()) + if err != nil { + existing.log.Err(err).Msg("Failed to update user when removing management room") + } + } + + user.ManagementRoom = roomID + user.bridge.managementRooms[user.ManagementRoom] = user + err := user.Update(context.TODO()) + if err != nil { + user.log.Error().Err(err).Msg("Error setting management room") + } +} + +func (user *User) GetIDoublePuppet() bridge.DoublePuppet { + p := user.bridge.GetPuppetByCustomMXID(user.MXID) + if p == nil || p.CustomIntent() == nil { + return nil + } + return p +} + +func (user *User) GetIGhost() bridge.Ghost { + p := user.bridge.GetPuppetBySignalID(user.SignalID) + if p == nil { + return nil + } + return p +} + +// ** User creation and fetching ** + +func (br *SignalBridge) loadUser(ctx context.Context, dbUser *database.User, mxid *id.UserID) *User { + if dbUser == nil { + if mxid == nil { + return nil + } + dbUser = br.DB.User.New() + dbUser.MXID = *mxid + err := dbUser.Insert(ctx) + if err != nil { + br.ZLog.Err(err).Msg("Error creating user %s") + return nil + } + } + + user := br.NewUser(dbUser) + br.usersByMXID[user.MXID] = user + if user.SignalID != uuid.Nil { + br.usersBySignalID[user.SignalID] = user + } + if user.ManagementRoom != "" { + br.managementRoomsLock.Lock() + br.managementRooms[user.ManagementRoom] = user + br.managementRoomsLock.Unlock() + } + // TODO this is completely wrong and shouldn't be here at all + // Ensure a puppet is created for this user + newPuppet := br.GetPuppetBySignalID(user.SignalID) + if newPuppet != nil && newPuppet.CustomMXID == "" { + newPuppet.CustomMXID = user.MXID + err := newPuppet.Update(ctx) + if err != nil { + br.ZLog.Err(err).Msg("Error updating puppet for user %s") + } + } + return user +} + +func (br *SignalBridge) GetUserByMXID(userID id.UserID) *User { + if userID == br.Bot.UserID || br.IsGhost(userID) { + return nil + } + br.usersLock.Lock() + defer br.usersLock.Unlock() + + user, ok := br.usersByMXID[userID] + if !ok { + dbUser, err := br.DB.User.GetByMXID(context.TODO(), userID) + if err != nil { + br.ZLog.Err(err).Msg("Failed to get user from database") + return nil + } + return br.loadUser(context.TODO(), dbUser, &userID) + } + return user +} + +func (br *SignalBridge) GetUserBySignalID(id uuid.UUID) *User { + br.usersLock.Lock() + defer br.usersLock.Unlock() + + user, ok := br.usersBySignalID[id] + if !ok { + dbUser, err := br.DB.User.GetBySignalID(context.TODO(), id) + if err != nil { + br.ZLog.Err(err).Msg("Failed to get user from database") + return nil + } + return br.loadUser(context.TODO(), dbUser, nil) + } + return user +} + +func (br *SignalBridge) NewUser(dbUser *database.User) *User { + user := &User{ + User: dbUser, + bridge: br, + log: br.ZLog.With().Str("user_id", dbUser.MXID.String()).Logger(), + + PermissionLevel: br.Config.Bridge.Permissions.Get(dbUser.MXID), + } + user.Admin = user.PermissionLevel >= bridgeconfig.PermissionLevelAdmin + user.BridgeState = br.NewBridgeStateQueue(user) + return user +} + +func (user *User) ensureInvited(intent *appservice.IntentAPI, roomID id.RoomID, isDirect bool) (ok bool) { + log := user.log.With().Str("action", "ensure_invited").Str("room_id", roomID.String()).Logger() + if user.bridge.StateStore.GetMembership(roomID, user.MXID) == event.MembershipJoin { + ok = true + return + } + extraContent := make(map[string]interface{}) + if isDirect { + extraContent["is_direct"] = true + } + customPuppet := user.bridge.GetPuppetByCustomMXID(user.MXID) + if customPuppet != nil && customPuppet.CustomIntent() != nil { + log.Debug().Msg("adding will_auto_accept to invite content") + extraContent["fi.mau.will_auto_accept"] = true + } else { + log.Debug().Msg("NOT adding will_auto_accept to invite content") + } + _, err := intent.InviteUser(roomID, &mautrix.ReqInviteUser{UserID: user.MXID}, extraContent) + var httpErr mautrix.HTTPError + if err != nil && errors.As(err, &httpErr) && httpErr.RespError != nil && strings.Contains(httpErr.RespError.Err, "is already in the room") { + user.bridge.StateStore.SetMembership(roomID, user.MXID, event.MembershipJoin) + ok = true + return + } else if err != nil { + log.Warn().Err(err).Msg("Failed to invite user to room") + } else { + ok = true + } + + if customPuppet != nil && customPuppet.CustomIntent() != nil { + log.Debug().Msg("ensuring custom puppet is joined") + err = customPuppet.CustomIntent().EnsureJoined(roomID, appservice.EnsureJoinedParams{IgnoreCache: true}) + if err != nil { + log.Warn().Err(err).Msg("Failed to auto-join custom puppet") + ok = false + } else { + ok = true + } + } + return +} + +func (user *User) GetSpaceRoom() id.RoomID { + if !user.bridge.Config.Bridge.PersonalFilteringSpaces { + return "" + } + + if len(user.SpaceRoom) == 0 { + user.spaceCreateLock.Lock() + defer user.spaceCreateLock.Unlock() + if len(user.SpaceRoom) > 0 { + return user.SpaceRoom + } + + resp, err := user.bridge.Bot.CreateRoom(&mautrix.ReqCreateRoom{ + Visibility: "private", + Name: "Signal", + Topic: "Your Signal bridged chats", + InitialState: []*event.Event{{ + Type: event.StateRoomAvatar, + Content: event.Content{ + Parsed: &event.RoomAvatarEventContent{ + URL: user.bridge.Config.AppService.Bot.ParsedAvatar, + }, + }, + }}, + CreationContent: map[string]interface{}{ + "type": event.RoomTypeSpace, + }, + PowerLevelOverride: &event.PowerLevelsEventContent{ + Users: map[id.UserID]int{ + user.bridge.Bot.UserID: 9001, + user.MXID: 50, + }, + }, + }) + + if err != nil { + user.log.Err(err).Msg("Failed to auto-create space room") + } else { + user.SpaceRoom = resp.RoomID + err = user.Update(context.TODO()) + if err != nil { + user.log.Err(err).Msg("Failed to save user in database after creating space room") + } + user.ensureInvited(user.bridge.Bot, user.SpaceRoom, false) + } + } else if !user.spaceMembershipChecked { + user.ensureInvited(user.bridge.Bot, user.SpaceRoom, false) + } + user.spaceMembershipChecked = true + + return user.SpaceRoom +} + +func (user *User) syncChatDoublePuppetDetails(portal *Portal, justCreated bool) { + doublePuppet := portal.bridge.GetPuppetByCustomMXID(user.MXID) + if doublePuppet == nil { + return + } + if doublePuppet == nil || doublePuppet.CustomIntent() == nil || len(portal.MXID) == 0 { + return + } + + // TODO: Get chat setting from Signal and sync them here + //if justCreated || !user.bridge.Config.Bridge.TagOnlyOnCreate { + // chat, err := user.SignalDevice.Store.ChatSettings.GetChatSettings(portal.Key().ChatID) + // if err != nil { + // user.log.Warn().Err(err).Msgf("Failed to get settings of %s", portal.Key().ChatID) + // return + // } + // intent := doublePuppet.CustomIntent() + // if portal.Key.JID == types.StatusBroadcastJID && justCreated { + // if user.bridge.Config.Bridge.MuteStatusBroadcast { + // user.updateChatMute(intent, portal, time.Now().Add(365*24*time.Hour)) + // } + // if len(user.bridge.Config.Bridge.StatusBroadcastTag) > 0 { + // user.updateChatTag(intent, portal, user.bridge.Config.Bridge.StatusBroadcastTag, true) + // } + // return + // } else if !chat.Found { + // return + // } + // user.updateChatMute(intent, portal, chat.MutedUntil) + // user.updateChatTag(intent, portal, user.bridge.Config.Bridge.ArchiveTag, chat.Archived) + // user.updateChatTag(intent, portal, user.bridge.Config.Bridge.PinnedTag, chat.Pinned) + //} +} + +// ** status.BridgeStateFiller methods ** + +func (user *User) GetMXID() id.UserID { + return user.MXID +} +func (user *User) GetRemoteID() string { + return user.SignalID.String() +} + +func (user *User) GetRemoteName() string { + return user.SignalUsername +} + +// ** Startup, connection and shutdown methods ** + +func (br *SignalBridge) getAllLoggedInUsers() []*User { + br.usersLock.Lock() + defer br.usersLock.Unlock() + + dbUsers, err := br.DB.User.GetAllLoggedIn(context.TODO()) + if err != nil { + br.ZLog.Err(err).Msg("Error getting all logged in users") + return nil + } + users := make([]*User, len(dbUsers)) + + for idx, dbUser := range dbUsers { + user, ok := br.usersByMXID[dbUser.MXID] + if !ok { + user = br.loadUser(context.TODO(), dbUser, nil) + } + users[idx] = user + } + return users +} + +func (user *User) startupTryConnect(retryCount int) { + user.BridgeState.Send(status.BridgeState{StateEvent: status.StateConnecting}) + + // Make sure user has the Signal device populated + user.populateSignalDevice() + + user.log.Debug().Msg("Connecting to Signal") + ctx := user.log.WithContext(context.Background()) + statusChan, err := signalmeow.StartReceiveLoops(ctx, user.SignalDevice) + + if err != nil { + user.log.Error().Err(err).Msg("Error connecting on startup") + if errors.Is(err, ErrNotLoggedIn) { + user.log.Warn().Msg("Not logged in, clearing Signal device keys") + user.BridgeState.Send(status.BridgeState{StateEvent: status.StateBadCredentials, Message: "You have been logged out of Signal, please reconnect"}) + user.clearKeysAndDisconnect() + } else if retryCount < 6 { + user.BridgeState.Send(status.BridgeState{StateEvent: status.StateTransientDisconnect, Error: "unknown-websocket-error", Message: err.Error()}) + retryInSeconds := 2 << retryCount + user.log.Debug().Int("retry_in_seconds", retryInSeconds).Msg("Sleeping and retrying connection") + time.Sleep(time.Duration(retryInSeconds) * time.Second) + user.startupTryConnect(retryCount + 1) + } else { + user.BridgeState.Send(status.BridgeState{StateEvent: status.StateUnknownError, Error: "unknown-websocket-error", Message: err.Error()}) + } + } + + if statusChan == nil { + user.log.Error().Msg("statusChan is nil after Connect") + return + } + // After Connect returns, all bridge states are triggered by events on the statusChan + go func() { + var peekedConnectionStatus signalmeow.SignalConnectionStatus + for { + var connectionStatus signalmeow.SignalConnectionStatus + if peekedConnectionStatus.Event != signalmeow.SignalConnectionEventNone { + user.log.Debug(). + Str("peeked_connection_status_event", peekedConnectionStatus.Event.String()). + Msg("Using peeked connectionStatus event") + connectionStatus = peekedConnectionStatus + peekedConnectionStatus = signalmeow.SignalConnectionStatus{} + } else { + var ok bool + connectionStatus, ok = <-statusChan + if !ok { + user.log.Debug().Msg("statusChan channel closed") + return + } + } + + err := connectionStatus.Err + switch connectionStatus.Event { + case signalmeow.SignalConnectionEventConnected: + user.log.Debug().Msg("Sending Connected BridgeState") + user.BridgeState.Send(status.BridgeState{StateEvent: status.StateConnected}) + + case signalmeow.SignalConnectionEventDisconnected: + user.log.Debug().Msg("Received SignalConnectionEventDisconnected") + + // Debounce: wait 7s before sending TransientDisconnect, in case we get a reconnect + // We should wait until the next message comes in, or 7 seconds has passed. + // - If a disconnected event comes in, just loop again, unless it's been more than 7 seconds. + // - If a non-disconnected event comes in, store it in peekedConnectionStatus, + // break out of this loop and go back to the top of the goroutine to handle it in the switch. + // - If 7 seconds passes without any non-disconnect messages, send the TransientDisconnect. + // (Why 7 seconds? It was 5 at first, but websockets min retry is 5 seconds, + // so it would send TransientDisconnect right before reconnecting. 7 seems to work well.) + debounceTimer := time.NewTimer(7 * time.Second) + PeekLoop: + for { + var ok bool + select { + case peekedConnectionStatus, ok = <-statusChan: + // Handle channel closing + if !ok { + user.log.Debug().Msg("connectionStatus channel closed") + return + } + // If it's another Disconnected event, just keep looping + if peekedConnectionStatus.Event == signalmeow.SignalConnectionEventDisconnected { + peekedConnectionStatus = signalmeow.SignalConnectionStatus{} + continue + } + // If it's a non-disconnect event, break out of the PeekLoop and handle it in the switch + break PeekLoop + case <-debounceTimer.C: + // Time is up, so break out of the loop and send the TransientDisconnect + break PeekLoop + } + } + // We're out of the PeekLoop, so either we got a non-disconnect event, or it's been 7 seconds (or both). + // We want to send TransientDisconnect if it's been 7 seconds, but not if the latest event was something + // other than Disconnected + if !debounceTimer.Stop() { // If the timer has already expired + // Send TransientDisconnect only if the latest event is a disconnect or no event + // (peekedConnectionStatus could be something else if the timer and the event race) + if peekedConnectionStatus.Event == signalmeow.SignalConnectionEventDisconnected || + peekedConnectionStatus.Event == signalmeow.SignalConnectionEventNone { + user.log.Debug().Msg("Sending TransientDisconnect BridgeState") + if err == nil { + user.BridgeState.Send(status.BridgeState{StateEvent: status.StateTransientDisconnect}) + } else { + user.BridgeState.Send(status.BridgeState{StateEvent: status.StateTransientDisconnect, Error: "unknown-websocket-error", Message: err.Error()}) + } + } + } + + case signalmeow.SignalConnectionEventLoggedOut: + user.log.Debug().Msg("Sending BadCredentials BridgeState") + if err == nil { + user.BridgeState.Send(status.BridgeState{StateEvent: status.StateBadCredentials, Message: "You have been logged out of Signal, please reconnect"}) + } else { + user.BridgeState.Send(status.BridgeState{StateEvent: status.StateBadCredentials, Message: err.Error()}) + } + user.clearKeysAndDisconnect() + + case signalmeow.SignalConnectionEventError: + user.log.Debug().Msg("Sending UnknownError BridgeState") + user.BridgeState.Send(status.BridgeState{StateEvent: status.StateUnknownError, Error: "unknown-websocket-error", Message: err.Error()}) + + case signalmeow.SignalConnectionCleanShutdown: + if user.SignalDevice.IsDeviceLoggedIn() { + user.log.Debug().Msg("Clean Shutdown - sending no BridgeState") + } else { + user.log.Debug().Msg("Clean Shutdown, but logged out - Sending BadCredentials BridgeState") + user.BridgeState.Send(status.BridgeState{StateEvent: status.StateBadCredentials, Message: "You have been logged out of Signal, please reconnect"}) + } + } + } + }() +} + +func (user *User) clearKeysAndDisconnect() { + // We need to clear out keys associated with the Signal device that no longer has valid credentials + user.log.Debug().Msg("Clearing out Signal device keys") + err := user.SignalDevice.ClearKeysAndDisconnect() + if err != nil { + user.log.Err(err).Msg("Error clearing device keys") + } +} + +func (br *SignalBridge) StartUsers() { + br.ZLog.Debug().Msg("Starting users") + + usersWithToken := br.getAllLoggedInUsers() + numUsersStarting := 0 + for _, u := range usersWithToken { + device := u.populateSignalDevice() + if device == nil || !device.IsDeviceLoggedIn() { + br.ZLog.Warn().Str("user_id", u.MXID.String()).Msg("No device found for user, skipping Connect and sending BadCredentials BridgeState") + u.BridgeState.Send(status.BridgeState{StateEvent: status.StateBadCredentials, Message: "You have been logged out of Signal, please reconnect"}) + continue + } + go u.Connect() + numUsersStarting++ + } + if numUsersStarting == 0 { + br.SendGlobalBridgeState(status.BridgeState{StateEvent: status.StateUnconfigured}.Fill(nil)) + } + + br.ZLog.Debug().Msg("Starting custom puppets") + for _, customPuppet := range br.GetAllPuppetsWithCustomMXID() { + go func(puppet *Puppet) { + br.ZLog.Debug().Str("user_id", puppet.CustomMXID.String()).Msg("Starting custom puppet") + + if err := puppet.StartCustomMXID(true); err != nil { + puppet.log.Error().Err(err).Msg("Failed to start custom puppet") + } + }(customPuppet) + } +} + +func (user *User) Login() (<-chan signalmeow.ProvisioningResponse, error) { + user.Lock() + defer user.Unlock() + + provChan := signalmeow.PerformProvisioning(context.TODO(), user.bridge.MeowStore, user.bridge.Config.Signal.DeviceName) + + return provChan, nil +} + +func (user *User) Connect() { + user.startupTryConnect(0) +} + +func (user *User) populateSignalDevice() *signalmeow.Device { + user.Lock() + defer user.Unlock() + log := user.log.With(). + Str("action", "populate signal device"). + Str("signal_id", user.SignalID.String()). + Logger() + + if user.SignalID == uuid.Nil { + return nil + } + + device, err := user.bridge.MeowStore.DeviceByAci(user.SignalID.String()) + if err != nil { + log.Err(err).Msg("problem looking up ACI") + return nil + } + if device == nil { + log.Err(ErrNotLoggedIn).Msg("no device found for ACI") + return nil + } + + user.SignalDevice = device + device.Connection.EventHandler = user.eventHandler + return device +} + +func updatePuppetWithSignalContact(ctx context.Context, user *User, puppet *Puppet, newContactAvatar *types.ContactAvatar) error { + log := user.log.With(). + Str("action", "update puppet with signal contact"). + Str("signal_id", puppet.SignalID.String()). + Logger() + contact, newProfileAvatar, err := user.SignalDevice.ContactByIDWithProfileAvatar(puppet.SignalID) + if err != nil { + log.Err(err).Msg("error retrieving contact") + return err + } + + name := user.bridge.Config.Bridge.FormatDisplayname(contact) + if name != puppet.Name { + log.Debug().Str("new_name", name).Msg("updating puppet name") + puppet.Name = name + puppet.NameSet = false + err = puppet.DefaultIntent().SetDisplayName(name) + if err != nil { + log.Err(err).Msg("error setting display name") + return err + } + puppet.NameSet = true + err = puppet.Update(ctx) + if err != nil { + log.Err(err).Msg("error updating puppet with new name") + return err + } + } + + preferredAvatarHash := contact.ProfileAvatarHash + newAvatar := newProfileAvatar + if user.bridge.Config.Bridge.UseContactAvatars { + if contact.ContactAvatarHash != "" { + preferredAvatarHash = contact.ContactAvatarHash + } + if newContactAvatar != nil { + newAvatar = newContactAvatar + } + } + + if preferredAvatarHash == "" && puppet.AvatarSet { + log.Debug().Msg("clearing avatar") + puppet.AvatarSet = false + puppet.AvatarURL = id.ContentURI{} + puppet.AvatarHash = "" + err = puppet.DefaultIntent().SetAvatarURL(id.ContentURI{}) + if err != nil { + log.Err(err).Msg("error clearing avatar url") + return err + } + err = puppet.Update(ctx) + if err != nil { + log.Err(err).Msg("error updating puppet while clearing avatar") + return err + } + return nil + } + + // If avatar is set, we must have a new avatar image, so update it + if newAvatar != nil { + log.Debug().Msg("uploading avatar") + avatarURL, err := puppet.DefaultIntent().UploadBytes(newAvatar.Image, newAvatar.ContentType) + if err != nil { + log.Err(err).Msg("error uploading avatar") + return err + } + puppet.AvatarURL = avatarURL.ContentURI + puppet.AvatarSet = true + puppet.AvatarHash = newAvatar.Hash + + err = puppet.DefaultIntent().SetAvatarURL(avatarURL.ContentURI) + if err != nil { + log.Err(err).Msg("error setting avatar URL") + return err + } + err = puppet.Update(ctx) + if err != nil { + log.Err(err).Msg("error updating puppet with new avatar") + return err + } + } + return nil +} + +func ensureGroupPuppetsAreJoinedToPortal(ctx context.Context, user *User, portal *Portal) error { + // Ensure our puppet is joined to the room + err := portal.MainIntent().EnsureJoined(portal.MXID) + if err != nil { + user.log.Err(err).Msg("error ensuring joined") + return err + } + + // Check if ChatID is a groupID (not a UUID), otherwise do nothing else + // TODO: do better than passing around strings and seeing if they are UUIDs or not + if _, err := uuid.Parse(portal.ChatID); err == nil { + return nil + } + user.log.Info().Msgf("Ensuring everyone is joined to room %s, groupID: %s", portal.MXID, portal.ChatID) + group, err := signalmeow.RetrieveGroupByID(ctx, user.SignalDevice, types.GroupIdentifier(portal.ChatID)) + if err != nil { + user.log.Err(err).Msg("error retrieving group") + return err + } + for _, member := range group.Members { + parsedUserID, err := uuid.Parse(member.UserID) + if err != nil { + // TODO log? + continue + } + if parsedUserID == user.SignalID { + continue + } + memberPuppet := portal.bridge.GetPuppetBySignalID(parsedUserID) + if memberPuppet == nil { + user.log.Err(err).Msgf("no puppet found for signalID %s", member.UserID) + continue + } + _ = updatePuppetWithSignalContact(context.TODO(), user, memberPuppet, nil) + err = memberPuppet.DefaultIntent().EnsureJoined(portal.MXID) + if err != nil { + user.log.Err(err).Msg("error ensuring joined") + } + } + return nil +} + +func (user *User) handleReceipt(evt *events.Receipt) { + log := user.log.With(). + Str("action", "handle receipt"). + Str("receipt_type", evt.Content.GetType().String()). + Str("sender_uuid", evt.Sender.String()). + Logger() + ctx := log.WithContext(context.TODO()) + messages, err := user.bridge.DB.Message.GetManyBySignalID(ctx, user.SignalID, evt.Content.GetTimestamp(), user.SignalID, false) + if err != nil { + log.Err(err).Msg("Failed to get receipt target messages from database") + return + } + sender := user.bridge.GetPuppetBySignalID(evt.Sender) + missingMessageIDMap := make(map[uint64]struct{}, len(evt.Content.GetTimestamp())) + for _, msg := range evt.Content.GetTimestamp() { + missingMessageIDMap[msg] = struct{}{} + } + foundMessageIDs := make([]uint64, len(messages)) + switch evt.Content.GetType() { + case signalpb.ReceiptMessage_READ: + messageMap := make(map[string]*database.Message) + for i, msg := range messages { + foundMessageIDs[i] = msg.Timestamp + delete(missingMessageIDMap, msg.Timestamp) + // The database returns messages from newest to oldest, so only include the first message per chat + _, ok := messageMap[msg.SignalChatID] + if !ok { + messageMap[msg.SignalChatID] = msg + } + } + log.Debug(). + Uints64("found_message_ids", foundMessageIDs). + Uints64("not_found_message_ids", maps.Keys(missingMessageIDMap)). + Int("chat_count", len(messageMap)). + Msg("Received read receipt") + for _, msg := range messageMap { + portal := user.GetPortalByChatID(msg.SignalChatID) + if portal == nil { + continue + } + err = portal.SendReadReceipt(sender, msg) + if err != nil { + log.Err(err).Msg("Failed to send read receipt") + } + } + case signalpb.ReceiptMessage_DELIVERY: + messageMap := make(map[string][]*database.Message) + for i, msg := range messages { + foundMessageIDs[i] = msg.Timestamp + delete(missingMessageIDMap, msg.Timestamp) + messageMap[msg.SignalChatID] = append(messageMap[msg.SignalChatID], msg) + } + log.Debug(). + Uints64("found_message_ids", foundMessageIDs). + Uints64("not_found_message_ids", maps.Keys(missingMessageIDMap)). + Int("chat_count", len(messageMap)). + Msg("Received delivery receipt") + for _, msgs := range messageMap { + portal := user.GetPortalByChatID(msgs[0].SignalChatID) + if portal == nil { + continue + } + // There should always only be 1 part, but use the last part to be safe + portal.MarkDelivered(msgs[len(msgs)-1]) + } + } +} + +func (user *User) handleReadSelf(evt *events.ReadSelf) { + messagesByChat := map[string]*database.Message{} + for _, part := range evt.Messages { + log := user.log.With(). + Str("action", "handle read self"). + Str("sender_uuid", part.GetSenderAci()). + Uint64("msg_timestamp", part.GetTimestamp()). + Logger() + ctx := log.WithContext(context.TODO()) + if senderUUID, err := uuid.Parse(part.GetSenderAci()); err != nil { + log.Err(err).Msg("Failed to parse sender UUID") + } else if msg, err := user.bridge.DB.Message.GetLastPartBySignalIDWithUnknownReceiver(ctx, senderUUID, part.GetTimestamp(), user.SignalID); err != nil { + log.Err(err).Msg("Failed to get message from database") + } else if msg == nil { + log.Warn().Msg("Message not found in database") + } else if existingMsg, ok := messagesByChat[msg.SignalChatID]; ok && existingMsg.Timestamp > msg.Timestamp { + log.Debug(). + Str("chat_id", msg.SignalChatID). + Uint64("newer_msg", existingMsg.Timestamp). + Msg("Receipt event contains a newer message, skipping this one") + } else { + log.Debug().Str("chat_id", msg.SignalChatID).Msg("Received own read receipt") + messagesByChat[msg.SignalChatID] = msg + } + } + puppet := user.bridge.GetPuppetBySignalID(user.SignalID) + for _, msg := range messagesByChat { + portal := user.GetPortalByChatID(msg.SignalChatID) + if portal == nil { + continue + } + portal.ScheduleDisappearing() + err := portal.SendReadReceipt(puppet, msg) + if err != nil { + user.log.Err(err).Str("mxid", msg.MXID.String()).Msg("Failed to send read receipt") + } + } +} + +func (user *User) handleContactChange(evt *events.ContactChange) { + puppet := user.bridge.GetPuppetBySignalID(evt.UUID) + if puppet == nil { + return + } + err := updatePuppetWithSignalContact(context.TODO(), user, puppet, evt.Avatar) + if err != nil { + user.log.Err(err).Msg("error updating puppet with signal contact") + } +} + +func (user *User) syncPortalInfo(portal *Portal) { + updatePortal := false + if !portal.IsPrivateChat() { + group, avatarImage, err := signalmeow.RetrieveGroupAndAvatarByID(context.Background(), user.SignalDevice, portal.GroupID()) + if err != nil { + user.log.Err(err).Msg("error retrieving group") + return + } + if portal.Revision < int(group.Revision) { + portal.Revision = int(group.Revision) + updatePortal = true + } + if portal.Name != group.Title { + portal.Name = group.Title + portal.NameSet = false + updatePortal = true + } + if portal.Topic != group.Description { + portal.Topic = group.Description + updatePortal = true + } + if portal.ExpirationTime != int(group.DisappearingMessagesDuration) { + portal.ExpirationTime = int(group.DisappearingMessagesDuration) + updatePortal = true + portal.log.Debug().Msgf("Updating expiration time to %d (group)", group.DisappearingMessagesDuration) + // TODO send message + //portal.HandleNewDisappearingMessageTime(group.DisappearingMessagesDuration) + } + // avatarImage is only not nil if there's a new avatar to set + if avatarImage != nil { + user.log.Debug().Msg("Uploading new group avatar") + avatarURL, err := portal.MainIntent().UploadBytes(avatarImage, http.DetectContentType(avatarImage)) + if err != nil { + user.log.Err(err).Msg("error uploading group avatar") + return + } + portal.AvatarURL = avatarURL.ContentURI + portal.AvatarSet = false + hash := sha256.Sum256(avatarImage) + portal.AvatarHash = hex.EncodeToString(hash[:]) + updatePortal = true + } + + if portal.MXID != "" { + // ensure everyone is invited to the group + portal.ensureUserInvited(user) + _ = ensureGroupPuppetsAreJoinedToPortal(context.Background(), user, portal) + go portal.addToPersonalSpace(portal.log.WithContext(context.TODO()), user) + } + } else if portal.shouldSetDMRoomMetadata() { + puppet := user.bridge.GetPuppetBySignalID(portal.UserID()) + if puppet.Name != portal.Name { + portal.Name = puppet.Name + portal.NameSet = false + updatePortal = true + } + if puppet.AvatarHash != portal.AvatarHash { + portal.AvatarHash = puppet.AvatarHash + portal.AvatarURL = puppet.AvatarURL + portal.AvatarSet = false + updatePortal = true + } + } + if updatePortal { + if portal.MXID != "" { + _, err := portal.MainIntent().SetRoomName(portal.MXID, portal.Name) + if err != nil { + user.log.Err(err).Msg("error setting room name") + } + portal.NameSet = err == nil + _, err = portal.MainIntent().SetRoomTopic(portal.MXID, portal.Topic) + if err != nil { + user.log.Err(err).Msg("error setting room topic") + } + _, err = portal.MainIntent().SetRoomAvatar(portal.MXID, portal.AvatarURL) + if err != nil { + user.log.Err(err).Msg("error setting room avatar") + } + portal.AvatarSet = err == nil + } + err := portal.Update(context.TODO()) + if err != nil { + user.log.Err(err).Msg("error updating portal") + } + portal.UpdateBridgeInfo() + } +} + +func (user *User) eventHandler(rawEvt events.SignalEvent) { + switch evt := rawEvt.(type) { + case *events.ChatEvent: + portal := user.GetPortalByChatID(evt.Info.ChatID) + if portal != nil { + if portal.Revision < evt.Info.GroupRevision { + user.syncPortalInfo(portal) + } + portal.signalMessages <- portalSignalMessage{user: user, evt: evt} + } else { + user.log.Warn().Str("chat_id", evt.Info.ChatID).Msg("Couldn't get portal, dropping message") + } + case *events.Receipt: + user.handleReceipt(evt) + case *events.ReadSelf: + user.handleReadSelf(evt) + case *events.Call: + portal := user.GetPortalByChatID(evt.Info.ChatID) + content := &event.MessageEventContent{MsgType: event.MsgNotice} + if evt.IsRinging { + content.Body = "Incoming call" + if portal.IsPrivateChat() { + content.MsgType = event.MsgText + } + } else { + content.Body = "Call ended" + } + portal.sendMainIntentMessage(content) + case *events.ContactChange: + user.handleContactChange(evt) + case *events.GroupChange: + portal := user.GetPortalByChatID(evt.GroupID.String()) + if portal != nil { + user.syncPortalInfo(portal) + } + default: + user.log.Warn().Type("event_type", evt).Msg("Unrecognized event type from signalmeow") + } +} + +func (user *User) GetPortalByChatID(signalID string) *Portal { + pk := database.PortalKey{ + ChatID: signalID, + Receiver: user.SignalID, + } + return user.bridge.GetPortalByChatID(pk) +} + +func (user *User) disconnectNoLock() (*signalmeow.Device, error) { + if user.SignalDevice == nil { + return nil, ErrNotConnected + } + + disconnectedDevice := user.SignalDevice + err := signalmeow.StopReceiveLoops(user.SignalDevice) + user.SignalDevice = nil + return disconnectedDevice, err +} +func (user *User) Disconnect() error { + user.Lock() + defer user.Unlock() + user.log.Info().Msg("Disconnecting session manually") + _, err := user.disconnectNoLock() + return err +} + +func (user *User) Logout() error { + user.Lock() + defer user.Unlock() + user.log.Info().Msg("Logging out of session") + loggedOutDevice, err := user.disconnectNoLock() + user.bridge.MeowStore.DeleteDevice(&loggedOutDevice.Data) + user.bridge.GetPuppetByCustomMXID(user.MXID).ClearCustomMXID() + return err +} + +// ** Misc Methods ** + +// Used in CreateMatrixRoom in portal.go +func (user *User) UpdateDirectChats(chats map[id.UserID][]id.RoomID) { + if !user.bridge.Config.Bridge.SyncDirectChatList { + return + } + + puppet := user.bridge.GetPuppetByMXID(user.MXID) + if puppet == nil { + return + } + + intent := puppet.CustomIntent() + if intent == nil { + return + } + + method := http.MethodPatch + if chats == nil { + chats = user.getDirectChats() + method = http.MethodPut + } + + user.log.Debug().Msg("Updating m.direct list on homeserver") + + var err error + if user.bridge.Config.Homeserver.Software == bridgeconfig.SoftwareAsmux { + urlPath := intent.BuildURL(mautrix.ClientURLPath{"unstable", "com.beeper.asmux", "dms"}) + _, err = intent.MakeFullRequest(mautrix.FullRequest{ + Method: method, + URL: urlPath, + Headers: http.Header{"X-Asmux-Auth": {user.bridge.AS.Registration.AppToken}}, + RequestJSON: chats, + }) + } else { + existingChats := map[id.UserID][]id.RoomID{} + + err = intent.GetAccountData(event.AccountDataDirectChats.Type, &existingChats) + if err != nil { + user.log.Warn().Err(err).Msg("Failed to get m.direct event to update it") + return + } + + for userID, rooms := range existingChats { + if _, ok := user.bridge.ParsePuppetMXID(userID); !ok { + // This is not a ghost user, include it in the new list + chats[userID] = rooms + } else if _, ok := chats[userID]; !ok && method == http.MethodPatch { + // This is a ghost user, but we're not replacing the whole list, so include it too + chats[userID] = rooms + } + } + + err = intent.SetAccountData(event.AccountDataDirectChats.Type, &chats) + } + + if err != nil { + user.log.Warn().Err(err).Msg("Failed to update m.direct event") + } +} + +func (user *User) getDirectChats() map[id.UserID][]id.RoomID { + chats := map[id.UserID][]id.RoomID{} + + privateChats, err := user.bridge.DB.Portal.FindPrivateChatsOf(context.TODO(), user.SignalID) + if err != nil { + user.log.Err(err).Msg("Failed to get private chats") + return chats + } + for _, portal := range privateChats { + if portal.MXID != "" { + puppetMXID := user.bridge.FormatPuppetMXID(portal.UserID()) + + chats[puppetMXID] = []id.RoomID{portal.MXID} + } + } + + return chats +}