mirror of
https://github.com/Unkn0wnCat/matrix-veles.git
synced 2025-06-03 19:22:00 +02:00
api: Update graphql schema
This commit is contained in:
parent
39f721101e
commit
4f587820d1
9 changed files with 578 additions and 200 deletions
|
@ -12,6 +12,30 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
func PerformListMaintainerCheck(listIdHex string, userIdHex string) error {
|
||||
id, err := primitive.ObjectIDFromHex(listIdHex)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
list, err := db.GetListByID(id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if list.Creator.Hex() == userIdHex {
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, maintainerId := range list.Maintainers {
|
||||
if maintainerId.Hex() == userIdHex {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return errors.New("unauthorized")
|
||||
}
|
||||
|
||||
func GetUserFromContext(ctx context.Context) (*model2.DBUser, error) {
|
||||
userID, err := GetUserIDFromContext(ctx)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue