Merge branch 'develop' of github.com:matrix-org/synapse into federation_client_retries
						commit
						8046df6efa
					
				| 
						 | 
				
			
			@ -222,7 +222,7 @@ to install using pip and a virtualenv::
 | 
			
		|||
 | 
			
		||||
    $ virtualenv env
 | 
			
		||||
    $ source env/bin/activate
 | 
			
		||||
    $ python synapse/dependencies | xargs -i pip install
 | 
			
		||||
    $ python synapse/python_dependencies.py | xargs -n1 pip install
 | 
			
		||||
    $ pip install setuptools_trial mock
 | 
			
		||||
 | 
			
		||||
This will run a process of downloading and installing all the needed
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										5
									
								
								setup.py
								
								
								
								
							
							
						
						
									
										5
									
								
								setup.py
								
								
								
								
							| 
						 | 
				
			
			@ -32,7 +32,7 @@ setup(
 | 
			
		|||
    description="Reference Synapse Home Server",
 | 
			
		||||
    install_requires=[
 | 
			
		||||
        "syutil==0.0.2",
 | 
			
		||||
        "matrix_angular_sdk>=0.6.0",
 | 
			
		||||
        "matrix_angular_sdk>=0.6.1",
 | 
			
		||||
        "Twisted==14.0.2",
 | 
			
		||||
        "service_identity>=1.0.0",
 | 
			
		||||
        "pyopenssl>=0.14",
 | 
			
		||||
| 
						 | 
				
			
			@ -43,11 +43,12 @@ setup(
 | 
			
		|||
        "py-bcrypt",
 | 
			
		||||
        "frozendict>=0.4",
 | 
			
		||||
        "pillow",
 | 
			
		||||
        "pydenticon",
 | 
			
		||||
    ],
 | 
			
		||||
    dependency_links=[
 | 
			
		||||
        "https://github.com/matrix-org/syutil/tarball/v0.0.2#egg=syutil-0.0.2",
 | 
			
		||||
        "https://github.com/pyca/pynacl/tarball/d4d3175589b892f6ea7c22f466e0e223853516fa#egg=pynacl-0.3.0",
 | 
			
		||||
        "https://github.com/matrix-org/matrix-angular-sdk/tarball/v0.6.0/#egg=matrix_angular_sdk-0.6.0",
 | 
			
		||||
        "https://github.com/matrix-org/matrix-angular-sdk/tarball/v0.6.1/#egg=matrix_angular_sdk-0.6.1",
 | 
			
		||||
    ],
 | 
			
		||||
    setup_requires=[
 | 
			
		||||
        "Twisted==14.0.2", # Here to override setuptools_trial's dependency on Twisted>=2.4.0
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,4 +16,4 @@
 | 
			
		|||
""" This is a reference implementation of a Matrix home server.
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
__version__ = "0.6.1b"
 | 
			
		||||
__version__ = "0.6.1d"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,14 +37,14 @@ class Pusher(object):
 | 
			
		|||
 | 
			
		||||
    INEQUALITY_EXPR = re.compile("^([=<>]*)([0-9]*)$")
 | 
			
		||||
 | 
			
		||||
    def __init__(self, _hs, instance_handle, user_name, app_id,
 | 
			
		||||
    def __init__(self, _hs, profile_tag, user_name, app_id,
 | 
			
		||||
                 app_display_name, device_display_name, pushkey, pushkey_ts,
 | 
			
		||||
                 data, last_token, last_success, failing_since):
 | 
			
		||||
        self.hs = _hs
 | 
			
		||||
        self.evStreamHandler = self.hs.get_handlers().event_stream_handler
 | 
			
		||||
        self.store = self.hs.get_datastore()
 | 
			
		||||
        self.clock = self.hs.get_clock()
 | 
			
		||||
        self.instance_handle = instance_handle
 | 
			
		||||
        self.profile_tag = profile_tag
 | 
			
		||||
        self.user_name = user_name
 | 
			
		||||
        self.app_id = app_id
 | 
			
		||||
        self.app_display_name = app_display_name
 | 
			
		||||
| 
						 | 
				
			
			@ -147,9 +147,9 @@ class Pusher(object):
 | 
			
		|||
                return False
 | 
			
		||||
            return fnmatch.fnmatch(val.upper(), pat.upper())
 | 
			
		||||
        elif condition['kind'] == 'device':
 | 
			
		||||
            if 'instance_handle' not in condition:
 | 
			
		||||
            if 'profile_tag' not in condition:
 | 
			
		||||
                return True
 | 
			
		||||
            return condition['instance_handle'] == self.instance_handle
 | 
			
		||||
            return condition['profile_tag'] == self.profile_tag
 | 
			
		||||
        elif condition['kind'] == 'contains_display_name':
 | 
			
		||||
            # This is special because display names can be different
 | 
			
		||||
            # between rooms and so you can't really hard code it in a rule.
 | 
			
		||||
| 
						 | 
				
			
			@ -400,8 +400,8 @@ def _tweaks_for_actions(actions):
 | 
			
		|||
    for a in actions:
 | 
			
		||||
        if not isinstance(a, dict):
 | 
			
		||||
            continue
 | 
			
		||||
        if 'set_sound' in a:
 | 
			
		||||
            tweaks['sound'] = a['set_sound']
 | 
			
		||||
        if 'set_tweak' in a and 'value' in a:
 | 
			
		||||
            tweaks[a['set_tweak']] = a['value']
 | 
			
		||||
    return tweaks
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,7 +38,8 @@ def make_base_rules(user_name):
 | 
			
		|||
            'actions': [
 | 
			
		||||
                'notify',
 | 
			
		||||
                {
 | 
			
		||||
                    'set_sound': 'default'
 | 
			
		||||
                    'set_tweak': 'sound',
 | 
			
		||||
                    'value': 'default'
 | 
			
		||||
                }
 | 
			
		||||
            ]
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,12 +24,12 @@ logger = logging.getLogger(__name__)
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
class HttpPusher(Pusher):
 | 
			
		||||
    def __init__(self, _hs, instance_handle, user_name, app_id,
 | 
			
		||||
    def __init__(self, _hs, profile_tag, user_name, app_id,
 | 
			
		||||
                 app_display_name, device_display_name, pushkey, pushkey_ts,
 | 
			
		||||
                 data, last_token, last_success, failing_since):
 | 
			
		||||
        super(HttpPusher, self).__init__(
 | 
			
		||||
            _hs,
 | 
			
		||||
            instance_handle,
 | 
			
		||||
            profile_tag,
 | 
			
		||||
            user_name,
 | 
			
		||||
            app_id,
 | 
			
		||||
            app_display_name,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -55,7 +55,7 @@ class PusherPool:
 | 
			
		|||
        self._start_pushers(pushers)
 | 
			
		||||
 | 
			
		||||
    @defer.inlineCallbacks
 | 
			
		||||
    def add_pusher(self, user_name, instance_handle, kind, app_id,
 | 
			
		||||
    def add_pusher(self, user_name, profile_tag, kind, app_id,
 | 
			
		||||
                   app_display_name, device_display_name, pushkey, lang, data):
 | 
			
		||||
        # we try to create the pusher just to validate the config: it
 | 
			
		||||
        # will then get pulled out of the database,
 | 
			
		||||
| 
						 | 
				
			
			@ -64,7 +64,7 @@ class PusherPool:
 | 
			
		|||
        self._create_pusher({
 | 
			
		||||
            "user_name": user_name,
 | 
			
		||||
            "kind": kind,
 | 
			
		||||
            "instance_handle": instance_handle,
 | 
			
		||||
            "profile_tag": profile_tag,
 | 
			
		||||
            "app_id": app_id,
 | 
			
		||||
            "app_display_name": app_display_name,
 | 
			
		||||
            "device_display_name": device_display_name,
 | 
			
		||||
| 
						 | 
				
			
			@ -77,18 +77,18 @@ class PusherPool:
 | 
			
		|||
            "failing_since": None
 | 
			
		||||
        })
 | 
			
		||||
        yield self._add_pusher_to_store(
 | 
			
		||||
            user_name, instance_handle, kind, app_id,
 | 
			
		||||
            user_name, profile_tag, kind, app_id,
 | 
			
		||||
            app_display_name, device_display_name,
 | 
			
		||||
            pushkey, lang, data
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    @defer.inlineCallbacks
 | 
			
		||||
    def _add_pusher_to_store(self, user_name, instance_handle, kind, app_id,
 | 
			
		||||
    def _add_pusher_to_store(self, user_name, profile_tag, kind, app_id,
 | 
			
		||||
                             app_display_name, device_display_name,
 | 
			
		||||
                             pushkey, lang, data):
 | 
			
		||||
        yield self.store.add_pusher(
 | 
			
		||||
            user_name=user_name,
 | 
			
		||||
            instance_handle=instance_handle,
 | 
			
		||||
            profile_tag=profile_tag,
 | 
			
		||||
            kind=kind,
 | 
			
		||||
            app_id=app_id,
 | 
			
		||||
            app_display_name=app_display_name,
 | 
			
		||||
| 
						 | 
				
			
			@ -104,7 +104,7 @@ class PusherPool:
 | 
			
		|||
        if pusherdict['kind'] == 'http':
 | 
			
		||||
            return HttpPusher(
 | 
			
		||||
                self.hs,
 | 
			
		||||
                instance_handle=pusherdict['instance_handle'],
 | 
			
		||||
                profile_tag=pusherdict['profile_tag'],
 | 
			
		||||
                user_name=pusherdict['user_name'],
 | 
			
		||||
                app_id=pusherdict['app_id'],
 | 
			
		||||
                app_display_name=pusherdict['app_display_name'],
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,8 +16,30 @@ REQUIREMENTS = {
 | 
			
		|||
    "py-bcrypt": ["bcrypt"],
 | 
			
		||||
    "frozendict>=0.4": ["frozendict"],
 | 
			
		||||
    "pillow": ["PIL"],
 | 
			
		||||
    "pydenticon": ["pydenticon"],
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
def github_link(project, version, egg):
 | 
			
		||||
    return "https://github.com/%s/tarball/%s/#egg=%s" % (project, version, egg)
 | 
			
		||||
 | 
			
		||||
DEPENDENCY_LINKS=[
 | 
			
		||||
    github_link(
 | 
			
		||||
        project="matrix-org/syutil",
 | 
			
		||||
        version="v0.0.2",
 | 
			
		||||
        egg="syutil-0.0.2",
 | 
			
		||||
    ),
 | 
			
		||||
    github_link(
 | 
			
		||||
        project="matrix-org/matrix-angular-sdk",
 | 
			
		||||
        version="v0.6.0",
 | 
			
		||||
        egg="matrix_angular_sdk-0.6.0",
 | 
			
		||||
    ),
 | 
			
		||||
    github_link(
 | 
			
		||||
        project="pyca/pynacl",
 | 
			
		||||
        version="d4d3175589b892f6ea7c22f466e0e223853516fa",
 | 
			
		||||
        egg="pynacl-0.3.0",
 | 
			
		||||
    )
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class MissingRequirementError(Exception):
 | 
			
		||||
    pass
 | 
			
		||||
| 
						 | 
				
			
			@ -78,3 +100,23 @@ def check_requirements():
 | 
			
		|||
                        "Unexpected version of %r in %r. %r != %r"
 | 
			
		||||
                        % (dependency, file_path, version, required_version)
 | 
			
		||||
                    )
 | 
			
		||||
 | 
			
		||||
def list_requirements():
 | 
			
		||||
    result = []
 | 
			
		||||
    linked = []
 | 
			
		||||
    for link in DEPENDENCY_LINKS:
 | 
			
		||||
        egg = link.split("#egg=")[1]
 | 
			
		||||
        linked.append(egg.split('-')[0])
 | 
			
		||||
        result.append(link)
 | 
			
		||||
    for requirement in REQUIREMENTS:
 | 
			
		||||
        is_linked = False
 | 
			
		||||
        for link in linked:
 | 
			
		||||
            if requirement.replace('-','_').startswith(link):
 | 
			
		||||
                is_linked = True
 | 
			
		||||
        if not is_linked:
 | 
			
		||||
            result.append(requirement)
 | 
			
		||||
    return result
 | 
			
		||||
 | 
			
		||||
if __name__ == "__main__":
 | 
			
		||||
    import sys
 | 
			
		||||
    sys.stdout.writelines(req + "\n" for req in list_requirements())
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -73,7 +73,7 @@ class PushRuleRestServlet(ClientV1RestServlet):
 | 
			
		|||
            'rule_id': rule_id
 | 
			
		||||
        }
 | 
			
		||||
        if device:
 | 
			
		||||
            spec['device'] = device
 | 
			
		||||
            spec['profile_tag'] = device
 | 
			
		||||
        return spec
 | 
			
		||||
 | 
			
		||||
    def rule_tuple_from_request_object(self, rule_template, rule_id, req_obj, device=None):
 | 
			
		||||
| 
						 | 
				
			
			@ -112,7 +112,7 @@ class PushRuleRestServlet(ClientV1RestServlet):
 | 
			
		|||
        if device:
 | 
			
		||||
            conditions.append({
 | 
			
		||||
                'kind': 'device',
 | 
			
		||||
                'instance_handle': device
 | 
			
		||||
                'profile_tag': device
 | 
			
		||||
            })
 | 
			
		||||
 | 
			
		||||
        if 'actions' not in req_obj:
 | 
			
		||||
| 
						 | 
				
			
			@ -188,15 +188,15 @@ class PushRuleRestServlet(ClientV1RestServlet):
 | 
			
		|||
 | 
			
		||||
        user, _ = yield self.auth.get_user_by_req(request)
 | 
			
		||||
 | 
			
		||||
        if 'device' in spec:
 | 
			
		||||
        if 'profile_tag' in spec:
 | 
			
		||||
            rules = yield self.hs.get_datastore().get_push_rules_for_user_name(
 | 
			
		||||
                user.to_string()
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
            for r in rules:
 | 
			
		||||
                conditions = json.loads(r['conditions'])
 | 
			
		||||
                ih = _instance_handle_from_conditions(conditions)
 | 
			
		||||
                if ih == spec['device'] and r['priority_class'] == priority_class:
 | 
			
		||||
                pt = _profile_tag_from_conditions(conditions)
 | 
			
		||||
                if pt == spec['profile_tag'] and r['priority_class'] == priority_class:
 | 
			
		||||
                    yield self.hs.get_datastore().delete_push_rule(
 | 
			
		||||
                        user.to_string(), spec['rule_id']
 | 
			
		||||
                    )
 | 
			
		||||
| 
						 | 
				
			
			@ -239,19 +239,19 @@ class PushRuleRestServlet(ClientV1RestServlet):
 | 
			
		|||
 | 
			
		||||
            if r['priority_class'] > PushRuleRestServlet.PRIORITY_CLASS_MAP['override']:
 | 
			
		||||
                # per-device rule
 | 
			
		||||
                instance_handle = _instance_handle_from_conditions(r["conditions"])
 | 
			
		||||
                profile_tag = _profile_tag_from_conditions(r["conditions"])
 | 
			
		||||
                r = _strip_device_condition(r)
 | 
			
		||||
                if not instance_handle:
 | 
			
		||||
                if not profile_tag:
 | 
			
		||||
                    continue
 | 
			
		||||
                if instance_handle not in rules['device']:
 | 
			
		||||
                    rules['device'][instance_handle] = {}
 | 
			
		||||
                    rules['device'][instance_handle] = (
 | 
			
		||||
                if profile_tag not in rules['device']:
 | 
			
		||||
                    rules['device'][profile_tag] = {}
 | 
			
		||||
                    rules['device'][profile_tag] = (
 | 
			
		||||
                        _add_empty_priority_class_arrays(
 | 
			
		||||
                            rules['device'][instance_handle]
 | 
			
		||||
                            rules['device'][profile_tag]
 | 
			
		||||
                        )
 | 
			
		||||
                    )
 | 
			
		||||
 | 
			
		||||
                rulearray = rules['device'][instance_handle][template_name]
 | 
			
		||||
                rulearray = rules['device'][profile_tag][template_name]
 | 
			
		||||
            else:
 | 
			
		||||
                rulearray = rules['global'][template_name]
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -282,13 +282,13 @@ class PushRuleRestServlet(ClientV1RestServlet):
 | 
			
		|||
            if path[0] == '':
 | 
			
		||||
                defer.returnValue((200, rules['device']))
 | 
			
		||||
 | 
			
		||||
            instance_handle = path[0]
 | 
			
		||||
            profile_tag = path[0]
 | 
			
		||||
            path = path[1:]
 | 
			
		||||
            if instance_handle not in rules['device']:
 | 
			
		||||
            if profile_tag not in rules['device']:
 | 
			
		||||
                ret = {}
 | 
			
		||||
                ret = _add_empty_priority_class_arrays(ret)
 | 
			
		||||
                defer.returnValue((200, ret))
 | 
			
		||||
            ruleset = rules['device'][instance_handle]
 | 
			
		||||
            ruleset = rules['device'][profile_tag]
 | 
			
		||||
            result = _filter_ruleset_with_path(ruleset, path)
 | 
			
		||||
            defer.returnValue((200, result))
 | 
			
		||||
        else:
 | 
			
		||||
| 
						 | 
				
			
			@ -304,14 +304,14 @@ def _add_empty_priority_class_arrays(d):
 | 
			
		|||
    return d
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def _instance_handle_from_conditions(conditions):
 | 
			
		||||
def _profile_tag_from_conditions(conditions):
 | 
			
		||||
    """
 | 
			
		||||
    Given a list of conditions, return the instance handle of the
 | 
			
		||||
    Given a list of conditions, return the profile tag of the
 | 
			
		||||
    device rule if there is one
 | 
			
		||||
    """
 | 
			
		||||
    for c in conditions:
 | 
			
		||||
        if c['kind'] == 'device':
 | 
			
		||||
            return c['instance_handle']
 | 
			
		||||
            return c['profile_tag']
 | 
			
		||||
    return None
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -41,7 +41,7 @@ class PusherRestServlet(ClientV1RestServlet):
 | 
			
		|||
            )
 | 
			
		||||
            defer.returnValue((200, {}))
 | 
			
		||||
 | 
			
		||||
        reqd = ['instance_handle', 'kind', 'app_id', 'app_display_name',
 | 
			
		||||
        reqd = ['profile_tag', 'kind', 'app_id', 'app_display_name',
 | 
			
		||||
                'device_display_name', 'pushkey', 'lang', 'data']
 | 
			
		||||
        missing = []
 | 
			
		||||
        for i in reqd:
 | 
			
		||||
| 
						 | 
				
			
			@ -54,7 +54,7 @@ class PusherRestServlet(ClientV1RestServlet):
 | 
			
		|||
        try:
 | 
			
		||||
            yield pusher_pool.add_pusher(
 | 
			
		||||
                user_name=user.to_string(),
 | 
			
		||||
                instance_handle=content['instance_handle'],
 | 
			
		||||
                profile_tag=content['profile_tag'],
 | 
			
		||||
                kind=content['kind'],
 | 
			
		||||
                app_id=content['app_id'],
 | 
			
		||||
                app_display_name=content['app_display_name'],
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,51 @@
 | 
			
		|||
from pydenticon import Generator
 | 
			
		||||
from twisted.web.resource import Resource
 | 
			
		||||
 | 
			
		||||
FOREGROUND = [
 | 
			
		||||
    "rgb(45,79,255)",
 | 
			
		||||
    "rgb(254,180,44)",
 | 
			
		||||
    "rgb(226,121,234)",
 | 
			
		||||
    "rgb(30,179,253)",
 | 
			
		||||
    "rgb(232,77,65)",
 | 
			
		||||
    "rgb(49,203,115)",
 | 
			
		||||
    "rgb(141,69,170)"
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
BACKGROUND = "rgb(224,224,224)"
 | 
			
		||||
SIZE = 5
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class IdenticonResource(Resource):
 | 
			
		||||
    isLeaf = True
 | 
			
		||||
 | 
			
		||||
    def __init__(self):
 | 
			
		||||
        Resource.__init__(self)
 | 
			
		||||
        self.generator = Generator(
 | 
			
		||||
            SIZE, SIZE, foreground=FOREGROUND, background=BACKGROUND,
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def generate_identicon(self, name, width, height):
 | 
			
		||||
        v_padding = width % SIZE
 | 
			
		||||
        h_padding = height % SIZE
 | 
			
		||||
        top_padding = v_padding // 2
 | 
			
		||||
        left_padding = h_padding // 2
 | 
			
		||||
        bottom_padding = v_padding - top_padding
 | 
			
		||||
        right_padding = h_padding - left_padding
 | 
			
		||||
        width -= v_padding
 | 
			
		||||
        height -= h_padding
 | 
			
		||||
        padding = (top_padding, bottom_padding, left_padding, right_padding)
 | 
			
		||||
        identicon = self.generator.generate(
 | 
			
		||||
            name, width, height, padding=padding
 | 
			
		||||
        )
 | 
			
		||||
        return identicon
 | 
			
		||||
 | 
			
		||||
    def render_GET(self, request):
 | 
			
		||||
        name = "/".join(request.postpath)
 | 
			
		||||
        width = int(request.args.get("width", [96])[0])
 | 
			
		||||
        height = int(request.args.get("height", [96])[0])
 | 
			
		||||
        identicon_bytes = self.generate_identicon(name, width, height)
 | 
			
		||||
        request.setHeader(b"Content-Type", b"image/png")
 | 
			
		||||
        request.setHeader(
 | 
			
		||||
            b"Cache-Control", b"public,max-age=86400,s-maxage=86400"
 | 
			
		||||
        )
 | 
			
		||||
        return identicon_bytes
 | 
			
		||||
| 
						 | 
				
			
			@ -16,6 +16,7 @@
 | 
			
		|||
from .upload_resource import UploadResource
 | 
			
		||||
from .download_resource import DownloadResource
 | 
			
		||||
from .thumbnail_resource import ThumbnailResource
 | 
			
		||||
from .identicon_resource import IdenticonResource
 | 
			
		||||
from .filepath import MediaFilePaths
 | 
			
		||||
 | 
			
		||||
from twisted.web.resource import Resource
 | 
			
		||||
| 
						 | 
				
			
			@ -75,3 +76,4 @@ class MediaRepositoryResource(Resource):
 | 
			
		|||
        self.putChild("upload", UploadResource(hs, filepaths))
 | 
			
		||||
        self.putChild("download", DownloadResource(hs, filepaths))
 | 
			
		||||
        self.putChild("thumbnail", ThumbnailResource(hs, filepaths))
 | 
			
		||||
        self.putChild("identicon", IdenticonResource())
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,7 +29,7 @@ class PusherStore(SQLBaseStore):
 | 
			
		|||
    @defer.inlineCallbacks
 | 
			
		||||
    def get_pushers_by_app_id_and_pushkey(self, app_id_and_pushkey):
 | 
			
		||||
        sql = (
 | 
			
		||||
            "SELECT id, user_name, kind, instance_handle, app_id,"
 | 
			
		||||
            "SELECT id, user_name, kind, profile_tag, app_id,"
 | 
			
		||||
            "app_display_name, device_display_name, pushkey, ts, data, "
 | 
			
		||||
            "last_token, last_success, failing_since "
 | 
			
		||||
            "FROM pushers "
 | 
			
		||||
| 
						 | 
				
			
			@ -45,7 +45,7 @@ class PusherStore(SQLBaseStore):
 | 
			
		|||
                "id": r[0],
 | 
			
		||||
                "user_name": r[1],
 | 
			
		||||
                "kind": r[2],
 | 
			
		||||
                "instance_handle": r[3],
 | 
			
		||||
                "profile_tag": r[3],
 | 
			
		||||
                "app_id": r[4],
 | 
			
		||||
                "app_display_name": r[5],
 | 
			
		||||
                "device_display_name": r[6],
 | 
			
		||||
| 
						 | 
				
			
			@ -64,7 +64,7 @@ class PusherStore(SQLBaseStore):
 | 
			
		|||
    @defer.inlineCallbacks
 | 
			
		||||
    def get_all_pushers(self):
 | 
			
		||||
        sql = (
 | 
			
		||||
            "SELECT id, user_name, kind, instance_handle, app_id,"
 | 
			
		||||
            "SELECT id, user_name, kind, profile_tag, app_id,"
 | 
			
		||||
            "app_display_name, device_display_name, pushkey, ts, data, "
 | 
			
		||||
            "last_token, last_success, failing_since "
 | 
			
		||||
            "FROM pushers"
 | 
			
		||||
| 
						 | 
				
			
			@ -77,7 +77,7 @@ class PusherStore(SQLBaseStore):
 | 
			
		|||
                "id": r[0],
 | 
			
		||||
                "user_name": r[1],
 | 
			
		||||
                "kind": r[2],
 | 
			
		||||
                "instance_handle": r[3],
 | 
			
		||||
                "profile_tag": r[3],
 | 
			
		||||
                "app_id": r[4],
 | 
			
		||||
                "app_display_name": r[5],
 | 
			
		||||
                "device_display_name": r[6],
 | 
			
		||||
| 
						 | 
				
			
			@ -94,7 +94,7 @@ class PusherStore(SQLBaseStore):
 | 
			
		|||
        defer.returnValue(ret)
 | 
			
		||||
 | 
			
		||||
    @defer.inlineCallbacks
 | 
			
		||||
    def add_pusher(self, user_name, instance_handle, kind, app_id,
 | 
			
		||||
    def add_pusher(self, user_name, profile_tag, kind, app_id,
 | 
			
		||||
                   app_display_name, device_display_name,
 | 
			
		||||
                   pushkey, pushkey_ts, lang, data):
 | 
			
		||||
        try:
 | 
			
		||||
| 
						 | 
				
			
			@ -107,7 +107,7 @@ class PusherStore(SQLBaseStore):
 | 
			
		|||
                dict(
 | 
			
		||||
                    user_name=user_name,
 | 
			
		||||
                    kind=kind,
 | 
			
		||||
                    instance_handle=instance_handle,
 | 
			
		||||
                    profile_tag=profile_tag,
 | 
			
		||||
                    app_display_name=app_display_name,
 | 
			
		||||
                    device_display_name=device_display_name,
 | 
			
		||||
                    ts=pushkey_ts,
 | 
			
		||||
| 
						 | 
				
			
			@ -158,7 +158,7 @@ class PushersTable(Table):
 | 
			
		|||
        "id",
 | 
			
		||||
        "user_name",
 | 
			
		||||
        "kind",
 | 
			
		||||
        "instance_handle",
 | 
			
		||||
        "profile_tag",
 | 
			
		||||
        "app_id",
 | 
			
		||||
        "app_display_name",
 | 
			
		||||
        "device_display_name",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,7 +24,7 @@ CREATE TABLE IF NOT EXISTS rejections(
 | 
			
		|||
CREATE TABLE IF NOT EXISTS pushers (
 | 
			
		||||
  id INTEGER PRIMARY KEY AUTOINCREMENT,
 | 
			
		||||
  user_name TEXT NOT NULL,
 | 
			
		||||
  instance_handle varchar(32) NOT NULL,
 | 
			
		||||
  profile_tag varchar(32) NOT NULL,
 | 
			
		||||
  kind varchar(8) NOT NULL,
 | 
			
		||||
  app_id varchar(64) NOT NULL,
 | 
			
		||||
  app_display_name varchar(64) NOT NULL,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,7 +16,7 @@
 | 
			
		|||
CREATE TABLE IF NOT EXISTS pushers (
 | 
			
		||||
  id INTEGER PRIMARY KEY AUTOINCREMENT,
 | 
			
		||||
  user_name TEXT NOT NULL,
 | 
			
		||||
  instance_handle varchar(32) NOT NULL,
 | 
			
		||||
  profile_tag varchar(32) NOT NULL,
 | 
			
		||||
  kind varchar(8) NOT NULL,
 | 
			
		||||
  app_id varchar(64) NOT NULL,
 | 
			
		||||
  app_display_name varchar(64) NOT NULL,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue