Пример #1
0
    def list_subscriptions(self, request):
        current_user = endpoints.get_current_user()
        if current_user is None:
            return SubscriptionCollection(subscriptions = [])
        userId = PushHelper.user_email_to_id(current_user.email())

        subscriptions = Subscription.query(ancestor=ndb.Key(Account, userId)).fetch()
        output = []
        for subscription in subscriptions:
            output.append(SubscriptionMessage(model_key = subscription.model_key, notifications = PushHelper.notification_string_from_enums(subscription.notification_types), model_type = subscription.model_type))
        return SubscriptionCollection(subscriptions = output)
Пример #2
0
    def list_subscriptions(self, request):
        user_id = get_current_user_id(self.headers)
        if user_id is None:
            return SubscriptionCollection(subscriptions=[])

        subscriptions = Subscription.query(
            ancestor=ndb.Key(Account, user_id)).fetch()
        output = []
        for subscription in subscriptions:
            output.append(
                SubscriptionMessage(
                    model_key=subscription.model_key,
                    notifications=PushHelper.notification_string_from_enums(
                        subscription.notification_types),
                    model_type=subscription.model_type))
        return SubscriptionCollection(subscriptions=output)