Work on implementing search filter in app [WIP]
This commit is contained in:
87
scnserver/api/handler/apiSenderNames.go
Normal file
87
scnserver/api/handler/apiSenderNames.go
Normal file
@@ -0,0 +1,87 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"blackforestbytes.com/simplecloudnotifier/logic"
|
||||
"blackforestbytes.com/simplecloudnotifier/models"
|
||||
"gogs.mikescher.com/BlackForestBytes/goext/ginext"
|
||||
)
|
||||
|
||||
// ListUserSenderNames swaggerdoc
|
||||
//
|
||||
// @Summary List sender-names (of allthe messages of this user)
|
||||
// @ID api-usersendernames-list
|
||||
// @Tags API-v2
|
||||
//
|
||||
// @Param uid path string true "UserID"
|
||||
//
|
||||
// @Success 200 {object} handler.ListUserKeys.response
|
||||
// @Failure 400 {object} ginresp.apiError "supplied values/parameters cannot be parsed / are invalid"
|
||||
// @Failure 401 {object} ginresp.apiError "user is not authorized / has missing permissions"
|
||||
// @Failure 404 {object} ginresp.apiError "message not found"
|
||||
// @Failure 500 {object} ginresp.apiError "internal server error"
|
||||
//
|
||||
// @Router /api/v2/users/{uid}/keys [GET]
|
||||
func (h APIHandler) ListUserSenderNames(pctx ginext.PreContext) ginext.HTTPResponse {
|
||||
type uri struct {
|
||||
UserID models.UserID `uri:"uid" binding:"entityid"`
|
||||
}
|
||||
type response struct {
|
||||
}
|
||||
|
||||
var u uri
|
||||
ctx, g, errResp := pctx.URI(&u).Start()
|
||||
if errResp != nil {
|
||||
return *errResp
|
||||
}
|
||||
defer ctx.Cancel()
|
||||
|
||||
return h.app.DoRequest(ctx, g, models.TLockRead, func(ctx *logic.AppContext, finishSuccess func(r ginext.HTTPResponse) ginext.HTTPResponse) ginext.HTTPResponse {
|
||||
|
||||
if permResp := ctx.CheckPermissionUserRead(u.UserID); permResp != nil {
|
||||
return *permResp
|
||||
}
|
||||
|
||||
return nil //TODO
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
// ListSenderNames swaggerdoc
|
||||
//
|
||||
// @Summary List sender-names (of all messages this user can view, eitehr own or foreign-subscribed)
|
||||
// @ID api-sendernames-list
|
||||
// @Tags API-v2
|
||||
//
|
||||
// @Success 200 {object} handler.ListSenderNames.response
|
||||
// @Failure 400 {object} ginresp.apiError "supplied values/parameters cannot be parsed / are invalid"
|
||||
// @Failure 401 {object} ginresp.apiError "user is not authorized / has missing permissions"
|
||||
// @Failure 404 {object} ginresp.apiError "message not found"
|
||||
// @Failure 500 {object} ginresp.apiError "internal server error"
|
||||
//
|
||||
// @Router /api/v2/sender-names [GET]
|
||||
func (h APIHandler) ListSenderNames(pctx ginext.PreContext) ginext.HTTPResponse {
|
||||
type response struct {
|
||||
}
|
||||
|
||||
ctx, g, errResp := pctx.Start()
|
||||
if errResp != nil {
|
||||
return *errResp
|
||||
}
|
||||
defer ctx.Cancel()
|
||||
|
||||
return h.app.DoRequest(ctx, g, models.TLockRead, func(ctx *logic.AppContext, finishSuccess func(r ginext.HTTPResponse) ginext.HTTPResponse) ginext.HTTPResponse {
|
||||
|
||||
if permResp := ctx.CheckPermissionAny(); permResp != nil {
|
||||
return *permResp
|
||||
}
|
||||
|
||||
userid := *ctx.GetPermissionUserID()
|
||||
|
||||
if permResp := ctx.CheckPermissionUserRead(userid); permResp != nil {
|
||||
return *permResp
|
||||
}
|
||||
|
||||
return nil //TODO
|
||||
|
||||
})
|
||||
}
|
@@ -152,10 +152,14 @@ func (r *Router) Init(e *ginext.GinWrapper) error {
|
||||
apiv2.DELETE("/users/:uid/subscriptions/:sid").Handle(r.apiHandler.CancelSubscription)
|
||||
apiv2.PATCH("/users/:uid/subscriptions/:sid").Handle(r.apiHandler.UpdateSubscription)
|
||||
|
||||
apiv2.GET("/users/:uid/sender-names").Handle(r.apiHandler.ListUserSenderNames)
|
||||
|
||||
apiv2.GET("/messages").Handle(r.apiHandler.ListMessages)
|
||||
apiv2.GET("/messages/:mid").Handle(r.apiHandler.GetMessage)
|
||||
apiv2.DELETE("/messages/:mid").Handle(r.apiHandler.DeleteMessage)
|
||||
|
||||
apiv2.GET("/sender-names").Handle(r.apiHandler.ListSenderNames)
|
||||
|
||||
apiv2.GET("/preview/users/:uid").Handle(r.apiHandler.GetUserPreview)
|
||||
apiv2.GET("/preview/keys/:kid").Handle(r.apiHandler.GetUserKeyPreview)
|
||||
apiv2.GET("/preview/channels/:cid").Handle(r.apiHandler.GetChannelPreview)
|
||||
|
Reference in New Issue
Block a user