mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-09-09 14:02:25 +00:00
Merge branch 'hotfixes-v0.6.0'
This commit is contained in:
commit
420ccfc925
@ -2,6 +2,12 @@ Changes in synapse 0.6.0 (2014-12-16)
|
|||||||
=====================================
|
=====================================
|
||||||
|
|
||||||
* Add new API for media upload and download that supports thumbnailing.
|
* Add new API for media upload and download that supports thumbnailing.
|
||||||
|
* Replicate media uploads over multiple homeservers so media is always served
|
||||||
|
to clients from their local homeserver. This obsoletes the
|
||||||
|
--content-addr parameter and confusion over accessing content directly
|
||||||
|
from remote homeservers.
|
||||||
|
* Implement exponential backoff when retrying federation requests when
|
||||||
|
sending to remote homeservers which are offline.
|
||||||
* Implement typing notifications.
|
* Implement typing notifications.
|
||||||
* Fix bugs where we sent events with invalid signatures due to bugs where
|
* Fix bugs where we sent events with invalid signatures due to bugs where
|
||||||
we incorrectly persisted events.
|
we incorrectly persisted events.
|
||||||
|
@ -155,4 +155,4 @@ class DirectoryHandler(BaseHandler):
|
|||||||
"room_id": room_id,
|
"room_id": room_id,
|
||||||
"sender": user_id,
|
"sender": user_id,
|
||||||
"content": {"aliases": aliases},
|
"content": {"aliases": aliases},
|
||||||
})
|
}, ratelimit=False)
|
||||||
|
@ -19,6 +19,7 @@ from synapse.api.constants import EventTypes, Membership
|
|||||||
from synapse.api.errors import RoomError
|
from synapse.api.errors import RoomError
|
||||||
from synapse.streams.config import PaginationConfig
|
from synapse.streams.config import PaginationConfig
|
||||||
from synapse.events.validator import EventValidator
|
from synapse.events.validator import EventValidator
|
||||||
|
from synapse.util.logcontext import PreserveLoggingContext
|
||||||
|
|
||||||
from ._base import BaseHandler
|
from ._base import BaseHandler
|
||||||
|
|
||||||
@ -106,7 +107,7 @@ class MessageHandler(BaseHandler):
|
|||||||
defer.returnValue(chunk)
|
defer.returnValue(chunk)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def create_and_send_event(self, event_dict):
|
def create_and_send_event(self, event_dict, ratelimit=True):
|
||||||
""" Given a dict from a client, create and handle a new event.
|
""" Given a dict from a client, create and handle a new event.
|
||||||
|
|
||||||
Creates an FrozenEvent object, filling out auth_events, prev_events,
|
Creates an FrozenEvent object, filling out auth_events, prev_events,
|
||||||
@ -123,7 +124,8 @@ class MessageHandler(BaseHandler):
|
|||||||
|
|
||||||
self.validator.validate_new(builder)
|
self.validator.validate_new(builder)
|
||||||
|
|
||||||
self.ratelimit(builder.user_id)
|
if ratelimit:
|
||||||
|
self.ratelimit(builder.user_id)
|
||||||
# TODO(paul): Why does 'event' not have a 'user' object?
|
# TODO(paul): Why does 'event' not have a 'user' object?
|
||||||
user = self.hs.parse_userid(builder.user_id)
|
user = self.hs.parse_userid(builder.user_id)
|
||||||
assert self.hs.is_mine(user), "User must be our own: %s" % (user,)
|
assert self.hs.is_mine(user), "User must be our own: %s" % (user,)
|
||||||
@ -152,6 +154,11 @@ class MessageHandler(BaseHandler):
|
|||||||
context=context,
|
context=context,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if event.type == EventTypes.Message:
|
||||||
|
presence = self.hs.get_handlers().presence_handler
|
||||||
|
with PreserveLoggingContext():
|
||||||
|
presence.bump_presence_active_time(user)
|
||||||
|
|
||||||
defer.returnValue(event)
|
defer.returnValue(event)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
@ -194,6 +194,8 @@ class ProfileHandler(BaseHandler):
|
|||||||
if not self.hs.is_mine(user):
|
if not self.hs.is_mine(user):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
self.ratelimit(user.to_string())
|
||||||
|
|
||||||
joins = yield self.store.get_rooms_for_user_where_membership_is(
|
joins = yield self.store.get_rooms_for_user_where_membership_is(
|
||||||
user.to_string(),
|
user.to_string(),
|
||||||
[Membership.JOIN],
|
[Membership.JOIN],
|
||||||
@ -214,5 +216,5 @@ class ProfileHandler(BaseHandler):
|
|||||||
"room_id": j.room_id,
|
"room_id": j.room_id,
|
||||||
"state_key": j.state_key,
|
"state_key": j.state_key,
|
||||||
"content": content,
|
"content": content,
|
||||||
"sender": j.state_key,
|
"sender": j.state_key
|
||||||
})
|
}, ratelimit=False)
|
||||||
|
@ -130,6 +130,7 @@ class RoomCreationHandler(BaseHandler):
|
|||||||
"type": EventTypes.Name,
|
"type": EventTypes.Name,
|
||||||
"room_id": room_id,
|
"room_id": room_id,
|
||||||
"sender": user_id,
|
"sender": user_id,
|
||||||
|
"state_key": "",
|
||||||
"content": {"name": name},
|
"content": {"name": name},
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -139,6 +140,7 @@ class RoomCreationHandler(BaseHandler):
|
|||||||
"type": EventTypes.Topic,
|
"type": EventTypes.Topic,
|
||||||
"room_id": room_id,
|
"room_id": room_id,
|
||||||
"sender": user_id,
|
"sender": user_id,
|
||||||
|
"state_key": "",
|
||||||
"content": {"topic": topic},
|
"content": {"topic": topic},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -135,26 +135,26 @@ class RoomStore(SQLBaseStore):
|
|||||||
defer.returnValue(ret)
|
defer.returnValue(ret)
|
||||||
|
|
||||||
def _store_room_topic_txn(self, txn, event):
|
def _store_room_topic_txn(self, txn, event):
|
||||||
if hasattr(event, "topic"):
|
if hasattr(event, "content") and "topic" in event.content:
|
||||||
self._simple_insert_txn(
|
self._simple_insert_txn(
|
||||||
txn,
|
txn,
|
||||||
"topics",
|
"topics",
|
||||||
{
|
{
|
||||||
"event_id": event.event_id,
|
"event_id": event.event_id,
|
||||||
"room_id": event.room_id,
|
"room_id": event.room_id,
|
||||||
"topic": event.topic,
|
"topic": event.content["topic"],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
def _store_room_name_txn(self, txn, event):
|
def _store_room_name_txn(self, txn, event):
|
||||||
if hasattr(event, "name"):
|
if hasattr(event, "content") and "name" in event.content:
|
||||||
self._simple_insert_txn(
|
self._simple_insert_txn(
|
||||||
txn,
|
txn,
|
||||||
"room_names",
|
"room_names",
|
||||||
{
|
{
|
||||||
"event_id": event.event_id,
|
"event_id": event.event_id,
|
||||||
"room_id": event.room_id,
|
"room_id": event.room_id,
|
||||||
"name": event.name,
|
"name": event.content["name"],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ presence and profiles; namely, the displayname and avatar_url."""
|
|||||||
from tests import unittest
|
from tests import unittest
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
|
||||||
from mock import Mock, call, ANY
|
from mock import Mock, call, ANY, NonCallableMock
|
||||||
|
|
||||||
from ..utils import MockClock, MockKey
|
from ..utils import MockClock, MockKey
|
||||||
|
|
||||||
@ -75,8 +75,13 @@ class PresenceProfilelikeDataTestCase(unittest.TestCase):
|
|||||||
resource_for_federation=Mock(),
|
resource_for_federation=Mock(),
|
||||||
http_client=None,
|
http_client=None,
|
||||||
replication_layer=MockReplication(),
|
replication_layer=MockReplication(),
|
||||||
config=self.mock_config,
|
ratelimiter=NonCallableMock(spec_set=[
|
||||||
)
|
"send_message",
|
||||||
|
]),
|
||||||
|
config=self.mock_config
|
||||||
|
)
|
||||||
|
self.ratelimiter = hs.get_ratelimiter()
|
||||||
|
self.ratelimiter.send_message.return_value = (True, 0)
|
||||||
hs.handlers = PresenceAndProfileHandlers(hs)
|
hs.handlers = PresenceAndProfileHandlers(hs)
|
||||||
|
|
||||||
self.datastore = hs.get_datastore()
|
self.datastore = hs.get_datastore()
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
from tests import unittest
|
from tests import unittest
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
|
||||||
from mock import Mock
|
from mock import Mock, NonCallableMock
|
||||||
|
|
||||||
from synapse.api.errors import AuthError
|
from synapse.api.errors import AuthError
|
||||||
from synapse.server import HomeServer
|
from synapse.server import HomeServer
|
||||||
@ -59,7 +59,14 @@ class ProfileTestCase(unittest.TestCase):
|
|||||||
resource_for_federation=Mock(),
|
resource_for_federation=Mock(),
|
||||||
replication_layer=self.mock_federation,
|
replication_layer=self.mock_federation,
|
||||||
config=self.mock_config,
|
config=self.mock_config,
|
||||||
|
ratelimiter=NonCallableMock(spec_set=[
|
||||||
|
"send_message",
|
||||||
|
])
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.ratelimiter = hs.get_ratelimiter()
|
||||||
|
self.ratelimiter.send_message.return_value = (True, 0)
|
||||||
|
|
||||||
hs.handlers = ProfileHandlers(hs)
|
hs.handlers = ProfileHandlers(hs)
|
||||||
|
|
||||||
self.store = hs.get_datastore()
|
self.store = hs.get_datastore()
|
||||||
|
Loading…
Reference in New Issue
Block a user