Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beeper 1.100.0 #23

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
642b73b
Add prometheus histograms for room shutdown/delete/purge
Fizzadar Mar 12, 2024
155b7c9
Install shared secret authenticator in Docker image
Fizzadar Mar 8, 2024
e68a340
Update Beeper base rules
Fizzadar Mar 8, 2024
8d6e918
Add JWT UI auth flow
Fizzadar Mar 8, 2024
084e181
Update email copy for Beeper
Fizzadar Mar 8, 2024
7928ccb
Add Beeper log formatter
Fizzadar Mar 8, 2024
3786cd9
Add Beeper previews
Fizzadar Mar 8, 2024
109fb25
Add Beeper inbox endpoints
Fizzadar Mar 8, 2024
ae8597a
Remove any bridge bot users from ignored user account data
Fizzadar Mar 8, 2024
00c0d2a
Add Beeper notification counts
Fizzadar Mar 12, 2024
fea8cd6
Include stream ordering in the unsigned event dict
Fizzadar Mar 8, 2024
1ace1e9
Allow clients to add extra content to receipts
Fizzadar Mar 8, 2024
50f0f69
Include empty identity server in well known
Fizzadar Mar 8, 2024
67d879f
Add env var to disable storing of client IPs entirely
Fizzadar Mar 12, 2024
68e1e70
Allow checking username availability when registration disabled
Fizzadar Mar 8, 2024
2e95e0d
Change default DM room redaction power level to 100
Fizzadar Mar 8, 2024
932d311
Disable transaction timeout when purging rooms
Fizzadar Mar 8, 2024
1efb1b9
Add Beeper unread counting logic
Fizzadar Mar 8, 2024
635af69
Add missing Beeper notifications schema
Fizzadar Mar 8, 2024
f3c55fa
Send all notifications as high priority
Fizzadar Mar 8, 2024
0c25837
Add Beeper specific test cases
Fizzadar Mar 8, 2024
7fe8cd4
Add CI
Fizzadar Mar 8, 2024
bd35602
Remove dependabot config
Fizzadar Mar 8, 2024
6e98fcf
Add Beeper readme
Fizzadar Mar 8, 2024
62b41c7
Add missing await
Fizzadar Mar 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .github/dependabot.yml

This file was deleted.

138 changes: 138 additions & 0 deletions .github/workflows/beeper-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: Beep

on:
push:
branches: ["beeper", "beeper-*"]
pull_request:


jobs:
lint-style:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- run: pip install poetry
- run: poetry install
- run: poetry run isort --check synapse
- run: poetry run black --check synapse

lint-types:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- run: pip install poetry
- run: poetry install --extras all
- run: poetry run mypy

# Tests

test-trial:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- run: pip install poetry
- run: poetry install --extras all
- run: poetry run trial -j4 tests

test-sytest:
runs-on: ubuntu-latest
container:
image: matrixdotorg/sytest-synapse:focal
volumes:
- ${{ github.workspace }}:/src
env:
SYTEST_BRANCH: 845764081c890180e3842f135f87e0aa778557a6
TOP: ${{ github.workspace }}
POSTGRES: 1
MULTI_POSTGRES: 1
WOKRERS: 1
steps:
- uses: actions/checkout@v2
- name: Run SyTest
run: /bootstrap.sh synapse
working-directory: /src
- name: Summarise results.tap
if: ${{ always() }}
run: /sytest/scripts/tap_to_gha.pl /logs/results.tap
- name: Upload SyTest logs
uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: Sytest Logs - ${{ job.status }} - (${{ join(matrix.*, ', ') }})
path: |
/logs/results.tap
/logs/**/*.log*

test-complement:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2
with:
repository: matrix-org/complement
path: complement
ref: 39b3b9dbb2df96ca1df6b6ae86bdbc63fc96f39e
- name: Install complement dependencies
run: |-
sudo apt-get -qq update
sudo apt-get install -qqy libolm3 libolm-dev
go install -v github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
- name: Run Complement
run: ./scripts-dev/complement.sh
env:
COMPLEMENT_DIR: complement

# Builds

build-python:
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: 1
steps:
- uses: actions/checkout@v2
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
with:
# TEMPORARY, see: https://github.com/docker/build-push-action/issues/761
driver-opts: |
image=moby/buildkit:v0.10.6
- uses: docker/login-action@v2
with:
registry: ${{ secrets.CI_REGISTRY }}
username: ${{ secrets.CI_REGISTRY_USER }}
password: ${{ secrets.CI_REGISTRY_PASSWORD }}
- run: |-
if [ "${{ github.ref_name }}" = "beeper" ]; then
tag=$(cat pyproject.toml | grep -E "^version =" | sed -E 's/^version = "(.+)"$/\1/')
else
tag="${{ github.head_ref || github.ref_name }}"
fi

docker buildx build \
--push \
--platform linux/amd64 \
--tag ${{ secrets.CI_REGISTRY }}/synapse:$tag-${{ github.sha }} \
-f docker/Dockerfile \
.

if [ "${{ github.ref_name }}" = "beeper" ]; then
docker pull ${{ secrets.CI_REGISTRY }}/synapse:$tag-${{ github.sha }}
docker tag \
${{ secrets.CI_REGISTRY }}/synapse:$tag-${{ github.sha }} \
${{ secrets.CI_REGISTRY }}/synapse:latest
docker push ${{ secrets.CI_REGISTRY }}/synapse:latest
fi

# Ensure the image works properly
docker run \
--entrypoint '' \
${{ secrets.CI_REGISTRY }}/synapse:$tag-${{ github.sha }} \
python -m synapse.app.homeserver --help

echo "Pushed image: synapse:$tag-${{ github.sha }}"
if [ "${{ github.ref_name }}" = "beeper" ]; then
echo "Pushed image: synapse:latest"
fi
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Synapse: Beeper Edition


## Rebase flow

### Create PR

Here we're upgrading to `v1.96.1`:

```
# Make a new branch from the upstream release, we do this so we can create a PR
# of Beeper -> upstream to run tests/confirm we're happy.
git checkout -f v1.96.1
git checkout -b upstream-1.96.1
git push -u beeper upstream-1.96.1

# Check out the base branch, pull any changes
git checkout beeper
git pull

# Now create a new branch to rebase
git checkout -b beeper-1.96.1
# And do the rebase
git rebase v1.96.1
# fix any conflicts...

# Push and make a PR from this branch to the upstream one created above
git push -u beeper beeper-1.96.1
```

### Make release

Once it's ready we just overwrite the `beeper` branch with the new one:

```
git checkout beeper-1.96.1
git push --force beeper beeper
```
4 changes: 4 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ COPY --from=requirements /synapse/requirements.txt /synapse/
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --prefix="/install" --no-deps --no-warn-script-location -r /synapse/requirements.txt

# Beeper: install shared secret authenticator
RUN pip install --prefix="/install" --no-deps --no-warn-script-location \
'git+https://github.com/devture/matrix-synapse-shared-secret-auth@e178353ec87c56e0169dd04466d4769da5ed9c46#egg=shared_secret_authenticator'

# Copy over the rest of the synapse source code.
COPY synapse /synapse/synapse/
COPY rust /synapse/rust/
Expand Down
116 changes: 100 additions & 16 deletions rust/src/push/base_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,76 @@ pub const BASE_APPEND_OVERRIDE_RULES: &[PushRule] = &[
default: true,
default_enabled: false,
},
// Disable notifications for auto-accepted room invites
// NOTE: this rule must be a higher prio than .m.rule.invite_for_me because
// that will also match the same events.
PushRule {
rule_id: Cow::Borrowed("global/override/.m.rule.suppress_notices"),
rule_id: Cow::Borrowed("global/override/.com.beeper.suppress_auto_invite"),
priority_class: 5,
conditions: Cow::Borrowed(&[
Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
key: Cow::Borrowed("type"),
pattern: Cow::Borrowed("m.room.member"),
})),
Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
key: Cow::Borrowed("content.membership"),
pattern: Cow::Borrowed("invite"),
})),
Condition::Known(KnownCondition::EventMatchType(EventMatchTypeCondition {
key: Cow::Borrowed("state_key"),
pattern_type: Cow::Borrowed(&EventMatchPatternType::UserId),
})),
Condition::Known(KnownCondition::EventPropertyIs(EventPropertyIsCondition {
key: Cow::Borrowed("content.fi\\.mau\\.will_auto_accept"),
value: Cow::Borrowed(&SimpleJsonValue::Bool(true)),
})),
]),
actions: Cow::Borrowed(&[Action::DontNotify]),
default: true,
default_enabled: true,
},
// We don't want to notify on edits. Not only can this be confusing in real
// time (2 notifications, one message) but it's especially confusing
// if a bridge needs to edit a previously backfilled message.
PushRule {
rule_id: Cow::Borrowed("global/override/.com.beeper.suppress_edits"),
priority_class: 5,
conditions: Cow::Borrowed(&[Condition::Known(KnownCondition::EventMatch(
EventMatchCondition {
key: Cow::Borrowed("content.msgtype"),
pattern: Cow::Borrowed("m.notice"),
key: Cow::Borrowed("content.m\\.relates_to.rel_type"),
pattern: Cow::Borrowed("m.replace"),
},
))]),
actions: Cow::Borrowed(&[]),
default: true,
default_enabled: true,
},
PushRule {
rule_id: Cow::Borrowed("global/override/.com.beeper.suppress_send_message_status"),
priority_class: 5,
conditions: Cow::Borrowed(&[
Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
key: Cow::Borrowed("type"),
pattern: Cow::Borrowed("com.beeper.message_send_status"),
})),
]),
actions: Cow::Borrowed(&[Action::DontNotify]),
default: true,
default_enabled: true,
},
PushRule {
rule_id: Cow::Borrowed("global/override/.com.beeper.suppress_power_levels"),
priority_class: 5,
conditions: Cow::Borrowed(&[
Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
key: Cow::Borrowed("type"),
pattern: Cow::Borrowed("cm.room.power_levels"),
})),
]),
actions: Cow::Borrowed(&[Action::DontNotify]),
default: true,
default_enabled: true,
},
PushRule {
rule_id: Cow::Borrowed("global/override/.m.rule.invite_for_me"),
priority_class: 5,
Expand Down Expand Up @@ -215,19 +272,6 @@ pub const BASE_APPEND_OVERRIDE_RULES: &[PushRule] = &[
default: true,
default_enabled: true,
},
PushRule {
rule_id: Cow::Borrowed("global/override/.m.rule.reaction"),
priority_class: 5,
conditions: Cow::Borrowed(&[Condition::Known(KnownCondition::EventMatch(
EventMatchCondition {
key: Cow::Borrowed("type"),
pattern: Cow::Borrowed("m.reaction"),
},
))]),
actions: Cow::Borrowed(&[]),
default: true,
default_enabled: true,
},
PushRule {
rule_id: Cow::Borrowed("global/override/.m.rule.room.server_acl"),
priority_class: 5,
Expand Down Expand Up @@ -290,6 +334,22 @@ pub const BASE_APPEND_CONTENT_RULES: &[PushRule] = &[PushRule {
}];

pub const BASE_APPEND_UNDERRIDE_RULES: &[PushRule] = &[
// Beeper change: this rule is moved down from override. This means room
// rules take precedence, so if you enable bot notifications (by modifying
// this rule) notifications will not be sent for muted rooms.
PushRule {
rule_id: Cow::Borrowed("global/underride/.m.rule.suppress_notices"),
priority_class: 1,
conditions: Cow::Borrowed(&[Condition::Known(KnownCondition::EventMatch(
EventMatchCondition {
key: Cow::Borrowed("content.msgtype"),
pattern: Cow::Borrowed("m.notice"),
},
))]),
actions: Cow::Borrowed(&[Action::DontNotify]),
default: true,
default_enabled: true,
},
PushRule {
rule_id: Cow::Borrowed("global/underride/.m.rule.call"),
priority_class: 1,
Expand Down Expand Up @@ -640,6 +700,30 @@ pub const BASE_APPEND_UNDERRIDE_RULES: &[PushRule] = &[
default: true,
default_enabled: true,
},
// Enable notifications for reactions to your own messages *in rooms with less
// than 20 members*.
PushRule {
rule_id: Cow::Borrowed("global/underride/.com.beeper.reaction"),
priority_class: 1,
conditions: Cow::Borrowed(&[
Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
key: Cow::Borrowed("type"),
pattern: Cow::Borrowed("m.reaction"),
})),
Condition::Known(KnownCondition::RoomMemberCount {
is: Some(Cow::Borrowed("<20")),
}),
Condition::Known(KnownCondition::RelatedEventMatchType(RelatedEventMatchTypeCondition {
key: Cow::Borrowed("sender"),
pattern_type: Cow::Borrowed(&EventMatchPatternType::UserId),
rel_type: Cow::Borrowed("m.annotation"),
include_fallbacks: None,
})),
]),
actions: Cow::Borrowed(&[Action::Notify, HIGHLIGHT_FALSE_ACTION]),
default: true,
default_enabled: true,
},
PushRule {
rule_id: Cow::Borrowed("global/underride/.org.matrix.msc3930.rule.poll_start_one_to_one"),
priority_class: 1,
Expand Down
2 changes: 2 additions & 0 deletions synapse/api/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class LoginType:
SSO: Final = "m.login.sso"
DUMMY: Final = "m.login.dummy"
REGISTRATION_TOKEN: Final = "m.login.registration_token"
JWT: Final = "org.matrix.login.jwt"


# This is used in the `type` parameter for /register when called by
Expand Down Expand Up @@ -268,6 +269,7 @@ class ReceiptTypes:
READ: Final = "m.read"
READ_PRIVATE: Final = "m.read.private"
FULLY_READ: Final = "m.fully_read"
BEEPER_INBOX_DONE: Final = "com.beeper.inbox.done"


class PublicRoomsFilterFields:
Expand Down
2 changes: 2 additions & 0 deletions synapse/app/generic_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
ApplicationServiceTransactionWorkerStore,
ApplicationServiceWorkerStore,
)
from synapse.storage.databases.main.beeper import BeeperStore
from synapse.storage.databases.main.censor_events import CensorEventsStore
from synapse.storage.databases.main.client_ips import ClientIpWorkerStore
from synapse.storage.databases.main.deviceinbox import DeviceInboxWorkerStore
Expand Down Expand Up @@ -155,6 +156,7 @@ class GenericWorkerStore(
LockStore,
SessionStore,
TaskSchedulerWorkerStore,
BeeperStore,
):
# Properties that multiple storage classes define. Tell mypy what the
# expected type is.
Expand Down
Loading
Loading