Add create post endpoint and check target to the makefile

This commit is contained in:
Miguel de la Cruz 2021-09-25 17:23:56 +02:00
parent 08ab312f92
commit 3067beb96c
12 changed files with 280 additions and 5 deletions

View file

@ -0,0 +1,6 @@
package app
// ToDo: implement
func (a *App) HasPermissionToGame(userID, gameID int) bool {
return true
}

15
server/app/post.go Normal file
View file

@ -0,0 +1,15 @@
package app
import (
"fmt"
"git.ctrlz.es/mgdelacroix/craban/model"
)
func (a *App) CreatePost(post *model.Post) (*model.Post, error) {
if err := post.IsValid(); err != nil {
return nil, fmt.Errorf("invalid post for creation: %w", err)
}
return a.Store.Post().Create(post)
}