Commit 37729c75 authored by zauberstuhl's avatar zauberstuhl

Add visibility parameter to Post.Index

visibility = 0 for all posts;
             1 for public posts;
             2 for private posts;
parent b8a2fe86
......@@ -40,11 +40,13 @@ func (p ApiPost) Index() revel.Result {
var (
offset int
fields string
visibility int
posts models.Posts
)
p.Params.Bind(&offset, "offset")
p.Params.Bind(&fields, "fields")
p.Params.Bind(&visibility, "visibility")
user, err := models.CurrentUser(p.Params, p.Session)
if err != nil {
......@@ -52,7 +54,13 @@ func (p ApiPost) Index() revel.Result {
return p.RenderApiError(err)
}
err = posts.FindAll(user.ID, offset)
if visibility == 0 {
err = posts.FindAll(user.ID, offset)
} else if visibility == 1 {
err = posts.FindAllPublic(offset)
} else if visibility == 2 {
err = posts.FindAllPrivate(user.ID, offset)
}
if err != nil {
revel.AppLog.Error(err.Error())
return p.RenderApiError(err)
......@@ -125,7 +133,7 @@ func (p ApiPost) Create() revel.Result {
return p.RenderApiError(err)
}
// create an aspect visibillity entry
// create an aspect visibility entry
// the host has to remember the recipients
visibility := models.AspectVisibility{
ShareableID: post.ID,
......
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