Commit c7ce8503 authored by zauberstuhl's avatar zauberstuhl

Trigger notification on like if parent is local

parent 519cbf51
...@@ -195,23 +195,18 @@ func (l ApiLike) Create() revel.Result { ...@@ -195,23 +195,18 @@ func (l ApiLike) Create() revel.Result {
return l.ApiError(http.StatusInternalServerError, ERR_SERVER) return l.ApiError(http.StatusInternalServerError, ERR_SERVER)
} }
// deliver to the network
dispatcher := jobs.Dispatcher{ dispatcher := jobs.Dispatcher{
User: user, User: user,
Message: entityLike, Message: entityLike,
} }
// NOTE the user table should start with 1
// a null check would be better in respect of if parentUser, ok := like.ParentIsLocal(); ok {
// multiple database support
if user.Person.UserID > 0 {
var parentUser models.User
err = parentUser.FindByID(user.Person.UserID)
if err != nil {
l.Log.Error(TAG, "db", err, "api", ERR_SERVER)
return l.ApiError(http.StatusInternalServerError, ERR_SERVER)
}
dispatcher.ParentUser = &parentUser dispatcher.ParentUser = &parentUser
// notify local user about a new comment
go like.TriggerNotification(parentUser)
} }
// deliver to the network
go dispatcher.Run() go dispatcher.Run()
return l.RenderJSON(like) return l.RenderJSON(like)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment