This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Integrate presence from hotfixes #3694
Merged
Merged
Changes from 25 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
03b1103
some way of running docker to run postgresql
hawkowl 25a3b5e
changes made in the hotfixes branch
hawkowl 3844e39
make it use a config option
hawkowl f21d641
add it as a default
hawkowl ed38a2e
initial tests
hawkowl 613068c
Merge remote-tracking branch 'origin/develop' into hawkowl/hotfixes-r…
hawkowl 3b7759f
some initial tests
hawkowl 16d20ff
minor fix
hawkowl f320a5e
other fix
hawkowl e49e3e0
fixes
hawkowl 850c47f
fix
hawkowl 204884f
changelog
hawkowl 3a905cd
fixes
hawkowl 48e1a7a
fix name
hawkowl 83f5c52
some fixes
hawkowl f95d03f
fix
hawkowl b985d80
fix test
hawkowl 6323339
fix
hawkowl 5908148
remove stuff not meant to be in this branch
hawkowl ede5fdb
clean comment
hawkowl 6c62124
port this over too
hawkowl bf83b44
tests & fixes
hawkowl 50a6bbc
Merge remote-tracking branch 'origin/develop' into hawkowl/hotfixes-r…
hawkowl 414e430
fix
hawkowl 72735e5
fix pep8
hawkowl c1c0d21
Merge remote-tracking branch 'origin/develop' into hawkowl/hotfixes-r…
hawkowl b9febad
docs, fix
hawkowl 45cac1a
fix
hawkowl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Synapse's presence functionality can now be disabled with the "use_presence" configuration option. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,6 +185,7 @@ def __nonzero__(self): | |
class SyncHandler(object): | ||
|
||
def __init__(self, hs): | ||
self.hs = hs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We try and avoid storing the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made it |
||
self.store = hs.get_datastore() | ||
self.notifier = hs.get_notifier() | ||
self.presence_handler = hs.get_presence_handler() | ||
|
@@ -860,7 +861,7 @@ def generate_sync_result(self, sync_config, since_token=None, full_state=False): | |
since_token is None and | ||
sync_config.filter_collection.blocks_all_presence() | ||
) | ||
if not block_all_presence_data: | ||
if self.hs.config.use_presence and not block_all_presence_data: | ||
yield self._generate_sync_entry_for_presence( | ||
sync_result_builder, newly_joined_rooms, newly_joined_users | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2018 New Vector Ltd | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from synapse.app.frontend_proxy import FrontendProxyServer | ||
|
||
from tests.unittest import HomeserverTestCase | ||
|
||
|
||
class FrontendProxyTests(HomeserverTestCase): | ||
def make_homeserver(self, reactor, clock): | ||
|
||
hs = self.setup_test_homeserver( | ||
http_client=None, homeserverToUse=FrontendProxyServer | ||
) | ||
|
||
return hs | ||
|
||
def test_listen_http_with_presence_enabled(self): | ||
""" | ||
When presence is on, the stub servlet will not register. | ||
""" | ||
# Presence is on | ||
self.hs.config.use_presence = True | ||
|
||
config = { | ||
"port": 8080, | ||
"bind_addresses": ["0.0.0.0"], | ||
"resources": [{"names": ["client"]}], | ||
} | ||
|
||
# Listen with the config | ||
self.hs._listen_http(config) | ||
|
||
# Grab the resource from the site that was told to listen | ||
self.assertEqual(len(self.reactor.tcpServers), 1) | ||
site = self.reactor.tcpServers[0][1] | ||
self.resource = ( | ||
site.resource.children["_matrix"].children["client"].children["r0"] | ||
) | ||
|
||
request, channel = self.make_request("PUT", "presence/a/status") | ||
self.render(request) | ||
|
||
# 400 + unrecognised, because nothing is registered | ||
self.assertEqual(channel.code, 400) | ||
self.assertEqual(channel.json_body["errcode"], "M_UNRECOGNIZED") | ||
|
||
def test_listen_http_with_presence_disabled(self): | ||
""" | ||
When presence is on, the stub servlet will register. | ||
""" | ||
# Presence is off | ||
self.hs.config.use_presence = False | ||
|
||
config = { | ||
"port": 8080, | ||
"bind_addresses": ["0.0.0.0"], | ||
"resources": [{"names": ["client"]}], | ||
} | ||
|
||
# Listen with the config | ||
self.hs._listen_http(config) | ||
|
||
# Grab the resource from the site that was told to listen | ||
self.assertEqual(len(self.reactor.tcpServers), 1) | ||
site = self.reactor.tcpServers[0][1] | ||
self.resource = ( | ||
site.resource.children["_matrix"].children["client"].children["r0"] | ||
) | ||
|
||
request, channel = self.make_request("PUT", "presence/a/status") | ||
self.render(request) | ||
|
||
# 401, because the stub servlet still checks authentication | ||
self.assertEqual(channel.code, 401) | ||
self.assertEqual(channel.json_body["errcode"], "M_MISSING_TOKEN") |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth mentioning in
docs/workers.rst
that you can point presence endpoints at frontend worker when presence is disabled?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done