diff options
Diffstat (limited to 'internal/api')
| -rw-r--r-- | internal/api/client/notification/notification.go | 2 | ||||
| -rw-r--r-- | internal/api/client/notification/notificationsget.go | 69 | ||||
| -rw-r--r-- | internal/api/model/notification.go | 2 | 
3 files changed, 71 insertions, 2 deletions
diff --git a/internal/api/client/notification/notification.go b/internal/api/client/notification/notification.go index 61a84f60a..6ade0b02f 100644 --- a/internal/api/client/notification/notification.go +++ b/internal/api/client/notification/notification.go @@ -36,6 +36,8 @@ const (  	BasePathWithID    = BasePath + "/:" + IDKey  	BasePathWithClear = BasePath + "/clear" +	// ExcludeTypes is an array specifying notification types to exclude +	ExcludeTypesKey = "exclude_types[]"  	// MaxIDKey is the url query for setting a max notification ID to return  	MaxIDKey = "max_id"  	// LimitKey is for specifying maximum number of notifications to return. diff --git a/internal/api/client/notification/notificationsget.go b/internal/api/client/notification/notificationsget.go index 88220107e..88c2f663b 100644 --- a/internal/api/client/notification/notificationsget.go +++ b/internal/api/client/notification/notificationsget.go @@ -29,7 +29,70 @@ import (  	"github.com/superseriousbusiness/gotosocial/internal/oauth"  ) -// NotificationsGETHandler serves a list of notifications to the caller, with the desired query parameters +// NotificationsGETHandler swagger:operation GET /api/v1/notifications notifications +// +// Get notifications for currently authorized user. +// +// The notifications will be returned in descending chronological order (newest first), with sequential IDs (bigger = newer). +// +// --- +// tags: +// - notifications +// +// produces: +// - application/json +// +// parameters: +// - name: limit +//   type: integer +//   description: Number of notifications to return. +//   default: 20 +//   in: query +//   required: false +// - name: exclude_types +//   type: array +//   items: +//     type: string +//   description: Array of types of notifications to exclude (follow, favourite, reblog, mention, poll, follow_request) +//   in: query +//   required: false +// - name: max_id +//   type: string +//   description: |- +//     Return only notifications *OLDER* than the given max status ID. +//     The status with the specified ID will not be included in the response. +//   in: query +//   required: false +// - name: since_id +//   type: string +//   description: |- +//     Return only notifications *NEWER* than the given since status ID. +//     The status with the specified ID will not be included in the response. +//   in: query +//   required: false +// +// security: +// - OAuth2 Bearer: +//   - read:notifications +// +// responses: +//   '200': +//     name: notifications +//     description: Array of notifications. +//     schema: +//       type: array +//       items: +//         "$ref": "#/definitions/notification" +//   '400': +//      description: bad request +//   '401': +//      description: unauthorized +//   '404': +//      description: not found +//   '406': +//      description: not acceptable +//   '500': +//      description: internal server error  func (m *Module) NotificationsGETHandler(c *gin.Context) {  	authed, err := oauth.Authed(c, true, true, true, true)  	if err != nil { @@ -66,7 +129,9 @@ func (m *Module) NotificationsGETHandler(c *gin.Context) {  		sinceID = sinceIDString  	} -	resp, errWithCode := m.processor.NotificationsGet(c.Request.Context(), authed, limit, maxID, sinceID) +	excludeTypes := c.QueryArray(ExcludeTypesKey) + +	resp, errWithCode := m.processor.NotificationsGet(c.Request.Context(), authed, excludeTypes, limit, maxID, sinceID)  	if errWithCode != nil {  		api.ErrorHandler(c, errWithCode, m.processor.InstanceGet)  		return diff --git a/internal/api/model/notification.go b/internal/api/model/notification.go index efcd2431b..c43e80b3b 100644 --- a/internal/api/model/notification.go +++ b/internal/api/model/notification.go @@ -19,6 +19,8 @@  package model  // Notification represents a notification of an event relevant to the user. +// +// swagger:model notification  type Notification struct {  	// REQUIRED  | 
