Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: matrix-org/synapse
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 9b9750e538eda1609c493401d221227ee9abc603
Choose a base ref
..
head repository: matrix-org/synapse
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 6413bcd5a946b9624bb8b4085c79deb79f7d6a2a
Choose a head ref
23 changes: 23 additions & 0 deletions .github/workflows/dependabot_changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Write changelog for dependabot PR
on:
pull_request:
types:
- opened

jobs:
add-changelog:
runs-on: 'ubuntu-latest'
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Write, commit and push changelog
run: |
echo "${{ github.event.pull_request.title }}." > "changelog.d/${{ github.event.pull_request.number }}".docker
git add changelog.d
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "GitHub Actions"
git commit -m "Changelog"
git push
shell: bash
3 changes: 3 additions & 0 deletions build_rust.py
Original file line number Diff line number Diff line change
@@ -15,6 +15,9 @@ def build(setup_kwargs: Dict[str, Any]) -> None:
path=cargo_toml_path,
binding=Binding.PyO3,
py_limited_api=True,
# We force always building in release mode, as we can't tell the
# difference between using `poetry` in development vs production.
debug=False,
)
setup_kwargs.setdefault("rust_extensions", []).append(extension)
setup_kwargs["zip_safe"] = False
1 change: 1 addition & 0 deletions changelog.d/13925.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update mypy (0.950 -> 0.981) and mypy-zope (0.3.7 -> 0.3.11).
1 change: 1 addition & 0 deletions changelog.d/13960.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use dedicated `get_local_users_in_room(room_id)` function to find local users when calculating users to copy over during a room upgrade.
1 change: 1 addition & 0 deletions changelog.d/13966.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Refactor language in user directory `_track_user_joined_room` code to make it more clear that we use both local and remote users.
1 change: 1 addition & 0 deletions changelog.d/13969.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Revert catch-all exceptions being recorded as event pull attempt failures (only handle what we know about).
1 change: 1 addition & 0 deletions changelog.d/13992.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Speed up calculating push actions in large rooms.
1 change: 1 addition & 0 deletions changelog.d/13993.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update mypy (0.950 -> 0.981) and mypy-zope (0.3.7 -> 0.3.11).
1 change: 1 addition & 0 deletions changelog.d/13998.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Prototype a workflow to automatically add changelogs to dependabot PRs.
1 change: 1 addition & 0 deletions changelog.d/14009.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix bug where Rust extension wasn't built in `release` mode when using `poetry install`.
59 changes: 30 additions & 29 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions scripts-dev/check_pydantic_models.py
Original file line number Diff line number Diff line change
@@ -88,10 +88,9 @@ def make_wrapper(factory: Callable[P, R]) -> Callable[P, R]:

@functools.wraps(factory)
def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
# type-ignore: should be redundant once we can use https://github.com/python/mypy/pull/12668
if "strict" not in kwargs: # type: ignore[attr-defined]
if "strict" not in kwargs:
raise MissingStrictInConstrainedTypeException(factory.__name__)
if not kwargs["strict"]: # type: ignore[index]
if not kwargs["strict"]:
raise MissingStrictInConstrainedTypeException(factory.__name__)
return factory(*args, **kwargs)

4 changes: 1 addition & 3 deletions synapse/app/_base.py
Original file line number Diff line number Diff line change
@@ -98,9 +98,7 @@ def register_sighup(func: Callable[P, None], *args: P.args, **kwargs: P.kwargs)
func: Function to be called when sent a SIGHUP signal.
*args, **kwargs: args and kwargs to be passed to the target function.
"""
# This type-ignore should be redundant once we use a mypy release with
# https://github.com/python/mypy/pull/12668.
_sighup_callbacks.append((func, args, kwargs)) # type: ignore[arg-type]
_sighup_callbacks.append((func, args, kwargs))


def start_worker_reactor(
10 changes: 0 additions & 10 deletions synapse/handlers/federation_event.py
Original file line number Diff line number Diff line change
@@ -866,11 +866,6 @@ async def _process_pulled_event(
event.room_id, event_id, str(err)
)
return
except Exception as exc:
await self._store.record_event_failed_pull_attempt(
event.room_id, event_id, str(exc)
)
raise exc

try:
try:
@@ -913,11 +908,6 @@ async def _process_pulled_event(
logger.warning("Pulled event %s failed history check.", event_id)
else:
raise
except Exception as exc:
await self._store.record_event_failed_pull_attempt(
event.room_id, event_id, str(exc)
)
raise exc

@trace
async def _compute_event_context_with_maybe_missing_prevs(
4 changes: 2 additions & 2 deletions synapse/handlers/room_member.py
Original file line number Diff line number Diff line change
@@ -1150,8 +1150,8 @@ async def transfer_room_state_on_room_upgrade(
logger.info("Transferring room state from %s to %s", old_room_id, room_id)

# Find all local users that were in the old room and copy over each user's state
users = await self.store.get_users_in_room(old_room_id)
await self.copy_user_state_on_room_upgrade(old_room_id, room_id, users)
local_users = await self.store.get_local_users_in_room(old_room_id)
await self.copy_user_state_on_room_upgrade(old_room_id, room_id, local_users)

# Add new room to the room directory if the old room was there
# Remove old room from the room directory
36 changes: 24 additions & 12 deletions synapse/handlers/user_directory.py
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
# limitations under the License.

import logging
from typing import TYPE_CHECKING, Any, Dict, List, Optional
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Set, Tuple

import synapse.metrics
from synapse.api.constants import EventTypes, HistoryVisibility, JoinRules, Membership
@@ -379,7 +379,7 @@ async def _upsert_directory_entry_for_remote_user(
user_id, event.content.get("displayname"), event.content.get("avatar_url")
)

async def _track_user_joined_room(self, room_id: str, user_id: str) -> None:
async def _track_user_joined_room(self, room_id: str, joining_user_id: str) -> None:
"""Someone's just joined a room. Update `users_in_public_rooms` or
`users_who_share_private_rooms` as appropriate.
@@ -390,32 +390,44 @@ async def _track_user_joined_room(self, room_id: str, user_id: str) -> None:
room_id
)
if is_public:
await self.store.add_users_in_public_rooms(room_id, (user_id,))
await self.store.add_users_in_public_rooms(room_id, (joining_user_id,))
else:
users_in_room = await self.store.get_users_in_room(room_id)
other_users_in_room = [
other
for other in users_in_room
if other != user_id
if other != joining_user_id
and (
# We can't apply any special rules to remote users so
# they're always included
not self.is_mine_id(other)
# Check the special rules whether the local user should be
# included in the user directory
or await self.store.should_include_local_user_in_dir(other)
)
]
to_insert = set()
updates_to_users_who_share_rooms: Set[Tuple[str, str]] = set()

# First, if they're our user then we need to update for every user
if self.is_mine_id(user_id):
# First, if the joining user is our local user then we need an
# update for every other user in the room.
if self.is_mine_id(joining_user_id):
for other_user_id in other_users_in_room:
to_insert.add((user_id, other_user_id))
updates_to_users_who_share_rooms.add(
(joining_user_id, other_user_id)
)

# Next we need to update for every local user in the room
# Next, we need an update for every other local user in the room
# that they now share a room with the joining user.
for other_user_id in other_users_in_room:
if self.is_mine_id(other_user_id):
to_insert.add((other_user_id, user_id))
updates_to_users_who_share_rooms.add(
(other_user_id, joining_user_id)
)

if to_insert:
await self.store.add_users_who_share_private_room(room_id, to_insert)
if updates_to_users_who_share_rooms:
await self.store.add_users_who_share_private_room(
room_id, updates_to_users_who_share_rooms
)

async def _handle_remove_user(self, room_id: str, user_id: str) -> None:
"""Called when when someone leaves a room. The user may be local or remote.
20 changes: 10 additions & 10 deletions synapse/logging/context.py
Original file line number Diff line number Diff line change
@@ -586,29 +586,29 @@ def filter(self, record: logging.LogRecord) -> Literal[True]:
True to include the record in the log output.
"""
context = current_context()
record.request = self._default_request # type: ignore
record.request = self._default_request

# context should never be None, but if it somehow ends up being, then
# we end up in a death spiral of infinite loops, so let's check, for
# robustness' sake.
if context is not None:
# Logging is interested in the request ID. Note that for backwards
# compatibility this is stored as the "request" on the record.
record.request = str(context) # type: ignore
record.request = str(context)

# Add some data from the HTTP request.
request = context.request
if request is None:
return True

record.ip_address = request.ip_address # type: ignore
record.site_tag = request.site_tag # type: ignore
record.requester = request.requester # type: ignore
record.authenticated_entity = request.authenticated_entity # type: ignore
record.method = request.method # type: ignore
record.url = request.url # type: ignore
record.protocol = request.protocol # type: ignore
record.user_agent = request.user_agent # type: ignore
record.ip_address = request.ip_address
record.site_tag = request.site_tag
record.requester = request.requester
record.authenticated_entity = request.authenticated_entity
record.method = request.method
record.url = request.url
record.protocol = request.protocol
record.user_agent = request.user_agent

return True

4 changes: 2 additions & 2 deletions synapse/logging/opentracing.py
Original file line number Diff line number Diff line change
@@ -992,9 +992,9 @@ def _wrapping_logic(
# FIXME: We could update this to handle any type of function by ignoring the
# first argument only if it's named `self` or `cls`. This isn't fool-proof
# but handles the idiomatic cases.
for i, arg in enumerate(args[1:], start=1): # type: ignore[index]
for i, arg in enumerate(args[1:], start=1):
set_tag(SynapseTags.FUNC_ARG_PREFIX + argspec.args[i], str(arg))
set_tag(SynapseTags.FUNC_ARGS, str(args[len(argspec.args) :])) # type: ignore[index]
set_tag(SynapseTags.FUNC_ARGS, str(args[len(argspec.args) :]))
set_tag(SynapseTags.FUNC_KWARGS, str(kwargs))
yield

5 changes: 5 additions & 0 deletions synapse/push/bulk_push_rule_evaluator.py
Original file line number Diff line number Diff line change
@@ -332,6 +332,11 @@ async def action_for_event_by_user(
# Push rules say we should notify the user of this event
actions_by_user[uid] = actions

# If there aren't any actions then we can skip the rest of the
# processing.
if not actions_by_user:
return

# This is a check for the case where user joins a room without being
# allowed to see history, and then the server receives a delayed event
# from before the user joined, which they should not be pushed for
Loading