summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-12-03 11:56:49 +0000
committerErik Johnston <erik@matrix.org>2014-12-03 11:56:49 +0000
commit6941a1971548ea8ba37130deeffe2a2e2cd88085 (patch)
tree9b6947d42c18e4a7ccb9c4e34525faa8e073cf76 /synapse
parentBegin fleshing out a new Event object (diff)
parentFix bug where did not always resolve all the deferreds in _attempt_new_transa... (diff)
downloadsynapse-6941a1971548ea8ba37130deeffe2a2e2cd88085.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse into events_refactor
Diffstat (limited to 'synapse')
-rw-r--r--synapse/__init__.py2
-rw-r--r--synapse/config/logger.py6
-rw-r--r--synapse/config/server.py7
-rw-r--r--synapse/federation/replication.py8
-rw-r--r--synapse/handlers/presence.py5
-rw-r--r--synapse/handlers/room.py6
-rw-r--r--synapse/rest/room.py4
-rw-r--r--synapse/storage/roommember.py4
-rw-r--r--synapse/streams/config.py6
9 files changed, 39 insertions, 9 deletions
diff --git a/synapse/__init__.py b/synapse/__init__.py
index 658574dab9..0b43932305 100644
--- a/synapse/__init__.py
+++ b/synapse/__init__.py
@@ -16,4 +16,4 @@
 """ This is a reference implementation of a synapse home server.
 """
 
-__version__ = "0.5.3a"
+__version__ = "0.5.3c"
diff --git a/synapse/config/logger.py b/synapse/config/logger.py
index 8566296433..089d906fa5 100644
--- a/synapse/config/logger.py
+++ b/synapse/config/logger.py
@@ -52,12 +52,18 @@ class LoggingConfig(Config):
         if self.log_config is None:
 
             level = logging.INFO
+            level_for_storage = logging.INFO
             if self.verbosity:
                 level = logging.DEBUG
+                if self.verbosity > 1:
+                    level_for_storage = logging.DEBUG
 
             # FIXME: we need a logging.WARN for a -q quiet option
             logger = logging.getLogger('')
             logger.setLevel(level)
+
+            logging.getLogger('synapse.storage').setLevel(level_for_storage)
+
             formatter = logging.Formatter(log_format)
             if self.log_file:
                 handler = logging.FileHandler(self.log_file)
diff --git a/synapse/config/server.py b/synapse/config/server.py
index 814a4c349b..f8a0844b8c 100644
--- a/synapse/config/server.py
+++ b/synapse/config/server.py
@@ -35,8 +35,11 @@ class ServerConfig(Config):
         if not args.content_addr:
             host = args.server_name
             if ':' not in host:
-                host = "%s:%d" % (host, args.bind_port)
-            args.content_addr = "https://%s" % (host,)
+                host = "%s:%d" % (host, args.unsecure_port)
+            else:
+                host = host.split(':')[0]
+                host = "%s:%d" % (host, args.unsecure_port)
+            args.content_addr = "http://%s" % (host,)
 
         self.content_addr = args.content_addr
 
diff --git a/synapse/federation/replication.py b/synapse/federation/replication.py
index 312d69fcaa..01f87fe423 100644
--- a/synapse/federation/replication.py
+++ b/synapse/federation/replication.py
@@ -853,7 +853,10 @@ class _TransactionQueue(object):
 
                 # Ensures we don't continue until all callbacks on that
                 # deferred have fired
-                yield deferred
+                try:
+                    yield deferred
+                except:
+                    pass
 
             logger.debug("TX [%s] Yielded to callbacks", destination)
 
@@ -865,7 +868,8 @@ class _TransactionQueue(object):
             logger.exception(e)
 
             for deferred in deferreds:
-                deferred.errback(e)
+                if not deferred.called:
+                    deferred.errback(e)
 
         finally:
             # We want to be *very* sure we delete this after we stop processing
diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py
index 179b431aa5..1808e00ae8 100644
--- a/synapse/handlers/presence.py
+++ b/synapse/handlers/presence.py
@@ -651,11 +651,16 @@ class PresenceHandler(BaseHandler):
             logger.debug("Incoming presence update from %s", user)
 
             observers = set(self._remote_recvmap.get(user, set()))
+            if observers:
+                logger.debug(" | %d interested local observers %r", len(observers), observers)
 
             rm_handler = self.homeserver.get_handlers().room_member_handler
             room_ids = yield rm_handler.get_rooms_for_user(user)
+            if room_ids:
+                logger.debug(" | %d interested room IDs %r", len(room_ids), room_ids)
 
             if not observers and not room_ids:
+                logger.debug(" | no interested observers or room IDs")
                 continue
 
             state = dict(push)
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py
index 315fb02e7b..6e1c37df03 100644
--- a/synapse/handlers/room.py
+++ b/synapse/handlers/room.py
@@ -522,7 +522,11 @@ class RoomMemberHandler(BaseHandler):
             user_id=user.to_string(), membership_list=membership_list
         )
 
-        defer.returnValue([r.room_id for r in rooms])
+        # For some reason the list of events contains duplicates
+        # TODO(paul): work out why because I really don't think it should
+        room_ids = set(r.room_id for r in rooms)
+
+        defer.returnValue(room_ids)
 
     @defer.inlineCallbacks
     def _do_local_membership_update(self, event, membership, snapshot,
diff --git a/synapse/rest/room.py b/synapse/rest/room.py
index cc6ffb9aff..3147d7a60b 100644
--- a/synapse/rest/room.py
+++ b/synapse/rest/room.py
@@ -327,7 +327,9 @@ class RoomMessageListRestServlet(RestServlet):
     @defer.inlineCallbacks
     def on_GET(self, request, room_id):
         user = yield self.auth.get_user_by_req(request)
-        pagination_config = PaginationConfig.from_request(request)
+        pagination_config = PaginationConfig.from_request(request,
+            default_limit=10,
+        )
         with_feedback = "feedback" in request.args
         handler = self.handlers.message_handler
         msgs = yield handler.get_messages(
diff --git a/synapse/storage/roommember.py b/synapse/storage/roommember.py
index c37df59d45..05b275663e 100644
--- a/synapse/storage/roommember.py
+++ b/synapse/storage/roommember.py
@@ -218,7 +218,9 @@ class RoomMemberStore(SQLBaseStore):
             "ON m.event_id = c.event_id "
             "WHERE m.membership = 'join' "
             "AND (%(clause)s) "
-            "GROUP BY m.room_id HAVING COUNT(m.room_id) = ?"
+            # TODO(paul): We've got duplicate rows in the database somewhere
+            #   so we have to DISTINCT m.user_id here
+            "GROUP BY m.room_id HAVING COUNT(DISTINCT m.user_id) = ?"
         ) % {"clause": user_list_clause}
 
         args = list(user_id_list)
diff --git a/synapse/streams/config.py b/synapse/streams/config.py
index 0317e78c08..2114c940e7 100644
--- a/synapse/streams/config.py
+++ b/synapse/streams/config.py
@@ -47,7 +47,8 @@ class PaginationConfig(object):
         self.limit = int(limit) if limit is not None else None
 
     @classmethod
-    def from_request(cls, request, raise_invalid_params=True):
+    def from_request(cls, request, raise_invalid_params=True,
+                     default_limit=None):
         def get_param(name, default=None):
             lst = request.args.get(name, [])
             if len(lst) > 1:
@@ -84,6 +85,9 @@ class PaginationConfig(object):
         if limit is not None and not limit.isdigit():
             raise SynapseError(400, "'limit' parameter must be an integer.")
 
+        if limit is None:
+            limit = default_limit
+
         try:
             return PaginationConfig(from_tok, to_tok, direction, limit)
         except: