Synapse module to patch push rules when new users register
  • Python 95.4%
  • Shell 4.6%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2022-04-25 19:05:34 +02:00
.github Cookiecutter generation 2022-04-07 17:33:44 +01:00
scripts-dev Cookiecutter generation 2022-04-07 17:33:44 +01:00
synapse_patch_push_rules First cut of a module to automatically change push rule actions when new users register (#1) 2022-04-25 19:05:34 +02:00
tests First cut of a module to automatically change push rule actions when new users register (#1) 2022-04-25 19:05:34 +02:00
.gitignore Cookiecutter generation 2022-04-07 17:33:44 +01:00
.gitlab-ci.yml Cookiecutter generation 2022-04-07 17:33:44 +01:00
LICENSE Cookiecutter generation 2022-04-07 17:33:44 +01:00
mypy.ini Cookiecutter generation 2022-04-07 17:33:44 +01:00
pyproject.toml Cookiecutter generation 2022-04-07 17:33:44 +01:00
README.md First cut of a module to automatically change push rule actions when new users register (#1) 2022-04-25 19:05:34 +02:00
setup.cfg First cut of a module to automatically change push rule actions when new users register (#1) 2022-04-25 19:05:34 +02:00
tox.ini Cookiecutter generation 2022-04-07 17:33:44 +01:00

Push rules patcher

Synapse module to change the actions of specific push rules when a new user registers.

Installation

From the virtual environment that you use for Synapse, install this module with:

pip install path/to/synapse-patch-push-rules

(If you run into issues, you may need to upgrade pip first, e.g. by running pip install --upgrade pip)

Then alter your homeserver configuration, adding to your modules configuration:

modules:
  - module: synapse_patch_push_rules.PushRulesPatcher
    config:
      # Rules to change with new actions when new users register.
      # Required.
      rules:
        # The rule ID. Must be one of the predefined rules defined in the Matrix
        # specification. See https://spec.matrix.org/latest/client-server-api/#predefined-rules
        # for a complete list.
        ".m.rule.message":
          # The kind (override, underride or content) of the rule being modified.
          # Required.
          kind: "underride"
          # The new actions for this rule.
          # See https://spec.matrix.org/latest/client-server-api/#push-rules for a
          # reference on the allowed values and format.
          # Required.
          actions:
            - "dont_notify"

Development

In a virtual environment with pip ≥ 21.1, run

pip install -e .[dev]

To run the unit tests, you can either use:

tox -e py

or

trial tests

To run the linters and mypy type checker, use ./scripts-dev/lint.sh.

Releasing

The exact steps for releasing will vary; but this is an approach taken by the Synapse developers (assuming a Unix-like shell):

  1. Set a shell variable to the version you are releasing (this just makes subsequent steps easier):

    version=X.Y.Z
    
  2. Update setup.cfg so that the version is correct.

  3. Stage the changed files and commit.

    git add -u
    git commit -m v$version -n
    
  4. Push your changes.

    git push
    
  5. When ready, create a signed tag for the release:

    git tag -s v$version
    

    Base the tag message on the changelog.

  6. Push the tag.

    git push origin tag v$version
    
  7. Create a source distribution and upload it to PyPI:

    python -m build
    twine upload dist/synapse_patch_push_rules-$version*