Exemple #1
0
def index():
    """
    ---
    get:
      summary: Get notifications
      description: Get all the notifications for the user
      responses:
        '200':
          content:
            application/json:
              schema:
                type: object
                allOf:
                - $ref: '#/components/schemas/QueryResponse'
                properties:
                  results:
                    type: array
                    items:
                      $ref: '#/components/schemas/Notification'
          description: OK
      tags:
      - Notification
    """
    require(request.authz.logged_in)
    role = Role.by_id(request.authz.id)
    query = Notification.by_channels(get_role_channels(role), role)
    result = DatabaseQueryResult(request, query)
    return NotificationSerializer.jsonify_result(result)
def index():
    require(request.authz.logged_in)
    role = Role.by_id(request.authz.id)
    query = Notification.by_channels(get_role_channels(role),
                                     since=role.notified_at,
                                     exclude_actor_id=role.id)
    result = DatabaseQueryResult(request, query)
    return NotificationSerializer.jsonify_result(result)
Exemple #3
0
def index():
    require(request.authz.logged_in)
    role = Role.by_id(request.authz.id)
    query = Notification.by_channels(get_role_channels(role),
                                     since=role.notified_at,
                                     exclude_actor_id=role.id)
    result = DatabaseQueryResult(request, query)
    return NotificationSerializer.jsonify_result(result)
Exemple #4
0
def update_role(role):
    """Synchronize denormalised role configuration."""
    refresh_role(role)
    get_role(role.id)
    get_role_channels(role)
Exemple #5
0
 def get_filters(self):
     channels = get_role_channels(self.parser.authz.role)
     filters = super(NotificationsQuery, self).get_filters()
     filters.append({"terms": {"channels": channels}})
     return filters