MCPcopy
hub / github.com/gotify/server / GetMessagesWithApplication

Method GetMessagesWithApplication

api/message.go:180–199  ·  view source on GitHub ↗

GetMessagesWithApplication returns all messages from a specific application. swagger:operation GET /application/{id}/message message getAppMessages Return all messages from a specific application. --- produces: [application/json] security: [clientTokenAuthorizationHeader: [], clientTokenHeader:

(ctx *gin.Context)

Source from the content-addressed store, hash-verified

178// schema:
179// $ref: "#/definitions/Error"
180func (a *MessageAPI) GetMessagesWithApplication(ctx *gin.Context) {
181 withID(ctx, "id", func(id uint) {
182 withPaging(ctx, func(params *pagingParams) {
183 app, err := a.DB.GetApplicationByID(id)
184 if success := successOrAbort(ctx, 500, err); !success {
185 return
186 }
187 if app != nil && app.UserID == auth.GetUserID(ctx) {
188 // the +1 is used to check if there are more messages and will be removed on buildWithPaging
189 messages, err := a.DB.GetMessagesByApplicationSince(id, params.Limit+1, params.Since)
190 if success := successOrAbort(ctx, 500, err); !success {
191 return
192 }
193 ctx.JSON(200, buildWithPaging(ctx, params, messages))
194 } else {
195 ctx.AbortWithError(404, errors.New("application does not exist"))
196 }
197 })
198 })
199}
200
201// DeleteMessages delete all messages from a user.
202// swagger:operation DELETE /message message deleteMessages

Calls 7

GetUserIDFunction · 0.92
withIDFunction · 0.85
withPagingFunction · 0.85
successOrAbortFunction · 0.85
buildWithPagingFunction · 0.85
GetApplicationByIDMethod · 0.65