Add create post endpoint and check target to the makefile
This commit is contained in:
parent
08ab312f92
commit
3067beb96c
12 changed files with 280 additions and 5 deletions
6
server/app/permissions.go
Normal file
6
server/app/permissions.go
Normal 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
15
server/app/post.go
Normal 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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue