Oops: second part of commit dc938606
This commit is contained in:
parent
dc93860619
commit
ede491b4e0
|
@ -21,6 +21,7 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
|
||||
class Codes(object):
|
||||
UNRECOGNIZED = "M_UNRECOGNIZED"
|
||||
UNAUTHORIZED = "M_UNAUTHORIZED"
|
||||
FORBIDDEN = "M_FORBIDDEN"
|
||||
BAD_JSON = "M_BAD_JSON"
|
||||
|
@ -82,6 +83,17 @@ class RegistrationError(SynapseError):
|
|||
pass
|
||||
|
||||
|
||||
class UnrecognizedRequestError(SynapseError):
|
||||
"""An error indicating we don't understand the request you're trying to make"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
if "errcode" not in kwargs:
|
||||
kwargs["errcode"] = Codes.NOT_FOUND
|
||||
super(UnrecognizedRequestError, self).__init__(
|
||||
400,
|
||||
"Unrecognized request",
|
||||
**kwargs
|
||||
)
|
||||
|
||||
class AuthError(SynapseError):
|
||||
"""An error raised when there was a problem authorising an event."""
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
from synapse.http.agent_name import AGENT_NAME
|
||||
from synapse.api.errors import (
|
||||
cs_exception, SynapseError, CodeMessageException
|
||||
cs_exception, SynapseError, CodeMessageException, UnrecognizedRequestError
|
||||
)
|
||||
from synapse.util.logcontext import LoggingContext
|
||||
|
||||
|
@ -139,11 +139,7 @@ class JsonResource(HttpServer, resource.Resource):
|
|||
return
|
||||
|
||||
# Huh. No one wanted to handle that? Fiiiiiine. Send 400.
|
||||
self._send_response(
|
||||
request,
|
||||
400,
|
||||
{"error": "Unrecognized request"}
|
||||
)
|
||||
raise UnrecognizedRequestError()
|
||||
except CodeMessageException as e:
|
||||
if isinstance(e, SynapseError):
|
||||
logger.info("%s SynapseError: %s - %s", request, e.code, e.msg)
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
from . import (
|
||||
room, events, register, login, profile, presence, initial_sync, directory,
|
||||
voip, admin, pusher,
|
||||
voip, admin, pusher, push_rule
|
||||
)
|
||||
|
||||
|
||||
|
@ -46,3 +46,4 @@ class RestServletFactory(object):
|
|||
voip.register_servlets(hs, client_resource)
|
||||
admin.register_servlets(hs, client_resource)
|
||||
pusher.register_servlets(hs, client_resource)
|
||||
push_rule.register_servlets(hs, client_resource)
|
||||
|
|
|
@ -30,6 +30,7 @@ from .transactions import TransactionStore
|
|||
from .keys import KeyStore
|
||||
from .event_federation import EventFederationStore
|
||||
from .pusher import PusherStore
|
||||
from .push_rule import PushRuleStore
|
||||
from .media_repository import MediaRepositoryStore
|
||||
|
||||
from .state import StateStore
|
||||
|
@ -62,6 +63,7 @@ SCHEMAS = [
|
|||
"event_edges",
|
||||
"event_signatures",
|
||||
"pusher",
|
||||
"push_rules",
|
||||
"media_repository",
|
||||
]
|
||||
|
||||
|
@ -85,6 +87,7 @@ class DataStore(RoomMemberStore, RoomStore,
|
|||
EventFederationStore,
|
||||
MediaRepositoryStore,
|
||||
PusherStore,
|
||||
PushRuleStore
|
||||
):
|
||||
|
||||
def __init__(self, hs):
|
||||
|
|
|
@ -31,3 +31,16 @@ CREATE TABLE IF NOT EXISTS pushers (
|
|||
FOREIGN KEY(user_name) REFERENCES users(name),
|
||||
UNIQUE (app_id, pushkey)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS push_rules (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_name TEXT NOT NULL,
|
||||
rule_id TEXT NOT NULL,
|
||||
priority_class TINYINT NOT NULL,
|
||||
priority INTEGER NOT NULL DEFAULT 0,
|
||||
conditions TEXT NOT NULL,
|
||||
actions TEXT NOT NULL,
|
||||
UNIQUE(user_name, rule_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS push_rules_user_name on push_rules (user_name);
|
||||
|
|
|
@ -31,3 +31,16 @@ CREATE TABLE IF NOT EXISTS pushers (
|
|||
FOREIGN KEY(user_name) REFERENCES users(name),
|
||||
UNIQUE (app_id, pushkey)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS push_rules (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_name TEXT NOT NULL,
|
||||
rule_id TEXT NOT NULL,
|
||||
priority_class TINYINT NOT NULL,
|
||||
priority INTEGER NOT NULL DEFAULT 0,
|
||||
conditions TEXT NOT NULL,
|
||||
actions TEXT NOT NULL,
|
||||
UNIQUE(user_name, rule_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS push_rules_user_name on push_rules (user_name);
|
||||
|
|
Loading…
Reference in New Issue