def on_GET(self, request): requester = yield self.auth.get_user_by_req(request) user_id = requester.user.to_string() # we build up the full structure and then decide which bits of it # to send which means doing unnecessary work sometimes but is # is probably not going to make a whole lot of difference rawrules = yield self.store.get_push_rules_for_user(user_id) enabled_map = yield self.store.get_push_rules_enabled_for_user(user_id) rules = format_push_rules_for_user(requester.user, rawrules, enabled_map) path = request.postpath[1:] if path == []: # we're a reference impl: pedantry is our job. raise UnrecognizedRequestError( PushRuleRestServlet.SLIGHTLY_PEDANTIC_TRAILING_SLASH_ERROR ) if path[0] == '': defer.returnValue((200, rules)) elif path[0] == 'global': path = path[1:] result = _filter_ruleset_with_path(rules['global'], path) defer.returnValue((200, result)) else: raise UnrecognizedRequestError()
def on_GET(self, request): requester = yield self.auth.get_user_by_req(request) user_id = requester.user.to_string() # we build up the full structure and then decide which bits of it # to send which means doing unnecessary work sometimes but is # is probably not going to make a whole lot of difference rules = yield self.store.get_push_rules_for_user(user_id) rules = format_push_rules_for_user(requester.user, rules) path = request.postpath[1:] if path == []: # we're a reference impl: pedantry is our job. raise UnrecognizedRequestError( PushRuleRestServlet.SLIGHTLY_PEDANTIC_TRAILING_SLASH_ERROR) if path[0] == '': defer.returnValue((200, rules)) elif path[0] == 'global': path = path[1:] result = _filter_ruleset_with_path(rules['global'], path) defer.returnValue((200, result)) else: raise UnrecognizedRequestError()
async def on_GET(self, request: SynapseRequest, path: str) -> Tuple[int, JsonDict]: requester = await self.auth.get_user_by_req(request) user_id = requester.user.to_string() # we build up the full structure and then decide which bits of it # to send which means doing unnecessary work sometimes but is # is probably not going to make a whole lot of difference rules_raw = await self.store.get_push_rules_for_user(user_id) rules = format_push_rules_for_user(requester.user, rules_raw) path_parts = path.split("/")[1:] if path_parts == []: # we're a reference impl: pedantry is our job. raise UnrecognizedRequestError( PushRuleRestServlet.SLIGHTLY_PEDANTIC_TRAILING_SLASH_ERROR ) if path_parts[0] == "": return 200, rules elif path_parts[0] == "global": result = _filter_ruleset_with_path(rules["global"], path_parts[1:]) return 200, result else: raise UnrecognizedRequestError()
def push_rules_for_user(self, user): user_id = user.to_string() rules = yield self.store.get_push_rules_for_user(user_id) rules = format_push_rules_for_user(user, rules) defer.returnValue(rules)
def push_rules_for_user(self, user): user_id = user.to_string() rules = yield self.store.get_push_rules_for_user(user_id) rules = format_push_rules_for_user(user, rules) defer.returnValue(rules)
def push_rules_for_user(self, user): user_id = user.to_string() rawrules = yield self.store.get_push_rules_for_user(user_id) enabled_map = yield self.store.get_push_rules_enabled_for_user(user_id) rules = format_push_rules_for_user(user, rawrules, enabled_map) defer.returnValue(rules)
def push_rules_for_user(self, user): user_id = user.to_string() rawrules = yield self.store.get_push_rules_for_user(user_id) enabled_map = yield self.store.get_push_rules_enabled_for_user(user_id) rules = format_push_rules_for_user(user, rawrules, enabled_map) defer.returnValue(rules)