Richard van der Hoff
c8f568ddf9
Fix up deferred handling in federation.py
...
* Avoid preserve_context_over_deferred, which is broken
* set consumeErrors=True on defer.gatherResults, to avoid spurious "unhandled
failure" erros
2017-10-06 22:14:24 +01:00
David Baker
f878e6f8af
Spam checking: add the invitee to user_may_invite
2017-10-05 14:02:28 +01:00
David Baker
1e375468de
pass room id too
2017-10-03 17:13:14 +01:00
Erik Johnston
e4ab96021e
Update comments
2017-10-03 14:10:41 +01:00
David Baker
2a7ed700d5
Fix param name & lint
2017-10-03 14:04:10 +01:00
David Baker
84716d267c
Allow spam checker to reject invites too
2017-10-03 13:56:43 +01:00
Erik Johnston
f2da6df568
Remove spurious line feed
2017-10-03 11:31:06 +01:00
Erik Johnston
30848c0fcd
Ignore incoming events for rooms that we have left
...
When synapse receives an event for a room its not in over federation, it
double checks with the remote server to see if it is in fact in the
room. This is done so that if the server has forgotten about the room
(usually as a result of the database being dropped) it can recover from
it.
However, in the presence of state resets in large rooms, this can cause
a lot of work for servers that have legitimately left. As a hacky
solution that supports both cases we drop incoming events for rooms that
we have explicitly left.
This means that we no longer support the case of servers having
forgotten that they've rejoined a room, but that is sufficiently rare
that we're not going to support it for now.
2017-10-03 11:18:21 +01:00
Richard van der Hoff
aa620d09a0
Add a config option to block all room invites ( #2457 )
...
- allows sysadmins the ability to lock down their servers so that people can't
send their users room invites.
2017-09-19 16:08:14 +01:00
Richard van der Hoff
2eabdf3f98
add some comments to on_exchange_third_party_invite_request
2017-09-19 12:20:36 +01:00
Richard van der Hoff
3f405b34e9
Fix overzealous kicking of guest users ( #2453 )
...
We should only kick guest users if the guest access event is authorised.
2017-09-19 08:52:52 +01:00
Erik Johnston
9a6fd3ef29
Don't compute push actions for backfilled events
2017-07-11 10:02:21 +01:00
Erik Johnston
5a7f561a9b
Fix bug where pusherpool didn't start and broke some rooms
...
Since we didn't instansiate the PusherPool at start time it could fail
at run time, which it did for some users.
This may or may not fix things for those users, but it should happen at
start time and stop the server from starting.
2017-07-06 17:55:51 +01:00
Mark Haines
3e279411fe
Improve the error handling for bad invites received over federation
2017-06-30 16:20:30 +01:00
Erik Johnston
d7fe6b356c
Add shutdown room API
2017-06-19 12:37:27 +01:00
Erik Johnston
1664948e41
Comment
2017-06-09 13:05:05 +01:00
Erik Johnston
7132e5cdff
Mark remote invite rejections as outliers
2017-06-09 10:08:18 +01:00
Erik Johnston
c049472b8a
Only store event_auth for state events
2017-05-24 15:23:31 +01:00
Erik Johnston
cafe659f72
Store ActionGenerator in HomeServer
2017-05-19 10:09:56 +01:00
Erik Johnston
7b222fc56e
Remove redundant reset of destination timers
2017-05-05 11:14:09 +01:00
Erik Johnston
ef862186dd
Merge together redundant calculations/logging
2017-05-03 10:06:43 +01:00
Erik Johnston
2347efc065
Fixup
2017-04-28 12:46:53 +01:00
Erik Johnston
9b147cd730
Remove unncessary call in _get_missing_events_for_pdu
2017-04-28 11:55:25 +01:00
Erik Johnston
3a9f5bf6dd
Don't fetch state for missing events that we fetched
2017-04-28 11:26:46 +01:00
Erik Johnston
87ae59f5e9
Typo
2017-04-27 15:16:21 +01:00
Erik Johnston
e42b4ebf0f
Add some extra logging for edge cases of federation
2017-04-27 14:38:21 +01:00
Richard van der Hoff
0cdb32fc43
Remove redundant try/except clauses
...
The `except SynapseError` clauses were pointless because the wrapped functions
would never throw a `SynapseError` (they either throw a `CodeMessageException`
or a `RuntimeError`).
The `except CodeMessageException` is now also pointless because the caller
treats all exceptions equally, so we may as well just throw the
`CodeMessageException`.
2017-04-21 01:32:01 +01:00
Erik Johnston
f3cf3ff8b6
Merge branch 'master' of github.com:matrix-org/synapse into develop
2017-04-11 11:13:32 +01:00
Richard van der Hoff
64765e5199
When we do an invite rejection, save the signed leave event to the db
...
During a rejection of an invite received over federation, we ask a remote
server to make us a `leave` event, then sign it, then send that with
`send_leave`.
We were saving the *unsigned* version of the event (which has a different event
id to the signed version) to our db (and sending it to the clients), whereas
other servers in the room will have seen the *signed* version. We're not aware
of any actual problems that caused, except that it makes the database confusing
to look at and generally leaves the room in a weird state.
2017-04-07 14:39:32 +01:00
Richard van der Hoff
773e64cc1a
Merge pull request #2095 from matrix-org/rav/cull_log_preserves
...
Cull spurious PreserveLoggingContexts
2017-04-03 17:02:25 +01:00
Richard van der Hoff
30bcbf775a
Accept join events from all servers
...
Make sure that we accept join events from any server, rather than just the
origin server, to make the federation join dance work correctly.
(Fixes #1893 ).
2017-04-03 15:58:07 +01:00
Richard van der Hoff
0b08c48fc5
Remove more spurious PreserveLoggingContext
s
...
Remove `PreserveLoggingContext` around calls to `Notifier.on_new_room_event`;
there is no problem if the logcontext is set when calling it.
2017-04-03 15:43:37 +01:00
Richard van der Hoff
eddce9d74a
Merge pull request #2027 from matrix-org/rav/logcontext_leaks
...
A few fixes to logcontext things
2017-03-20 11:53:36 +00:00
Richard van der Hoff
f40c2db05a
Stop preserve_fn leaking context into the reactor
...
Fix a bug in ``logcontext.preserve_fn`` which made it leak context into the
reactor, and add a test for it.
Also, get rid of ``logcontext.reset_context_after_deferred``, which tried to do
the same thing but had its own, different, set of bugs.
2017-03-18 00:07:43 +00:00
Richard van der Hoff
5068fb16a5
Refactoring and cleanups
...
A few non-functional changes:
* A bunch of docstrings to document types
* Split `EventsStore._persist_events_txn` up a bit. Hopefully it's a bit more
readable.
* Rephrase `EventFederationStore._update_min_depth_for_room_txn` to avoid
mind-bending conditional.
* Rephrase rejected/outlier conditional in `_update_outliers_txn` to avoid
mind-bending conditional.
2017-03-17 15:06:07 +00:00
Richard van der Hoff
9ce53a3861
Queue up federation PDUs while a room join is in progress
...
This just takes the existing `room_queues` logic and moves it out to
`on_receive_pdu` instead of `_process_received_pdu`, which ensures that we
don't start trying to fetch prev_events and whathaveyou until the join has
completed.
2017-03-15 18:01:11 +00:00
Richard van der Hoff
29235901b8
Move FederationServer._handle_new_pdu to FederationHandler
...
Unfortunately this significantly increases the size of the already-rather-big
FederationHandler, but the code fits more naturally here, and it paves the way
for the tighter integration that I need between handling incoming PDUs and
doing the join dance.
Other than renaming the existing `FederationHandler.on_receive_pdu` to
`_process_received_pdu` to make way for it, this just consists of the move, and
replacing `self.handler` with `self` and `self` with `self.replication_layer`.
2017-03-09 16:20:13 +00:00
Erik Johnston
848cf95ea0
Pop with default value to stop throwing
2017-02-28 10:02:54 +00:00
Erik Johnston
64a2cef9bb
Pop rather than del from dict
2017-02-27 19:15:36 +00:00
Erik Johnston
09eb08f910
Derive current_state_events from state groups
2017-01-20 11:52:51 +00:00
Erik Johnston
f9058ca785
Merge pull request #1822 from matrix-org/erikj/statE_logging
...
Change resolve_state_groups call site logging to DEBUG
2017-01-18 11:02:03 +00:00
Erik Johnston
5f027d1fc5
Change resolve_state_groups call site logging to DEBUG
2017-01-17 17:07:15 +00:00
Erik Johnston
e6153e1bd1
Fix couple of federation state bugs
2017-01-17 13:22:34 +00:00
Erik Johnston
5d6bad1b3c
Optimise state resolution
2017-01-17 13:22:19 +00:00
Matthew Hodgson
883ff92a7f
Fix case
2017-01-05 13:45:02 +00:00
Matthew Hodgson
d79d165761
add logging for all the places we call resolve_state_groups. my kingdom for a backtrace that actually works.
2017-01-05 13:40:39 +00:00
Mark Haines
f784980d2b
Only send events that originate on this server.
...
Or events that are sent via the federation "send_join" API.
This should match the behaviour from before v0.18.5 and #1635 landed.
2017-01-05 11:26:30 +00:00
Erik Johnston
b8255eba26
Comment
2016-12-14 13:49:54 +00:00
Erik Johnston
b2999a7055
Fix /backfill returning events it shouldn't
2016-12-14 13:41:45 +00:00
Erik Johnston
feec718265
Shuffle receipt handler around so that worker apps don't need to load it
2016-11-23 15:14:24 +00:00
Erik Johnston
9687e039e7
Remove explicit calls to send_pdu
2016-11-21 14:48:51 +00:00
Erik Johnston
59ef517e6b
Use new federation_sender DI
2016-11-16 14:47:52 +00:00
Erik Johnston
2e9ee30969
Add comments
2016-09-22 11:59:46 +01:00
Erik Johnston
1168cbd54d
Allow invites via 3pid to bypass sender sig check
...
When a server sends a third party invite another server may be the one
that the inviting user registers with. In this case it is that remote
server that will issue an actual invitation, and wants to do it "in the
name of" the original invitee. However, the new proper invite will not
be signed by the original server, and thus other servers would reject
the invite if it was seen as coming from the original user.
To fix this, a special case has been added to the auth rules whereby
another server can send an invite "in the name of" another server's
user, so long as that user had previously issued a third party invite
that is now being accepted.
2016-09-22 10:56:53 +01:00
Erik Johnston
d5ae1f1291
Ensure we don't mutate state cache entries
2016-09-14 10:03:48 +01:00
Erik Johnston
69a2d4e38c
Use get_joined_users_from_context instead of manually looking up hosts
2016-09-05 13:44:40 +01:00
Erik Johnston
273b6bcf22
Merge pull request #1064 from matrix-org/erikj/on_receive_check
...
Only check if host is in room if we have state and auth_chain
2016-09-02 14:43:35 +01:00
Erik Johnston
f7f1027d3d
Comment on when auth chain and state are None
2016-09-02 14:42:38 +01:00
Erik Johnston
34e5e17f91
Comment
2016-09-02 14:26:07 +01:00
Erik Johnston
b96c6c3185
Docstrings
2016-09-02 14:19:22 +01:00
Erik Johnston
bd9b8d87ae
Only check if host is in room if we have state and auth_chain
2016-09-02 13:40:28 +01:00
Erik Johnston
2854ee2a52
Only pull out IDs from DB for /state_ids/ request
2016-09-02 10:53:36 +01:00
Erik Johnston
c10cb581c6
Correctly handle the difference between prev and current state
2016-08-31 14:26:22 +01:00
Erik Johnston
11faa4296d
Measure _filter_events_for_server
2016-08-26 11:15:40 +01:00
Erik Johnston
f6338d6a3e
Don't pull out full state for _filter_events_for_server
2016-08-26 11:13:16 +01:00
Erik Johnston
30961182f2
Merge branch 'develop' of github.com:matrix-org/synapse into erikj/state_ids
2016-08-26 09:48:13 +01:00
Erik Johnston
a3dc1e9cbe
Replace context.current_state with context.current_state_ids
2016-08-25 17:32:22 +01:00
Erik Johnston
17f4f14df7
Pull out event ids rather than full events for state
2016-08-25 13:42:44 +01:00
Erik Johnston
cd5b264b03
Fix None check in backfill
2016-08-25 10:39:19 +01:00
Erik Johnston
fda97dd58a
Merge branch 'develop' of github.com:matrix-org/synapse into erikj/preserve_log_contexts
2016-08-24 13:22:02 +01:00
Erik Johnston
9219139351
Preserve some logcontexts
2016-08-24 11:58:40 +01:00
Erik Johnston
ba07d4a70e
Add None checks to backfill
2016-08-24 10:31:05 +01:00
Erik Johnston
2ee1bd124c
Limit number of extremeties in backfill request
...
This works around a bug where if we make a backfill request with too
many extremeties it causes the request URI to be too long.
2016-08-16 11:34:36 +01:00
Erik Johnston
739ea29d1e
Also check if server is in the room
2016-08-10 13:32:23 +01:00
Erik Johnston
7f41bcbeec
Correctly auth /event/ requests
2016-08-10 13:22:20 +01:00
Erik Johnston
11fdfaf03b
Only resign our own events
2016-08-10 13:16:58 +01:00
Erik Johnston
93acf49e9b
Fix backfill auth events
2016-08-05 12:59:04 +01:00
Erik Johnston
7b0f6293f2
Merge pull request #940 from matrix-org/erikj/fed_state_cache
...
Cache federation state responses
2016-08-02 15:21:37 +01:00
Erik Johnston
c51a52f300
Mention that func will fetch auth events
2016-07-29 11:17:04 +01:00
Erik Johnston
3d13c3a295
Update docstring
2016-07-29 10:45:05 +01:00
Erik Johnston
1e2740caab
Handle the case of missing auth events when joining a room
2016-07-28 16:08:33 +01:00
Erik Johnston
248e6770ca
Cache federation state responses
2016-07-21 10:30:12 +01:00
Erik Johnston
57dca35692
Don't notify pusher pool for backfilled events
2016-07-20 13:25:06 +01:00
Erik Johnston
9e1b43bcbf
Comment
2016-07-15 09:29:54 +01:00
Erik Johnston
ebdafd8114
Check sender signed event
2016-07-14 17:03:24 +01:00
Erik Johnston
2d21d43c34
Add purge_history API
2016-07-05 10:28:51 +01:00
Erik Johnston
2884712ca7
Only re-sign our own events
2016-06-17 14:47:33 +01:00
Erik Johnston
b31c49d676
Correctly mark backfilled events as backfilled
2016-06-15 10:59:08 +01:00
Mark Haines
0b2158719c
Remove dead code.
...
Loading push rules now happens in the datastore, so we can remove
the methods that loaded them outside the datastore.
The ``waiting_for_join_list`` in federation handler is populated by
anything, so can be removed.
The ``_get_members_events_txn`` method isn't called from anywhere
so can be removed.
2016-06-07 15:07:11 +01:00
Mark Haines
1a3a2002ff
Spell "domain" correctly
...
s/domian/domain/g
2016-05-16 19:17:23 +01:00
Mark Haines
a458a40337
missed a spot
2016-05-12 18:19:58 +01:00
Mark Haines
30057b1e15
Move _create_new_client_event and handle_new_client_event out of base handler
2016-05-11 09:09:20 +01:00
Erik Johnston
08dfa8eee2
Add and use get_domian_from_id
2016-05-09 10:36:03 +01:00
Erik Johnston
c53f9d561e
Don't auto log failed auth checks
2016-04-13 11:11:46 +01:00
Erik Johnston
c48465dbaa
More comments
2016-04-12 12:48:30 +01:00
Erik Johnston
8be1a37909
More comments
2016-04-12 12:04:19 +01:00
Erik Johnston
d3d0be4167
Don't append to unused list
2016-04-12 11:59:00 +01:00
Erik Johnston
762ada1e07
Add back backfilled parameter that was removed
2016-04-12 11:58:04 +01:00
Erik Johnston
0d3da210f0
Add comment
2016-04-12 11:54:41 +01:00
Erik Johnston
cccf86dd05
Check if we've already backfilled events
2016-04-12 11:19:32 +01:00
David Baker
2547dffccc
Merge pull request #705 from matrix-org/dbkr/pushers_use_event_actions
...
Change pushers to use the event_actions table
2016-04-11 12:58:55 +01:00
Mark Haines
b9ee5650b0
Move all the wrapper functions for distributor.fire
...
Move the functions inside the distributor and import them
where needed. This reduces duplication and makes it possible
for flake8 to detect when the functions aren't used in a
given file.
2016-04-08 11:01:38 +01:00
David Baker
9c99ab4572
Merge remote-tracking branch 'origin/develop' into dbkr/pushers_use_event_actions
2016-04-07 16:35:22 +01:00
David Baker
7e2c89a37f
Make pushers use the event_push_actions table instead of listening on an event stream & running the rules again. Sytest passes, but remaining to do:
...
* Make badges work again
* Remove old, unused code
2016-04-06 15:42:15 +01:00
Erik Johnston
c2b429ab24
Merge pull request #693 from matrix-org/erikj/backfill_self
...
Don't backfill from self
2016-04-05 13:04:36 +01:00
Erik Johnston
6222ae51ce
Don't backfill from self
2016-04-05 12:56:29 +01:00
Erik Johnston
b29f98377d
Merge pull request #691 from matrix-org/erikj/member
...
Fix stuck invites
2016-04-05 12:44:39 +01:00
Erik Johnston
df727f2126
Fix stuck invites
...
If rejecting a remote invite fails with an error response don't fail
the entire request; instead mark the invite as locally rejected.
This fixes the bug where users can get stuck invites which they can
neither accept nor reject.
2016-04-05 11:13:24 +01:00
Mark Haines
89e6839a48
Merge pull request #686 from matrix-org/markjh/doc_strings
...
Use google style doc strings.
2016-04-01 16:20:09 +01:00
Mark Haines
2a37467fa1
Use google style doc strings.
...
pycharm supports them so there is no need to use the other format.
Might as well convert the existing strings to reduce the risk of
people accidentally cargo culting the wrong doc string format.
2016-04-01 16:12:07 +01:00
Mark Haines
dc4c1579d4
Remove outlier parameter from compute_event_context
...
Use event.internal_metadata.is_outlier instead.
2016-03-31 15:32:24 +01:00
Mark Haines
76503f95ed
Remove the is_new_state argument to persist event.
...
Move the checks for whether an event is new state inside persist
event itself.
This was harder than expected because there wasn't enough information
passed to persist event to correctly handle invites from remote servers
for new rooms.
2016-03-31 15:00:42 +01:00
Mark Haines
5244c0b48e
Remove unused backfilled parameter from persist_event
2016-03-21 18:06:08 +00:00
Mark Haines
58f8226c7f
remove unused current_state variable from on_receive_pdu
2016-03-21 14:20:34 +00:00
Erik Johnston
e5f0e58931
Remove needless PreserveLoggingContext
2016-03-15 13:48:40 +00:00
Erik Johnston
9e982750ee
Persist rejection of invites over federation
2016-03-15 13:24:31 +00:00
Mark Haines
239badea9b
Use syntax that works on both py2.7 and py3
2016-03-07 20:13:10 +00:00
Daniel Wagner-Hall
b4022cc487
Pass whole requester to ratelimiting
...
This will enable more detailed decisions
2016-03-03 16:43:42 +00:00
Daniel Wagner-Hall
577951b032
Allow third_party_signed to be specified on /join
2016-02-23 15:11:25 +00:00
Daniel Wagner-Hall
4bfb32f685
Branch off member and non member sends
...
Unclean, needs tidy-up, but works
2016-02-15 18:21:30 +00:00
Erik Johnston
7b0d846407
Atomically persit push actions when we persist the event
2016-02-09 16:19:15 +00:00
Erik Johnston
2c1fbea531
Fix up logcontexts
2016-02-08 14:26:45 +00:00
Richard van der Hoff
d6d60b4d6c
Federation: drop events which cause SynapseErrors
...
... rather than rejecting any attempt to federate channels which contain such
events.
2016-01-27 17:02:10 +00:00
Erik Johnston
5a7d1ecffc
Add regex cache. Only caculate push actions for users that have sent read receipts, and are on that server
2016-01-19 16:01:05 +00:00
Erik Johnston
63485b3029
Re-enable urnead notifications
2016-01-18 14:48:30 +00:00
Daniel Wagner-Hall
ac5a4477ad
Require unbanning before other membership changes
2016-01-15 16:27:26 +00:00
Erik Johnston
fcb05b4c82
Temporarily disable notification branch
2016-01-13 17:39:58 +00:00
David Baker
c232780081
Merge pull request #456 from matrix-org/store_event_actions
...
Send unread notification counts
2016-01-08 14:47:15 +00:00
Matthew Hodgson
6c28ac260c
copyrights
2016-01-07 04:26:29 +00:00
David Baker
c79f221192
Add is_guest flag to users db to track whether a user is a guest user or not. Use this so we can run _filter_events_for_client when calculating event_push_actions.
2016-01-06 11:38:09 +00:00
David Baker
3051c9d002
Address minor PR issues
2016-01-04 13:39:29 +00:00
David Baker
c061b47c57
Merge remote-tracking branch 'origin/develop' into store_event_actions
2015-12-21 15:30:26 +00:00
David Baker
f73f154ec2
Only run pushers for users on this hs!
2015-12-21 15:28:54 +00:00
Daniel Wagner-Hall
bdacee476d
Add display_name to 3pid invite in m.room.member invites
2015-12-17 18:55:08 +01:00
Daniel Wagner-Hall
8c5f252edb
Strip address and such out of 3pid invites
...
We're not meant to leak that into the graph
2015-12-17 18:09:51 +01:00
David Baker
a84a693327
Having consulted The Erikle, this should go at the end of on_receive_pdu, otherwise it will be triggered whenever we backfill too.
2015-12-10 17:18:46 +00:00
Paul "LeoNerd" Evans
99afb4b750
Ensure that the event that gets persisted is the one that was signed
2015-12-10 17:08:21 +00:00
David Baker
21f135ba76
Very first cut of calculating actions for events as they come in. Doesn't store them yet. Not very efficient.
2015-12-10 16:26:08 +00:00
Mark Haines
c2c70f7daf
Use the context returned by _handle_new_event
2015-12-02 12:01:24 +00:00
Mark Haines
c30cdb0d68
Add comments
2015-12-02 10:49:35 +00:00
Mark Haines
2a0ec3b89d
Merge branch 'develop' into markjh/edu_frequency
...
Conflicts:
synapse/handlers/federation.py
synapse/handlers/room.py
2015-12-02 10:40:22 +00:00
Mark Haines
a9526831a4
Wrap calls to distributor.fire in appropriately named functions so that static analysis can work out want is calling what
2015-12-01 20:53:04 +00:00
Mark Haines
ed0f79bdc5
Only fire user_joined_room if the membership has changed
2015-12-01 19:46:15 +00:00
Erik Johnston
c0b3554401
Fix missing profile data in federation joins
...
There was a regression where we stopped including profile data in
initial joins for rooms joined over federation.
2015-11-12 16:19:55 +00:00
Daniel Wagner-Hall
38d82edf0e
Allow guest users to join and message rooms
2015-11-10 16:57:13 +00:00
Daniel Wagner-Hall
2cebe53545
Exchange 3pid invites for m.room.member invites
2015-11-05 16:43:19 +00:00
Mark Haines
c452dabc3d
Remove the LockManager class because it wasn't being used
2015-11-04 14:08:15 +00:00
Daniel Wagner-Hall
137fafce4e
Allow rejecting invites
...
This is done by using the same /leave flow as you would use if you had
already accepted the invite and wanted to leave.
2015-10-20 11:58:58 +01:00
Daniel Wagner-Hall
f38df51e8d
Merge branch 'develop' into daniel/3pidinvites
2015-10-15 11:51:55 +01:00
Erik Johnston
858634e1d0
Remove unused room_id arg
2015-10-14 09:31:20 +01:00