コード例 #1
0
ファイル: httppusher.py プロジェクト: mebjas/synapse
    def _process_one(self, push_action):
        if 'notify' not in push_action['actions']:
            defer.returnValue(True)

        tweaks = push_rule_evaluator.tweaks_for_actions(push_action['actions'])
        badge = yield push_tools.get_badge_count(self.hs.get_datastore(), self.user_id)

        event = yield self.store.get_event(push_action['event_id'], allow_none=True)
        if event is None:
            defer.returnValue(True)  # It's been redacted
        rejected = yield self.dispatch_push(event, tweaks, badge)
        if rejected is False:
            defer.returnValue(False)

        if isinstance(rejected, list) or isinstance(rejected, tuple):
            for pk in rejected:
                if pk != self.pushkey:
                    # for sanity, we only remove the pushkey if it
                    # was the one we actually sent...
                    logger.warn(
                        ("Ignoring rejected pushkey %s because we"
                         " didn't send it"), pk
                    )
                else:
                    logger.info(
                        "Pushkey %s was rejected: removing",
                        pk
                    )
                    yield self.hs.remove_pusher(
                        self.app_id, pk, self.user_id
                    )
        defer.returnValue(True)
コード例 #2
0
    def _process_one(self, push_action):
        if 'notify' not in push_action['actions']:
            defer.returnValue(True)

        tweaks = push_rule_evaluator.tweaks_for_actions(push_action['actions'])
        badge = yield push_tools.get_badge_count(self.hs.get_datastore(),
                                                 self.user_id)

        event = yield self.store.get_event(push_action['event_id'],
                                           allow_none=True)
        if event is None:
            defer.returnValue(True)  # It's been redacted
        rejected = yield self.dispatch_push(event, tweaks, badge)
        if rejected is False:
            defer.returnValue(False)

        if isinstance(rejected, list) or isinstance(rejected, tuple):
            for pk in rejected:
                if pk != self.pushkey:
                    # for sanity, we only remove the pushkey if it
                    # was the one we actually sent...
                    logger.warn(("Ignoring rejected pushkey %s because we"
                                 " didn't send it"), pk)
                else:
                    logger.info("Pushkey %s was rejected: removing", pk)
                    yield self.hs.remove_pusher(self.app_id, pk, self.user_id)
        defer.returnValue(True)
コード例 #3
0
ファイル: httppusher.py プロジェクト: Ralith/synapse
    def on_new_receipts(self, min_stream_id, max_stream_id):
        # Note that the min here shouldn't be relied upon to be accurate.

        # We could check the receipts are actually m.read receipts here,
        # but currently that's the only type of receipt anyway...
        with LoggingContext("push.on_new_receipts"):
            with Measure(self.clock, "push.on_new_receipts"):
                badge = yield push_tools.get_badge_count(self.hs.get_datastore(), self.user_id)
            yield self._send_badge(badge)
コード例 #4
0
    def on_new_receipts(self, min_stream_id, max_stream_id):
        # Note that the min here shouldn't be relied upon to be accurate.

        # We could check the receipts are actually m.read receipts here,
        # but currently that's the only type of receipt anyway...
        with LoggingContext("push.on_new_receipts"):
            with Measure(self.clock, "push.on_new_receipts"):
                badge = yield push_tools.get_badge_count(
                    self.hs.get_datastore(), self.user_id)
            yield self._send_badge(badge)