Commit 13aaae9f authored by zauberstuhl's avatar zauberstuhl

Create shareable and visibility object on post creation

parent c146953c
......@@ -59,7 +59,7 @@ func (c ApiComment) Create() revel.Result {
return c.RenderError(err)
}
err = post.FindByID(postID, false)
err = post.FindByID(postID, true)
if err != nil {
revel.ERROR.Println(err)
return c.NotFound("Post not found")
......@@ -67,6 +67,7 @@ func (c ApiComment) Create() revel.Result {
dispatcher := jobs.Dispatcher{
User: user,
ParentPerson: &post.Person,
Message: federation.EntityComment{
ParentGuid: post.Guid,
Text: comment,
......
......@@ -96,6 +96,29 @@ func (p ApiPost) Create() revel.Result {
return p.RenderError(err)
}
// this is required for mapping
// posts to the author
shareable := models.Shareable{
ShareableID: post.ID,
UserID: user.ID,
ShareableType: models.ShareablePost,
}; if err := shareable.Create(); err != nil {
revel.ERROR.Println(err)
return p.RenderError(err)
}
// create an aspect visibillity entry
// the host has to remember the recipients
visibility := models.AspectVisibility{
ShareableID: post.ID,
AspectID: aspectID,
ShareableType: models.ShareablePost,
}
if err := visibility.Create(); err != nil {
revel.ERROR.Println(err)
return p.RenderError(err)
}
dispatcher := jobs.Dispatcher{
User: user,
AspectID: aspectID,
......
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