fix some endpoints

This commit is contained in:
sam 2023-09-15 16:33:08 +02:00
parent 7aee99ac42
commit 6f1b94c040
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
10 changed files with 47 additions and 41 deletions

View file

@ -75,6 +75,12 @@ func (app *App) Create(w http.ResponseWriter, r *http.Request) (api.Post, error)
return api.Post{}, err
}
acct, err := app.Account(conn).ByID(ctx, blog.AccountID)
if err != nil {
log.Err(err).Msg("fetching account")
return api.Post{}, err
}
if blog.AccountID != token.UserID {
return api.Post{}, api.Error{Code: api.ErrNotYourObject}
}
@ -87,5 +93,5 @@ func (app *App) Create(w http.ResponseWriter, r *http.Request) (api.Post, error)
}
// TODO: federate post + push to websockets
return api.DBPostToPost(post, blog), nil
return api.DBPostToPost(post, blog, acct), nil
}