mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-09-07 15:51:53 +00:00
Merge branch 'develop' of github.com:matrix-org/synapse into client_server_url_rename
This commit is contained in:
commit
27979028b2
@ -6,7 +6,7 @@ CWD=$(pwd)
|
||||
|
||||
cd "$DIR/.."
|
||||
|
||||
for port in "8080" "8081" "8082"; do
|
||||
for port in 8080 8081 8082; do
|
||||
echo "Starting server on port $port... "
|
||||
|
||||
python -m synapse.app.homeserver \
|
||||
@ -15,7 +15,8 @@ for port in "8080" "8081" "8082"; do
|
||||
-f "$DIR/$port.log" \
|
||||
-d "$DIR/$port.db" \
|
||||
-vv \
|
||||
-D --pid-file "$DIR/$port.pid"
|
||||
-D --pid-file "$DIR/$port.pid" \
|
||||
--manhole $((port + 1000))
|
||||
done
|
||||
|
||||
echo "Starting webclient on port 8000..."
|
||||
|
@ -31,6 +31,7 @@ from synapse.api.urls import (
|
||||
)
|
||||
|
||||
from daemonize import Daemonize
|
||||
import twisted.manhole.telnet
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
@ -238,6 +239,8 @@ def setup():
|
||||
default="hs.pid")
|
||||
parser.add_argument("-W", "--webclient", dest="webclient", default=True,
|
||||
action="store_false", help="Don't host a web client.")
|
||||
parser.add_argument("--manhole", dest="manhole", type=int, default=None,
|
||||
help="Turn on the twisted telnet manhole service.")
|
||||
args = parser.parse_args()
|
||||
|
||||
verbosity = int(args.verbose) if args.verbose else None
|
||||
@ -281,6 +284,13 @@ def setup():
|
||||
|
||||
hs.build_db_pool()
|
||||
|
||||
if args.manhole:
|
||||
f = twisted.manhole.telnet.ShellFactory()
|
||||
f.username = "matrix"
|
||||
f.password = "rabbithole"
|
||||
f.namespace['hs'] = hs
|
||||
reactor.listenTCP(args.manhole, f, interface='127.0.0.1')
|
||||
|
||||
if args.daemonize:
|
||||
daemon = Daemonize(
|
||||
app="synapse-homeserver",
|
||||
|
@ -159,12 +159,11 @@ class PresenceHandler(BaseHandler):
|
||||
if allowed_by_subscription:
|
||||
defer.returnValue(True)
|
||||
|
||||
rm_handler = self.homeserver.get_handlers().room_member_handler
|
||||
for room_id in (yield rm_handler.get_rooms_for_user(observer_user)):
|
||||
if observed_user in (yield rm_handler.get_room_members(room_id)):
|
||||
defer.returnValue(True)
|
||||
share_room = yield self.store.do_users_share_a_room(
|
||||
[observer_user, observed_user]
|
||||
)
|
||||
|
||||
defer.returnValue(False)
|
||||
defer.returnValue(share_room)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def get_state(self, target_user, auth_user):
|
||||
|
@ -150,3 +150,24 @@ class RoomMemberStore(SQLBaseStore):
|
||||
|
||||
results = [self._parse_event_from_row(r) for r in rows]
|
||||
defer.returnValue(results)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def do_users_share_a_room(self, user_list):
|
||||
""" Checks whether a list of users share a room.
|
||||
"""
|
||||
user_list_clause = " OR ".join(["m.user_id = ?"] * len(user_list))
|
||||
sql = (
|
||||
"SELECT m.room_id FROM room_memberships as m "
|
||||
"INNER JOIN current_state_events as c "
|
||||
"ON m.event_id = c.event_id "
|
||||
"WHERE m.membership = 'join' "
|
||||
"AND (%(clause)s) "
|
||||
"GROUP BY m.room_id HAVING COUNT(m.room_id) = ?"
|
||||
) % {"clause": user_list_clause}
|
||||
|
||||
args = user_list
|
||||
args.append(len(user_list))
|
||||
|
||||
rows = yield self._execute(None, sql, *args)
|
||||
|
||||
defer.returnValue(len(rows) > 0)
|
||||
|
Loading…
Reference in New Issue
Block a user