Merge two of the room join codepaths

There's at least one more to merge in.

Side-effects:
 * Stop reporting None as displayname and avatar_url in some cases
 * Joining a room by alias populates guest-ness in join event
 * Remove unspec'd PUT version of /join/<room_id_or_alias> which has not
   been called on matrix.org according to logs
 * Stop recording access_token_id on /join/room_id - currently we don't
   record it on /join/room_alias; I can try to thread it through at some
   point.
This commit is contained in:
Daniel Wagner-Hall 2016-02-12 15:11:49 +00:00 committed by review.rocks
parent 66f9a49ce9
commit cf81375b94
5 changed files with 73 additions and 69 deletions

View file

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from synapse.api.errors import SynapseError
from synapse.api.errors import SynapseError, BadIdentifierError
from collections import namedtuple
@ -51,13 +51,13 @@ class DomainSpecificString(
def from_string(cls, s):
"""Parse the string given by 's' into a structure object."""
if len(s) < 1 or s[0] != cls.SIGIL:
raise SynapseError(400, "Expected %s string to start with '%s'" % (
raise BadIdentifierError(400, "Expected %s string to start with '%s'" % (
cls.__name__, cls.SIGIL,
))
parts = s[1:].split(':', 1)
if len(parts) != 2:
raise SynapseError(
raise BadIdentifierError(
400, "Expected %s of the form '%slocalname:domain'" % (
cls.__name__, cls.SIGIL,
)
@ -69,6 +69,14 @@ class DomainSpecificString(
# names on one HS
return cls(localpart=parts[0], domain=domain)
@classmethod
def is_valid(cls, s):
try:
cls.from_string(s)
return True
except:
return False
def to_string(self):
"""Return a string encoding the fields of the structure object."""
return "%s%s:%s" % (self.SIGIL, self.localpart, self.domain)