Improved post UI

This commit is contained in:
2019-08-30 11:42:46 +09:00
parent 2894a92af1
commit 3ba9b8bf3b
6 changed files with 55 additions and 38 deletions

View File

@ -35,13 +35,19 @@ func LikeAction() *api.Action {
return errors.New("Drafts need to be published before they can be liked")
}
likeable := obj.(Likeable)
user := GetUserFromContext(ctx)
if user == nil {
return errors.New("Not logged in")
}
postable, isPostable := obj.(Postable)
if isPostable && postable.Creator().ID == user.ID {
return errors.New("You can't like your own posts")
}
likeable := obj.(Likeable)
likeable.Like(user.ID)
// Call OnLike if the object implements it