Open platform to collect and prioritize feedback
refactor: rename Ideas to Posts (#476)
Guilherme Oenningec4d2794938d
diff --git a/app/actions/actions_test.go b/app/actions/actions_test.goindex 18c2d973d..adfa81cfd 100644--- a/app/actions/actions_test.go+++ b/app/actions/actions_test.go@@ -18,7 +18,7 @@ var jonSnowToken, _ = jwt.Encode(jwt.OAuthClaims{var services = &app.Services{Tenants: inmemory.NewTenantStorage(),Users: &inmemory.UserStorage{},- Ideas: inmemory.NewIdeaStorage(),+ Posts: inmemory.NewPostStorage(),Tags: inmemory.NewTagStorage(),Notifications: inmemory.NewNotificationStorage(),}diff --git a/app/actions/idea.go b/app/actions/post.gosimilarity index 71%rename from app/actions/idea.gorename to app/actions/post.goindex 2e19010ab..4c5705085 100644--- a/app/actions/idea.go+++ b/app/actions/post.go@@ -11,24 +11,24 @@ import ("github.com/getfider/fider/app/pkg/validate")-// CreateNewIdea is used to create a new idea-type CreateNewIdea struct {- Model *models.NewIdea+// CreateNewPost is used to create a new post+type CreateNewPost struct {+ Model *models.NewPost}// Initialize the model-func (input *CreateNewIdea) Initialize() interface{} {- input.Model = new(models.NewIdea)+func (input *CreateNewPost) Initialize() interface{} {+ input.Model = new(models.NewPost)return input.Model}// IsAuthorized returns true if current user is authorized to perform this action-func (input *CreateNewIdea) IsAuthorized(user *models.User, services *app.Services) bool {+func (input *CreateNewPost) IsAuthorized(user *models.User, services *app.Services) bool {return user != nil}// Validate is current model is valid-func (input *CreateNewIdea) Validate(user *models.User, services *app.Services) *validate.Result {+func (input *CreateNewPost) Validate(user *models.User, services *app.Services) *validate.Result {result := validate.Success()if input.Model.Title == "" {@@ -41,38 +41,38 @@ func (input *CreateNewIdea) Validate(user *models.User, services *app.Services)result.AddFieldFailure("title", "Title must have less than 100 characters.")}- idea, err := services.Ideas.GetBySlug(slug.Make(input.Model.Title))+ post, err := services.Posts.GetBySlug(slug.Make(input.Model.Title))if err != nil && errors.Cause(err) != app.ErrNotFound {return validate.Error(err)- } else if idea != nil {+ } else if post != nil {result.AddFieldFailure("title", "This has already been posted before.")}return result}-// UpdateIdea is used to edit an existing new idea-type UpdateIdea struct {- Model *models.UpdateIdea- Idea *models.Idea+// UpdatePost is used to edit an existing new post+type UpdatePost struct {+ Model *models.UpdatePost+ Post *models.Post}// Initialize the model-func (input *UpdateIdea) Initialize() interface{} {- input.Model = new(models.UpdateIdea)+func (input *UpdatePost) Initialize() interface{} {+ input.Model = new(models.UpdatePost)return input.Model}// IsAuthorized returns true if current user is authorized to perform this action-func (input *UpdateIdea) IsAuthorized(user *models.User, services *app.Services) bool {+func (input *UpdatePost) IsAuthorized(user *models.User, services *app.Services) bool {return user != nil && user.IsCollaborator()}// Validate is current model is valid-func (input *UpdateIdea) Validate(user *models.User, services *app.Services) *validate.Result {+func (input *UpdatePost) Validate(user *models.User, services *app.Services) *validate.Result {result := validate.Success()- idea, err := services.Ideas.GetByNumber(input.Model.Number)+ post, err := services.Posts.GetByNumber(input.Model.Number)if err != nil {return validate.Error(err)}@@ -87,14 +87,14 @@ func (input *UpdateIdea) Validate(user *models.User, services *app.Services) *varesult.AddFieldFailure("title", "Title must have less than 100 characters.")}- another, err := services.Ideas.GetBySlug(slug.Make(input.Model.Title))+ another, err := services.Posts.GetBySlug(slug.Make(input.Model.Title))if err != nil && errors.Cause(err) != app.ErrNotFound {return validate.Error(err)- } else if another != nil && another.ID != idea.ID {+ } else if another != nil && another.ID != post.ID {result.AddFieldFailure("title", "This has already been posted before.")}- input.Idea = idea+ input.Post = postreturn result}@@ -126,10 +126,10 @@ func (input *AddNewComment) Validate(user *models.User, services *app.Services)return result}-// SetResponse represents the action to update an idea response+// SetResponse represents the action to update an post responsetype SetResponse struct {Model *models.SetResponse- Original *models.Idea+ Original *models.Post}// Initialize the model@@ -147,19 +147,19 @@ func (input *SetResponse) IsAuthorized(user *models.User, services *app.Servicesfunc (input *SetResponse) Validate(user *models.User, services *app.Services) *validate.Result {result := validate.Success()- if input.Model.Status < models.IdeaOpen || input.Model.Status > models.IdeaDuplicate {+ if input.Model.Status < models.PostOpen || input.Model.Status > models.PostDuplicate {result.AddFieldFailure("status", "Status is invalid.")}- if input.Model.Status == models.IdeaDuplicate {+ if input.Model.Status == models.PostDuplicate {if input.Model.OriginalNumber == input.Model.Number {result.AddFieldFailure("originalNumber", "Cannot be a duplicate of itself")}- original, err := services.Ideas.GetByNumber(input.Model.OriginalNumber)+ original, err := services.Posts.GetByNumber(input.Model.OriginalNumber)if err != nil {if errors.Cause(err) == app.ErrNotFound {- result.AddFieldFailure("originalNumber", "Original idea not found")+ result.AddFieldFailure("originalNumber", "Original post not found")} else {return validate.Error(err)}@@ -172,40 +172,40 @@ func (input *SetResponse) Validate(user *models.User, services *app.Services) *vreturn result}-// DeleteIdea represents the action of an administrator deleting an existing Idea-type DeleteIdea struct {- Model *models.DeleteIdea- Idea *models.Idea+// DeletePost represents the action of an administrator deleting an existing Post+type DeletePost struct {+ Model *models.DeletePost+ Post *models.Post}// Initialize the model-func (input *DeleteIdea) Initialize() interface{} {- input.Model = new(models.DeleteIdea)+func (input *DeletePost) Initialize() interface{} {+ input.Model = new(models.DeletePost)return input.Model}// IsAuthorized returns true if current user is authorized to perform this action-func (input *DeleteIdea) IsAuthorized(user *models.User, services *app.Services) bool {+func (input *DeletePost) IsAuthorized(user *models.User, services *app.Services) bool {return user != nil && user.IsAdministrator()}// Validate if current model is valid-func (input *DeleteIdea) Validate(user *models.User, services *app.Services) *validate.Result {- idea, err := services.Ideas.GetByNumber(input.Model.Number)+func (input *DeletePost) Validate(user *models.User, services *app.Services) *validate.Result {+ post, err := services.Posts.GetByNumber(input.Model.Number)if err != nil {return validate.Error(err)}- isReferenced, err := services.Ideas.IsReferenced(idea)+ isReferenced, err := services.Posts.IsReferenced(post)if err != nil {return validate.Error(err)}if isReferenced {- return validate.Failed("This idea cannot be deleted because it's being referenced by a duplicated idea.")+ return validate.Failed("This post cannot be deleted because it's being referenced by a duplicated post.")}- input.Idea = idea+ input.Post = postreturn validate.Success()}@@ -223,7 +223,7 @@ func (input *EditComment) Initialize() interface{} {// IsAuthorized returns true if current user is authorized to perform this actionfunc (input *EditComment) IsAuthorized(user *models.User, services *app.Services) bool {- comment, err := services.Ideas.GetCommentByID(input.Model.ID)+ comment, err := services.Posts.GetCommentByID(input.Model.ID)if err != nil {return false}diff --git a/app/actions/idea_test.go b/app/actions/post_test.gosimilarity index 58%rename from app/actions/idea_test.gorename to app/actions/post_test.goindex 71ebfec28..57f0cc277 100644--- a/app/actions/idea_test.go+++ b/app/actions/post_test.go@@ -8,39 +8,39 @@ import (. "github.com/getfider/fider/app/pkg/assert")-func TestCreateNewIdea_InvalidIdeaTitles(t *testing.T) {+func TestCreateNewPost_InvalidPostTitles(t *testing.T) {RegisterT(t)services.SetCurrentUser(&models.User{ID: 1})- services.Ideas.Add("My great idea", "With a great description")+ services.Posts.Add("My great post", "With a great description")for _, title := range []string{"me",""," ","signup",- "My great great great great great great great great great great great great great great great great great idea.",+ "My great great great great great great great great great great great great great great great great great post.","my company","my@company","my.company","my+company","1234567890123456789012345678901234567890ABC",- "my GREAT idea",+ "my GREAT post",} {- action := &actions.CreateNewIdea{Model: &models.NewIdea{Title: title}}+ action := &actions.CreateNewPost{Model: &models.NewPost{Title: title}}result := action.Validate(nil, services)ExpectFailed(result, "title")}}-func TestCreateNewIdea_ValidIdeaTitles(t *testing.T) {+func TestCreateNewPost_ValidPostTitles(t *testing.T) {RegisterT(t)for _, title := range []string{- "this is my new idea",- "this idea is very descriptive",+ "this is my new post",+ "this post is very descriptive",} {- action := &actions.CreateNewIdea{Model: &models.NewIdea{Title: title}}+ action := &actions.CreateNewPost{Model: &models.NewPost{Title: title}}result := action.Validate(nil, services)ExpectSuccess(result)}@@ -50,28 +50,28 @@ func TestSetResponse_InvalidStatus(t *testing.T) {RegisterT(t)action := &actions.SetResponse{Model: &models.SetResponse{- Status: models.IdeaDeleted,+ Status: models.PostDeleted,Text: "Spam!",}}result := action.Validate(nil, services)ExpectFailed(result, "status")}-func TestDeleteIdea_WhenIsBeingReferenced(t *testing.T) {+func TestDeletePost_WhenIsBeingReferenced(t *testing.T) {RegisterT(t)services.SetCurrentUser(&models.User{ID: 1})- idea1, _ := services.Ideas.Add("Idea #1", "")- idea2, _ := services.Ideas.Add("Idea #2", "")- services.Ideas.MarkAsDuplicate(idea2, idea1)+ post1, _ := services.Posts.Add("Post #1", "")+ post2, _ := services.Posts.Add("Post #2", "")+ services.Posts.MarkAsDuplicate(post2, post1)- model := &models.DeleteIdea{- Number: idea2.Number,+ model := &models.DeletePost{+ Number: post2.Number,Text: "Spam!",}- action := &actions.DeleteIdea{Model: model}+ action := &actions.DeletePost{Model: model}ExpectSuccess(action.Validate(nil, services))- model.Number = idea1.Number+ model.Number = post1.NumberExpectFailed(action.Validate(nil, services))}diff --git a/app/actions/settings_test.go b/app/actions/settings_test.goindex 51b35766f..4c08bb2e4 100644--- a/app/actions/settings_test.go+++ b/app/actions/settings_test.go@@ -62,7 +62,7 @@ func TestValidSettings(t *testing.T) {for _, settings := range []map[string]string{nil,map[string]string{- models.NotificationEventNewIdea.UserSettingsKeyName: models.NotificationEventNewIdea.DefaultSettingValue,+ models.NotificationEventNewPost.UserSettingsKeyName: models.NotificationEventNewPost.DefaultSettingValue,models.NotificationEventNewComment.UserSettingsKeyName: models.NotificationEventNewComment.DefaultSettingValue,models.NotificationEventChangeStatus.UserSettingsKeyName: models.NotificationEventChangeStatus.DefaultSettingValue,},diff --git a/app/actions/tag.go b/app/actions/tag.goindex 4ffd4d949..10aa65c91 100644--- a/app/actions/tag.go+++ b/app/actions/tag.go@@ -92,10 +92,10 @@ func (input *DeleteTag) Validate(user *models.User, services *app.Services) *valreturn validate.Success()}-// AssignUnassignTag is used to assign or remove a tag to/from an idea+// AssignUnassignTag is used to assign or remove a tag to/from an posttype AssignUnassignTag struct {Tag *models.Tag- Idea *models.Idea+ Post *models.PostModel *models.AssignUnassignTag}@@ -112,7 +112,7 @@ func (input *AssignUnassignTag) IsAuthorized(user *models.User, services *app.Se// Validate is current model is validfunc (input *AssignUnassignTag) Validate(user *models.User, services *app.Services) *validate.Result {- idea, err := services.Ideas.GetByNumber(input.Model.Number)+ post, err := services.Posts.GetByNumber(input.Model.Number)if err != nil {return validate.Error(err)}@@ -123,6 +123,6 @@ func (input *AssignUnassignTag) Validate(user *models.User, services *app.Servic}input.Tag = tag- input.Idea = idea+ input.Post = postreturn validate.Success()}diff --git a/app/cmd/routes.go b/app/cmd/routes.goindex bb4310c4a..a2ce33226 100644--- a/app/cmd/routes.go+++ b/app/cmd/routes.go@@ -2,6 +2,7 @@ package cmdimport ("net/http"+ "strings""time""github.com/getfider/fider/app/handlers"@@ -83,10 +84,19 @@ func routes(r *web.Engine) *web.Engine {public := page.Group(){public.Get("/", handlers.Index())- public.Get("/api/ideas/search", handlers.SearchIdeas())- public.Get("/ideas/:number", handlers.IdeaDetails())- public.Get("/ideas/:number/*all", handlers.IdeaDetails())+ public.Get("/api/posts/search", handlers.SearchPosts())+ public.Get("/posts/:number", handlers.PostDetails())+ public.Get("/posts/:number/*all", handlers.PostDetails())public.Get("/signout", handlers.SignOut())++ /* This is a temporary redirect and should be removed in the future */+ public.Get("/ideas/:number", func(c web.Context) error {+ return c.Redirect(strings.Replace(c.Request.URL.Path, "/ideas/", "/posts/", 1))+ })+ public.Get("/ideas/:number/*all", func(c web.Context) error {+ return c.Redirect(strings.Replace(c.Request.URL.Path, "/ideas/", "/posts/", 1))+ })+ /* This is a temporary redirect and should be removed in the future */}private := page.Group()@@ -97,17 +107,17 @@ func routes(r *web.Engine) *web.Engine {private.Get("/notifications/:id", handlers.ReadNotification())private.Get("/change-email/verify", handlers.VerifyChangeEmailKey())- private.Post("/api/ideas", handlers.PostIdea())- private.Post("/api/ideas/:number", handlers.UpdateIdea())- private.Post("/api/ideas/:number/comments", handlers.PostComment())- private.Post("/api/ideas/:number/comments/:id", handlers.UpdateComment())- private.Post("/api/ideas/:number/status", handlers.SetResponse())- private.Post("/api/ideas/:number/support", handlers.AddSupporter())- private.Post("/api/ideas/:number/unsupport", handlers.RemoveSupporter())- private.Post("/api/ideas/:number/subscribe", handlers.Subscribe())- private.Post("/api/ideas/:number/unsubscribe", handlers.Unsubscribe())- private.Post("/api/ideas/:number/tags/:slug", handlers.AssignTag())- private.Delete("/api/ideas/:number/tags/:slug", handlers.UnassignTag())+ private.Post("/api/posts", handlers.CreatePost())+ private.Post("/api/posts/:number", handlers.UpdatePost())+ private.Post("/api/posts/:number/comments", handlers.PostComment())+ private.Post("/api/posts/:number/comments/:id", handlers.UpdateComment())+ private.Post("/api/posts/:number/status", handlers.SetResponse())+ private.Post("/api/posts/:number/support", handlers.AddSupporter())+ private.Post("/api/posts/:number/unsupport", handlers.RemoveSupporter())+ private.Post("/api/posts/:number/subscribe", handlers.Subscribe())+ private.Post("/api/posts/:number/unsubscribe", handlers.Unsubscribe())+ private.Post("/api/posts/:number/tags/:slug", handlers.AssignTag())+ private.Delete("/api/posts/:number/tags/:slug", handlers.UnassignTag())private.Delete("/api/user", handlers.DeleteUser())private.Post("/api/user/settings", handlers.UpdateUserSettings())private.Post("/api/user/change-email", handlers.ChangeUserEmail())@@ -130,8 +140,8 @@ func routes(r *web.Engine) *web.Engine {private.Use(middlewares.IsAuthorized(models.RoleAdministrator))private.Get("/admin/export", handlers.Page("Export · Site Settings", ""))- private.Get("/admin/export/ideas.csv", handlers.ExportIdeasToCSV())- private.Delete("/api/ideas/:number", handlers.DeleteIdea())+ private.Get("/admin/export/posts.csv", handlers.ExportPostsToCSV())+ private.Delete("/api/posts/:number", handlers.DeletePost())private.Post("/api/admin/settings/general", handlers.UpdateSettings())private.Post("/api/admin/settings/advanced", handlers.UpdateAdvancedSettings())private.Post("/api/admin/settings/privacy", handlers.UpdatePrivacy())diff --git a/app/handlers/oauth.go b/app/handlers/oauth.goindex b2bf4340e..12d49bb36 100644--- a/app/handlers/oauth.go+++ b/app/handlers/oauth.go@@ -153,11 +153,6 @@ func OAuthCallback() web.HandlerFunc {return c.Redirect(redirectURL.String())}- //IDEA! when checking for signup, check if it's echo, if yes, redirect with identifier and code and do everything there, expose method to get raw re-- //TODO: check if echo, then skip user creation just redirect to /echo + send extract info plus raw GET response- //TODO: else check if config is enabled before looking for users-//Test OAuthif redirectURL.Path == fmt.Sprintf("/oauth/%s/echo", provider) {var query = redirectURL.Query()diff --git a/app/handlers/oauth_test.go b/app/handlers/oauth_test.goindex 319acb64d..dceda7a72 100644--- a/app/handlers/oauth_test.go+++ b/app/handlers/oauth_test.go@@ -255,7 +255,7 @@ func TestOAuthTokenHandler_NewUser_PrivateTenant(t *testing.T) {mock.AvengersTenant.IsPrivate = truecode, response := server.- WithURL("http://ideas.theavengers.com/oauth/facebook/token?code=456&identifier=888&redirect=/").+ WithURL("http://feedback.theavengers.com/oauth/facebook/token?code=456&identifier=888&redirect=/").AddCookie(web.CookieOAuthIdentifier, "888").OnTenant(mock.AvengersTenant).AddParam("provider", oauth.FacebookProvider).@@ -276,7 +276,7 @@ func TestOAuthTokenHandler_InvalidIdentifier(t *testing.T) {mock.AvengersTenant.IsPrivate = truecode, response := server.- WithURL("http://ideas.theavengers.com/oauth/facebook/token?code=456&identifier=888&redirect=/").+ WithURL("http://feedback.theavengers.com/oauth/facebook/token?code=456&identifier=888&redirect=/").AddCookie(web.CookieOAuthIdentifier, "777").OnTenant(mock.AvengersTenant).AddParam("provider", oauth.FacebookProvider).diff --git a/app/handlers/idea.go b/app/handlers/post.gosimilarity index 58%rename from app/handlers/idea.gorename to app/handlers/post.goindex f2d4116ba..0178e8e4f 100644--- a/app/handlers/idea.go+++ b/app/handlers/post.go@@ -12,7 +12,7 @@ import (// Index is the default home pagefunc Index() web.HandlerFunc {return func(c web.Context) error {- ideas, err := c.Services().Ideas.Search(+ posts, err := c.Services().Posts.Search(c.QueryParam("q"),c.QueryParam("f"),c.QueryParam("l"),@@ -27,7 +27,7 @@ func Index() web.HandlerFunc {return c.Failure(err)}- stats, err := c.Services().Ideas.CountPerStatus()+ stats, err := c.Services().Posts.CountPerStatus()if err != nil {return c.Failure(err)}@@ -36,13 +36,13 @@ func Index() web.HandlerFunc {if c.Tenant().WelcomeMessage != "" {description = markdown.PlainText(c.Tenant().WelcomeMessage)} else {- description = "We'd love to hear what you're thinking about. What can we do better? This is the place for you to vote, discuss and share ideas."+ description = "We'd love to hear what you're thinking about. What can we do better? This is the place for you to vote, discuss and share posts."}return c.Page(web.Props{Description: description,Data: web.Map{- "ideas": ideas,+ "posts": posts,"tags": tags,"countPerStatus": stats,},@@ -50,10 +50,10 @@ func Index() web.HandlerFunc {}}-// SearchIdeas return existing ideas based on search criteria-func SearchIdeas() web.HandlerFunc {+// SearchPosts return existing posts based on search criteria+func SearchPosts() web.HandlerFunc {return func(c web.Context) error {- ideas, err := c.Services().Ideas.Search(+ posts, err := c.Services().Posts.Search(c.QueryParam("q"),c.QueryParam("f"),c.QueryParam("l"),@@ -62,43 +62,43 @@ func SearchIdeas() web.HandlerFunc {if err != nil {return c.Failure(err)}- return c.Ok(ideas)+ return c.Ok(posts)}}-// PostIdea creates a new idea on current tenant-func PostIdea() web.HandlerFunc {+// CreatePost creates a new post on current tenant+func CreatePost() web.HandlerFunc {return func(c web.Context) error {- input := new(actions.CreateNewIdea)+ input := new(actions.CreateNewPost)if result := c.BindTo(input); !result.Ok {return c.HandleValidation(result)}- ideas := c.Services().Ideas- idea, err := ideas.Add(input.Model.Title, input.Model.Description)+ posts := c.Services().Posts+ post, err := posts.Add(input.Model.Title, input.Model.Description)if err != nil {return c.Failure(err)}- if err := ideas.AddSupporter(idea, c.User()); err != nil {+ if err := posts.AddSupporter(post, c.User()); err != nil {return c.Failure(err)}- c.Enqueue(tasks.NotifyAboutNewIdea(idea))+ c.Enqueue(tasks.NotifyAboutNewPost(post))- return c.Ok(idea)+ return c.Ok(post)}}-// UpdateIdea updates an existing idea of current tenant-func UpdateIdea() web.HandlerFunc {+// UpdatePost updates an existing post of current tenant+func UpdatePost() web.HandlerFunc {return func(c web.Context) error {- input := new(actions.UpdateIdea)+ input := new(actions.UpdatePost)if result := c.BindTo(input); !result.Ok {return c.HandleValidation(result)}- _, err := c.Services().Ideas.Update(input.Idea, input.Model.Title, input.Model.Description)+ _, err := c.Services().Posts.Update(input.Post, input.Model.Title, input.Model.Description)if err != nil {return c.Failure(err)}@@ -107,15 +107,15 @@ func UpdateIdea() web.HandlerFunc {}}-// DeleteIdea deletes an existing idea of current tenant-func DeleteIdea() web.HandlerFunc {+// DeletePost deletes an existing post of current tenant+func DeletePost() web.HandlerFunc {return func(c web.Context) error {- input := new(actions.DeleteIdea)+ input := new(actions.DeletePost)if result := c.BindTo(input); !result.Ok {return c.HandleValidation(result)}- err := c.Services().Ideas.SetResponse(input.Idea, input.Model.Text, models.IdeaDeleted)+ err := c.Services().Posts.SetResponse(input.Post, input.Model.Text, models.PostDeleted)if err != nil {return c.Failure(err)}@@ -124,21 +124,21 @@ func DeleteIdea() web.HandlerFunc {}}-// IdeaDetails shows details of given Idea by id-func IdeaDetails() web.HandlerFunc {+// PostDetails shows details of given Post by id+func PostDetails() web.HandlerFunc {return func(c web.Context) error {number, err := c.ParamAsInt("number")if err != nil {return c.Failure(err)}- ideas := c.Services().Ideas- idea, err := ideas.GetByNumber(number)+ posts := c.Services().Posts+ post, err := posts.GetByNumber(number)if err != nil {return c.Failure(err)}- comments, err := ideas.GetCommentsByIdea(idea)+ comments, err := posts.GetCommentsByPost(post)if err != nil {return c.Failure(err)}@@ -148,25 +148,25 @@ func IdeaDetails() web.HandlerFunc {return c.Failure(err)}- subscribed, err := c.Services().Users.HasSubscribedTo(idea.ID)+ subscribed, err := c.Services().Users.HasSubscribedTo(post.ID)if err != nil {return c.Failure(err)}return c.Page(web.Props{- Title: idea.Title,- Description: markdown.PlainText(idea.Description),+ Title: post.Title,+ Description: markdown.PlainText(post.Description),Data: web.Map{"comments": comments,"subscribed": subscribed,- "idea": idea,+ "post": post,"tags": tags,},})}}-// PostComment creates a new comment on given idea+// PostComment creates a new comment on given postfunc PostComment() web.HandlerFunc {return func(c web.Context) error {input := new(actions.AddNewComment)@@ -174,17 +174,17 @@ func PostComment() web.HandlerFunc {return c.HandleValidation(result)}- idea, err := c.Services().Ideas.GetByNumber(input.Model.Number)+ post, err := c.Services().Posts.GetByNumber(input.Model.Number)if err != nil {return c.Failure(err)}- _, err = c.Services().Ideas.AddComment(idea, input.Model.Content)+ _, err = c.Services().Posts.AddComment(post, input.Model.Content)if err != nil {return c.Failure(err)}- c.Enqueue(tasks.NotifyAboutNewComment(idea, input.Model))+ c.Enqueue(tasks.NotifyAboutNewComment(post, input.Model))return c.Ok(web.Map{})}@@ -198,7 +198,7 @@ func UpdateComment() web.HandlerFunc {return c.HandleValidation(result)}- err := c.Services().Ideas.UpdateComment(input.Model.ID, input.Model.Content)+ err := c.Services().Posts.UpdateComment(input.Model.ID, input.Model.Content)if err != nil {return c.Failure(err)}@@ -207,7 +207,7 @@ func UpdateComment() web.HandlerFunc {}}-// SetResponse changes current idea staff response+// SetResponse changes current post staff responsefunc SetResponse() web.HandlerFunc {return func(c web.Context) error {input := new(actions.SetResponse)@@ -215,67 +215,67 @@ func SetResponse() web.HandlerFunc {return c.HandleValidation(result)}- idea, err := c.Services().Ideas.GetByNumber(input.Model.Number)+ post, err := c.Services().Posts.GetByNumber(input.Model.Number)if err != nil {return c.Failure(err)}- prevStatus := idea.Status- if input.Model.Status == models.IdeaDuplicate {- err = c.Services().Ideas.MarkAsDuplicate(idea, input.Original)+ prevStatus := post.Status+ if input.Model.Status == models.PostDuplicate {+ err = c.Services().Posts.MarkAsDuplicate(post, input.Original)} else {- err = c.Services().Ideas.SetResponse(idea, input.Model.Text, input.Model.Status)+ err = c.Services().Posts.SetResponse(post, input.Model.Text, input.Model.Status)}if err != nil {return c.Failure(err)}- c.Enqueue(tasks.NotifyAboutStatusChange(idea, prevStatus))+ c.Enqueue(tasks.NotifyAboutStatusChange(post, prevStatus))return c.Ok(web.Map{})}}-// AddSupporter adds current user to given idea list of supporters+// AddSupporter adds current user to given post list of supportersfunc AddSupporter() web.HandlerFunc {return func(c web.Context) error {- return addOrRemove(c, c.Services().Ideas.AddSupporter)+ return addOrRemove(c, c.Services().Posts.AddSupporter)}}-// RemoveSupporter removes current user from given idea list of supporters+// RemoveSupporter removes current user from given post list of supportersfunc RemoveSupporter() web.HandlerFunc {return func(c web.Context) error {- return addOrRemove(c, c.Services().Ideas.RemoveSupporter)+ return addOrRemove(c, c.Services().Posts.RemoveSupporter)}}-// Subscribe adds current user to list of subscribers of given idea+// Subscribe adds current user to list of subscribers of given postfunc Subscribe() web.HandlerFunc {return func(c web.Context) error {- return addOrRemove(c, c.Services().Ideas.AddSubscriber)+ return addOrRemove(c, c.Services().Posts.AddSubscriber)}}-// Unsubscribe removes current user from list of subscribers of given idea+// Unsubscribe removes current user from list of subscribers of given postfunc Unsubscribe() web.HandlerFunc {return func(c web.Context) error {- return addOrRemove(c, c.Services().Ideas.RemoveSubscriber)+ return addOrRemove(c, c.Services().Posts.RemoveSubscriber)}}-func addOrRemove(c web.Context, addOrRemove func(idea *models.Idea, user *models.User) error) error {+func addOrRemove(c web.Context, addOrRemove func(post *models.Post, user *models.User) error) error {number, err := c.ParamAsInt("number")if err != nil {return c.Failure(err)}- idea, err := c.Services().Ideas.GetByNumber(number)+ post, err := c.Services().Posts.GetByNumber(number)if err != nil {return c.Failure(err)}- err = addOrRemove(idea, c.User())+ err = addOrRemove(post, c.User())if err != nil {return c.Failure(err)}@@ -283,20 +283,20 @@ func addOrRemove(c web.Context, addOrRemove func(idea *models.Idea, user *modelsreturn c.Ok(web.Map{})}-// ExportIdeasToCSV returns a CSV with all ideas-func ExportIdeasToCSV() web.HandlerFunc {+// ExportPostsToCSV returns a CSV with all posts+func ExportPostsToCSV() web.HandlerFunc {return func(c web.Context) error {- ideas, err := c.Services().Ideas.GetAll()+ posts, err := c.Services().Posts.GetAll()if err != nil {return c.Failure(err)}- bytes, err := csv.FromIdeas(ideas)+ bytes, err := csv.FromPosts(posts)if err != nil {return c.Failure(err)}- return c.Attachment("ideas.csv", "text/csv", bytes)+ return c.Attachment("posts.csv", "text/csv", bytes)}}diff --git a/app/handlers/idea_test.go b/app/handlers/post_test.gosimilarity index 64%rename from app/handlers/idea_test.gorename to app/handlers/post_test.goindex 1feafd7c0..6d90f74fd 100644--- a/app/handlers/idea_test.go+++ b/app/handlers/post_test.go@@ -29,13 +29,13 @@ func TestDetailsHandler(t *testing.T) {server, services := mock.NewServer()services.SetCurrentTenant(mock.DemoTenant)services.SetCurrentUser(mock.JonSnow)- idea, _ := services.Ideas.Add("My Idea", "My Idea Description")+ post, _ := services.Posts.Add("My Post", "My Post Description")code, _ := server.OnTenant(mock.DemoTenant).AsUser(mock.JonSnow).- AddParam("number", idea.Number).- Execute(handlers.IdeaDetails())+ AddParam("number", post.Number).+ Execute(handlers.PostDetails())Expect(code).Equals(http.StatusOK)}@@ -48,96 +48,96 @@ func TestDetailsHandler_NotFound(t *testing.T) {OnTenant(mock.DemoTenant).AsUser(mock.JonSnow).AddParam("number", "99").- Execute(handlers.IdeaDetails())+ Execute(handlers.PostDetails())Expect(code).Equals(http.StatusNotFound)}-func TestPostIdeaHandler(t *testing.T) {+func TestCreatePostHandler(t *testing.T) {RegisterT(t)server, services := mock.NewServer()code, _ := server.OnTenant(mock.DemoTenant).AsUser(mock.JonSnow).- ExecutePost(handlers.PostIdea(), `{ "title": "My newest idea :)" }`)+ ExecutePost(handlers.CreatePost(), `{ "title": "My newest post :)" }`)- idea, err := services.Ideas.GetByID(1)+ post, err := services.Posts.GetByID(1)Expect(code).Equals(http.StatusOK)Expect(err).IsNil()- Expect(idea.Title).Equals("My newest idea :)")- Expect(idea.TotalSupporters).Equals(1)+ Expect(post.Title).Equals("My newest post :)")+ Expect(post.TotalSupporters).Equals(1)}-func TestPostIdeaHandler_WithoutTitle(t *testing.T) {+func TestCreatePostHandler_WithoutTitle(t *testing.T) {RegisterT(t)server, services := mock.NewServer()code, _ := server.OnTenant(mock.DemoTenant).AsUser(mock.JonSnow).- ExecutePost(handlers.PostIdea(), `{ "title": "" }`)+ ExecutePost(handlers.CreatePost(), `{ "title": "" }`)- _, err := services.Ideas.GetByID(1)+ _, err := services.Posts.GetByID(1)Expect(code).Equals(http.StatusBadRequest)Expect(err).IsNotNil()}-func TestUpdateIdeaHandler_TenantStaff(t *testing.T) {+func TestUpdatePostHandler_TenantStaff(t *testing.T) {RegisterT(t)server, services := mock.NewServer()services.SetCurrentTenant(mock.DemoTenant)services.SetCurrentUser(mock.AryaStark)- idea, _ := services.Ideas.Add("My First Idea", "With a description")+ post, _ := services.Posts.Add("My First Post", "With a description")code, _ := server.OnTenant(mock.DemoTenant).AsUser(mock.JonSnow).- AddParam("number", idea.Number).- ExecutePost(handlers.UpdateIdea(), `{ "title": "the new title", "description": "new description" }`)+ AddParam("number", post.Number).+ ExecutePost(handlers.UpdatePost(), `{ "title": "the new title", "description": "new description" }`)- idea, _ = services.Ideas.GetByNumber(idea.Number)+ post, _ = services.Posts.GetByNumber(post.Number)Expect(code).Equals(http.StatusOK)- Expect(idea.Title).Equals("the new title")- Expect(idea.Description).Equals("new description")+ Expect(post.Title).Equals("the new title")+ Expect(post.Description).Equals("new description")}-func TestUpdateIdeaHandler_NonAuthorized(t *testing.T) {+func TestUpdatePostHandler_NonAuthorized(t *testing.T) {RegisterT(t)server, services := mock.NewServer()services.SetCurrentTenant(mock.DemoTenant)services.SetCurrentUser(mock.JonSnow)- idea, _ := services.Ideas.Add("My First Idea", "With a description")+ post, _ := services.Posts.Add("My First Post", "With a description")code, _ := server.OnTenant(mock.DemoTenant).AsUser(mock.AryaStark).- AddParam("number", idea.Number).- ExecutePost(handlers.UpdateIdea(), `{ "title": "the new title", "description": "new description" }`)+ AddParam("number", post.Number).+ ExecutePost(handlers.UpdatePost(), `{ "title": "the new title", "description": "new description" }`)Expect(code).Equals(http.StatusForbidden)}-func TestUpdateIdeaHandler_InvalidTitle(t *testing.T) {+func TestUpdatePostHandler_InvalidTitle(t *testing.T) {RegisterT(t)server, services := mock.NewServer()services.SetCurrentTenant(mock.DemoTenant)services.SetCurrentUser(mock.JonSnow)- idea, _ := services.Ideas.Add("My First Idea", "With a description")+ post, _ := services.Posts.Add("My First Post", "With a description")code, _ := server.OnTenant(mock.DemoTenant).AsUser(mock.JonSnow).- AddParam("number", idea.Number).- ExecutePost(handlers.UpdateIdea(), `{ "title": "", "description": "" }`)+ AddParam("number", post.Number).+ ExecutePost(handlers.UpdatePost(), `{ "title": "", "description": "" }`)Expect(code).Equals(http.StatusBadRequest)}-func TestUpdateIdeaHandler_InvalidIdea(t *testing.T) {+func TestUpdatePostHandler_InvalidPost(t *testing.T) {RegisterT(t)server, _ := mock.NewServer()@@ -146,25 +146,25 @@ func TestUpdateIdeaHandler_InvalidIdea(t *testing.T) {OnTenant(mock.DemoTenant).AsUser(mock.JonSnow).AddParam("number", 999).- ExecutePost(handlers.UpdateIdea(), `{ "title": "This is a good title!", "description": "And description too..." }`)+ ExecutePost(handlers.UpdatePost(), `{ "title": "This is a good title!", "description": "And description too..." }`)Expect(code).Equals(http.StatusNotFound)}-func TestUpdateIdeaHandler_DuplicateTitle(t *testing.T) {+func TestUpdatePostHandler_DuplicateTitle(t *testing.T) {RegisterT(t)server, services := mock.NewServer()services.SetCurrentTenant(mock.DemoTenant)services.SetCurrentUser(mock.JonSnow)- idea1, _ := services.Ideas.Add("My First Idea", "With a description")- services.Ideas.Add("My Second Idea", "With a description")+ post1, _ := services.Posts.Add("My First Post", "With a description")+ services.Posts.Add("My Second Post", "With a description")code, _ := server.OnTenant(mock.DemoTenant).AsUser(mock.JonSnow).- AddParam("number", idea1.Number).- ExecutePost(handlers.UpdateIdea(), `{ "title": "My Second Idea", "description": "And description too..." }`)+ AddParam("number", post1.Number).+ ExecutePost(handlers.UpdatePost(), `{ "title": "My Second Post", "description": "And description too..." }`)Expect(code).Equals(http.StatusBadRequest)}@@ -175,12 +175,12 @@ func TestPostCommentHandler(t *testing.T) {server, services := mock.NewServer()services.SetCurrentTenant(mock.DemoTenant)services.SetCurrentUser(mock.JonSnow)- idea, _ := services.Ideas.Add("My First Idea", "With a description")+ post, _ := services.Posts.Add("My First Post", "With a description")code, _ := server.OnTenant(mock.DemoTenant).AsUser(mock.JonSnow).- AddParam("number", idea.Number).+ AddParam("number", post.Number).ExecutePost(handlers.PostComment(), `{ "content": "This is a comment!" }`)Expect(code).Equals(http.StatusOK)@@ -192,12 +192,12 @@ func TestPostCommentHandler_WithoutContent(t *testing.T) {server, services := mock.NewServer()services.SetCurrentTenant(mock.DemoTenant)services.SetCurrentUser(mock.JonSnow)- idea, _ := services.Ideas.Add("My First Idea", "With a description")+ post, _ := services.Posts.Add("My First Post", "With a description")code, _ := server.OnTenant(mock.DemoTenant).AsUser(mock.JonSnow).- AddParam("number", idea.Number).+ AddParam("number", post.Number).ExecutePost(handlers.PostComment(), `{ "content": "" }`)Expect(code).Equals(http.StatusBadRequest)@@ -209,8 +209,8 @@ func TestAddSupporterHandler(t *testing.T) {server, services := mock.NewServer()services.SetCurrentTenant(mock.DemoTenant)services.SetCurrentUser(mock.JonSnow)- first, _ := services.Ideas.Add("The Idea #1", "The Description #1")- second, _ := services.Ideas.Add("The Idea #2", "The Description #2")+ first, _ := services.Posts.Add("The Post #1", "The Description #1")+ second, _ := services.Posts.Add("The Post #2", "The Description #2")code, _ := server.OnTenant(mock.DemoTenant).@@ -218,15 +218,15 @@ func TestAddSupporterHandler(t *testing.T) {AddParam("number", second.Number).Execute(handlers.AddSupporter())- first, _ = services.Ideas.GetByNumber(1)- second, _ = services.Ideas.GetByNumber(2)+ first, _ = services.Posts.GetByNumber(1)+ second, _ = services.Posts.GetByNumber(2)Expect(code).Equals(http.StatusOK)Expect(first.TotalSupporters).Equals(0)Expect(second.TotalSupporters).Equals(1)}-func TestAddSupporterHandler_InvalidIdea(t *testing.T) {+func TestAddSupporterHandler_InvalidPost(t *testing.T) {RegisterT(t)server, _ := mock.NewServer()@@ -245,20 +245,20 @@ func TestRemoveSupporterHandler(t *testing.T) {server, services := mock.NewServer()services.SetCurrentTenant(mock.DemoTenant)services.SetCurrentUser(mock.JonSnow)- idea, _ := services.Ideas.Add("The Idea #1", "The Description #1")- services.Ideas.AddSupporter(idea, mock.JonSnow)- services.Ideas.AddSupporter(idea, mock.AryaStark)+ post, _ := services.Posts.Add("The Post #1", "The Description #1")+ services.Posts.AddSupporter(post, mock.JonSnow)+ services.Posts.AddSupporter(post, mock.AryaStark)code, _ := server.OnTenant(mock.DemoTenant).AsUser(mock.AryaStark).- AddParam("number", idea.ID).+ AddParam("number", post.ID).Execute(handlers.RemoveSupporter())- idea, _ = services.Ideas.GetByNumber(idea.Number)+ post, _ = services.Posts.GetByNumber(post.Number)Expect(code).Equals(http.StatusOK)- Expect(idea.TotalSupporters).Equals(1)+ Expect(post.TotalSupporters).Equals(1)}func TestSetResponseHandler(t *testing.T) {@@ -267,21 +267,21 @@ func TestSetResponseHandler(t *testing.T) {server, services := mock.NewServer()services.SetCurrentTenant(mock.DemoTenant)services.SetCurrentUser(mock.AryaStark)- idea, _ := services.Ideas.Add("The Idea #1", "The Description #1")- services.Ideas.AddSupporter(idea, mock.AryaStark)+ post, _ := services.Posts.Add("The Post #1", "The Description #1")+ services.Posts.AddSupporter(post, mock.AryaStark)code, _ := server.OnTenant(mock.DemoTenant).AsUser(mock.JonSnow).- AddParam("number", idea.ID).- ExecutePost(handlers.SetResponse(), fmt.Sprintf(`{ "status": %d, "text": "Done!" }`, models.IdeaCompleted))+ AddParam("number", post.ID).+ ExecutePost(handlers.SetResponse(), fmt.Sprintf(`{ "status": %d, "text": "Done!" }`, models.PostCompleted))- idea, _ = services.Ideas.GetByNumber(idea.Number)+ post, _ = services.Posts.GetByNumber(post.Number)Expect(code).Equals(http.StatusOK)- Expect(idea.Status).Equals(models.IdeaCompleted)- Expect(idea.Response.Text).Equals("Done!")- Expect(idea.Response.User.ID).Equals(mock.JonSnow.ID)+ Expect(post.Status).Equals(models.PostCompleted)+ Expect(post.Response.Text).Equals("Done!")+ Expect(post.Response.User.ID).Equals(mock.JonSnow.ID)}func TestSetResponseHandler_Unauthorized(t *testing.T) {@@ -290,19 +290,19 @@ func TestSetResponseHandler_Unauthorized(t *testing.T) {server, services := mock.NewServer()services.SetCurrentTenant(mock.DemoTenant)services.SetCurrentUser(mock.AryaStark)- idea, _ := services.Ideas.Add("The Idea #1", "The Description #1")- services.Ideas.AddSupporter(idea, mock.AryaStark)+ post, _ := services.Posts.Add("The Post #1", "The Description #1")+ services.Posts.AddSupporter(post, mock.AryaStark)code, _ := server.OnTenant(mock.DemoTenant).AsUser(mock.AryaStark).- AddParam("number", idea.ID).- ExecutePost(handlers.SetResponse(), fmt.Sprintf(`{ "status": %d, "text": "Done!" }`, models.IdeaCompleted))+ AddParam("number", post.ID).+ ExecutePost(handlers.SetResponse(), fmt.Sprintf(`{ "status": %d, "text": "Done!" }`, models.PostCompleted))- idea, _ = services.Ideas.GetByNumber(idea.Number)+ post, _ = services.Posts.GetByNumber(post.Number)Expect(code).Equals(http.StatusForbidden)- Expect(idea.Status).Equals(models.IdeaOpen)+ Expect(post.Status).Equals(models.PostOpen)}func TestSetResponseHandler_Duplicate(t *testing.T) {@@ -311,22 +311,22 @@ func TestSetResponseHandler_Duplicate(t *testing.T) {server, services := mock.NewServer()services.SetCurrentTenant(mock.DemoTenant)services.SetCurrentUser(mock.AryaStark)- idea1, _ := services.Ideas.Add("The Idea #1", "The Description #1")- idea2, _ := services.Ideas.Add("The Idea #2", "The Description #2")+ post1, _ := services.Posts.Add("The Post #1", "The Description #1")+ post2, _ := services.Posts.Add("The Post #2", "The Description #2")- body := fmt.Sprintf(`{ "status": %d, "originalNumber": %d }`, models.IdeaDuplicate, idea2.Number)+ body := fmt.Sprintf(`{ "status": %d, "originalNumber": %d }`, models.PostDuplicate, post2.Number)code, _ := server.OnTenant(mock.DemoTenant).AsUser(mock.JonSnow).- AddParam("number", idea1.ID).+ AddParam("number", post1.ID).ExecutePost(handlers.SetResponse(), body)Expect(code).Equals(http.StatusOK)- idea1, _ = services.Ideas.GetByNumber(idea1.Number)- Expect(idea1.Status).Equals(models.IdeaDuplicate)+ post1, _ = services.Posts.GetByNumber(post1.Number)+ Expect(post1.Status).Equals(models.PostDuplicate)- idea2, _ = services.Ideas.GetByNumber(idea2.Number)- Expect(idea2.Status).Equals(models.IdeaOpen)+ post2, _ = services.Posts.GetByNumber(post2.Number)+ Expect(post2.Status).Equals(models.PostOpen)}func TestSetResponseHandler_Duplicate_NotFound(t *testing.T) {@@ -335,13 +335,13 @@ func TestSetResponseHandler_Duplicate_NotFound(t *testing.T) {server, services := mock.NewServer()services.SetCurrentTenant(mock.DemoTenant)services.SetCurrentUser(mock.AryaStark)- idea1, _ := services.Ideas.Add("The Idea #1", "The Description #1")+ post1, _ := services.Posts.Add("The Post #1", "The Description #1")- body := fmt.Sprintf(`{ "status": %d, "originalNumber": 9999 }`, models.IdeaDuplicate)+ body := fmt.Sprintf(`{ "status": %d, "originalNumber": 9999 }`, models.PostDuplicate)code, _ := server.OnTenant(mock.DemoTenant).AsUser(mock.JonSnow).- AddParam("number", idea1.ID).+ AddParam("number", post1.ID).ExecutePost(handlers.SetResponse(), body)Expect(code).Equals(http.StatusBadRequest)@@ -353,13 +353,13 @@ func TestSetResponseHandler_Duplicate_Itself(t *testing.T) {server, services := mock.NewServer()services.SetCurrentTenant(mock.DemoTenant)services.SetCurrentUser(mock.AryaStark)- idea, _ := services.Ideas.Add("The Idea #1", "The Description #1")+ post, _ := services.Posts.Add("The Post #1", "The Description #1")- body := fmt.Sprintf(`{ "status": %d, "originalNumber": %d }`, models.IdeaDuplicate, idea.Number)+ body := fmt.Sprintf(`{ "status": %d, "originalNumber": %d }`, models.PostDuplicate, post.Number)code, _ := server.OnTenant(mock.DemoTenant).AsUser(mock.JonSnow).- AddParam("number", idea.ID).+ AddParam("number", post.ID).ExecutePost(handlers.SetResponse(), body)Expect(code).Equals(http.StatusBadRequest)@@ -371,16 +371,16 @@ func TestAddCommentHandler(t *testing.T) {server, services := mock.NewServer()services.SetCurrentTenant(mock.DemoTenant)services.SetCurrentUser(mock.AryaStark)- idea, _ := services.Ideas.Add("The Idea #1", "The Description #1")+ post, _ := services.Posts.Add("The Post #1", "The Description #1")code, _ := server.OnTenant(mock.DemoTenant).AsUser(mock.JonSnow).- AddParam("number", idea.Number).+ AddParam("number", post.Number).ExecutePost(handlers.PostComment(), `{ "content": "My first comment" }`)Expect(code).Equals(http.StatusOK)- comments, _ := services.Ideas.GetCommentsByIdea(idea)+ comments, _ := services.Posts.GetCommentsByPost(post)Expect(comments).HasLen(1)}@@ -390,18 +390,18 @@ func TestUpdateCommentHandler_Authorized(t *testing.T) {server, services := mock.NewServer()services.SetCurrentTenant(mock.DemoTenant)services.SetCurrentUser(mock.AryaStark)- idea, _ := services.Ideas.Add("The Idea #1", "The Description #1")- commentId, _ := services.Ideas.AddComment(idea, "My first comment")+ post, _ := services.Posts.Add("The Post #1", "The Description #1")+ commentId, _ := services.Posts.AddComment(post, "My first comment")code, _ := server.OnTenant(mock.DemoTenant).AsUser(mock.AryaStark).- AddParam("number", idea.Number).+ AddParam("number", post.Number).AddParam("id", commentId).ExecutePost(handlers.UpdateComment(), `{ "content": "My first comment has been edited" }`)Expect(code).Equals(http.StatusOK)- comment, _ := services.Ideas.GetCommentByID(commentId)+ comment, _ := services.Posts.GetCommentByID(commentId)Expect(comment.Content).Equals("My first comment has been edited")}@@ -411,37 +411,37 @@ func TestUpdateCommentHandler_Unauthorized(t *testing.T) {server, services := mock.NewServer()services.SetCurrentTenant(mock.DemoTenant)services.SetCurrentUser(mock.JonSnow)- idea, _ := services.Ideas.Add("The Idea #1", "The Description #1")- commentId, _ := services.Ideas.AddComment(idea, "My first comment")+ post, _ := services.Posts.Add("The Post #1", "The Description #1")+ commentId, _ := services.Posts.AddComment(post, "My first comment")code, _ := server.OnTenant(mock.DemoTenant).AsUser(mock.AryaStark).- AddParam("number", idea.Number).+ AddParam("number", post.Number).AddParam("id", commentId).ExecutePost(handlers.UpdateComment(), `{ "content": "My first comment has been edited" }`)Expect(code).Equals(http.StatusForbidden)- comment, _ := services.Ideas.GetCommentByID(commentId)+ comment, _ := services.Posts.GetCommentByID(commentId)Expect(comment.Content).Equals("My first comment")}-func TestDeleteIdeaHandler_Authorized(t *testing.T) {+func TestDeletePostHandler_Authorized(t *testing.T) {RegisterT(t)server, services := mock.NewServer()services.SetCurrentTenant(mock.DemoTenant)services.SetCurrentUser(mock.JonSnow)- idea, _ := services.Ideas.Add("The Idea #1", "The Description #1")+ post, _ := services.Posts.Add("The Post #1", "The Description #1")code, _ := server.OnTenant(mock.DemoTenant).AsUser(mock.JonSnow).- AddParam("number", idea.Number).- ExecutePost(handlers.DeleteIdea(), `{ }`)+ AddParam("number", post.Number).+ ExecutePost(handlers.DeletePost(), `{ }`)Expect(code).Equals(http.StatusOK)- idea, err := services.Ideas.GetByNumber(idea.Number)- Expect(idea).IsNil()+ post, err := services.Posts.GetByNumber(post.Number)+ Expect(post).IsNil()Expect(errors.Cause(err)).Equals(app.ErrNotFound)}diff --git a/app/handlers/settings_test.go b/app/handlers/settings_test.goindex 307a63d02..1dff11288 100644--- a/app/handlers/settings_test.go+++ b/app/handlers/settings_test.go@@ -75,7 +75,7 @@ func TestUpdateUserSettingsHandler_NewSettings(t *testing.T) {settings, _ := services.Users.GetUserSettings()Expect(settings).Equals(map[string]string{- models.NotificationEventNewIdea.UserSettingsKeyName: "1",+ models.NotificationEventNewPost.UserSettingsKeyName: "1",models.NotificationEventNewComment.UserSettingsKeyName: "2",models.NotificationEventChangeStatus.UserSettingsKeyName: "3",})diff --git a/app/handlers/tag.go b/app/handlers/tag.goindex a5a4204e6..ee4c475da 100644--- a/app/handlers/tag.go+++ b/app/handlers/tag.go@@ -75,7 +75,7 @@ func AssignTag() web.HandlerFunc {return c.HandleValidation(result)}- err := c.Services().Tags.AssignTag(input.Tag, input.Idea)+ err := c.Services().Tags.AssignTag(input.Tag, input.Post)if err != nil {return c.Failure(err)}@@ -92,7 +92,7 @@ func UnassignTag() web.HandlerFunc {return c.HandleValidation(result)}- err := c.Services().Tags.UnassignTag(input.Tag, input.Idea)+ err := c.Services().Tags.UnassignTag(input.Tag, input.Post)if err != nil {return c.Failure(err)}diff --git a/app/handlers/tag_test.go b/app/handlers/tag_test.goindex cc0fccf28..09406c1dd 100644--- a/app/handlers/tag_test.go+++ b/app/handlers/tag_test.go@@ -178,15 +178,15 @@ func TestAssignTagHandler_Success(t *testing.T) {services.SetCurrentTenant(mock.DemoTenant)services.SetCurrentUser(mock.JonSnow)tag, _ := services.Tags.Add("Bug", "0000FF", true)- idea, _ := services.Ideas.Add("Idea Title", "Idea Description")+ post, _ := services.Posts.Add("Post Title", "Post Description")status, _ := server.AsUser(mock.JonSnow).AddParam("slug", tag.Slug).- AddParam("number", idea.Number).+ AddParam("number", post.Number).Execute(handlers.AssignTag())- tags, err := services.Tags.GetAssigned(idea)+ tags, err := services.Tags.GetAssigned(post)Expect(status).Equals(http.StatusOK)Expect(err).IsNil()Expect(tags[0]).Equals(tag)@@ -219,12 +219,12 @@ func TestAssignOrUnassignTagHandler_Unauthorized(t *testing.T) {services.SetCurrentTenant(mock.DemoTenant)services.SetCurrentUser(mock.JonSnow)tag, _ := services.Tags.Add("Bug", "0000FF", true)- idea, _ := services.Ideas.Add("Idea Title", "Idea Description")+ post, _ := services.Posts.Add("Post Title", "Post Description")status, _ := server.AsUser(mock.AryaStark).AddParam("slug", tag.Slug).- AddParam("number", idea.Number).+ AddParam("number", post.Number).Execute(handler)Expect(status).Equals(http.StatusForbidden)@@ -238,16 +238,16 @@ func TestUnassignTagHandler_Success(t *testing.T) {services.SetCurrentTenant(mock.DemoTenant)services.SetCurrentUser(mock.JonSnow)tag, _ := services.Tags.Add("Bug", "0000FF", true)- idea, _ := services.Ideas.Add("Idea Title", "Idea Description")- services.Tags.AssignTag(tag, idea)+ post, _ := services.Posts.Add("Post Title", "Post Description")+ services.Tags.AssignTag(tag, post)status, _ := server.AsUser(mock.JonSnow).AddParam("slug", tag.Slug).- AddParam("number", idea.Number).+ AddParam("number", post.Number).Execute(handlers.UnassignTag())- tags, err := services.Tags.GetAssigned(idea)+ tags, err := services.Tags.GetAssigned(post)Expect(status).Equals(http.StatusOK)Expect(err).IsNil()Expect(tags).HasLen(0)diff --git a/app/middlewares/domain_test.go b/app/middlewares/domain_test.goindex 3fd19dd26..f4d584e37 100644--- a/app/middlewares/domain_test.go+++ b/app/middlewares/domain_test.go@@ -96,7 +96,7 @@ func TestMultiTenant_CanonicalHeader(t *testing.T) {}{{"http://avengers.test.fider.io/",- "<http://ideas.theavengers.com/>; rel=\"canonical\"",+ "<http://feedback.theavengers.com/>; rel=\"canonical\"",false,},{@@ -105,18 +105,18 @@ func TestMultiTenant_CanonicalHeader(t *testing.T) {true,},{- "http://ideas.theavengers.com/",+ "http://feedback.theavengers.com/","",false,},{- "http://avengers.test.fider.io/ideas",- "<http://ideas.theavengers.com/ideas>; rel=\"canonical\"",+ "http://avengers.test.fider.io/posts",+ "<http://feedback.theavengers.com/posts>; rel=\"canonical\"",false,},{- "http://avengers.test.fider.io/ideas?q=1",- "<http://ideas.theavengers.com/ideas?q=1>; rel=\"canonical\"",+ "http://avengers.test.fider.io/posts?q=1",+ "<http://feedback.theavengers.com/posts?q=1>; rel=\"canonical\"",false,},{diff --git a/app/middlewares/setup.go b/app/middlewares/setup.goindex 117047250..e529e7e6f 100644--- a/app/middlewares/setup.go+++ b/app/middlewares/setup.go@@ -52,7 +52,7 @@ func WorkerSetup() worker.MiddlewareFunc {c.SetServices(&app.Services{Tenants: postgres.NewTenantStorage(trx),Users: postgres.NewUserStorage(trx),- Ideas: postgres.NewIdeaStorage(trx),+ Posts: postgres.NewPostStorage(trx),Tags: postgres.NewTagStorage(trx),Notifications: postgres.NewNotificationStorage(trx),Emailer: newEmailer(c.Logger()),@@ -137,7 +137,7 @@ func WebSetup() web.MiddlewareFunc {Tenants: tenantStorage,OAuth: web.NewOAuthService(oauthBaseURL, tenantStorage),Users: postgres.NewUserStorage(trx),- Ideas: postgres.NewIdeaStorage(trx),+ Posts: postgres.NewPostStorage(trx),Tags: postgres.NewTagStorage(trx),Notifications: postgres.NewNotificationStorage(trx),Emailer: newEmailer(c.Logger()),diff --git a/app/models/feedback.go b/app/models/feedback.goindex 49f793654..642d4ad5a 100644--- a/app/models/feedback.go+++ b/app/models/feedback.go@@ -5,8 +5,8 @@ import ("time")-//Idea represents an idea on a tenant board-type Idea struct {+//Post represents an post on a tenant board+type Post struct {ID int `json:"id"`Number int `json:"number"`Title string `json:"title"`@@ -18,30 +18,30 @@ type Idea struct {TotalSupporters int `json:"totalSupporters"`TotalComments int `json:"totalComments"`Status int `json:"status"`- Response *IdeaResponse `json:"response"`+ Response *PostResponse `json:"response"`Tags []string `json:"tags"`}-// CanBeSupported returns true if this idea can be Supported/UnSupported-func (i *Idea) CanBeSupported() bool {- return i.Status != IdeaCompleted && i.Status != IdeaDeclined && i.Status != IdeaDuplicate+// CanBeSupported returns true if this post can be Supported/UnSupported+func (i *Post) CanBeSupported() bool {+ return i.Status != PostCompleted && i.Status != PostDeclined && i.Status != PostDuplicate}-// NewIdea represents a new idea-type NewIdea struct {+// NewPost represents a new post+type NewPost struct {Title string `json:"title"`Description string `json:"description"`}-// UpdateIdea represents a request to edit an existing idea-type UpdateIdea struct {+// UpdatePost represents a request to edit an existing post+type UpdatePost struct {Number int `route:"number"`Title string `json:"title"`Description string `json:"description"`}-// DeleteIdea represents a request to delete an existing idea-type DeleteIdea struct {+// DeletePost represents a request to delete an existing post+type DeletePost struct {Number int `route:"number"`Text string `json:"text"`}@@ -54,12 +54,12 @@ type NewComment struct {// EditComment represents a request to edit existing commenttype EditComment struct {- IdeaNumber int `route:"number"`+ PostNumber int `route:"number"`ID int `route:"id"`Content string `json:"content"`}-// SetResponse represents the action to update an idea response+// SetResponse represents the action to update an post responsetype SetResponse struct {Number int `route:"number"`Status int `json:"status"`@@ -67,23 +67,23 @@ type SetResponse struct {OriginalNumber int `json:"originalNumber"`}-//IdeaResponse is a staff response to a given idea-type IdeaResponse struct {+//PostResponse is a staff response to a given post+type PostResponse struct {Text string `json:"text"`RespondedOn time.Time `json:"respondedOn"`User *User `json:"user"`- Original *OriginalIdea `json:"original"`+ Original *OriginalPost `json:"original"`}-//OriginalIdea holds details of the original idea of a duplicate-type OriginalIdea struct {+//OriginalPost holds details of the original post of a duplicate+type OriginalPost struct {Number int `json:"number"`Title string `json:"title"`Slug string `json:"slug"`Status int `json:"status"`}-//Comment represents an user comment on an idea+//Comment represents an user comment on an posttype Comment struct {ID int `json:"id"`Content string `json:"content"`@@ -115,45 +115,45 @@ type DeleteTag struct {Slug string `route:"slug"`}-// AssignUnassignTag is used to assign or remove a tag to/from an idea+// AssignUnassignTag is used to assign or remove a tag to/from an posttype AssignUnassignTag struct {Slug string `route:"slug"`Number int `route:"number"`}var (- //IdeaOpen is the default status- IdeaOpen = 0- //IdeaStarted is used when the idea has been accepted and work is in progress- IdeaStarted = 1- //IdeaCompleted is used when the idea has been accepted and already implemented- IdeaCompleted = 2- //IdeaDeclined is used when organizers decide to decline an idea- IdeaDeclined = 3- //IdeaPlanned is used when organizers have accepted an idea and it's on the roadmap- IdeaPlanned = 4- //IdeaDuplicate is used when the idea has already been posted before- IdeaDuplicate = 5- //IdeaDeleted is used when the idea is completely removed from the site and should never be shown again- IdeaDeleted = 6+ //PostOpen is the default status+ PostOpen = 0+ //PostStarted is used when the post has been accepted and work is in progress+ PostStarted = 1+ //PostCompleted is used when the post has been accepted and already implemented+ PostCompleted = 2+ //PostDeclined is used when organizers decide to decline an post+ PostDeclined = 3+ //PostPlanned is used when organizers have accepted an post and it's on the roadmap+ PostPlanned = 4+ //PostDuplicate is used when the post has already been posted before+ PostDuplicate = 5+ //PostDeleted is used when the post is completely removed from the site and should never be shown again+ PostDeleted = 6)-// GetIdeaStatusName returns the name of an idea status-func GetIdeaStatusName(status int) string {+// GetPostStatusName returns the name of a post status+func GetPostStatusName(status int) string {switch status {- case IdeaOpen:+ case PostOpen:return "Open"- case IdeaStarted:+ case PostStarted:return "Started"- case IdeaCompleted:+ case PostCompleted:return "Completed"- case IdeaDeclined:+ case PostDeclined:return "Declined"- case IdeaPlanned:+ case PostPlanned:return "Planned"- case IdeaDuplicate:+ case PostDuplicate:return "Duplicate"- case IdeaDeleted:+ case PostDeleted:return "Deleted"default:return "Unknown"@@ -191,8 +191,8 @@ func notificationEventValidation(v string) bool {}var (- //NotificationEventNewIdea is triggered when a new idea is posted- NotificationEventNewIdea = NotificationEvent{+ //NotificationEventNewPost is triggered when a new post is posted+ NotificationEventNewPost = NotificationEvent{UserSettingsKeyName: "event_notification_new_idea",DefaultSettingValue: strconv.Itoa(int(NotificationChannelWeb | NotificationChannelEmail)),RequiresSubscripionUserRoles: []Role{},@@ -216,7 +216,7 @@ var (},Validate: notificationEventValidation,}- //NotificationEventChangeStatus is triggered when a new idea has its status changed+ //NotificationEventChangeStatus is triggered when a new post has its status changedNotificationEventChangeStatus = NotificationEvent{UserSettingsKeyName: "event_notification_change_status",DefaultSettingValue: strconv.Itoa(int(NotificationChannelWeb | NotificationChannelEmail)),@@ -232,7 +232,7 @@ var (}//AllNotificationEvents contains all possible notification eventsAllNotificationEvents = []NotificationEvent{- NotificationEventNewIdea,+ NotificationEventNewPost,NotificationEventNewComment,NotificationEventChangeStatus,}diff --git a/app/pkg/csv/csv.go b/app/pkg/csv/csv.goindex fd2614be0..58a0ad578 100644--- a/app/pkg/csv/csv.go+++ b/app/pkg/csv/csv.go@@ -10,8 +10,8 @@ import ("github.com/getfider/fider/app/models")-//FromIdeas return a byte array of CSV file containing all ideas-func FromIdeas(ideas []*models.Idea) ([]byte, error) {+//FromPosts return a byte array of CSV file containing all posts+func FromPosts(posts []*models.Post) ([]byte, error) {buffer := &bytes.Buffer{}writer := gocsv.NewWriter(buffer)@@ -35,7 +35,7 @@ func FromIdeas(ideas []*models.Idea) ([]byte, error) {return nil, err}- for _, idea := range ideas {+ for _, post := range posts {var (originalNumber stringoriginalTitle string@@ -44,31 +44,31 @@ func FromIdeas(ideas []*models.Idea) ([]byte, error) {response string)- if idea.Response != nil {- respondedBy = idea.Response.User.Name- respondedOn = idea.Response.RespondedOn.Format(time.RFC3339)- response = idea.Response.Text- if idea.Response.Original != nil {- originalNumber = strconv.Itoa(idea.Response.Original.Number)- originalTitle = idea.Response.Original.Title+ if post.Response != nil {+ respondedBy = post.Response.User.Name+ respondedOn = post.Response.RespondedOn.Format(time.RFC3339)+ response = post.Response.Text+ if post.Response.Original != nil {+ originalNumber = strconv.Itoa(post.Response.Original.Number)+ originalTitle = post.Response.Original.Title}}record := []string{- strconv.Itoa(idea.Number),- idea.Title,- idea.Description,- idea.CreatedOn.Format(time.RFC3339),- idea.User.Name,- strconv.Itoa(idea.TotalSupporters),- strconv.Itoa(idea.TotalComments),- models.GetIdeaStatusName(idea.Status),+ strconv.Itoa(post.Number),+ post.Title,+ post.Description,+ post.CreatedOn.Format(time.RFC3339),+ post.User.Name,+ strconv.Itoa(post.TotalSupporters),+ strconv.Itoa(post.TotalComments),+ models.GetPostStatusName(post.Status),respondedBy,respondedOn,response,originalNumber,originalTitle,- strings.Join(idea.Tags, ", "),+ strings.Join(post.Tags, ", "),}if err := writer.Write(record); err != nil {return nil, errdiff --git a/app/pkg/csv/csv_test.go b/app/pkg/csv/csv_test.goindex b2acbe640..b1666c65f 100644--- a/app/pkg/csv/csv_test.go+++ b/app/pkg/csv/csv_test.go@@ -10,48 +10,48 @@ import ("github.com/getfider/fider/app/pkg/csv")-func TestExportIdeasToCSV_Empty(t *testing.T) {+func TestExportPostsToCSV_Empty(t *testing.T) {RegisterT(t)- ideas := []*models.Idea{}+ posts := []*models.Post{}expected, err := ioutil.ReadFile("./testdata/empty.csv")Expect(err).IsNil()- actual, err := csv.FromIdeas(ideas)+ actual, err := csv.FromPosts(posts)Expect(err).IsNil()Expect(actual).Equals(expected)}-func TestExportIdeasToCSV_OneIdea(t *testing.T) {+func TestExportPostsToCSV_OnePost(t *testing.T) {RegisterT(t)- ideas := []*models.Idea{- declinedIdea,+ posts := []*models.Post{+ declinedPost,}- expected, err := ioutil.ReadFile("./testdata/one-idea.csv")+ expected, err := ioutil.ReadFile("./testdata/one-post.csv")Expect(err).IsNil()- actual, err := csv.FromIdeas(ideas)+ actual, err := csv.FromPosts(posts)Expect(err).IsNil()Expect(actual).Equals(expected)}-func TestExportIdeasToCSV_MoreIdeas(t *testing.T) {+func TestExportPostsToCSV_MorePosts(t *testing.T) {RegisterT(t)- ideas := []*models.Idea{- declinedIdea,- openIdea,- duplicateIdea,+ posts := []*models.Post{+ declinedPost,+ openPost,+ duplicatePost,}- expected, err := ioutil.ReadFile("./testdata/more-ideas.csv")+ expected, err := ioutil.ReadFile("./testdata/more-posts.csv")Expect(err).IsNil()- actual, err := csv.FromIdeas(ideas)+ actual, err := csv.FromPosts(posts)Expect(err).IsNil()Expect(actual).Equals(expected)}-var declinedIdea = &models.Idea{+var declinedPost = &models.Post{Number: 10,Title: "Go is fast",Description: "Very tiny description",@@ -61,8 +61,8 @@ var declinedIdea = &models.Idea{},TotalSupporters: 4,TotalComments: 2,- Status: models.IdeaDeclined,- Response: &models.IdeaResponse{+ Status: models.PostDeclined,+ Response: &models.PostResponse{Text: "Nothing we need to do",RespondedOn: time.Date(2018, 4, 4, 19, 48, 10, 0, time.UTC),User: &models.User{@@ -72,7 +72,7 @@ var declinedIdea = &models.Idea{Tags: []string{"easy", "ignored"},}-var openIdea = &models.Idea{+var openPost = &models.Post{Number: 15,Title: "Go is great",Description: "",@@ -82,10 +82,10 @@ var openIdea = &models.Idea{},TotalSupporters: 4,TotalComments: 2,- Status: models.IdeaOpen,+ Status: models.PostOpen,}-var duplicateIdea = &models.Idea{+var duplicatePost = &models.Post{Number: 20,Title: "Go is easy",Description: "",@@ -95,14 +95,14 @@ var duplicateIdea = &models.Idea{},TotalSupporters: 4,TotalComments: 2,- Status: models.IdeaDuplicate,- Response: &models.IdeaResponse{+ Status: models.PostDuplicate,+ Response: &models.PostResponse{Text: "This has already been suggested",RespondedOn: time.Date(2018, 3, 17, 10, 15, 42, 0, time.UTC),User: &models.User{Name: "Arya Stark",},- Original: &models.OriginalIdea{+ Original: &models.OriginalPost{Number: 99,Title: "Go is very easy",},diff --git a/app/pkg/csv/testdata/more-ideas.csv b/app/pkg/csv/testdata/more-posts.csvsimilarity index 100%rename from app/pkg/csv/testdata/more-ideas.csvrename to app/pkg/csv/testdata/more-posts.csvdiff --git a/app/pkg/csv/testdata/one-idea.csv b/app/pkg/csv/testdata/one-post.csvsimilarity index 100%rename from app/pkg/csv/testdata/one-idea.csvrename to app/pkg/csv/testdata/one-post.csvdiff --git a/app/pkg/dbx/dbx_test.go b/app/pkg/dbx/dbx_test.goindex 4e7785e69..f0742cd20 100644--- a/app/pkg/dbx/dbx_test.go+++ b/app/pkg/dbx/dbx_test.go@@ -239,12 +239,12 @@ func TestArray(t *testing.T) {trx, _ := db.Begin()defer trx.Rollback()- type ideaTags struct {+ type postTags struct {ID int `db:"id"`Tags []int64 `db:"tags"`}- result := ideaTags{}+ result := postTags{}err := trx.Get(&result, "SELECT 1 as id, array[5,10] as tags")Expect(err).IsNil()Expect(result.ID).Equals(1)diff --git a/app/pkg/mock/setup.go b/app/pkg/mock/setup.goindex b523874e2..6d626fef2 100644--- a/app/pkg/mock/setup.go+++ b/app/pkg/mock/setup.go@@ -51,7 +51,7 @@ func createServices(seed bool) *app.Services {Users: &inmemory.UserStorage{},Tags: inmemory.NewTagStorage(),Notifications: inmemory.NewNotificationStorage(),- Ideas: inmemory.NewIdeaStorage(),+ Posts: inmemory.NewPostStorage(),OAuth: &OAuthService{},Emailer: noop.NewSender(),}@@ -59,7 +59,7 @@ func createServices(seed bool) *app.Services {if seed {DemoTenant, _ = services.Tenants.Add("Demonstration", "demo", models.TenantActive)AvengersTenant, _ = services.Tenants.Add("Avengers", "avengers", models.TenantActive)- AvengersTenant.CNAME = "ideas.theavengers.com"+ AvengersTenant.CNAME = "feedback.theavengers.com"JonSnow = &models.User{Name: "Jon Snow",diff --git a/app/pkg/web/context_test.go b/app/pkg/web/context_test.goindex 916dc1520..813c0b6e3 100644--- a/app/pkg/web/context_test.go+++ b/app/pkg/web/context_test.go@@ -105,9 +105,9 @@ func TestTenantURL_WithCNAME(t *testing.T) {tenant := &models.Tenant{ID: 1,Subdomain: "theavengers",- CNAME: "ideas.theavengers.com",+ CNAME: "feedback.theavengers.com",}- Expect(ctx.TenantBaseURL(tenant)).Equals("http://ideas.theavengers.com:3000")+ Expect(ctx.TenantBaseURL(tenant)).Equals("http://feedback.theavengers.com:3000")}func TestTenantURL_SingleHostMode(t *testing.T) {@@ -126,9 +126,9 @@ func TestGlobalAssetsURL_SingleHostMode(t *testing.T) {RegisterT(t)os.Setenv("HOST_MODE", "single")- ctx := newGetContext("http://ideas.theavengers.com:3000", nil)- Expect(ctx.GlobalAssetsURL("/assets/main.js")).Equals("http://ideas.theavengers.com:3000/assets/main.js")- Expect(ctx.GlobalAssetsURL("/assets/main.css")).Equals("http://ideas.theavengers.com:3000/assets/main.css")+ ctx := newGetContext("http://feedback.theavengers.com:3000", nil)+ Expect(ctx.GlobalAssetsURL("/assets/main.js")).Equals("http://feedback.theavengers.com:3000/assets/main.js")+ Expect(ctx.GlobalAssetsURL("/assets/main.css")).Equals("http://feedback.theavengers.com:3000/assets/main.css")os.Setenv("CDN_HOST", "assets-fider.io")Expect(ctx.GlobalAssetsURL("/assets/main.js")).Equals("http://assets-fider.io/assets/main.js")@@ -143,7 +143,7 @@ func TestGlobalAssetsURL_MultiHostMode(t *testing.T) {ctx.SetTenant(&models.Tenant{ID: 1,Subdomain: "theavengers",- CNAME: "ideas.theavengers.com",+ CNAME: "feedback.theavengers.com",})Expect(ctx.GlobalAssetsURL("/assets/main.js")).Equals("http://theavengers.test.fider.io:3000/assets/main.js")@@ -158,14 +158,14 @@ func TestTenantAssetsURL_SingleHostMode(t *testing.T) {RegisterT(t)os.Setenv("HOST_MODE", "single")- ctx := newGetContext("http://ideas.theavengers.com:3000", nil)+ ctx := newGetContext("http://feedback.theavengers.com:3000", nil)ctx.SetTenant(&models.Tenant{ID: 1,Subdomain: "theavengers",})- Expect(ctx.TenantAssetsURL("/assets/main.js")).Equals("http://ideas.theavengers.com:3000/assets/main.js")- Expect(ctx.TenantAssetsURL("/assets/main.css")).Equals("http://ideas.theavengers.com:3000/assets/main.css")+ Expect(ctx.TenantAssetsURL("/assets/main.js")).Equals("http://feedback.theavengers.com:3000/assets/main.js")+ Expect(ctx.TenantAssetsURL("/assets/main.css")).Equals("http://feedback.theavengers.com:3000/assets/main.css")os.Setenv("CDN_HOST", "assets-fider.io")Expect(ctx.TenantAssetsURL("/assets/main.js")).Equals("http://assets-fider.io/assets/main.js")@@ -180,7 +180,7 @@ func TestTenantAssetsURL_MultiHostMode(t *testing.T) {ctx.SetTenant(&models.Tenant{ID: 1,Subdomain: "theavengers",- CNAME: "ideas.theavengers.com",+ CNAME: "feedback.theavengers.com",})Expect(ctx.TenantAssetsURL("/assets/main.js")).Equals("http://theavengers.test.fider.io:3000/assets/main.js")diff --git a/app/services.go b/app/services.goindex 9181ed4ad..aa478e2ac 100644--- a/app/services.go+++ b/app/services.go@@ -14,7 +14,7 @@ type Services struct {Tags storage.TagTenants storage.TenantNotifications storage.Notification- Ideas storage.Idea+ Posts storage.PostEmailer email.Sender}@@ -23,7 +23,7 @@ func (s *Services) SetCurrentTenant(tenant *models.Tenant) {s.Users.SetCurrentTenant(tenant)s.Tags.SetCurrentTenant(tenant)s.Tenants.SetCurrentTenant(tenant)- s.Ideas.SetCurrentTenant(tenant)+ s.Posts.SetCurrentTenant(tenant)s.Notifications.SetCurrentTenant(tenant)}@@ -32,6 +32,6 @@ func (s *Services) SetCurrentUser(user *models.User) {s.Users.SetCurrentUser(user)s.Tags.SetCurrentUser(user)s.Tenants.SetCurrentUser(user)- s.Ideas.SetCurrentUser(user)+ s.Posts.SetCurrentUser(user)s.Notifications.SetCurrentUser(user)}diff --git a/app/storage/inmemory/idea.go b/app/storage/inmemory/idea.godeleted file mode 100644index 0d4a6ee3c..000000000--- a/app/storage/inmemory/idea.go+++ /dev/null@@ -1,258 +0,0 @@-package inmemory--import (- "time"-- "github.com/gosimple/slug"-- "github.com/getfider/fider/app"- "github.com/getfider/fider/app/models"-)--// IdeaStorage contains read and write operations for ideas-type IdeaStorage struct {- lastID int- lastCommentID int- ideas []*models.Idea- ideasSupportedBy map[int][]int- ideaSubscribers map[int][]*models.User- ideaComments map[int][]*models.Comment- tenant *models.Tenant- user *models.User-}--// NewIdeaStorage creates a new IdeaStorage-func NewIdeaStorage() *IdeaStorage {- return &IdeaStorage{- ideas: make([]*models.Idea, 0),- ideasSupportedBy: make(map[int][]int, 0),- ideaSubscribers: make(map[int][]*models.User, 0),- ideaComments: make(map[int][]*models.Comment, 0),- }-}--// SetCurrentTenant to current context-func (s *IdeaStorage) SetCurrentTenant(tenant *models.Tenant) {- s.tenant = tenant-}--// SetCurrentUser to current context-func (s *IdeaStorage) SetCurrentUser(user *models.User) {- s.user = user-}--// GetByID returns idea by given id-func (s *IdeaStorage) GetByID(ideaID int) (*models.Idea, error) {- for _, idea := range s.ideas {- if idea.ID == ideaID {- return idea, nil- }- }- return nil, app.ErrNotFound-}--// Update given idea-func (s *IdeaStorage) Update(idea *models.Idea, title, description string) (*models.Idea, error) {- idea.Title = title- idea.Description = description- return idea, nil-}--// GetByNumber returns idea by tenant and number-func (s *IdeaStorage) GetByNumber(number int) (*models.Idea, error) {- for _, idea := range s.ideas {- if idea.Number == number {- return idea, nil- }- }- return nil, app.ErrNotFound-}--// GetBySlug returns idea by tenant and slug-func (s *IdeaStorage) GetBySlug(slug string) (*models.Idea, error) {- for _, idea := range s.ideas {- if idea.Slug == slug {- return idea, nil- }- }- return nil, app.ErrNotFound-}--// GetAll returns all tenant ideas-func (s *IdeaStorage) GetAll() ([]*models.Idea, error) {- return s.ideas, nil-}--// CountPerStatus returns total number of ideas per status-func (s *IdeaStorage) CountPerStatus() (map[int]int, error) {- return make(map[int]int, 0), nil-}--// Search existing ideas based on input-func (s *IdeaStorage) Search(query, filter, limit string, tags []string) ([]*models.Idea, error) {- return s.ideas, nil-}--// GetCommentsByIdea returns all comments from given idea-func (s *IdeaStorage) GetCommentsByIdea(idea *models.Idea) ([]*models.Comment, error) {- return s.ideaComments[idea.ID], nil-}--// Add a new idea in the database-func (s *IdeaStorage) Add(title, description string) (*models.Idea, error) {- s.lastID = s.lastID + 1- idea := &models.Idea{- ID: s.lastID,- Number: s.lastID,- Title: title,- Slug: slug.Make(title),- Description: description,- User: s.user,- }- s.ideas = append(s.ideas, idea)- s.ideasSupportedBy[s.user.ID] = append(s.ideasSupportedBy[s.user.ID], idea.ID)- s.AddSubscriber(idea, s.user)- return idea, nil-}--// AddComment places a new comment on an idea-func (s *IdeaStorage) AddComment(idea *models.Idea, content string) (int, error) {- s.lastCommentID++- s.ideaComments[idea.ID] = append(s.ideaComments[idea.ID], &models.Comment{- ID: s.lastCommentID,- Content: content,- CreatedOn: time.Now(),- User: s.user,- })-- return s.lastCommentID, nil-}--// GetCommentByID returns a comment by given ID-func (s *IdeaStorage) GetCommentByID(id int) (*models.Comment, error) {- for _, comments := range s.ideaComments {- for _, comment := range comments {- if comment.ID == id && comment.User.Tenant == s.tenant {- return comment, nil- }- }- }- return nil, app.ErrNotFound-}--// UpdateComment with given ID and content-func (s *IdeaStorage) UpdateComment(id int, content string) error {- now := time.Now()- comment, err := s.GetCommentByID(id)- if err != nil {- return err- }- comment.Content = content- comment.EditedOn = &now- comment.EditedBy = s.user- return nil-}--// AddSupporter adds user to idea list of supporters-func (s *IdeaStorage) AddSupporter(idea *models.Idea, user *models.User) error {- s.ideasSupportedBy[user.ID] = append(s.ideasSupportedBy[user.ID], idea.ID)- idea.TotalSupporters = idea.TotalSupporters + 1- return nil-}--// RemoveSupporter removes user from idea list of supporters-func (s *IdeaStorage) RemoveSupporter(idea *models.Idea, user *models.User) error {- for i, id := range s.ideasSupportedBy[user.ID] {- if id == idea.ID {- s.ideasSupportedBy[user.ID] = append(s.ideasSupportedBy[user.ID][:i], s.ideasSupportedBy[user.ID][i+1:]...)- break- }- }- idea.TotalSupporters = idea.TotalSupporters - 1- return nil-}--// SetResponse changes current idea response-func (s *IdeaStorage) SetResponse(idea *models.Idea, text string, status int) error {- for i, storedIdea := range s.ideas {- if storedIdea.Number == idea.Number {- if status == models.IdeaDeleted {- s.ideas = append(s.ideas[:i], s.ideas[i+1:]...)- } else {- storedIdea.Status = status- storedIdea.Response = &models.IdeaResponse{- Text: text,- User: s.user,- RespondedOn: time.Now(),- }- }- }- }- return nil-}--// MarkAsDuplicate set idea as a duplicate of another idea-func (s *IdeaStorage) MarkAsDuplicate(idea *models.Idea, original *models.Idea) error {- idea.Status = models.IdeaDuplicate- idea.Response = &models.IdeaResponse{- Original: &models.OriginalIdea{- Number: original.Number,- Title: original.Title,- Slug: original.Slug,- Status: original.Status,- },- Text: "",- User: s.user,- RespondedOn: time.Now(),- }- return nil-}--// IsReferenced returns true if another idea is referencing given idea-func (s *IdeaStorage) IsReferenced(idea *models.Idea) (bool, error) {- for _, i := range s.ideas {- if i.Status == models.IdeaDuplicate && i.Response.Original.Number == idea.Number {- return true, nil- }- }- return false, nil-}--// SupportedBy returns a list of Idea ID supported by given user-func (s *IdeaStorage) SupportedBy() ([]int, error) {- return s.ideasSupportedBy[s.user.ID], nil-}--// AddSubscriber adds user to the idea list of subscribers-func (s *IdeaStorage) AddSubscriber(idea *models.Idea, user *models.User) error {- s.ideaSubscribers[idea.ID] = append(s.ideaSubscribers[idea.ID], user)- return nil-}--// RemoveSubscriber removes user from idea list of subscribers-func (s *IdeaStorage) RemoveSubscriber(idea *models.Idea, user *models.User) error {- for i, u := range s.ideaSubscribers[idea.ID] {- if u.ID == user.ID {- s.ideaSubscribers[idea.ID] = append(s.ideaSubscribers[idea.ID][:i], s.ideaSubscribers[idea.ID][i+1:]...)- break- }- }- return nil-}--// GetActiveSubscribers based on input and settings-func (s *IdeaStorage) GetActiveSubscribers(number int, channel models.NotificationChannel, event models.NotificationEvent) ([]*models.User, error) {- idea, err := s.GetByNumber(number)- if err != nil {- return nil, err- }- subscribers, ok := s.ideaSubscribers[idea.ID]- if ok {- users := make([]*models.User, len(subscribers))- for i, user := range subscribers {- users[i] = user- }- return users, nil- }- return make([]*models.User, 0), nil-}diff --git a/app/storage/inmemory/notifications.go b/app/storage/inmemory/notifications.goindex ccffc9cef..c2dab9741 100644--- a/app/storage/inmemory/notifications.go+++ b/app/storage/inmemory/notifications.go@@ -34,7 +34,7 @@ func (s *NotificationStorage) SetCurrentUser(user *models.User) {}// Insert notification for given user-func (s *NotificationStorage) Insert(user *models.User, title, link string, ideaID int) (*models.Notification, error) {+func (s *NotificationStorage) Insert(user *models.User, title, link string, postID int) (*models.Notification, error) {s.lastID = s.lastID + 1newNotification := &models.Notification{ID: s.lastID,diff --git a/app/storage/inmemory/post.go b/app/storage/inmemory/post.gonew file mode 100644index 000000000..7522f9f91--- /dev/null+++ b/app/storage/inmemory/post.go@@ -0,0 +1,258 @@+package inmemory++import (+ "time"++ "github.com/gosimple/slug"++ "github.com/getfider/fider/app"+ "github.com/getfider/fider/app/models"+)++// PostStorage contains read and write operations for posts+type PostStorage struct {+ lastID int+ lastCommentID int+ posts []*models.Post+ postsSupportedBy map[int][]int+ postSubscribers map[int][]*models.User+ postComments map[int][]*models.Comment+ tenant *models.Tenant+ user *models.User+}++// NewPostStorage creates a new PostStorage+func NewPostStorage() *PostStorage {+ return &PostStorage{+ posts: make([]*models.Post, 0),+ postsSupportedBy: make(map[int][]int, 0),+ postSubscribers: make(map[int][]*models.User, 0),+ postComments: make(map[int][]*models.Comment, 0),+ }+}++// SetCurrentTenant to current context+func (s *PostStorage) SetCurrentTenant(tenant *models.Tenant) {+ s.tenant = tenant+}++// SetCurrentUser to current context+func (s *PostStorage) SetCurrentUser(user *models.User) {+ s.user = user+}++// GetByID returns post by given id+func (s *PostStorage) GetByID(postID int) (*models.Post, error) {+ for _, post := range s.posts {+ if post.ID == postID {+ return post, nil+ }+ }+ return nil, app.ErrNotFound+}++// Update given post+func (s *PostStorage) Update(post *models.Post, title, description string) (*models.Post, error) {+ post.Title = title+ post.Description = description+ return post, nil+}++// GetByNumber returns post by tenant and number+func (s *PostStorage) GetByNumber(number int) (*models.Post, error) {+ for _, post := range s.posts {+ if post.Number == number {+ return post, nil+ }+ }+ return nil, app.ErrNotFound+}++// GetBySlug returns post by tenant and slug+func (s *PostStorage) GetBySlug(slug string) (*models.Post, error) {+ for _, post := range s.posts {+ if post.Slug == slug {+ return post, nil+ }+ }+ return nil, app.ErrNotFound+}++// GetAll returns all tenant posts+func (s *PostStorage) GetAll() ([]*models.Post, error) {+ return s.posts, nil+}++// CountPerStatus returns total number of posts per status+func (s *PostStorage) CountPerStatus() (map[int]int, error) {+ return make(map[int]int, 0), nil+}++// Search existing posts based on input+func (s *PostStorage) Search(query, filter, limit string, tags []string) ([]*models.Post, error) {+ return s.posts, nil+}++// GetCommentsByPost returns all comments from given post+func (s *PostStorage) GetCommentsByPost(post *models.Post) ([]*models.Comment, error) {+ return s.postComments[post.ID], nil+}++// Add a new post in the database+func (s *PostStorage) Add(title, description string) (*models.Post, error) {+ s.lastID = s.lastID + 1+ post := &models.Post{+ ID: s.lastID,+ Number: s.lastID,+ Title: title,+ Slug: slug.Make(title),+ Description: description,+ User: s.user,+ }+ s.posts = append(s.posts, post)+ s.postsSupportedBy[s.user.ID] = append(s.postsSupportedBy[s.user.ID], post.ID)+ s.AddSubscriber(post, s.user)+ return post, nil+}++// AddComment places a new comment on an post+func (s *PostStorage) AddComment(post *models.Post, content string) (int, error) {+ s.lastCommentID+++ s.postComments[post.ID] = append(s.postComments[post.ID], &models.Comment{+ ID: s.lastCommentID,+ Content: content,+ CreatedOn: time.Now(),+ User: s.user,+ })++ return s.lastCommentID, nil+}++// GetCommentByID returns a comment by given ID+func (s *PostStorage) GetCommentByID(id int) (*models.Comment, error) {+ for _, comments := range s.postComments {+ for _, comment := range comments {+ if comment.ID == id && comment.User.Tenant == s.tenant {+ return comment, nil+ }+ }+ }+ return nil, app.ErrNotFound+}++// UpdateComment with given ID and content+func (s *PostStorage) UpdateComment(id int, content string) error {+ now := time.Now()+ comment, err := s.GetCommentByID(id)+ if err != nil {+ return err+ }+ comment.Content = content+ comment.EditedOn = &now+ comment.EditedBy = s.user+ return nil+}++// AddSupporter adds user to post list of supporters+func (s *PostStorage) AddSupporter(post *models.Post, user *models.User) error {+ s.postsSupportedBy[user.ID] = append(s.postsSupportedBy[user.ID], post.ID)+ post.TotalSupporters = post.TotalSupporters + 1+ return nil+}++// RemoveSupporter removes user from post list of supporters+func (s *PostStorage) RemoveSupporter(post *models.Post, user *models.User) error {+ for i, id := range s.postsSupportedBy[user.ID] {+ if id == post.ID {+ s.postsSupportedBy[user.ID] = append(s.postsSupportedBy[user.ID][:i], s.postsSupportedBy[user.ID][i+1:]...)+ break+ }+ }+ post.TotalSupporters = post.TotalSupporters - 1+ return nil+}++// SetResponse changes current post response+func (s *PostStorage) SetResponse(post *models.Post, text string, status int) error {+ for i, storedPost := range s.posts {+ if storedPost.Number == post.Number {+ if status == models.PostDeleted {+ s.posts = append(s.posts[:i], s.posts[i+1:]...)+ } else {+ storedPost.Status = status+ storedPost.Response = &models.PostResponse{+ Text: text,+ User: s.user,+ RespondedOn: time.Now(),+ }+ }+ }+ }+ return nil+}++// MarkAsDuplicate set post as a duplicate of another post+func (s *PostStorage) MarkAsDuplicate(post *models.Post, original *models.Post) error {+ post.Status = models.PostDuplicate+ post.Response = &models.PostResponse{+ Original: &models.OriginalPost{+ Number: original.Number,+ Title: original.Title,+ Slug: original.Slug,+ Status: original.Status,+ },+ Text: "",+ User: s.user,+ RespondedOn: time.Now(),+ }+ return nil+}++// IsReferenced returns true if another post is referencing given post+func (s *PostStorage) IsReferenced(post *models.Post) (bool, error) {+ for _, i := range s.posts {+ if i.Status == models.PostDuplicate && i.Response.Original.Number == post.Number {+ return true, nil+ }+ }+ return false, nil+}++// SupportedBy returns a list of Post ID supported by given user+func (s *PostStorage) SupportedBy() ([]int, error) {+ return s.postsSupportedBy[s.user.ID], nil+}++// AddSubscriber adds user to the post list of subscribers+func (s *PostStorage) AddSubscriber(post *models.Post, user *models.User) error {+ s.postSubscribers[post.ID] = append(s.postSubscribers[post.ID], user)+ return nil+}++// RemoveSubscriber removes user from post list of subscribers+func (s *PostStorage) RemoveSubscriber(post *models.Post, user *models.User) error {+ for i, u := range s.postSubscribers[post.ID] {+ if u.ID == user.ID {+ s.postSubscribers[post.ID] = append(s.postSubscribers[post.ID][:i], s.postSubscribers[post.ID][i+1:]...)+ break+ }+ }+ return nil+}++// GetActiveSubscribers based on input and settings+func (s *PostStorage) GetActiveSubscribers(number int, channel models.NotificationChannel, event models.NotificationEvent) ([]*models.User, error) {+ post, err := s.GetByNumber(number)+ if err != nil {+ return nil, err+ }+ subscribers, ok := s.postSubscribers[post.ID]+ if ok {+ users := make([]*models.User, len(subscribers))+ for i, user := range subscribers {+ users[i] = user+ }+ return users, nil+ }+ return make([]*models.User, 0), nil+}diff --git a/app/storage/inmemory/tag.go b/app/storage/inmemory/tag.goindex db79f063e..3874c64c3 100644--- a/app/storage/inmemory/tag.go+++ b/app/storage/inmemory/tag.go@@ -82,9 +82,9 @@ func (s *TagStorage) Delete(tag *models.Tag) error {return nil}-// AssignTag adds a tag to an idea-func (s *TagStorage) AssignTag(tag *models.Tag, idea *models.Idea) error {- assigned := s.assigned[idea.ID]+// AssignTag adds a tag to an post+func (s *TagStorage) AssignTag(tag *models.Tag, post *models.Post) error {+ assigned := s.assigned[post.ID]if assigned != nil {for _, assignedTag := range assigned {if assignedTag.ID == tag.ID {@@ -93,17 +93,17 @@ func (s *TagStorage) AssignTag(tag *models.Tag, idea *models.Idea) error {}}- s.assigned[idea.ID] = append(s.assigned[idea.ID], tag)+ s.assigned[post.ID] = append(s.assigned[post.ID], tag)return nil}-// UnassignTag removes a tag from an idea-func (s *TagStorage) UnassignTag(tag *models.Tag, idea *models.Idea) error {- assigned := s.assigned[idea.ID]+// UnassignTag removes a tag from an post+func (s *TagStorage) UnassignTag(tag *models.Tag, post *models.Post) error {+ assigned := s.assigned[post.ID]if assigned != nil {for i, assignedTag := range assigned {if assignedTag.ID == tag.ID {- s.assigned[idea.ID] = append(s.assigned[idea.ID][:i], s.assigned[idea.ID][i+1:]...)+ s.assigned[post.ID] = append(s.assigned[post.ID][:i], s.assigned[post.ID][i+1:]...)return nil}}@@ -111,9 +111,9 @@ func (s *TagStorage) UnassignTag(tag *models.Tag, idea *models.Idea) error {return nil}-// GetAssigned returns all tags assigned to given idea-func (s *TagStorage) GetAssigned(idea *models.Idea) ([]*models.Tag, error) {- assigned := s.assigned[idea.ID]+// GetAssigned returns all tags assigned to given post+func (s *TagStorage) GetAssigned(post *models.Post) ([]*models.Tag, error) {+ assigned := s.assigned[post.ID]if assigned != nil {return assigned, nil}diff --git a/app/storage/inmemory/user.go b/app/storage/inmemory/user.goindex 63f78dde3..00f550266 100644--- a/app/storage/inmemory/user.go+++ b/app/storage/inmemory/user.go@@ -137,8 +137,8 @@ func (s *UserStorage) GetUserSettings() (map[string]string, error) {return make(map[string]string, 0), nil}-// HasSubscribedTo returns true if current user is receiving notification from specific idea-func (s *UserStorage) HasSubscribedTo(ideaID int) (bool, error) {+// HasSubscribedTo returns true if current user is receiving notification from specific post+func (s *UserStorage) HasSubscribedTo(postID int) (bool, error) {return false, nil}diff --git a/app/storage/postgres/common.go b/app/storage/postgres/common.goindex d8c7bc92d..b77d5cf30 100644--- a/app/storage/postgres/common.go+++ b/app/storage/postgres/common.go@@ -22,9 +22,9 @@ func getFilterData(filter string) (string, []int, string) {sort string)statuses := []int{- models.IdeaOpen,- models.IdeaStarted,- models.IdeaPlanned,+ models.PostOpen,+ models.PostStarted,+ models.PostPlanned,}switch filter {case "recent":@@ -38,24 +38,24 @@ func getFilterData(filter string) (string, []int, string) {sort = "comments"case "planned":sort = "response_date"- statuses = []int{models.IdeaPlanned}+ statuses = []int{models.PostPlanned}case "started":sort = "response_date"- statuses = []int{models.IdeaStarted}+ statuses = []int{models.PostStarted}case "completed":sort = "response_date"- statuses = []int{models.IdeaCompleted}+ statuses = []int{models.PostCompleted}case "declined":sort = "response_date"- statuses = []int{models.IdeaDeclined}+ statuses = []int{models.PostDeclined}case "all":sort = "id"statuses = []int{- models.IdeaOpen,- models.IdeaStarted,- models.IdeaPlanned,- models.IdeaCompleted,- models.IdeaDeclined,+ models.PostOpen,+ models.PostStarted,+ models.PostPlanned,+ models.PostCompleted,+ models.PostDeclined,}case "trending":fallthroughdiff --git a/app/storage/postgres/idea_test.go b/app/storage/postgres/idea_test.godeleted file mode 100644index 535fed36c..000000000--- a/app/storage/postgres/idea_test.go+++ /dev/null@@ -1,508 +0,0 @@-package postgres_test--import (- "testing"- "time"-- "github.com/getfider/fider/app"- "github.com/getfider/fider/app/models"- . "github.com/getfider/fider/app/pkg/assert"- "github.com/getfider/fider/app/pkg/errors"-)--func TestIdeaStorage_GetAll(t *testing.T) {- SetupDatabaseTest(t)- defer TeardownDatabaseTest()-- now := time.Now()-- trx.Execute("INSERT INTO ideas (title, slug, number, description, created_on, tenant_id, user_id, status) VALUES ('add twitter integration', 'add-twitter-integration', 1, 'Would be great to see it integrated with twitter', $1, 1, 1, 1)", now)- trx.Execute("INSERT INTO ideas (title, slug, number, description, created_on, tenant_id, user_id, status) VALUES ('this is my idea', 'this-is-my-idea', 2, 'no description', $1, 1, 2, 2)", now)-- ideas.SetCurrentTenant(demoTenant)-- dbIdeas, err := ideas.GetAll()- Expect(err).IsNil()- Expect(dbIdeas).HasLen(2)-- Expect(dbIdeas[0].Title).Equals("this is my idea")- Expect(dbIdeas[0].Slug).Equals("this-is-my-idea")- Expect(dbIdeas[0].Number).Equals(2)- Expect(dbIdeas[0].Description).Equals("no description")- Expect(dbIdeas[0].User.Name).Equals("Arya Stark")- Expect(dbIdeas[0].TotalSupporters).Equals(0)- Expect(dbIdeas[0].Status).Equals(models.IdeaCompleted)-- Expect(dbIdeas[1].Title).Equals("add twitter integration")- Expect(dbIdeas[1].Slug).Equals("add-twitter-integration")- Expect(dbIdeas[1].Number).Equals(1)- Expect(dbIdeas[1].Description).Equals("Would be great to see it integrated with twitter")- Expect(dbIdeas[1].User.Name).Equals("Jon Snow")- Expect(dbIdeas[1].TotalSupporters).Equals(0)- Expect(dbIdeas[1].Status).Equals(models.IdeaStarted)-- dbIdeas, err = ideas.Search("twitter", "trending", "10", []string{})- Expect(err).IsNil()- Expect(dbIdeas).HasLen(1)- Expect(dbIdeas[0].Slug).Equals("add-twitter-integration")-- dbIdeas, err = ideas.Search("twitter", "trending", "0", []string{})- Expect(err).IsNil()- Expect(dbIdeas).HasLen(0)-}--func TestIdeaStorage_AddAndGet(t *testing.T) {- SetupDatabaseTest(t)- defer TeardownDatabaseTest()-- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(jonSnow)- idea, err := ideas.Add("My new idea", "with this description")- Expect(err).IsNil()-- dbIdeaById, err := ideas.GetByID(idea.ID)- Expect(err).IsNil()- Expect(dbIdeaById.ID).Equals(idea.ID)- Expect(dbIdeaById.Number).Equals(1)- Expect(dbIdeaById.ViewerSupported).IsFalse()- Expect(dbIdeaById.TotalSupporters).Equals(0)- Expect(dbIdeaById.Status).Equals(models.IdeaOpen)- Expect(dbIdeaById.Title).Equals("My new idea")- Expect(dbIdeaById.Description).Equals("with this description")- Expect(dbIdeaById.User.ID).Equals(1)- Expect(dbIdeaById.User.Name).Equals("Jon Snow")- Expect(dbIdeaById.User.Email).Equals("[email protected]")-- dbIdeaBySlug, err := ideas.GetBySlug("my-new-idea")-- Expect(err).IsNil()- Expect(dbIdeaBySlug.ID).Equals(idea.ID)- Expect(dbIdeaBySlug.Number).Equals(1)- Expect(dbIdeaBySlug.ViewerSupported).IsFalse()- Expect(dbIdeaBySlug.TotalSupporters).Equals(0)- Expect(dbIdeaBySlug.Status).Equals(models.IdeaOpen)- Expect(dbIdeaBySlug.Title).Equals("My new idea")- Expect(dbIdeaBySlug.Description).Equals("with this description")- Expect(dbIdeaBySlug.User.ID).Equals(1)- Expect(dbIdeaBySlug.User.Name).Equals("Jon Snow")- Expect(dbIdeaBySlug.User.Email).Equals("[email protected]")-}--func TestIdeaStorage_GetInvalid(t *testing.T) {- SetupDatabaseTest(t)- defer TeardownDatabaseTest()-- ideas.SetCurrentTenant(demoTenant)-- dbIdea, err := ideas.GetByID(1)- Expect(errors.Cause(err)).Equals(app.ErrNotFound)- Expect(dbIdea).IsNil()-}--func TestIdeaStorage_AddAndReturnComments(t *testing.T) {- SetupDatabaseTest(t)- defer TeardownDatabaseTest()-- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(jonSnow)- idea, err := ideas.Add("My new idea", "with this description")- Expect(err).IsNil()-- ideas.SetCurrentUser(jonSnow)- ideas.AddComment(idea, "Comment #1")- ideas.SetCurrentUser(aryaStark)- ideas.AddComment(idea, "Comment #2")-- comments, err := ideas.GetCommentsByIdea(idea)- Expect(err).IsNil()- Expect(comments).HasLen(2)-- Expect(comments[0].Content).Equals("Comment #1")- Expect(comments[0].User.Name).Equals("Jon Snow")- Expect(comments[1].Content).Equals("Comment #2")- Expect(comments[1].User.Name).Equals("Arya Stark")-}--func TestIdeaStorage_AddGetUpdateComment(t *testing.T) {- SetupDatabaseTest(t)- defer TeardownDatabaseTest()-- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(jonSnow)- idea, err := ideas.Add("My new idea", "with this description")- Expect(err).IsNil()-- commentId, err := ideas.AddComment(idea, "Comment #1")- Expect(err).IsNil()-- comment, err := ideas.GetCommentByID(commentId)- Expect(err).IsNil()- Expect(comment.ID).Equals(commentId)- Expect(comment.Content).Equals("Comment #1")- Expect(comment.User.ID).Equals(jonSnow.ID)- Expect(comment.EditedOn).IsNil()- Expect(comment.EditedBy).IsNil()-- ideas.SetCurrentUser(aryaStark)- err = ideas.UpdateComment(commentId, "Comment #1 with edit")- Expect(err).IsNil()-- comment, err = ideas.GetCommentByID(commentId)- Expect(err).IsNil()- Expect(comment.ID).Equals(commentId)- Expect(comment.Content).Equals("Comment #1 with edit")- Expect(comment.User.ID).Equals(jonSnow.ID)- Expect(comment.EditedOn).IsNotNil()- Expect(comment.EditedBy.ID).Equals(aryaStark.ID)-}--func TestIdeaStorage_AddAndGet_DifferentTenants(t *testing.T) {- SetupDatabaseTest(t)- defer TeardownDatabaseTest()-- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(jonSnow)- demoIdea, err := ideas.Add("My new idea", "with this description")- Expect(err).IsNil()-- ideas.SetCurrentTenant(avengersTenant)- ideas.SetCurrentUser(tonyStark)- avengersIdea, err := ideas.Add("My other idea", "with other description")- Expect(err).IsNil()-- ideas.SetCurrentTenant(demoTenant)- dbIdea, err := ideas.GetByNumber(1)-- Expect(err).IsNil()- Expect(dbIdea.ID).Equals(demoIdea.ID)- Expect(dbIdea.Number).Equals(1)- Expect(dbIdea.Title).Equals("My new idea")- Expect(dbIdea.Slug).Equals("my-new-idea")-- ideas.SetCurrentTenant(avengersTenant)- dbIdea, err = ideas.GetByNumber(1)-- Expect(err).IsNil()- Expect(dbIdea.ID).Equals(avengersIdea.ID)- Expect(dbIdea.Number).Equals(1)- Expect(dbIdea.Title).Equals("My other idea")- Expect(dbIdea.Slug).Equals("my-other-idea")-}--func TestIdeaStorage_Update(t *testing.T) {- SetupDatabaseTest(t)- defer TeardownDatabaseTest()-- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(jonSnow)-- idea, err := ideas.Add("My new idea", "with this description")- Expect(err).IsNil()-- idea, err = ideas.Update(idea, "The new comment", "With the new description")- Expect(err).IsNil()- Expect(idea.Title).Equals("The new comment")- Expect(idea.Description).Equals("With the new description")- Expect(idea.Slug).Equals("the-new-comment")-}--func TestIdeaStorage_AddSupporter(t *testing.T) {- SetupDatabaseTest(t)- defer TeardownDatabaseTest()-- users.SetCurrentTenant(demoTenant)- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(jonSnow)-- idea, err := ideas.Add("My new idea", "with this description")- Expect(err).IsNil()-- err = ideas.AddSupporter(idea, aryaStark)- Expect(err).IsNil()-- dbIdea, err := ideas.GetByNumber(1)- Expect(dbIdea.ViewerSupported).IsFalse()- Expect(dbIdea.TotalSupporters).Equals(1)-- err = ideas.AddSupporter(idea, jonSnow)- Expect(err).IsNil()-- dbIdea, err = ideas.GetByNumber(1)- Expect(err).IsNil()- Expect(dbIdea.ViewerSupported).IsTrue()- Expect(dbIdea.TotalSupporters).Equals(2)-}--func TestIdeaStorage_AddSupporter_Twice(t *testing.T) {- SetupDatabaseTest(t)- defer TeardownDatabaseTest()-- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(jonSnow)-- idea, _ := ideas.Add("My new idea", "with this description")-- err := ideas.AddSupporter(idea, jonSnow)- Expect(err).IsNil()-- err = ideas.AddSupporter(idea, jonSnow)- Expect(err).IsNil()-- dbIdea, err := ideas.GetByNumber(1)- Expect(err).IsNil()- Expect(dbIdea.TotalSupporters).Equals(1)-}--func TestIdeaStorage_RemoveSupporter(t *testing.T) {- SetupDatabaseTest(t)- defer TeardownDatabaseTest()-- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(jonSnow)-- idea, _ := ideas.Add("My new idea", "with this description")-- err := ideas.AddSupporter(idea, jonSnow)- Expect(err).IsNil()-- err = ideas.RemoveSupporter(idea, jonSnow)- Expect(err).IsNil()-- dbIdea, err := ideas.GetByNumber(1)- Expect(err).IsNil()- Expect(dbIdea.TotalSupporters).Equals(0)-}--func TestIdeaStorage_RemoveSupporter_Twice(t *testing.T) {- SetupDatabaseTest(t)- defer TeardownDatabaseTest()-- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(jonSnow)-- idea, _ := ideas.Add("My new idea", "with this description")-- err := ideas.AddSupporter(idea, jonSnow)- Expect(err).IsNil()-- err = ideas.RemoveSupporter(idea, jonSnow)- Expect(err).IsNil()-- err = ideas.RemoveSupporter(idea, jonSnow)- Expect(err).IsNil()-- dbIdea, err := ideas.GetByNumber(1)- Expect(err).IsNil()- Expect(dbIdea.TotalSupporters).Equals(0)-}--func TestIdeaStorage_SetResponse(t *testing.T) {- SetupDatabaseTest(t)- defer TeardownDatabaseTest()-- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(jonSnow)-- idea, _ := ideas.Add("My new idea", "with this description")- err := ideas.SetResponse(idea, "We liked this idea", models.IdeaStarted)-- Expect(err).IsNil()-- idea, _ = ideas.GetByID(idea.ID)- Expect(idea.Response.Text).Equals("We liked this idea")- Expect(idea.Status).Equals(models.IdeaStarted)- Expect(idea.Response.User.ID).Equals(1)-}--func TestIdeaStorage_SetResponse_KeepOpen(t *testing.T) {- SetupDatabaseTest(t)- defer TeardownDatabaseTest()-- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(jonSnow)-- idea, _ := ideas.Add("My new idea", "with this description")- err := ideas.SetResponse(idea, "We liked this idea", models.IdeaOpen)- Expect(err).IsNil()-}--func TestIdeaStorage_SetResponse_ChangeText(t *testing.T) {- SetupDatabaseTest(t)- defer TeardownDatabaseTest()-- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(jonSnow)-- idea, _ := ideas.Add("My new idea", "with this description")- ideas.SetResponse(idea, "We liked this idea", models.IdeaStarted)- idea, _ = ideas.GetByID(idea.ID)- respondedOn := idea.Response.RespondedOn-- ideas.SetResponse(idea, "We liked this idea and we'll work on it", models.IdeaStarted)- idea, _ = ideas.GetByID(idea.ID)- Expect(idea.Response.RespondedOn).Equals(respondedOn)-- ideas.SetResponse(idea, "We finished it", models.IdeaCompleted)- idea, _ = ideas.GetByID(idea.ID)- Expect(idea.Response.RespondedOn).TemporarilySimilar(respondedOn, time.Second)-}--func TestIdeaStorage_SetResponse_AsDuplicate(t *testing.T) {- SetupDatabaseTest(t)- defer TeardownDatabaseTest()-- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(jonSnow)-- idea1, _ := ideas.Add("My new idea", "with this description")- ideas.AddSupporter(idea1, jonSnow)-- ideas.SetCurrentUser(aryaStark)- idea2, _ := ideas.Add("My other idea", "with similar description")- ideas.AddSupporter(idea2, aryaStark)-- ideas.SetCurrentUser(jonSnow)- ideas.MarkAsDuplicate(idea2, idea1)- idea1, _ = ideas.GetByID(idea1.ID)-- Expect(idea1.TotalSupporters).Equals(2)- Expect(idea1.Status).Equals(models.IdeaOpen)- Expect(idea1.Response).IsNil()-- idea2, _ = ideas.GetByID(idea2.ID)-- Expect(idea2.Response.Text).Equals("")- Expect(idea2.TotalSupporters).Equals(1)- Expect(idea2.Status).Equals(models.IdeaDuplicate)- Expect(idea2.Response.User.ID).Equals(1)- Expect(idea2.Response.Original.Number).Equals(idea1.Number)- Expect(idea2.Response.Original.Title).Equals(idea1.Title)- Expect(idea2.Response.Original.Slug).Equals(idea1.Slug)- Expect(idea2.Response.Original.Status).Equals(idea1.Status)-}--func TestIdeaStorage_SetResponse_AsDeleted(t *testing.T) {- SetupDatabaseTest(t)- defer TeardownDatabaseTest()-- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(jonSnow)- idea, err := ideas.Add("My new idea", "with this description")- Expect(err).IsNil()-- ideas.SetResponse(idea, "Spam!", models.IdeaDeleted)-- idea1, err := ideas.GetByNumber(idea.Number)- Expect(errors.Cause(err)).Equals(app.ErrNotFound)- Expect(idea1).IsNil()-- idea2, err := ideas.GetByID(idea.ID)- Expect(errors.Cause(err)).Equals(app.ErrNotFound)- Expect(idea2).IsNil()-}--func TestIdeaStorage_AddSupporter_ClosedIdea(t *testing.T) {- SetupDatabaseTest(t)- defer TeardownDatabaseTest()-- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(jonSnow)- idea, _ := ideas.Add("My new idea", "with this description")- ideas.SetResponse(idea, "We liked this idea", models.IdeaCompleted)- ideas.AddSupporter(idea, jonSnow)-- dbIdea, err := ideas.GetByNumber(idea.Number)- Expect(err).IsNil()- Expect(dbIdea.TotalSupporters).Equals(0)-}--func TestIdeaStorage_RemoveSupporter_ClosedIdea(t *testing.T) {- SetupDatabaseTest(t)- defer TeardownDatabaseTest()-- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(jonSnow)- idea, _ := ideas.Add("My new idea", "with this description")- ideas.AddSupporter(idea, jonSnow)- ideas.SetResponse(idea, "We liked this idea", models.IdeaCompleted)- ideas.RemoveSupporter(idea, jonSnow)-- dbIdea, err := ideas.GetByNumber(idea.Number)- Expect(err).IsNil()- Expect(dbIdea.TotalSupporters).Equals(1)-}--func TestIdeaStorage_ListSupportedIdeas(t *testing.T) {- SetupDatabaseTest(t)- defer TeardownDatabaseTest()-- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(jonSnow)- idea1, _ := ideas.Add("My new idea", "with this description")- idea2, _ := ideas.Add("My other idea", "with better description")- ideas.AddSupporter(idea1, aryaStark)- ideas.AddSupporter(idea2, aryaStark)-- ideas.SetCurrentUser(jonSnow)- arr, err := ideas.SupportedBy()- Expect(err).IsNil()- Expect(arr).Equals([]int{})-- ideas.SetCurrentUser(aryaStark)- arr, err = ideas.SupportedBy()- Expect(err).IsNil()- Expect(arr).Equals([]int{idea1.ID, idea2.ID})-}--func TestIdeaStorage_WithTags(t *testing.T) {- SetupDatabaseTest(t)- defer TeardownDatabaseTest()-- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(aryaStark)- tags.SetCurrentTenant(demoTenant)- tags.SetCurrentUser(jonSnow)-- idea, _ := ideas.Add("My new idea", "with this description")- bug, _ := tags.Add("Bug", "FF0000", true)- featureRequest, _ := tags.Add("Feature Request", "00FF00", false)-- tags.AssignTag(bug, idea)- tags.AssignTag(featureRequest, idea)-- idea, _ = ideas.GetByID(idea.ID)- Expect(idea.Tags).HasLen(1)- Expect(idea.Tags[0]).Equals(bug.Slug)-- ideas.SetCurrentUser(jonSnow)- idea, _ = ideas.GetByID(idea.ID)- Expect(idea.Tags).HasLen(2)- Expect(idea.Tags[0]).Equals(bug.Slug)- Expect(idea.Tags[1]).Equals(featureRequest.Slug)-}--func TestIdeaStorage_IsReferenced(t *testing.T) {- SetupDatabaseTest(t)- defer TeardownDatabaseTest()-- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(jonSnow)- idea1, _ := ideas.Add("My first idea", "with this description")- idea2, _ := ideas.Add("My second idea", "with this description")- idea3, _ := ideas.Add("My third idea", "with this description")-- ideas.MarkAsDuplicate(idea2, idea3)- ideas.MarkAsDuplicate(idea3, idea1)-- referenced, err := ideas.IsReferenced(idea1)- Expect(referenced).IsTrue()- Expect(err).IsNil()-- referenced, err = ideas.IsReferenced(idea2)- Expect(referenced).IsFalse()- Expect(err).IsNil()-- referenced, err = ideas.IsReferenced(idea3)- Expect(referenced).IsTrue()- Expect(err).IsNil()-}diff --git a/app/storage/postgres/notifications.go b/app/storage/postgres/notifications.goindex 5fccf317a..c3bfd1dee 100644--- a/app/storage/postgres/notifications.go+++ b/app/storage/postgres/notifications.go@@ -33,7 +33,7 @@ func (s *NotificationStorage) SetCurrentUser(user *models.User) {}// Insert notification for given user-func (s *NotificationStorage) Insert(user *models.User, title, link string, ideaID int) (*models.Notification, error) {+func (s *NotificationStorage) Insert(user *models.User, title, link string, postID int) (*models.Notification, error) {if user.ID == s.user.ID {return nil, nil}@@ -49,7 +49,7 @@ func (s *NotificationStorage) Insert(user *models.User, title, link string, ideaINSERT INTO notifications (tenant_id, user_id, title, link, read, idea_id, author_id, created_on, updated_on)VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $8)RETURNING id- `, s.tenant.ID, user.ID, title, link, false, ideaID, s.user.ID, now)+ `, s.tenant.ID, user.ID, title, link, false, postID, s.user.ID, now)if err != nil {return nil, errors.Wrap(err, "failed to insert notification")}diff --git a/app/storage/postgres/notifications_test.go b/app/storage/postgres/notifications_test.goindex 6c001155b..9f6bc5754 100644--- a/app/storage/postgres/notifications_test.go+++ b/app/storage/postgres/notifications_test.go@@ -30,15 +30,15 @@ func TestNotificationStorage_Insert_Read_Count(t *testing.T) {SetupDatabaseTest(t)defer TeardownDatabaseTest()- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(jonSnow)+ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(jonSnow)notifications.SetCurrentTenant(demoTenant)notifications.SetCurrentUser(jonSnow)- idea, _ := ideas.Add("Title", "Description")+ post, _ := posts.Add("Title", "Description")- not1, err := notifications.Insert(aryaStark, "Hello World", "http://www.google.com.br", idea.ID)+ not1, err := notifications.Insert(aryaStark, "Hello World", "http://www.google.com.br", post.ID)Expect(err).IsNil()- not2, err := notifications.Insert(aryaStark, "Another thing happened", "http://www.google.com.br", idea.ID)+ not2, err := notifications.Insert(aryaStark, "Another thing happened", "http://www.google.com.br", post.ID)Expect(err).IsNil()notifications.SetCurrentUser(aryaStark)@@ -61,14 +61,14 @@ func TestNotificationStorage_GetActiveNotifications(t *testing.T) {SetupDatabaseTest(t)defer TeardownDatabaseTest()- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(jonSnow)+ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(jonSnow)notifications.SetCurrentTenant(demoTenant)notifications.SetCurrentUser(jonSnow)- idea, _ := ideas.Add("Title", "Description")+ post, _ := posts.Add("Title", "Description")- notifications.Insert(aryaStark, "Hello World", "http://www.google.com.br", idea.ID)- notifications.Insert(aryaStark, "Another thing happened", "http://www.google.com.br", idea.ID)+ notifications.Insert(aryaStark, "Hello World", "http://www.google.com.br", post.ID)+ notifications.Insert(aryaStark, "Another thing happened", "http://www.google.com.br", post.ID)notifications.SetCurrentUser(aryaStark)@@ -90,15 +90,15 @@ func TestNotificationStorage_ReadAll(t *testing.T) {SetupDatabaseTest(t)defer TeardownDatabaseTest()- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(jonSnow)+ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(jonSnow)notifications.SetCurrentTenant(demoTenant)notifications.SetCurrentUser(jonSnow)- idea, _ := ideas.Add("Title", "Description")+ post, _ := posts.Add("Title", "Description")- notifications.Insert(aryaStark, "Hello World", "http://www.google.com.br", idea.ID)- notifications.Insert(aryaStark, "Another thing happened", "http://www.google.com.br", idea.ID)+ notifications.Insert(aryaStark, "Hello World", "http://www.google.com.br", post.ID)+ notifications.Insert(aryaStark, "Another thing happened", "http://www.google.com.br", post.ID)notifications.SetCurrentUser(aryaStark)@@ -119,13 +119,13 @@ func TestNotificationStorage_GetNotificationById(t *testing.T) {SetupDatabaseTest(t)defer TeardownDatabaseTest()- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(jonSnow)+ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(jonSnow)notifications.SetCurrentTenant(demoTenant)notifications.SetCurrentUser(jonSnow)- idea, _ := ideas.Add("Title", "Description")+ post, _ := posts.Add("Title", "Description")- not1, err := notifications.Insert(aryaStark, "Hello World", "http://www.google.com.br", idea.ID)+ not1, err := notifications.Insert(aryaStark, "Hello World", "http://www.google.com.br", post.ID)Expect(err).IsNil()notifications.SetCurrentUser(aryaStark)@@ -140,13 +140,13 @@ func TestNotificationStorage_GetNotificationById_OtherUser(t *testing.T) {SetupDatabaseTest(t)defer TeardownDatabaseTest()- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(jonSnow)- idea, _ := ideas.Add("Title", "Description")+ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(jonSnow)+ post, _ := posts.Add("Title", "Description")notifications.SetCurrentTenant(demoTenant)notifications.SetCurrentUser(aryaStark)- not1, err := notifications.Insert(jonSnow, "Hello World", "http://www.google.com.br", idea.ID)+ not1, err := notifications.Insert(jonSnow, "Hello World", "http://www.google.com.br", post.ID)Expect(err).IsNil()not1, err = notifications.GetNotification(not1.ID)diff --git a/app/storage/postgres/idea.go b/app/storage/postgres/post.gosimilarity index 67%rename from app/storage/postgres/idea.gorename to app/storage/postgres/post.goindex 2ef63b9d1..8a462e3fb 100644--- a/app/storage/postgres/idea.go+++ b/app/storage/postgres/post.go@@ -14,7 +14,7 @@ import ("github.com/lib/pq")-type dbIdea struct {+type dbPost struct {ID int `db:"id"`Number int `db:"number"`Title string `db:"title"`@@ -38,8 +38,8 @@ type dbIdea struct {Tags []string `db:"tags"`}-func (i *dbIdea) toModel() *models.Idea {- idea := &models.Idea{+func (i *dbPost) toModel() *models.Post {+ post := &models.Post{ID: i.ID,Number: i.Number,Title: i.Title,@@ -55,13 +55,13 @@ func (i *dbIdea) toModel() *models.Idea {}if i.Response.Valid {- idea.Response = &models.IdeaResponse{+ post.Response = &models.PostResponse{Text: i.Response.String,RespondedOn: i.RespondedOn.Time,User: i.ResponseUser.toModel(),}- if idea.Status == models.IdeaDuplicate && i.OriginalNumber.Valid {- idea.Response.Original = &models.OriginalIdea{+ if post.Status == models.PostDuplicate && i.OriginalNumber.Valid {+ post.Response.Original = &models.OriginalPost{Number: int(i.OriginalNumber.Int64),Slug: i.OriginalSlug.String,Title: i.OriginalTitle.String,@@ -69,7 +69,7 @@ func (i *dbIdea) toModel() *models.Idea {}}}- return idea+ return post}type dbComment struct {@@ -100,32 +100,32 @@ type dbStatusCount struct {Count int `db:"count"`}-// IdeaStorage contains read and write operations for ideas-type IdeaStorage struct {+// PostStorage contains read and write operations for posts+type PostStorage struct {trx *dbx.Trxtenant *models.Tenantuser *models.User}-// NewIdeaStorage creates a new IdeaStorage-func NewIdeaStorage(trx *dbx.Trx) *IdeaStorage {- return &IdeaStorage{+// NewPostStorage creates a new PostStorage+func NewPostStorage(trx *dbx.Trx) *PostStorage {+ return &PostStorage{trx: trx,}}// SetCurrentTenant to current context-func (s *IdeaStorage) SetCurrentTenant(tenant *models.Tenant) {+func (s *PostStorage) SetCurrentTenant(tenant *models.Tenant) {s.tenant = tenant}// SetCurrentUser to current context-func (s *IdeaStorage) SetCurrentUser(user *models.User) {+func (s *PostStorage) SetCurrentUser(user *models.User) {s.user = user}var (- sqlSelectIdeasWhere = ` WITH+ sqlSelectPostsWhere = ` WITHagg_comments AS (SELECTidea_id,@@ -195,11 +195,11 @@ var (ON agg_c.idea_id = i.idLEFT JOIN agg_supporters agg_sON agg_s.idea_id = i.id- WHERE i.status != ` + strconv.Itoa(models.IdeaDeleted) + ` AND %s+ WHERE i.status != ` + strconv.Itoa(models.PostDeleted) + ` AND %sGROUP BY i.id, u.id, r.id, d.id, agg_s.all, agg_c.all, agg_c.recent, agg_s.recent`)-func (s *IdeaStorage) getIdeaQuery(filter string) string {+func (s *PostStorage) getPostQuery(filter string) string {viewerSupportedSubQuery := "null"if s.user != nil {viewerSupportedSubQuery = fmt.Sprintf("(SELECT true FROM idea_supporters WHERE idea_id = i.id AND user_id = %d)", s.user.ID)@@ -208,61 +208,61 @@ func (s *IdeaStorage) getIdeaQuery(filter string) string {if s.user != nil && s.user.IsCollaborator() {tagCondition = ``}- return fmt.Sprintf(sqlSelectIdeasWhere, viewerSupportedSubQuery, tagCondition, filter)+ return fmt.Sprintf(sqlSelectPostsWhere, viewerSupportedSubQuery, tagCondition, filter)}-func (s *IdeaStorage) getSingle(query string, args ...interface{}) (*models.Idea, error) {- idea := dbIdea{}+func (s *PostStorage) getSingle(query string, args ...interface{}) (*models.Post, error) {+ post := dbPost{}- if err := s.trx.Get(&idea, query, args...); err != nil {+ if err := s.trx.Get(&post, query, args...); err != nil {return nil, err}- return idea.toModel(), nil+ return post.toModel(), nil}-// GetByID returns idea by given id-func (s *IdeaStorage) GetByID(ideaID int) (*models.Idea, error) {- idea, err := s.getSingle(s.getIdeaQuery("i.tenant_id = $1 AND i.id = $2"), s.tenant.ID, ideaID)+// GetByID returns post by given id+func (s *PostStorage) GetByID(postID int) (*models.Post, error) {+ post, err := s.getSingle(s.getPostQuery("i.tenant_id = $1 AND i.id = $2"), s.tenant.ID, postID)if err != nil {- return nil, errors.Wrap(err, "failed to get idea with id '%d'", ideaID)+ return nil, errors.Wrap(err, "failed to get post with id '%d'", postID)}- return idea, nil+ return post, nil}-// GetBySlug returns idea by tenant and slug-func (s *IdeaStorage) GetBySlug(slug string) (*models.Idea, error) {- idea, err := s.getSingle(s.getIdeaQuery("i.tenant_id = $1 AND i.slug = $2"), s.tenant.ID, slug)+// GetBySlug returns post by tenant and slug+func (s *PostStorage) GetBySlug(slug string) (*models.Post, error) {+ post, err := s.getSingle(s.getPostQuery("i.tenant_id = $1 AND i.slug = $2"), s.tenant.ID, slug)if err != nil {- return nil, errors.Wrap(err, "failed to get idea with slug '%s'", slug)+ return nil, errors.Wrap(err, "failed to get post with slug '%s'", slug)}- return idea, nil+ return post, nil}-// GetByNumber returns idea by tenant and number-func (s *IdeaStorage) GetByNumber(number int) (*models.Idea, error) {- idea, err := s.getSingle(s.getIdeaQuery("i.tenant_id = $1 AND i.number = $2"), s.tenant.ID, number)+// GetByNumber returns post by tenant and number+func (s *PostStorage) GetByNumber(number int) (*models.Post, error) {+ post, err := s.getSingle(s.getPostQuery("i.tenant_id = $1 AND i.number = $2"), s.tenant.ID, number)if err != nil {- return nil, errors.Wrap(err, "failed to get idea with number '%d'", number)+ return nil, errors.Wrap(err, "failed to get post with number '%d'", number)}- return idea, nil+ return post, nil}-// GetAll returns all tenant ideas-func (s *IdeaStorage) GetAll() ([]*models.Idea, error) {- ideas, err := s.Search("", "all", "all", []string{})+// GetAll returns all tenant posts+func (s *PostStorage) GetAll() ([]*models.Post, error) {+ posts, err := s.Search("", "all", "all", []string{})if err != nil {- return nil, errors.Wrap(err, "failed to get all ideas")+ return nil, errors.Wrap(err, "failed to get all posts")}- return ideas, nil+ return posts, nil}-// CountPerStatus returns total number of ideas per status-func (s *IdeaStorage) CountPerStatus() (map[int]int, error) {+// CountPerStatus returns total number of posts per status+func (s *PostStorage) CountPerStatus() (map[int]int, error) {stats := []*dbStatusCount{}err := s.trx.Select(&stats, "SELECT status, COUNT(*) AS count FROM ideas WHERE tenant_id = $1 GROUP BY status", s.tenant.ID)if err != nil {- return nil, errors.Wrap(err, "failed to count ideas per status")+ return nil, errors.Wrap(err, "failed to count posts per status")}result := make(map[int]int, len(stats))for _, v := range stats {@@ -271,9 +271,9 @@ func (s *IdeaStorage) CountPerStatus() (map[int]int, error) {return result, nil}-// Search existing ideas based on input-func (s *IdeaStorage) Search(query, filter, limit string, tags []string) ([]*models.Idea, error) {- innerQuery := s.getIdeaQuery("i.tenant_id = $1 AND i.status = ANY($2)")+// Search existing posts based on input+func (s *PostStorage) Search(query, filter, limit string, tags []string) ([]*models.Post, error) {+ innerQuery := s.getPostQuery("i.tenant_id = $1 AND i.status = ANY($2)")if limit != "all" {if _, err := strconv.Atoi(limit); err != nil {@@ -282,7 +282,7 @@ func (s *IdeaStorage) Search(query, filter, limit string, tags []string) ([]*mod}var (- ideas []*dbIdea+ posts []*dbPosterr error)if query != "" {@@ -293,12 +293,12 @@ func (s *IdeaStorage) Search(query, filter, limit string, tags []string) ([]*modORDER BY %s DESCLIMIT %s`, innerQuery, scoreField, scoreField, limit)- err = s.trx.Select(&ideas, sql, s.tenant.ID, pq.Array([]int{- models.IdeaOpen,- models.IdeaStarted,- models.IdeaPlanned,- models.IdeaCompleted,- models.IdeaDeclined,+ err = s.trx.Select(&posts, sql, s.tenant.ID, pq.Array([]int{+ models.PostOpen,+ models.PostStarted,+ models.PostPlanned,+ models.PostCompleted,+ models.PostDeclined,}), ToTSQuery(query), query)} else {condition, statuses, sort := getFilterData(filter)@@ -308,22 +308,22 @@ func (s *IdeaStorage) Search(query, filter, limit string, tags []string) ([]*modORDER BY %s DESCLIMIT %s`, innerQuery, condition, sort, limit)- err = s.trx.Select(&ideas, sql, s.tenant.ID, pq.Array(statuses), pq.Array(tags))+ err = s.trx.Select(&posts, sql, s.tenant.ID, pq.Array(statuses), pq.Array(tags))}if err != nil {- return nil, errors.Wrap(err, "failed to search ideas")+ return nil, errors.Wrap(err, "failed to search posts")}- var result = make([]*models.Idea, len(ideas))- for i, idea := range ideas {- result[i] = idea.toModel()+ var result = make([]*models.Post, len(posts))+ for i, post := range posts {+ result[i] = post.toModel()}return result, nil}-// GetCommentsByIdea returns all comments from given idea-func (s *IdeaStorage) GetCommentsByIdea(idea *models.Idea) ([]*models.Comment, error) {+// GetCommentsByPost returns all comments from given post+func (s *PostStorage) GetCommentsByPost(post *models.Post) ([]*models.Comment, error) {comments := []*dbComment{}err := s.trx.Select(&comments,`SELECT c.id,@@ -352,9 +352,9 @@ func (s *IdeaStorage) GetCommentsByIdea(idea *models.Idea) ([]*models.Comment, eAND e.tenant_id = c.tenant_idWHERE i.id = $1AND i.tenant_id = $2- ORDER BY c.created_on ASC`, idea.ID, s.tenant.ID)+ ORDER BY c.created_on ASC`, post.ID, s.tenant.ID)if err != nil {- return nil, errors.Wrap(err, "failed get comments of idea with id '%d'", idea.ID)+ return nil, errors.Wrap(err, "failed get comments of post with id '%d'", post.ID)}var result = make([]*models.Comment, len(comments))@@ -364,54 +364,54 @@ func (s *IdeaStorage) GetCommentsByIdea(idea *models.Idea) ([]*models.Comment, ereturn result, nil}-// Update given idea-func (s *IdeaStorage) Update(idea *models.Idea, title, description string) (*models.Idea, error) {+// Update given post+func (s *PostStorage) Update(post *models.Post, title, description string) (*models.Post, error) {_, err := s.trx.Execute(`UPDATE ideas SET title = $1, slug = $2, description = $3- WHERE id = $4 AND tenant_id = $5`, title, slug.Make(title), description, idea.ID, s.tenant.ID)+ WHERE id = $4 AND tenant_id = $5`, title, slug.Make(title), description, post.ID, s.tenant.ID)if err != nil {- return nil, errors.Wrap(err, "failed update idea")+ return nil, errors.Wrap(err, "failed update post")}- idea.Slug = slug.Make(title)- idea.Title = title- idea.Description = description+ post.Slug = slug.Make(title)+ post.Title = title+ post.Description = description- return idea, nil+ return post, nil}-// Add a new idea in the database-func (s *IdeaStorage) Add(title, description string) (*models.Idea, error) {+// Add a new post in the database+func (s *PostStorage) Add(title, description string) (*models.Post, error) {var id interr := s.trx.Get(&id,`INSERT INTO ideas (title, slug, number, description, tenant_id, user_id, created_on, status)VALUES ($1, $2, (SELECT COALESCE(MAX(number), 0) + 1 FROM ideas i WHERE i.tenant_id = $4), $3, $4, $5, $6, 0)RETURNING id`, title, slug.Make(title), description, s.tenant.ID, s.user.ID, time.Now())if err != nil {- return nil, errors.Wrap(err, "failed add new idea")+ return nil, errors.Wrap(err, "failed add new post")}- idea, err := s.GetByID(id)+ post, err := s.GetByID(id)if err != nil {return nil, err}- if err := s.internalAddSubscriber(idea, s.user, false); err != nil {+ if err := s.internalAddSubscriber(post, s.user, false); err != nil {return nil, err}- return idea, nil+ return post, nil}-// AddComment places a new comment on an idea-func (s *IdeaStorage) AddComment(idea *models.Idea, content string) (int, error) {+// AddComment places a new comment on an post+func (s *PostStorage) AddComment(post *models.Post, content string) (int, error) {var id intif err := s.trx.Get(&id,"INSERT INTO comments (tenant_id, idea_id, content, user_id, created_on) VALUES ($1, $2, $3, $4, $5) RETURNING id",- s.tenant.ID, idea.ID, content, s.user.ID, time.Now()); err != nil {+ s.tenant.ID, post.ID, content, s.user.ID, time.Now()); err != nil {return 0, errors.Wrap(err, "failed add new comment")}- if err := s.internalAddSubscriber(idea, s.user, false); err != nil {+ if err := s.internalAddSubscriber(post, s.user, false); err != nil {return 0, err}@@ -419,7 +419,7 @@ func (s *IdeaStorage) AddComment(idea *models.Idea, content string) (int, error)}// GetCommentByID returns a comment by given ID-func (s *IdeaStorage) GetCommentByID(id int) (*models.Comment, error) {+func (s *PostStorage) GetCommentByID(id int) (*models.Comment, error) {comment := dbComment{}err := s.trx.Get(&comment,`SELECT c.id,@@ -454,7 +454,7 @@ func (s *IdeaStorage) GetCommentByID(id int) (*models.Comment, error) {}// UpdateComment with given ID and content-func (s *IdeaStorage) UpdateComment(id int, content string) error {+func (s *PostStorage) UpdateComment(id int, content string) error {_, err := s.trx.Execute(`UPDATE comments SET content = $1, edited_on = $2, edited_by_id = $3WHERE id = $4 AND tenant_id = $5`, content, time.Now(), s.user.ID, id, s.tenant.ID)@@ -464,43 +464,43 @@ func (s *IdeaStorage) UpdateComment(id int, content string) error {return nil}-// AddSupporter adds user to idea list of supporters-func (s *IdeaStorage) AddSupporter(idea *models.Idea, user *models.User) error {- if !idea.CanBeSupported() {+// AddSupporter adds user to post list of supporters+func (s *PostStorage) AddSupporter(post *models.Post, user *models.User) error {+ if !post.CanBeSupported() {return nil}_, err := s.trx.Execute(`INSERT INTO idea_supporters (tenant_id, user_id, idea_id, created_on) VALUES ($1, $2, $3, $4) ON CONFLICT DO NOTHING`,- s.tenant.ID, user.ID, idea.ID, time.Now())+ s.tenant.ID, user.ID, post.ID, time.Now())if err != nil {- return errors.Wrap(err, "failed add supporter to idea")+ return errors.Wrap(err, "failed add supporter to post")}- return s.internalAddSubscriber(idea, user, false)+ return s.internalAddSubscriber(post, user, false)}-// RemoveSupporter removes user from idea list of supporters-func (s *IdeaStorage) RemoveSupporter(idea *models.Idea, user *models.User) error {- if !idea.CanBeSupported() {+// RemoveSupporter removes user from post list of supporters+func (s *PostStorage) RemoveSupporter(post *models.Post, user *models.User) error {+ if !post.CanBeSupported() {return nil}- _, err := s.trx.Execute(`DELETE FROM idea_supporters WHERE user_id = $1 AND idea_id = $2 AND tenant_id = $3`, user.ID, idea.ID, s.tenant.ID)+ _, err := s.trx.Execute(`DELETE FROM idea_supporters WHERE user_id = $1 AND idea_id = $2 AND tenant_id = $3`, user.ID, post.ID, s.tenant.ID)if err != nil {- return errors.Wrap(err, "failed to delete idea supporter")+ return errors.Wrap(err, "failed to delete post supporter")}return err}-// AddSubscriber adds user to the idea list of subscribers-func (s *IdeaStorage) AddSubscriber(idea *models.Idea, user *models.User) error {- return s.internalAddSubscriber(idea, user, true)+// AddSubscriber adds user to the post list of subscribers+func (s *PostStorage) AddSubscriber(post *models.Post, user *models.User) error {+ return s.internalAddSubscriber(post, user, true)}-func (s *IdeaStorage) internalAddSubscriber(idea *models.Idea, user *models.User, force bool) error {+func (s *PostStorage) internalAddSubscriber(post *models.Post, user *models.User, force bool) error {conflict := " DO NOTHING"if force {conflict = "(user_id, idea_id) DO UPDATE SET status = $5, updated_on = $4"@@ -509,31 +509,31 @@ func (s *IdeaStorage) internalAddSubscriber(idea *models.Idea, user *models.User_, err := s.trx.Execute(fmt.Sprintf(`INSERT INTO idea_subscribers (tenant_id, user_id, idea_id, created_on, updated_on, status)VALUES ($1, $2, $3, $4, $4, $5) ON CONFLICT %s`, conflict),- s.tenant.ID, user.ID, idea.ID, time.Now(), models.SubscriberActive,+ s.tenant.ID, user.ID, post.ID, time.Now(), models.SubscriberActive,)if err != nil {- return errors.Wrap(err, "failed insert idea subscriber")+ return errors.Wrap(err, "failed insert post subscriber")}return nil}-// RemoveSubscriber removes user from idea list of subscribers-func (s *IdeaStorage) RemoveSubscriber(idea *models.Idea, user *models.User) error {+// RemoveSubscriber removes user from post list of subscribers+func (s *PostStorage) RemoveSubscriber(post *models.Post, user *models.User) error {_, err := s.trx.Execute(`INSERT INTO idea_subscribers (tenant_id, user_id, idea_id, created_on, updated_on, status)VALUES ($1, $2, $3, $4, $4, 0) ON CONFLICT (user_id, idea_id)DO UPDATE SET status = 0, updated_on = $4`,- s.tenant.ID, user.ID, idea.ID, time.Now(),+ s.tenant.ID, user.ID, post.ID, time.Now(),)if err != nil {- return errors.Wrap(err, "failed remove idea subscriber")+ return errors.Wrap(err, "failed remove post subscriber")}return nil}// GetActiveSubscribers based on input and settings-func (s *IdeaStorage) GetActiveSubscribers(number int, channel models.NotificationChannel, event models.NotificationEvent) ([]*models.User, error) {- idea, err := s.GetByNumber(number)+func (s *PostStorage) GetActiveSubscribers(number int, channel models.NotificationChannel, event models.NotificationEvent) ([]*models.User, error) {+ post, err := s.GetByNumber(number)if err != nil {return make([]*models.User, 0), err}@@ -579,7 +579,7 @@ func (s *IdeaStorage) GetActiveSubscribers(number int, channel models.Notificati(set.value IS NULL AND u.role = ANY($5))OR CAST(set.value AS integer) & $6 > 0)`,- idea.ID,+ post.ID,models.SubscriberActive,event.UserSettingsKeyName,s.tenant.ID,@@ -591,7 +591,7 @@ func (s *IdeaStorage) GetActiveSubscribers(number int, channel models.Notificati}if err != nil {- return nil, errors.Wrap(err, "failed to get idea number '%d' subscribers", number)+ return nil, errors.Wrap(err, "failed to get post number '%d' subscribers", number)}var result = make([]*models.User, len(users))@@ -601,28 +601,28 @@ func (s *IdeaStorage) GetActiveSubscribers(number int, channel models.Notificatireturn result, nil}-// SetResponse changes current idea response-func (s *IdeaStorage) SetResponse(idea *models.Idea, text string, status int) error {- if status == models.IdeaDuplicate {- return errors.New("Use MarkAsDuplicate to change an idea status to Duplicate")+// SetResponse changes current post response+func (s *PostStorage) SetResponse(post *models.Post, text string, status int) error {+ if status == models.PostDuplicate {+ return errors.New("Use MarkAsDuplicate to change an post status to Duplicate")}respondedOn := time.Now()- if idea.Status == status && idea.Response != nil {- respondedOn = idea.Response.RespondedOn+ if post.Status == status && post.Response != nil {+ respondedOn = post.Response.RespondedOn}_, err := s.trx.Execute(`UPDATE ideasSET response = $3, original_id = NULL, response_date = $4, response_user_id = $5, status = $6WHERE id = $1 and tenant_id = $2- `, idea.ID, s.tenant.ID, text, respondedOn, s.user.ID, status)+ `, post.ID, s.tenant.ID, text, respondedOn, s.user.ID, status)if err != nil {- return errors.Wrap(err, "failed to update idea's response")+ return errors.Wrap(err, "failed to update post's response")}- idea.Status = status- idea.Response = &models.IdeaResponse{+ post.Status = status+ post.Response = &models.PostResponse{Text: text,RespondedOn: respondedOn,User: s.user,@@ -630,17 +630,17 @@ func (s *IdeaStorage) SetResponse(idea *models.Idea, text string, status int) erreturn nil}-// MarkAsDuplicate set idea as a duplicate of another idea-func (s *IdeaStorage) MarkAsDuplicate(idea *models.Idea, original *models.Idea) error {+// MarkAsDuplicate set post as a duplicate of another post+func (s *PostStorage) MarkAsDuplicate(post *models.Post, original *models.Post) error {respondedOn := time.Now()- if idea.Status == models.IdeaDuplicate && idea.Response != nil {- respondedOn = idea.Response.RespondedOn+ if post.Status == models.PostDuplicate && post.Response != nil {+ respondedOn = post.Response.RespondedOn}var users []*dbUser- err := s.trx.Select(&users, "SELECT user_id AS id FROM idea_supporters WHERE idea_id = $1 AND tenant_id = $2", idea.ID, s.tenant.ID)+ err := s.trx.Select(&users, "SELECT user_id AS id FROM idea_supporters WHERE idea_id = $1 AND tenant_id = $2", post.ID, s.tenant.ID)if err != nil {- return errors.Wrap(err, "failed to get supporters of idea with id '%d'", idea.ID)+ return errors.Wrap(err, "failed to get supporters of post with id '%d'", post.ID)}for _, u := range users {@@ -653,16 +653,16 @@ func (s *IdeaStorage) MarkAsDuplicate(idea *models.Idea, original *models.Idea)UPDATE ideasSET response = '', original_id = $3, response_date = $4, response_user_id = $5, status = $6WHERE id = $1 and tenant_id = $2- `, idea.ID, s.tenant.ID, original.ID, respondedOn, s.user.ID, models.IdeaDuplicate)+ `, post.ID, s.tenant.ID, original.ID, respondedOn, s.user.ID, models.PostDuplicate)if err != nil {- return errors.Wrap(err, "failed to update idea's response")+ return errors.Wrap(err, "failed to update post's response")}- idea.Status = models.IdeaDuplicate- idea.Response = &models.IdeaResponse{+ post.Status = models.PostDuplicate+ post.Response = &models.PostResponse{RespondedOn: respondedOn,User: s.user,- Original: &models.OriginalIdea{+ Original: &models.OriginalPost{Number: original.Number,Title: original.Title,Slug: original.Slug,@@ -672,26 +672,26 @@ func (s *IdeaStorage) MarkAsDuplicate(idea *models.Idea, original *models.Idea)return nil}-// IsReferenced returns true if another idea is referencing given idea-func (s *IdeaStorage) IsReferenced(idea *models.Idea) (bool, error) {+// IsReferenced returns true if another post is referencing given post+func (s *PostStorage) IsReferenced(post *models.Post) (bool, error) {exists, err := s.trx.Exists(`SELECT 1 FROM ideas iINNER JOIN ideas oON o.tenant_id = i.tenant_idAND o.id = i.original_idWHERE i.tenant_id = $1- AND o.id = $2`, s.tenant.ID, idea.ID)+ AND o.id = $2`, s.tenant.ID, post.ID)if err != nil {- return false, errors.Wrap(err, "failed to check if idea is referenced")+ return false, errors.Wrap(err, "failed to check if post is referenced")}return exists, nil}-// SupportedBy returns a list of Idea ID supported by given user-func (s *IdeaStorage) SupportedBy() ([]int, error) {- ideas, err := s.trx.QueryIntArray("SELECT idea_id FROM idea_supporters WHERE user_id = $1 AND tenant_id = $2", s.user.ID, s.tenant.ID)+// SupportedBy returns a list of Post ID supported by given user+func (s *PostStorage) SupportedBy() ([]int, error) {+ posts, err := s.trx.QueryIntArray("SELECT idea_id FROM idea_supporters WHERE user_id = $1 AND tenant_id = $2", s.user.ID, s.tenant.ID)if err != nil {- return nil, errors.Wrap(err, "failed to get user's supported ideas")+ return nil, errors.Wrap(err, "failed to get user's supported posts")}- return ideas, nil+ return posts, nil}diff --git a/app/storage/postgres/post_test.go b/app/storage/postgres/post_test.gonew file mode 100644index 000000000..0babb953b--- /dev/null+++ b/app/storage/postgres/post_test.go@@ -0,0 +1,508 @@+package postgres_test++import (+ "testing"+ "time"++ "github.com/getfider/fider/app"+ "github.com/getfider/fider/app/models"+ . "github.com/getfider/fider/app/pkg/assert"+ "github.com/getfider/fider/app/pkg/errors"+)++func TestPostStorage_GetAll(t *testing.T) {+ SetupDatabaseTest(t)+ defer TeardownDatabaseTest()++ now := time.Now()++ trx.Execute("INSERT INTO ideas (title, slug, number, description, created_on, tenant_id, user_id, status) VALUES ('add twitter integration', 'add-twitter-integration', 1, 'Would be great to see it integrated with twitter', $1, 1, 1, 1)", now)+ trx.Execute("INSERT INTO ideas (title, slug, number, description, created_on, tenant_id, user_id, status) VALUES ('this is my post', 'this-is-my-post', 2, 'no description', $1, 1, 2, 2)", now)++ posts.SetCurrentTenant(demoTenant)++ dbPosts, err := posts.GetAll()+ Expect(err).IsNil()+ Expect(dbPosts).HasLen(2)++ Expect(dbPosts[0].Title).Equals("this is my post")+ Expect(dbPosts[0].Slug).Equals("this-is-my-post")+ Expect(dbPosts[0].Number).Equals(2)+ Expect(dbPosts[0].Description).Equals("no description")+ Expect(dbPosts[0].User.Name).Equals("Arya Stark")+ Expect(dbPosts[0].TotalSupporters).Equals(0)+ Expect(dbPosts[0].Status).Equals(models.PostCompleted)++ Expect(dbPosts[1].Title).Equals("add twitter integration")+ Expect(dbPosts[1].Slug).Equals("add-twitter-integration")+ Expect(dbPosts[1].Number).Equals(1)+ Expect(dbPosts[1].Description).Equals("Would be great to see it integrated with twitter")+ Expect(dbPosts[1].User.Name).Equals("Jon Snow")+ Expect(dbPosts[1].TotalSupporters).Equals(0)+ Expect(dbPosts[1].Status).Equals(models.PostStarted)++ dbPosts, err = posts.Search("twitter", "trending", "10", []string{})+ Expect(err).IsNil()+ Expect(dbPosts).HasLen(1)+ Expect(dbPosts[0].Slug).Equals("add-twitter-integration")++ dbPosts, err = posts.Search("twitter", "trending", "0", []string{})+ Expect(err).IsNil()+ Expect(dbPosts).HasLen(0)+}++func TestPostStorage_AddAndGet(t *testing.T) {+ SetupDatabaseTest(t)+ defer TeardownDatabaseTest()++ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(jonSnow)+ post, err := posts.Add("My new post", "with this description")+ Expect(err).IsNil()++ dbPostById, err := posts.GetByID(post.ID)+ Expect(err).IsNil()+ Expect(dbPostById.ID).Equals(post.ID)+ Expect(dbPostById.Number).Equals(1)+ Expect(dbPostById.ViewerSupported).IsFalse()+ Expect(dbPostById.TotalSupporters).Equals(0)+ Expect(dbPostById.Status).Equals(models.PostOpen)+ Expect(dbPostById.Title).Equals("My new post")+ Expect(dbPostById.Description).Equals("with this description")+ Expect(dbPostById.User.ID).Equals(1)+ Expect(dbPostById.User.Name).Equals("Jon Snow")+ Expect(dbPostById.User.Email).Equals("[email protected]")++ dbPostBySlug, err := posts.GetBySlug("my-new-post")++ Expect(err).IsNil()+ Expect(dbPostBySlug.ID).Equals(post.ID)+ Expect(dbPostBySlug.Number).Equals(1)+ Expect(dbPostBySlug.ViewerSupported).IsFalse()+ Expect(dbPostBySlug.TotalSupporters).Equals(0)+ Expect(dbPostBySlug.Status).Equals(models.PostOpen)+ Expect(dbPostBySlug.Title).Equals("My new post")+ Expect(dbPostBySlug.Description).Equals("with this description")+ Expect(dbPostBySlug.User.ID).Equals(1)+ Expect(dbPostBySlug.User.Name).Equals("Jon Snow")+ Expect(dbPostBySlug.User.Email).Equals("[email protected]")+}++func TestPostStorage_GetInvalid(t *testing.T) {+ SetupDatabaseTest(t)+ defer TeardownDatabaseTest()++ posts.SetCurrentTenant(demoTenant)++ dbPost, err := posts.GetByID(1)+ Expect(errors.Cause(err)).Equals(app.ErrNotFound)+ Expect(dbPost).IsNil()+}++func TestPostStorage_AddAndReturnComments(t *testing.T) {+ SetupDatabaseTest(t)+ defer TeardownDatabaseTest()++ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(jonSnow)+ post, err := posts.Add("My new post", "with this description")+ Expect(err).IsNil()++ posts.SetCurrentUser(jonSnow)+ posts.AddComment(post, "Comment #1")+ posts.SetCurrentUser(aryaStark)+ posts.AddComment(post, "Comment #2")++ comments, err := posts.GetCommentsByPost(post)+ Expect(err).IsNil()+ Expect(comments).HasLen(2)++ Expect(comments[0].Content).Equals("Comment #1")+ Expect(comments[0].User.Name).Equals("Jon Snow")+ Expect(comments[1].Content).Equals("Comment #2")+ Expect(comments[1].User.Name).Equals("Arya Stark")+}++func TestPostStorage_AddGetUpdateComment(t *testing.T) {+ SetupDatabaseTest(t)+ defer TeardownDatabaseTest()++ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(jonSnow)+ post, err := posts.Add("My new post", "with this description")+ Expect(err).IsNil()++ commentId, err := posts.AddComment(post, "Comment #1")+ Expect(err).IsNil()++ comment, err := posts.GetCommentByID(commentId)+ Expect(err).IsNil()+ Expect(comment.ID).Equals(commentId)+ Expect(comment.Content).Equals("Comment #1")+ Expect(comment.User.ID).Equals(jonSnow.ID)+ Expect(comment.EditedOn).IsNil()+ Expect(comment.EditedBy).IsNil()++ posts.SetCurrentUser(aryaStark)+ err = posts.UpdateComment(commentId, "Comment #1 with edit")+ Expect(err).IsNil()++ comment, err = posts.GetCommentByID(commentId)+ Expect(err).IsNil()+ Expect(comment.ID).Equals(commentId)+ Expect(comment.Content).Equals("Comment #1 with edit")+ Expect(comment.User.ID).Equals(jonSnow.ID)+ Expect(comment.EditedOn).IsNotNil()+ Expect(comment.EditedBy.ID).Equals(aryaStark.ID)+}++func TestPostStorage_AddAndGet_DifferentTenants(t *testing.T) {+ SetupDatabaseTest(t)+ defer TeardownDatabaseTest()++ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(jonSnow)+ demoPost, err := posts.Add("My new post", "with this description")+ Expect(err).IsNil()++ posts.SetCurrentTenant(avengersTenant)+ posts.SetCurrentUser(tonyStark)+ avengersPost, err := posts.Add("My other post", "with other description")+ Expect(err).IsNil()++ posts.SetCurrentTenant(demoTenant)+ dbPost, err := posts.GetByNumber(1)++ Expect(err).IsNil()+ Expect(dbPost.ID).Equals(demoPost.ID)+ Expect(dbPost.Number).Equals(1)+ Expect(dbPost.Title).Equals("My new post")+ Expect(dbPost.Slug).Equals("my-new-post")++ posts.SetCurrentTenant(avengersTenant)+ dbPost, err = posts.GetByNumber(1)++ Expect(err).IsNil()+ Expect(dbPost.ID).Equals(avengersPost.ID)+ Expect(dbPost.Number).Equals(1)+ Expect(dbPost.Title).Equals("My other post")+ Expect(dbPost.Slug).Equals("my-other-post")+}++func TestPostStorage_Update(t *testing.T) {+ SetupDatabaseTest(t)+ defer TeardownDatabaseTest()++ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(jonSnow)++ post, err := posts.Add("My new post", "with this description")+ Expect(err).IsNil()++ post, err = posts.Update(post, "The new comment", "With the new description")+ Expect(err).IsNil()+ Expect(post.Title).Equals("The new comment")+ Expect(post.Description).Equals("With the new description")+ Expect(post.Slug).Equals("the-new-comment")+}++func TestPostStorage_AddSupporter(t *testing.T) {+ SetupDatabaseTest(t)+ defer TeardownDatabaseTest()++ users.SetCurrentTenant(demoTenant)+ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(jonSnow)++ post, err := posts.Add("My new post", "with this description")+ Expect(err).IsNil()++ err = posts.AddSupporter(post, aryaStark)+ Expect(err).IsNil()++ dbPost, err := posts.GetByNumber(1)+ Expect(dbPost.ViewerSupported).IsFalse()+ Expect(dbPost.TotalSupporters).Equals(1)++ err = posts.AddSupporter(post, jonSnow)+ Expect(err).IsNil()++ dbPost, err = posts.GetByNumber(1)+ Expect(err).IsNil()+ Expect(dbPost.ViewerSupported).IsTrue()+ Expect(dbPost.TotalSupporters).Equals(2)+}++func TestPostStorage_AddSupporter_Twice(t *testing.T) {+ SetupDatabaseTest(t)+ defer TeardownDatabaseTest()++ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(jonSnow)++ post, _ := posts.Add("My new post", "with this description")++ err := posts.AddSupporter(post, jonSnow)+ Expect(err).IsNil()++ err = posts.AddSupporter(post, jonSnow)+ Expect(err).IsNil()++ dbPost, err := posts.GetByNumber(1)+ Expect(err).IsNil()+ Expect(dbPost.TotalSupporters).Equals(1)+}++func TestPostStorage_RemoveSupporter(t *testing.T) {+ SetupDatabaseTest(t)+ defer TeardownDatabaseTest()++ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(jonSnow)++ post, _ := posts.Add("My new post", "with this description")++ err := posts.AddSupporter(post, jonSnow)+ Expect(err).IsNil()++ err = posts.RemoveSupporter(post, jonSnow)+ Expect(err).IsNil()++ dbPost, err := posts.GetByNumber(1)+ Expect(err).IsNil()+ Expect(dbPost.TotalSupporters).Equals(0)+}++func TestPostStorage_RemoveSupporter_Twice(t *testing.T) {+ SetupDatabaseTest(t)+ defer TeardownDatabaseTest()++ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(jonSnow)++ post, _ := posts.Add("My new post", "with this description")++ err := posts.AddSupporter(post, jonSnow)+ Expect(err).IsNil()++ err = posts.RemoveSupporter(post, jonSnow)+ Expect(err).IsNil()++ err = posts.RemoveSupporter(post, jonSnow)+ Expect(err).IsNil()++ dbPost, err := posts.GetByNumber(1)+ Expect(err).IsNil()+ Expect(dbPost.TotalSupporters).Equals(0)+}++func TestPostStorage_SetResponse(t *testing.T) {+ SetupDatabaseTest(t)+ defer TeardownDatabaseTest()++ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(jonSnow)++ post, _ := posts.Add("My new post", "with this description")+ err := posts.SetResponse(post, "We liked this post", models.PostStarted)++ Expect(err).IsNil()++ post, _ = posts.GetByID(post.ID)+ Expect(post.Response.Text).Equals("We liked this post")+ Expect(post.Status).Equals(models.PostStarted)+ Expect(post.Response.User.ID).Equals(1)+}++func TestPostStorage_SetResponse_KeepOpen(t *testing.T) {+ SetupDatabaseTest(t)+ defer TeardownDatabaseTest()++ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(jonSnow)++ post, _ := posts.Add("My new post", "with this description")+ err := posts.SetResponse(post, "We liked this post", models.PostOpen)+ Expect(err).IsNil()+}++func TestPostStorage_SetResponse_ChangeText(t *testing.T) {+ SetupDatabaseTest(t)+ defer TeardownDatabaseTest()++ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(jonSnow)++ post, _ := posts.Add("My new post", "with this description")+ posts.SetResponse(post, "We liked this post", models.PostStarted)+ post, _ = posts.GetByID(post.ID)+ respondedOn := post.Response.RespondedOn++ posts.SetResponse(post, "We liked this post and we'll work on it", models.PostStarted)+ post, _ = posts.GetByID(post.ID)+ Expect(post.Response.RespondedOn).Equals(respondedOn)++ posts.SetResponse(post, "We finished it", models.PostCompleted)+ post, _ = posts.GetByID(post.ID)+ Expect(post.Response.RespondedOn).TemporarilySimilar(respondedOn, time.Second)+}++func TestPostStorage_SetResponse_AsDuplicate(t *testing.T) {+ SetupDatabaseTest(t)+ defer TeardownDatabaseTest()++ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(jonSnow)++ post1, _ := posts.Add("My new post", "with this description")+ posts.AddSupporter(post1, jonSnow)++ posts.SetCurrentUser(aryaStark)+ post2, _ := posts.Add("My other post", "with similar description")+ posts.AddSupporter(post2, aryaStark)++ posts.SetCurrentUser(jonSnow)+ posts.MarkAsDuplicate(post2, post1)+ post1, _ = posts.GetByID(post1.ID)++ Expect(post1.TotalSupporters).Equals(2)+ Expect(post1.Status).Equals(models.PostOpen)+ Expect(post1.Response).IsNil()++ post2, _ = posts.GetByID(post2.ID)++ Expect(post2.Response.Text).Equals("")+ Expect(post2.TotalSupporters).Equals(1)+ Expect(post2.Status).Equals(models.PostDuplicate)+ Expect(post2.Response.User.ID).Equals(1)+ Expect(post2.Response.Original.Number).Equals(post1.Number)+ Expect(post2.Response.Original.Title).Equals(post1.Title)+ Expect(post2.Response.Original.Slug).Equals(post1.Slug)+ Expect(post2.Response.Original.Status).Equals(post1.Status)+}++func TestPostStorage_SetResponse_AsDeleted(t *testing.T) {+ SetupDatabaseTest(t)+ defer TeardownDatabaseTest()++ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(jonSnow)+ post, err := posts.Add("My new post", "with this description")+ Expect(err).IsNil()++ posts.SetResponse(post, "Spam!", models.PostDeleted)++ post1, err := posts.GetByNumber(post.Number)+ Expect(errors.Cause(err)).Equals(app.ErrNotFound)+ Expect(post1).IsNil()++ post2, err := posts.GetByID(post.ID)+ Expect(errors.Cause(err)).Equals(app.ErrNotFound)+ Expect(post2).IsNil()+}++func TestPostStorage_AddSupporter_ClosedPost(t *testing.T) {+ SetupDatabaseTest(t)+ defer TeardownDatabaseTest()++ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(jonSnow)+ post, _ := posts.Add("My new post", "with this description")+ posts.SetResponse(post, "We liked this post", models.PostCompleted)+ posts.AddSupporter(post, jonSnow)++ dbPost, err := posts.GetByNumber(post.Number)+ Expect(err).IsNil()+ Expect(dbPost.TotalSupporters).Equals(0)+}++func TestPostStorage_RemoveSupporter_ClosedPost(t *testing.T) {+ SetupDatabaseTest(t)+ defer TeardownDatabaseTest()++ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(jonSnow)+ post, _ := posts.Add("My new post", "with this description")+ posts.AddSupporter(post, jonSnow)+ posts.SetResponse(post, "We liked this post", models.PostCompleted)+ posts.RemoveSupporter(post, jonSnow)++ dbPost, err := posts.GetByNumber(post.Number)+ Expect(err).IsNil()+ Expect(dbPost.TotalSupporters).Equals(1)+}++func TestPostStorage_ListSupportedPosts(t *testing.T) {+ SetupDatabaseTest(t)+ defer TeardownDatabaseTest()++ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(jonSnow)+ post1, _ := posts.Add("My new post", "with this description")+ post2, _ := posts.Add("My other post", "with better description")+ posts.AddSupporter(post1, aryaStark)+ posts.AddSupporter(post2, aryaStark)++ posts.SetCurrentUser(jonSnow)+ arr, err := posts.SupportedBy()+ Expect(err).IsNil()+ Expect(arr).Equals([]int{})++ posts.SetCurrentUser(aryaStark)+ arr, err = posts.SupportedBy()+ Expect(err).IsNil()+ Expect(arr).Equals([]int{post1.ID, post2.ID})+}++func TestPostStorage_WithTags(t *testing.T) {+ SetupDatabaseTest(t)+ defer TeardownDatabaseTest()++ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(aryaStark)+ tags.SetCurrentTenant(demoTenant)+ tags.SetCurrentUser(jonSnow)++ post, _ := posts.Add("My new post", "with this description")+ bug, _ := tags.Add("Bug", "FF0000", true)+ featureRequest, _ := tags.Add("Feature Request", "00FF00", false)++ tags.AssignTag(bug, post)+ tags.AssignTag(featureRequest, post)++ post, _ = posts.GetByID(post.ID)+ Expect(post.Tags).HasLen(1)+ Expect(post.Tags[0]).Equals(bug.Slug)++ posts.SetCurrentUser(jonSnow)+ post, _ = posts.GetByID(post.ID)+ Expect(post.Tags).HasLen(2)+ Expect(post.Tags[0]).Equals(bug.Slug)+ Expect(post.Tags[1]).Equals(featureRequest.Slug)+}++func TestPostStorage_IsReferenced(t *testing.T) {+ SetupDatabaseTest(t)+ defer TeardownDatabaseTest()++ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(jonSnow)+ post1, _ := posts.Add("My first post", "with this description")+ post2, _ := posts.Add("My second post", "with this description")+ post3, _ := posts.Add("My third post", "with this description")++ posts.MarkAsDuplicate(post2, post3)+ posts.MarkAsDuplicate(post3, post1)++ referenced, err := posts.IsReferenced(post1)+ Expect(referenced).IsTrue()+ Expect(err).IsNil()++ referenced, err = posts.IsReferenced(post2)+ Expect(referenced).IsFalse()+ Expect(err).IsNil()++ referenced, err = posts.IsReferenced(post3)+ Expect(referenced).IsTrue()+ Expect(err).IsNil()+}diff --git a/app/storage/postgres/setup_test.go b/app/storage/postgres/setup_test.goindex d390b45ea..e5bb00d5a 100644--- a/app/storage/postgres/setup_test.go+++ b/app/storage/postgres/setup_test.go@@ -15,7 +15,7 @@ var trx *dbx.Trxvar tenants *postgres.TenantStoragevar users *postgres.UserStorage-var ideas *postgres.IdeaStorage+var posts *postgres.PostStoragevar tags *postgres.TagStoragevar notifications *postgres.NotificationStorage@@ -33,7 +33,7 @@ func SetupDatabaseTest(t *testing.T) {tenants = postgres.NewTenantStorage(trx)users = postgres.NewUserStorage(trx)- ideas = postgres.NewIdeaStorage(trx)+ posts = postgres.NewPostStorage(trx)tags = postgres.NewTagStorage(trx)notifications = postgres.NewNotificationStorage(trx)diff --git a/app/storage/postgres/subscription_test.go b/app/storage/postgres/subscription_test.goindex b1fb59b3d..c08d14fe7 100644--- a/app/storage/postgres/subscription_test.go+++ b/app/storage/postgres/subscription_test.go@@ -12,44 +12,44 @@ func TestSubscription_NoSettings(t *testing.T) {SetupDatabaseTest(t)defer TeardownDatabaseTest()- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(aryaStark)- idea1, _ := ideas.Add("Idea #1", "Description #1")+ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(aryaStark)+ post1, _ := posts.Add("Post #1", "Description #1")- subscribers, err := ideas.GetActiveSubscribers(idea1.Number, models.NotificationChannelWeb, models.NotificationEventNewIdea)+ subscribers, err := posts.GetActiveSubscribers(post1.Number, models.NotificationChannelWeb, models.NotificationEventNewPost)Expect(err).IsNil()Expect(subscribers).HasLen(1)Expect(subscribers[0].ID).Equals(jonSnow.ID)- subscribers, err = ideas.GetActiveSubscribers(idea1.Number, models.NotificationChannelWeb, models.NotificationEventNewComment)+ subscribers, err = posts.GetActiveSubscribers(post1.Number, models.NotificationChannelWeb, models.NotificationEventNewComment)Expect(err).IsNil()Expect(subscribers).HasLen(2)Expect(subscribers[0].ID).Equals(jonSnow.ID)Expect(subscribers[1].ID).Equals(aryaStark.ID)- subscribers, err = ideas.GetActiveSubscribers(idea1.Number, models.NotificationChannelWeb, models.NotificationEventChangeStatus)+ subscribers, err = posts.GetActiveSubscribers(post1.Number, models.NotificationChannelWeb, models.NotificationEventChangeStatus)Expect(err).IsNil()Expect(subscribers).HasLen(2)Expect(subscribers[0].ID).Equals(jonSnow.ID)Expect(subscribers[1].ID).Equals(aryaStark.ID)users.SetCurrentUser(nil)- subscribed, err := users.HasSubscribedTo(idea1.ID)+ subscribed, err := users.HasSubscribedTo(post1.ID)Expect(err).IsNil()Expect(subscribed).IsFalse()users.SetCurrentUser(jonSnow)- subscribed, err = users.HasSubscribedTo(idea1.ID)+ subscribed, err = users.HasSubscribedTo(post1.ID)Expect(err).IsNil()Expect(subscribed).IsTrue()users.SetCurrentUser(aryaStark)- subscribed, err = users.HasSubscribedTo(idea1.ID)+ subscribed, err = users.HasSubscribedTo(post1.ID)Expect(err).IsNil()Expect(subscribed).IsTrue()users.SetCurrentUser(sansaStark)- subscribed, err = users.HasSubscribedTo(idea1.ID)+ subscribed, err = users.HasSubscribedTo(post1.ID)Expect(err).IsNil()Expect(subscribed).IsFalse()@@ -59,39 +59,39 @@ func TestSubscription_RemoveSubscriber(t *testing.T) {SetupDatabaseTest(t)defer TeardownDatabaseTest()- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(aryaStark)- idea1, _ := ideas.Add("Idea #1", "Description #1")- err := ideas.RemoveSubscriber(idea1, aryaStark)+ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(aryaStark)+ post1, _ := posts.Add("Post #1", "Description #1")+ err := posts.RemoveSubscriber(post1, aryaStark)Expect(err).IsNil()- subscribers, err := ideas.GetActiveSubscribers(idea1.Number, models.NotificationChannelWeb, models.NotificationEventNewIdea)+ subscribers, err := posts.GetActiveSubscribers(post1.Number, models.NotificationChannelWeb, models.NotificationEventNewPost)Expect(err).IsNil()Expect(subscribers).HasLen(1)Expect(subscribers[0].ID).Equals(jonSnow.ID)- subscribers, err = ideas.GetActiveSubscribers(idea1.Number, models.NotificationChannelWeb, models.NotificationEventNewComment)+ subscribers, err = posts.GetActiveSubscribers(post1.Number, models.NotificationChannelWeb, models.NotificationEventNewComment)Expect(err).IsNil()Expect(subscribers).HasLen(1)Expect(subscribers[0].ID).Equals(jonSnow.ID)- subscribers, err = ideas.GetActiveSubscribers(idea1.Number, models.NotificationChannelWeb, models.NotificationEventChangeStatus)+ subscribers, err = posts.GetActiveSubscribers(post1.Number, models.NotificationChannelWeb, models.NotificationEventChangeStatus)Expect(err).IsNil()Expect(subscribers).HasLen(1)Expect(subscribers[0].ID).Equals(jonSnow.ID)users.SetCurrentUser(jonSnow)- subscribed, err := users.HasSubscribedTo(idea1.ID)+ subscribed, err := users.HasSubscribedTo(post1.ID)Expect(err).IsNil()Expect(subscribed).IsTrue()users.SetCurrentUser(aryaStark)- subscribed, err = users.HasSubscribedTo(idea1.ID)+ subscribed, err = users.HasSubscribedTo(post1.ID)Expect(err).IsNil()Expect(subscribed).IsFalse()users.SetCurrentUser(sansaStark)- subscribed, err = users.HasSubscribedTo(idea1.ID)+ subscribed, err = users.HasSubscribedTo(post1.ID)Expect(err).IsNil()Expect(subscribed).IsFalse()}@@ -100,38 +100,38 @@ func TestSubscription_AdminSubmitted(t *testing.T) {SetupDatabaseTest(t)defer TeardownDatabaseTest()- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(jonSnow)+ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(jonSnow)- idea1, _ := ideas.Add("Idea #1", "Description #1")+ post1, _ := posts.Add("Post #1", "Description #1")- subscribers, err := ideas.GetActiveSubscribers(idea1.Number, models.NotificationChannelWeb, models.NotificationEventNewIdea)+ subscribers, err := posts.GetActiveSubscribers(post1.Number, models.NotificationChannelWeb, models.NotificationEventNewPost)Expect(err).IsNil()Expect(subscribers).HasLen(1)Expect(subscribers[0].ID).Equals(jonSnow.ID)- subscribers, err = ideas.GetActiveSubscribers(idea1.Number, models.NotificationChannelWeb, models.NotificationEventNewComment)+ subscribers, err = posts.GetActiveSubscribers(post1.Number, models.NotificationChannelWeb, models.NotificationEventNewComment)Expect(err).IsNil()Expect(subscribers).HasLen(1)Expect(subscribers[0].ID).Equals(jonSnow.ID)- subscribers, err = ideas.GetActiveSubscribers(idea1.Number, models.NotificationChannelWeb, models.NotificationEventChangeStatus)+ subscribers, err = posts.GetActiveSubscribers(post1.Number, models.NotificationChannelWeb, models.NotificationEventChangeStatus)Expect(err).IsNil()Expect(subscribers).HasLen(1)Expect(subscribers[0].ID).Equals(jonSnow.ID)users.SetCurrentUser(jonSnow)- subscribed, err := users.HasSubscribedTo(idea1.ID)+ subscribed, err := users.HasSubscribedTo(post1.ID)Expect(err).IsNil()Expect(subscribed).IsTrue()users.SetCurrentUser(aryaStark)- subscribed, err = users.HasSubscribedTo(idea1.ID)+ subscribed, err = users.HasSubscribedTo(post1.ID)Expect(err).IsNil()Expect(subscribed).IsFalse()users.SetCurrentUser(sansaStark)- subscribed, err = users.HasSubscribedTo(idea1.ID)+ subscribed, err = users.HasSubscribedTo(post1.ID)Expect(err).IsNil()Expect(subscribed).IsFalse()}@@ -140,29 +140,29 @@ func TestSubscription_AdminUnsubscribed(t *testing.T) {SetupDatabaseTest(t)defer TeardownDatabaseTest()- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(aryaStark)+ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(aryaStark)- idea1, _ := ideas.Add("Idea #1", "Description #1")- ideas.RemoveSubscriber(idea1, aryaStark)- ideas.RemoveSubscriber(idea1, jonSnow)+ post1, _ := posts.Add("Post #1", "Description #1")+ posts.RemoveSubscriber(post1, aryaStark)+ posts.RemoveSubscriber(post1, jonSnow)- subscribers, err := ideas.GetActiveSubscribers(idea1.Number, models.NotificationChannelWeb, models.NotificationEventNewComment)+ subscribers, err := posts.GetActiveSubscribers(post1.Number, models.NotificationChannelWeb, models.NotificationEventNewComment)Expect(err).IsNil()Expect(subscribers).HasLen(0)users.SetCurrentUser(jonSnow)- subscribed, err := users.HasSubscribedTo(idea1.ID)+ subscribed, err := users.HasSubscribedTo(post1.ID)Expect(err).IsNil()Expect(subscribed).IsFalse()users.SetCurrentUser(aryaStark)- subscribed, err = users.HasSubscribedTo(idea1.ID)+ subscribed, err = users.HasSubscribedTo(post1.ID)Expect(err).IsNil()Expect(subscribed).IsFalse()users.SetCurrentUser(sansaStark)- subscribed, err = users.HasSubscribedTo(idea1.ID)+ subscribed, err = users.HasSubscribedTo(post1.ID)Expect(err).IsNil()Expect(subscribed).IsFalse()}@@ -171,8 +171,8 @@ func TestSubscription_DisabledEmail(t *testing.T) {SetupDatabaseTest(t)defer TeardownDatabaseTest()- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(aryaStark)+ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(aryaStark)users.SetCurrentTenant(demoTenant)users.SetCurrentUser(aryaStark)@@ -181,64 +181,64 @@ func TestSubscription_DisabledEmail(t *testing.T) {})Expect(err).IsNil()- idea1, _ := ideas.Add("Idea #1", "Description #1")+ post1, _ := posts.Add("Post #1", "Description #1")- subscribers, err := ideas.GetActiveSubscribers(idea1.Number, models.NotificationChannelWeb, models.NotificationEventNewComment)+ subscribers, err := posts.GetActiveSubscribers(post1.Number, models.NotificationChannelWeb, models.NotificationEventNewComment)Expect(err).IsNil()Expect(subscribers).HasLen(2)Expect(subscribers[0].ID).Equals(jonSnow.ID)Expect(subscribers[1].ID).Equals(aryaStark.ID)- subscribers, err = ideas.GetActiveSubscribers(idea1.Number, models.NotificationChannelEmail, models.NotificationEventNewComment)+ subscribers, err = posts.GetActiveSubscribers(post1.Number, models.NotificationChannelEmail, models.NotificationEventNewComment)Expect(err).IsNil()Expect(subscribers).HasLen(1)Expect(subscribers[0].ID).Equals(jonSnow.ID)- subscribers, err = ideas.GetActiveSubscribers(idea1.Number, models.NotificationChannelWeb, models.NotificationEventChangeStatus)+ subscribers, err = posts.GetActiveSubscribers(post1.Number, models.NotificationChannelWeb, models.NotificationEventChangeStatus)Expect(err).IsNil()Expect(subscribers).HasLen(2)Expect(subscribers[0].ID).Equals(jonSnow.ID)Expect(subscribers[1].ID).Equals(aryaStark.ID)users.SetCurrentUser(jonSnow)- subscribed, err := users.HasSubscribedTo(idea1.ID)+ subscribed, err := users.HasSubscribedTo(post1.ID)Expect(err).IsNil()Expect(subscribed).IsTrue()users.SetCurrentUser(aryaStark)- subscribed, err = users.HasSubscribedTo(idea1.ID)+ subscribed, err = users.HasSubscribedTo(post1.ID)Expect(err).IsNil()Expect(subscribed).IsTrue()users.SetCurrentUser(sansaStark)- subscribed, err = users.HasSubscribedTo(idea1.ID)+ subscribed, err = users.HasSubscribedTo(post1.ID)Expect(err).IsNil()Expect(subscribed).IsFalse()}-func TestSubscription_VisitorEnabledNewIdea(t *testing.T) {+func TestSubscription_VisitorEnabledNewPost(t *testing.T) {SetupDatabaseTest(t)defer TeardownDatabaseTest()- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(jonSnow)+ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(jonSnow)users.SetCurrentTenant(demoTenant)users.SetCurrentUser(aryaStark)err := users.UpdateSettings(map[string]string{- models.NotificationEventNewIdea.UserSettingsKeyName: strconv.Itoa(int(models.NotificationChannelEmail | models.NotificationChannelWeb)),+ models.NotificationEventNewPost.UserSettingsKeyName: strconv.Itoa(int(models.NotificationChannelEmail | models.NotificationChannelWeb)),})Expect(err).IsNil()- idea1, _ := ideas.Add("Idea #1", "Description #1")+ post1, _ := posts.Add("Post #1", "Description #1")- subscribers, err := ideas.GetActiveSubscribers(idea1.Number, models.NotificationChannelWeb, models.NotificationEventNewIdea)+ subscribers, err := posts.GetActiveSubscribers(post1.Number, models.NotificationChannelWeb, models.NotificationEventNewPost)Expect(err).IsNil()Expect(subscribers).HasLen(2)Expect(subscribers[0].ID).Equals(jonSnow.ID)Expect(subscribers[1].ID).Equals(aryaStark.ID)- subscribers, err = ideas.GetActiveSubscribers(idea1.Number, models.NotificationChannelEmail, models.NotificationEventNewIdea)+ subscribers, err = posts.GetActiveSubscribers(post1.Number, models.NotificationChannelEmail, models.NotificationEventNewPost)Expect(err).IsNil()Expect(subscribers).HasLen(2)Expect(subscribers[0].ID).Equals(jonSnow.ID)@@ -249,11 +249,11 @@ func TestSubscription_DisabledEverything(t *testing.T) {SetupDatabaseTest(t)defer TeardownDatabaseTest()- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(jonSnow)+ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(jonSnow)users.SetCurrentTenant(demoTenant)disableAll := map[string]string{- models.NotificationEventNewIdea.UserSettingsKeyName: "0",+ models.NotificationEventNewPost.UserSettingsKeyName: "0",models.NotificationEventNewComment.UserSettingsKeyName: "0",models.NotificationEventChangeStatus.UserSettingsKeyName: "0",}@@ -262,29 +262,29 @@ func TestSubscription_DisabledEverything(t *testing.T) {users.SetCurrentUser(aryaStark)Expect(users.UpdateSettings(disableAll)).IsNil()- idea1, _ := ideas.Add("Idea #1", "Description #1")+ post1, _ := posts.Add("Post #1", "Description #1")- subscribers, err := ideas.GetActiveSubscribers(idea1.Number, models.NotificationChannelWeb, models.NotificationEventNewIdea)+ subscribers, err := posts.GetActiveSubscribers(post1.Number, models.NotificationChannelWeb, models.NotificationEventNewPost)Expect(err).IsNil()Expect(subscribers).HasLen(0)- subscribers, err = ideas.GetActiveSubscribers(idea1.Number, models.NotificationChannelWeb, models.NotificationEventNewComment)+ subscribers, err = posts.GetActiveSubscribers(post1.Number, models.NotificationChannelWeb, models.NotificationEventNewComment)Expect(err).IsNil()Expect(subscribers).HasLen(0)- subscribers, err = ideas.GetActiveSubscribers(idea1.Number, models.NotificationChannelWeb, models.NotificationEventChangeStatus)+ subscribers, err = posts.GetActiveSubscribers(post1.Number, models.NotificationChannelWeb, models.NotificationEventChangeStatus)Expect(err).IsNil()Expect(subscribers).HasLen(0)- subscribers, err = ideas.GetActiveSubscribers(idea1.Number, models.NotificationChannelEmail, models.NotificationEventNewIdea)+ subscribers, err = posts.GetActiveSubscribers(post1.Number, models.NotificationChannelEmail, models.NotificationEventNewPost)Expect(err).IsNil()Expect(subscribers).HasLen(0)- subscribers, err = ideas.GetActiveSubscribers(idea1.Number, models.NotificationChannelEmail, models.NotificationEventNewComment)+ subscribers, err = posts.GetActiveSubscribers(post1.Number, models.NotificationChannelEmail, models.NotificationEventNewComment)Expect(err).IsNil()Expect(subscribers).HasLen(0)- subscribers, err = ideas.GetActiveSubscribers(idea1.Number, models.NotificationChannelEmail, models.NotificationEventChangeStatus)+ subscribers, err = posts.GetActiveSubscribers(post1.Number, models.NotificationChannelEmail, models.NotificationEventChangeStatus)Expect(err).IsNil()Expect(subscribers).HasLen(0)}diff --git a/app/storage/postgres/tag.go b/app/storage/postgres/tag.goindex 5dbcc6f8e..cffed20fc 100644--- a/app/storage/postgres/tag.go+++ b/app/storage/postgres/tag.go@@ -97,7 +97,7 @@ func (s *TagStorage) Update(tag *models.Tag, name, color string, isPublic bool)func (s *TagStorage) Delete(tag *models.Tag) error {_, err := s.trx.Execute(`DELETE FROM idea_tags WHERE tag_id = $1 AND tenant_id = $2`, tag.ID, s.tenant.ID)if err != nil {- return errors.Wrap(err, "failed to remove tag with id '%d' from all ideas", tag.ID)+ return errors.Wrap(err, "failed to remove tag with id '%d' from all posts", tag.ID)}_, err = s.trx.Execute(`DELETE FROM tags WHERE id = $1 AND tenant_id = $2`, tag.ID, s.tenant.ID)@@ -107,9 +107,9 @@ func (s *TagStorage) Delete(tag *models.Tag) error {return nil}-// AssignTag adds a tag to an idea-func (s *TagStorage) AssignTag(tag *models.Tag, idea *models.Idea) error {- alreadyAssigned, err := s.trx.Exists("SELECT 1 FROM idea_tags WHERE idea_id = $1 AND tag_id = $2 AND tenant_id = $3", idea.ID, tag.ID, s.tenant.ID)+// AssignTag adds a tag to an post+func (s *TagStorage) AssignTag(tag *models.Tag, post *models.Post) error {+ alreadyAssigned, err := s.trx.Exists("SELECT 1 FROM idea_tags WHERE idea_id = $1 AND tag_id = $2 AND tenant_id = $3", post.ID, tag.ID, s.tenant.ID)if err != nil {return errors.Wrap(err, "failed to check if tag is already assigned")}@@ -120,30 +120,30 @@ func (s *TagStorage) AssignTag(tag *models.Tag, idea *models.Idea) error {_, err = s.trx.Execute(`INSERT INTO idea_tags (tag_id, idea_id, created_on, created_by_id, tenant_id) VALUES ($1, $2, $3, $4, $5)`,- tag.ID, idea.ID, time.Now(), s.user.ID, s.tenant.ID,+ tag.ID, post.ID, time.Now(), s.user.ID, s.tenant.ID,)if err != nil {- return errors.Wrap(err, "failed to assign tag to idea")+ return errors.Wrap(err, "failed to assign tag to post")}return nil}-// UnassignTag removes a tag from an idea-func (s *TagStorage) UnassignTag(tag *models.Tag, idea *models.Idea) error {+// UnassignTag removes a tag from an post+func (s *TagStorage) UnassignTag(tag *models.Tag, post *models.Post) error {_, err := s.trx.Execute(`DELETE FROM idea_tags WHERE tag_id = $1 AND idea_id = $2 AND tenant_id = $3`,- tag.ID, idea.ID, s.tenant.ID,+ tag.ID, post.ID, s.tenant.ID,)if err != nil {- return errors.Wrap(err, "failed to unassign tag from idea")+ return errors.Wrap(err, "failed to unassign tag from post")}return nil}-// GetAssigned returns all tags assigned to given idea-func (s *TagStorage) GetAssigned(idea *models.Idea) ([]*models.Tag, error) {+// GetAssigned returns all tags assigned to given post+func (s *TagStorage) GetAssigned(post *models.Post) ([]*models.Tag, error) {tags, err := s.getTags(`SELECT t.id, t.name, t.slug, t.color, t.is_publicFROM tags t@@ -152,7 +152,7 @@ func (s *TagStorage) GetAssigned(idea *models.Idea) ([]*models.Tag, error) {AND it.tenant_id = t.tenant_idWHERE it.idea_id = $1 AND t.tenant_id = $2ORDER BY t.name- `, idea.ID, s.tenant.ID)+ `, post.ID, s.tenant.ID)if err != nil {return nil, errors.Wrap(err, "failed get assigned tags")diff --git a/app/storage/postgres/tag_test.go b/app/storage/postgres/tag_test.goindex 9d381ba69..de77bb59f 100644--- a/app/storage/postgres/tag_test.go+++ b/app/storage/postgres/tag_test.go@@ -65,18 +65,18 @@ func TestTagStorage_Assign_Unassign(t *testing.T) {SetupDatabaseTest(t)defer TeardownDatabaseTest()- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(aryaStark)+ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(aryaStark)tags.SetCurrentTenant(demoTenant)tags.SetCurrentUser(aryaStark)- idea, _ := ideas.Add("My great idea", "with a great description")+ post, _ := posts.Add("My great post", "with a great description")tag, _ := tags.Add("Bug", "FFFFFF", true)- err := tags.AssignTag(tag, idea)+ err := tags.AssignTag(tag, post)Expect(err).IsNil()- assigned, err := tags.GetAssigned(idea)+ assigned, err := tags.GetAssigned(post)Expect(err).IsNil()Expect(assigned).HasLen(1)Expect(assigned[0].ID).Equals(tag.ID)@@ -85,10 +85,10 @@ func TestTagStorage_Assign_Unassign(t *testing.T) {Expect(assigned[0].Color).Equals("FFFFFF")Expect(assigned[0].IsPublic).IsTrue()- err = tags.UnassignTag(tag, idea)+ err = tags.UnassignTag(tag, post)Expect(err).IsNil()- assigned, err = tags.GetAssigned(idea)+ assigned, err = tags.GetAssigned(post)Expect(err).IsNil()Expect(assigned).HasLen(0)}@@ -97,21 +97,21 @@ func TestTagStorage_Assign_DeleteTag(t *testing.T) {SetupDatabaseTest(t)defer TeardownDatabaseTest()- ideas.SetCurrentTenant(demoTenant)- ideas.SetCurrentUser(aryaStark)+ posts.SetCurrentTenant(demoTenant)+ posts.SetCurrentUser(aryaStark)tags.SetCurrentTenant(demoTenant)tags.SetCurrentUser(aryaStark)- idea, _ := ideas.Add("My great idea", "with a great description")+ post, _ := posts.Add("My great post", "with a great description")tag, _ := tags.Add("Bug", "FFFFFF", true)- err := tags.AssignTag(tag, idea)+ err := tags.AssignTag(tag, post)Expect(err).IsNil()err = tags.Delete(tag)Expect(err).IsNil()- assigned, err := tags.GetAssigned(idea)+ assigned, err := tags.GetAssigned(post)Expect(err).IsNil()Expect(assigned).HasLen(0)}diff --git a/app/storage/postgres/user.go b/app/storage/postgres/user.goindex 0c7b1f23d..0712ad9d2 100644--- a/app/storage/postgres/user.go+++ b/app/storage/postgres/user.go@@ -254,14 +254,14 @@ func (s *UserStorage) GetAll() ([]*models.User, error) {return result, nil}-// HasSubscribedTo returns true if current user is receiving notification from specific idea-func (s *UserStorage) HasSubscribedTo(ideaID int) (bool, error) {+// HasSubscribedTo returns true if current user is receiving notification from specific post+func (s *UserStorage) HasSubscribedTo(postID int) (bool, error) {if s.user == nil {return false, nil}var status int- err := s.trx.Scalar(&status, "SELECT status FROM idea_subscribers WHERE user_id = $1 AND idea_id = $2", s.user.ID, ideaID)+ err := s.trx.Scalar(&status, "SELECT status FROM idea_subscribers WHERE user_id = $1 AND idea_id = $2", s.user.ID, postID)if err != nil && errors.Cause(err) != app.ErrNotFound {return false, errors.Wrap(err, "failed to get subscription status")}diff --git a/app/storage/postgres/user_test.go b/app/storage/postgres/user_test.goindex efd4214ae..a75856943 100644--- a/app/storage/postgres/user_test.go+++ b/app/storage/postgres/user_test.go@@ -267,7 +267,7 @@ func TestUserStorage_DefaultUserSettings(t *testing.T) {users.SetCurrentUser(jonSnow)settings, _ := users.GetUserSettings()Expect(settings).Equals(map[string]string{- models.NotificationEventNewIdea.UserSettingsKeyName: models.NotificationEventNewIdea.DefaultSettingValue,+ models.NotificationEventNewPost.UserSettingsKeyName: models.NotificationEventNewPost.DefaultSettingValue,models.NotificationEventNewComment.UserSettingsKeyName: models.NotificationEventNewComment.DefaultSettingValue,models.NotificationEventChangeStatus.UserSettingsKeyName: models.NotificationEventChangeStatus.DefaultSettingValue,})@@ -287,14 +287,14 @@ func TestUserStorage_SaveGetUserSettings(t *testing.T) {users.SetCurrentTenant(demoTenant)users.SetCurrentUser(aryaStark)disableAll := map[string]string{- models.NotificationEventNewIdea.UserSettingsKeyName: "0",+ models.NotificationEventNewPost.UserSettingsKeyName: "0",models.NotificationEventChangeStatus.UserSettingsKeyName: "0",}users.UpdateSettings(disableAll)settings, _ := users.GetUserSettings()Expect(settings).Equals(map[string]string{- models.NotificationEventNewIdea.UserSettingsKeyName: "0",+ models.NotificationEventNewPost.UserSettingsKeyName: "0",models.NotificationEventNewComment.UserSettingsKeyName: models.NotificationEventNewComment.DefaultSettingValue,models.NotificationEventChangeStatus.UserSettingsKeyName: "0",})diff --git a/app/storage/storage.go b/app/storage/storage.goindex 803c4dc88..b1ee98511 100644--- a/app/storage/storage.go+++ b/app/storage/storage.go@@ -12,29 +12,29 @@ type Base interface {SetCurrentUser(*models.User)}-// Idea contains read and write operations for ideas-type Idea interface {+// Post contains read and write operations for posts+type Post interface {Base- GetByID(ideaID int) (*models.Idea, error)- GetBySlug(slug string) (*models.Idea, error)- GetByNumber(number int) (*models.Idea, error)- GetCommentsByIdea(idea *models.Idea) ([]*models.Comment, error)- Search(query, filter, limit string, tags []string) ([]*models.Idea, error)- GetAll() ([]*models.Idea, error)+ GetByID(postID int) (*models.Post, error)+ GetBySlug(slug string) (*models.Post, error)+ GetByNumber(number int) (*models.Post, error)+ GetCommentsByPost(post *models.Post) ([]*models.Comment, error)+ Search(query, filter, limit string, tags []string) ([]*models.Post, error)+ GetAll() ([]*models.Post, error)CountPerStatus() (map[int]int, error)- Add(title, description string) (*models.Idea, error)- Update(idea *models.Idea, title, description string) (*models.Idea, error)- AddComment(idea *models.Idea, content string) (int, error)+ Add(title, description string) (*models.Post, error)+ Update(post *models.Post, title, description string) (*models.Post, error)+ AddComment(post *models.Post, content string) (int, error)GetCommentByID(id int) (*models.Comment, error)UpdateComment(id int, content string) error- AddSupporter(idea *models.Idea, user *models.User) error- RemoveSupporter(idea *models.Idea, user *models.User) error- AddSubscriber(idea *models.Idea, user *models.User) error- RemoveSubscriber(idea *models.Idea, user *models.User) error+ AddSupporter(post *models.Post, user *models.User) error+ RemoveSupporter(post *models.Post, user *models.User) error+ AddSubscriber(post *models.Post, user *models.User) error+ RemoveSubscriber(post *models.Post, user *models.User) errorGetActiveSubscribers(number int, channel models.NotificationChannel, event models.NotificationEvent) ([]*models.User, error)- SetResponse(idea *models.Idea, text string, status int) error- MarkAsDuplicate(idea *models.Idea, original *models.Idea) error- IsReferenced(idea *models.Idea) (bool, error)+ SetResponse(post *models.Post, text string, status int) error+ MarkAsDuplicate(post *models.Post, original *models.Post) error+ IsReferenced(post *models.Post) (bool, error)SupportedBy() ([]int, error)}@@ -53,7 +53,7 @@ type User interface {GetAll() ([]*models.User, error)GetUserSettings() (map[string]string, error)UpdateSettings(settings map[string]string) error- HasSubscribedTo(ideaID int) (bool, error)+ HasSubscribedTo(postID int) (bool, error)}// Tenant contains read and write operations for tenants@@ -84,16 +84,16 @@ type Tag interface {GetBySlug(slug string) (*models.Tag, error)Update(tag *models.Tag, name, color string, isPublic bool) (*models.Tag, error)Delete(tag *models.Tag) error- GetAssigned(idea *models.Idea) ([]*models.Tag, error)- AssignTag(tag *models.Tag, idea *models.Idea) error- UnassignTag(tag *models.Tag, idea *models.Idea) error+ GetAssigned(post *models.Post) ([]*models.Tag, error)+ AssignTag(tag *models.Tag, post *models.Post) error+ UnassignTag(tag *models.Tag, post *models.Post) errorGetAll() ([]*models.Tag, error)}// Notification contains read and write operations for notificationstype Notification interface {Base- Insert(user *models.User, title, link string, ideaID int) (*models.Notification, error)+ Insert(user *models.User, title, link string, postID int) (*models.Notification, error)MarkAsRead(id int) errorMarkAllAsRead() errorTotalUnread() (int, error)diff --git a/app/tasks/tasks.go b/app/tasks/tasks.goindex 7da093736..114d22c80 100644--- a/app/tasks/tasks.go+++ b/app/tasks/tasks.go@@ -64,27 +64,27 @@ func SendChangeEmailConfirmation(model *models.ChangeUserEmail) worker.Task {})}-//NotifyAboutNewIdea sends a notification (web and email) to subscribers-func NotifyAboutNewIdea(idea *models.Idea) worker.Task {- return describe("Notify about new idea", func(c *worker.Context) error {+//NotifyAboutNewPost sends a notification (web and email) to subscribers+func NotifyAboutNewPost(post *models.Post) worker.Task {+ return describe("Notify about new post", func(c *worker.Context) error {// Web notification- users, err := c.Services().Ideas.GetActiveSubscribers(idea.Number, models.NotificationChannelWeb, models.NotificationEventNewIdea)+ users, err := c.Services().Posts.GetActiveSubscribers(post.Number, models.NotificationChannelWeb, models.NotificationEventNewPost)if err != nil {return c.Failure(err)}- title := fmt.Sprintf("New idea: **%s**", idea.Title)- link := fmt.Sprintf("/ideas/%d/%s", idea.Number, idea.Slug)+ title := fmt.Sprintf("New post: **%s**", post.Title)+ link := fmt.Sprintf("/posts/%d/%s", post.Number, post.Slug)for _, user := range users {if user.ID != c.User().ID {- if _, err = c.Services().Notifications.Insert(user, title, link, idea.ID); err != nil {+ if _, err = c.Services().Notifications.Insert(user, title, link, post.ID); err != nil {return c.Failure(err)}}}// Email notification- users, err = c.Services().Ideas.GetActiveSubscribers(idea.Number, models.NotificationChannelEmail, models.NotificationEventNewIdea)+ users, err = c.Services().Posts.GetActiveSubscribers(post.Number, models.NotificationChannelEmail, models.NotificationEventNewPost)if err != nil {return c.Failure(err)}@@ -97,37 +97,37 @@ func NotifyAboutNewIdea(idea *models.Idea) worker.Task {}params := email.Params{- "title": fmt.Sprintf("[%s] %s", c.Tenant().Name, idea.Title),- "content": markdown.Parse(idea.Description),- "view": linkWithText("View it on your browser", c.BaseURL(), "/ideas/%d/%s", idea.Number, idea.Slug),+ "title": fmt.Sprintf("[%s] %s", c.Tenant().Name, post.Title),+ "content": markdown.Parse(post.Description),+ "view": linkWithText("View it on your browser", c.BaseURL(), "/posts/%d/%s", post.Number, post.Slug),"change": linkWithText("change your notification settings", c.BaseURL(), "/settings"),}- return c.Services().Emailer.BatchSend(c.Tenant(), "new_idea", params, c.User().Name, to)+ return c.Services().Emailer.BatchSend(c.Tenant(), "new_post", params, c.User().Name, to)})}//NotifyAboutNewComment sends a notification (web and email) to subscribers-func NotifyAboutNewComment(idea *models.Idea, comment *models.NewComment) worker.Task {+func NotifyAboutNewComment(post *models.Post, comment *models.NewComment) worker.Task {return describe("Notify about new comment", func(c *worker.Context) error {// Web notification- users, err := c.Services().Ideas.GetActiveSubscribers(idea.Number, models.NotificationChannelWeb, models.NotificationEventNewComment)+ users, err := c.Services().Posts.GetActiveSubscribers(post.Number, models.NotificationChannelWeb, models.NotificationEventNewComment)if err != nil {return c.Failure(err)}- title := fmt.Sprintf("**%s** left a comment on **%s**", c.User().Name, idea.Title)- link := fmt.Sprintf("/ideas/%d/%s", idea.Number, idea.Slug)+ title := fmt.Sprintf("**%s** left a comment on **%s**", c.User().Name, post.Title)+ link := fmt.Sprintf("/posts/%d/%s", post.Number, post.Slug)for _, user := range users {if user.ID != c.User().ID {- if _, err = c.Services().Notifications.Insert(user, title, link, idea.ID); err != nil {+ if _, err = c.Services().Notifications.Insert(user, title, link, post.ID); err != nil {return c.Failure(err)}}}// Email notification- users, err = c.Services().Ideas.GetActiveSubscribers(idea.Number, models.NotificationChannelEmail, models.NotificationEventNewComment)+ users, err = c.Services().Posts.GetActiveSubscribers(post.Number, models.NotificationChannelEmail, models.NotificationEventNewComment)if err != nil {return c.Failure(err)}@@ -140,10 +140,10 @@ func NotifyAboutNewComment(idea *models.Idea, comment *models.NewComment) worker}params := email.Params{- "title": fmt.Sprintf("[%s] %s", c.Tenant().Name, idea.Title),+ "title": fmt.Sprintf("[%s] %s", c.Tenant().Name, post.Title),"content": markdown.Parse(comment.Content),- "view": linkWithText("View it on your browser", c.BaseURL(), "/ideas/%d/%s", idea.Number, idea.Slug),- "unsubscribe": linkWithText("unsubscribe from it", c.BaseURL(), "/ideas/%d/%s", idea.Number, idea.Slug),+ "view": linkWithText("View it on your browser", c.BaseURL(), "/posts/%d/%s", post.Number, post.Slug),+ "unsubscribe": linkWithText("unsubscribe from it", c.BaseURL(), "/posts/%d/%s", post.Number, post.Slug),"change": linkWithText("change your notification settings", c.BaseURL(), "/settings"),}@@ -152,42 +152,42 @@ func NotifyAboutNewComment(idea *models.Idea, comment *models.NewComment) worker}//NotifyAboutStatusChange sends a notification (web and email) to subscribers-func NotifyAboutStatusChange(idea *models.Idea, prevStatus int) worker.Task {- return describe("Notify about idea status change", func(c *worker.Context) error {+func NotifyAboutStatusChange(post *models.Post, prevStatus int) worker.Task {+ return describe("Notify about post status change", func(c *worker.Context) error {//Don't notify if previous status is the same- if prevStatus == idea.Status {+ if prevStatus == post.Status {return nil}// Web notification- users, err := c.Services().Ideas.GetActiveSubscribers(idea.Number, models.NotificationChannelWeb, models.NotificationEventChangeStatus)+ users, err := c.Services().Posts.GetActiveSubscribers(post.Number, models.NotificationChannelWeb, models.NotificationEventChangeStatus)if err != nil {return c.Failure(err)}- title := fmt.Sprintf("**%s** changed status of **%s** to **%s**", c.User().Name, idea.Title, models.GetIdeaStatusName(idea.Status))- link := fmt.Sprintf("/ideas/%d/%s", idea.Number, idea.Slug)+ title := fmt.Sprintf("**%s** changed status of **%s** to **%s**", c.User().Name, post.Title, models.GetPostStatusName(post.Status))+ link := fmt.Sprintf("/posts/%d/%s", post.Number, post.Slug)for _, user := range users {if user.ID != c.User().ID {- if _, err = c.Services().Notifications.Insert(user, title, link, idea.ID); err != nil {+ if _, err = c.Services().Notifications.Insert(user, title, link, post.ID); err != nil {return c.Failure(err)}}}// Email notification- users, err = c.Services().Ideas.GetActiveSubscribers(idea.Number, models.NotificationChannelEmail, models.NotificationEventChangeStatus)+ users, err = c.Services().Posts.GetActiveSubscribers(post.Number, models.NotificationChannelEmail, models.NotificationEventChangeStatus)if err != nil {return c.Failure(err)}var duplicate template.HTML- if idea.Status == models.IdeaDuplicate {- originalIdea, err := c.Services().Ideas.GetByNumber(idea.Response.Original.Number)+ if post.Status == models.PostDuplicate {+ originalPost, err := c.Services().Posts.GetByNumber(post.Response.Original.Number)if err != nil {return c.Failure(err)}- duplicate = linkWithText(originalIdea.Title, c.BaseURL(), "/ideas/%d/%s", originalIdea.Number, originalIdea.Slug)+ duplicate = linkWithText(originalPost.Title, c.BaseURL(), "/posts/%d/%s", originalPost.Number, originalPost.Slug)}to := make([]email.Recipient, 0)@@ -198,12 +198,12 @@ func NotifyAboutStatusChange(idea *models.Idea, prevStatus int) worker.Task {}params := email.Params{- "title": fmt.Sprintf("[%s] %s", c.Tenant().Name, idea.Title),- "content": markdown.Parse(idea.Response.Text),- "status": models.GetIdeaStatusName(idea.Status),+ "title": fmt.Sprintf("[%s] %s", c.Tenant().Name, post.Title),+ "content": markdown.Parse(post.Response.Text),+ "status": models.GetPostStatusName(post.Status),"duplicate": duplicate,- "view": linkWithText("View it on your browser", c.BaseURL(), "/ideas/%d/%s", idea.Number, idea.Slug),- "unsubscribe": linkWithText("unsubscribe from it", c.BaseURL(), "/ideas/%d/%s", idea.Number, idea.Slug),+ "view": linkWithText("View it on your browser", c.BaseURL(), "/posts/%d/%s", post.Number, post.Slug),+ "unsubscribe": linkWithText("unsubscribe from it", c.BaseURL(), "/posts/%d/%s", post.Number, post.Slug),"change": linkWithText("change your notification settings", c.BaseURL(), "/settings"),}diff --git a/app/tasks/tasks_test.go b/app/tasks/tasks_test.goindex 4defc05ca..2f3309358 100644--- a/app/tasks/tasks_test.go+++ b/app/tasks/tasks_test.go@@ -108,16 +108,16 @@ func TestSendChangeEmailConfirmationTask(t *testing.T) {})}-func TestNotifyAboutNewIdeaTask(t *testing.T) {+func TestNotifyAboutNewPostTask(t *testing.T) {RegisterT(t)worker, services := mock.NewWorker()services.SetCurrentUser(mock.JonSnow)- idea, _ := services.Ideas.Add("Add support for TypeScript", "TypeScript is great, please add support for it")+ post, _ := services.Posts.Add("Add support for TypeScript", "TypeScript is great, please add support for it")- services.Ideas.AddSubscriber(idea, mock.AryaStark)+ services.Posts.AddSubscriber(post, mock.AryaStark)emailer := services.Emailer.(*noop.Sender)- task := tasks.NotifyAboutNewIdea(idea)+ task := tasks.NotifyAboutNewPost(post)err := worker.OnTenant(mock.DemoTenant).@@ -127,12 +127,12 @@ func TestNotifyAboutNewIdeaTask(t *testing.T) {Expect(err).IsNil()Expect(emailer.Requests).HasLen(1)- Expect(emailer.Requests[0].TemplateName).Equals("new_idea")+ Expect(emailer.Requests[0].TemplateName).Equals("new_post")Expect(emailer.Requests[0].Tenant).Equals(mock.DemoTenant)Expect(emailer.Requests[0].Params).Equals(email.Params{"title": "[Demonstration] Add support for TypeScript","content": template.HTML("<p>TypeScript is great, please add support for it</p>"),- "view": template.HTML("<a href='http://domain.com/ideas/1/add-support-for-typescript'>View it on your browser</a>"),+ "view": template.HTML("<a href='http://domain.com/posts/1/add-support-for-typescript'>View it on your browser</a>"),"change": template.HTML("<a href='http://domain.com/settings'>change your notification settings</a>"),})Expect(emailer.Requests[0].From).Equals("Jon Snow")@@ -149,9 +149,9 @@ func TestNotifyAboutNewIdeaTask(t *testing.T) {Expect(notifications).HasLen(1)Expect(notifications[0].ID).Equals(1)Expect(notifications[0].CreatedOn).TemporarilySimilar(time.Now(), 5*time.Second)- Expect(notifications[0].Link).Equals("/ideas/1/add-support-for-typescript")+ Expect(notifications[0].Link).Equals("/posts/1/add-support-for-typescript")Expect(notifications[0].Read).IsFalse()- Expect(notifications[0].Title).Equals("New idea: **Add support for TypeScript**")+ Expect(notifications[0].Title).Equals("New post: **Add support for TypeScript**")}func TestNotifyAboutNewCommentTask(t *testing.T) {@@ -159,14 +159,14 @@ func TestNotifyAboutNewCommentTask(t *testing.T) {worker, services := mock.NewWorker()services.SetCurrentUser(mock.JonSnow)- idea, _ := services.Ideas.Add("Add support for TypeScript", "TypeScript is great, please add support for it")+ post, _ := services.Posts.Add("Add support for TypeScript", "TypeScript is great, please add support for it")comment := &models.NewComment{- Number: idea.Number,+ Number: post.Number,Content: "I agree",}emailer := services.Emailer.(*noop.Sender)- task := tasks.NotifyAboutNewComment(idea, comment)+ task := tasks.NotifyAboutNewComment(post, comment)err := worker.OnTenant(mock.DemoTenant).@@ -181,9 +181,9 @@ func TestNotifyAboutNewCommentTask(t *testing.T) {Expect(emailer.Requests[0].Params).Equals(email.Params{"title": "[Demonstration] Add support for TypeScript","content": template.HTML("<p>I agree</p>"),- "view": template.HTML("<a href='http://domain.com/ideas/1/add-support-for-typescript'>View it on your browser</a>"),+ "view": template.HTML("<a href='http://domain.com/posts/1/add-support-for-typescript'>View it on your browser</a>"),"change": template.HTML("<a href='http://domain.com/settings'>change your notification settings</a>"),- "unsubscribe": template.HTML("<a href='http://domain.com/ideas/1/add-support-for-typescript'>unsubscribe from it</a>"),+ "unsubscribe": template.HTML("<a href='http://domain.com/posts/1/add-support-for-typescript'>unsubscribe from it</a>"),})Expect(emailer.Requests[0].From).Equals("Arya Stark")Expect(emailer.Requests[0].To).HasLen(1)@@ -199,7 +199,7 @@ func TestNotifyAboutNewCommentTask(t *testing.T) {Expect(notifications).HasLen(1)Expect(notifications[0].ID).Equals(1)Expect(notifications[0].CreatedOn).TemporarilySimilar(time.Now(), 5*time.Second)- Expect(notifications[0].Link).Equals("/ideas/1/add-support-for-typescript")+ Expect(notifications[0].Link).Equals("/posts/1/add-support-for-typescript")Expect(notifications[0].Read).IsFalse()Expect(notifications[0].Title).Equals("**Arya Stark** left a comment on **Add support for TypeScript**")}@@ -209,11 +209,11 @@ func TestNotifyAboutStatusChangeTask(t *testing.T) {worker, services := mock.NewWorker()services.SetCurrentUser(mock.AryaStark)- idea, _ := services.Ideas.Add("Add support for TypeScript", "TypeScript is great, please add support for it")- services.Ideas.SetResponse(idea, "Planned for next release.", models.IdeaPlanned)+ post, _ := services.Posts.Add("Add support for TypeScript", "TypeScript is great, please add support for it")+ services.Posts.SetResponse(post, "Planned for next release.", models.PostPlanned)emailer := services.Emailer.(*noop.Sender)- task := tasks.NotifyAboutStatusChange(idea, models.IdeaOpen)+ task := tasks.NotifyAboutStatusChange(post, models.PostOpen)err := worker.OnTenant(mock.DemoTenant).@@ -230,9 +230,9 @@ func TestNotifyAboutStatusChangeTask(t *testing.T) {"content": template.HTML("<p>Planned for next release.</p>"),"duplicate": template.HTML(""),"status": "Planned",- "view": template.HTML("<a href='http://domain.com/ideas/1/add-support-for-typescript'>View it on your browser</a>"),+ "view": template.HTML("<a href='http://domain.com/posts/1/add-support-for-typescript'>View it on your browser</a>"),"change": template.HTML("<a href='http://domain.com/settings'>change your notification settings</a>"),- "unsubscribe": template.HTML("<a href='http://domain.com/ideas/1/add-support-for-typescript'>unsubscribe from it</a>"),+ "unsubscribe": template.HTML("<a href='http://domain.com/posts/1/add-support-for-typescript'>unsubscribe from it</a>"),})Expect(emailer.Requests[0].From).Equals("Jon Snow")Expect(emailer.Requests[0].To).HasLen(1)@@ -248,7 +248,7 @@ func TestNotifyAboutStatusChangeTask(t *testing.T) {Expect(notifications).HasLen(1)Expect(notifications[0].ID).Equals(1)Expect(notifications[0].CreatedOn).TemporarilySimilar(time.Now(), 5*time.Second)- Expect(notifications[0].Link).Equals("/ideas/1/add-support-for-typescript")+ Expect(notifications[0].Link).Equals("/posts/1/add-support-for-typescript")Expect(notifications[0].Read).IsFalse()Expect(notifications[0].Title).Equals("**Jon Snow** changed status of **Add support for TypeScript** to **Planned**")}@@ -258,12 +258,12 @@ func TestNotifyAboutStatusChangeTask_Duplicate(t *testing.T) {worker, services := mock.NewWorker()services.SetCurrentUser(mock.AryaStark)- idea1, _ := services.Ideas.Add("Add support for TypeScript", "TypeScript is great, please add support for it")- idea2, _ := services.Ideas.Add("I need TypeScript", "")- services.Ideas.MarkAsDuplicate(idea2, idea1)+ post1, _ := services.Posts.Add("Add support for TypeScript", "TypeScript is great, please add support for it")+ post2, _ := services.Posts.Add("I need TypeScript", "")+ services.Posts.MarkAsDuplicate(post2, post1)emailer := services.Emailer.(*noop.Sender)- task := tasks.NotifyAboutStatusChange(idea2, models.IdeaOpen)+ task := tasks.NotifyAboutStatusChange(post2, models.PostOpen)err := worker.OnTenant(mock.DemoTenant).@@ -278,11 +278,11 @@ func TestNotifyAboutStatusChangeTask_Duplicate(t *testing.T) {Expect(emailer.Requests[0].Params).Equals(email.Params{"title": "[Demonstration] I need TypeScript","content": template.HTML(""),- "duplicate": template.HTML("<a href='http://domain.com/ideas/1/add-support-for-typescript'>Add support for TypeScript</a>"),+ "duplicate": template.HTML("<a href='http://domain.com/posts/1/add-support-for-typescript'>Add support for TypeScript</a>"),"status": "Duplicate",- "view": template.HTML("<a href='http://domain.com/ideas/2/i-need-typescript'>View it on your browser</a>"),+ "view": template.HTML("<a href='http://domain.com/posts/2/i-need-typescript'>View it on your browser</a>"),"change": template.HTML("<a href='http://domain.com/settings'>change your notification settings</a>"),- "unsubscribe": template.HTML("<a href='http://domain.com/ideas/2/i-need-typescript'>unsubscribe from it</a>"),+ "unsubscribe": template.HTML("<a href='http://domain.com/posts/2/i-need-typescript'>unsubscribe from it</a>"),})Expect(emailer.Requests[0].From).Equals("Jon Snow")Expect(emailer.Requests[0].To).HasLen(1)@@ -298,7 +298,7 @@ func TestNotifyAboutStatusChangeTask_Duplicate(t *testing.T) {Expect(notifications).HasLen(1)Expect(notifications[0].ID).Equals(1)Expect(notifications[0].CreatedOn).TemporarilySimilar(time.Now(), 5*time.Second)- Expect(notifications[0].Link).Equals("/ideas/2/i-need-typescript")+ Expect(notifications[0].Link).Equals("/posts/2/i-need-typescript")Expect(notifications[0].Read).IsFalse()Expect(notifications[0].Title).Equals("**Jon Snow** changed status of **I need TypeScript** to **Duplicate**")}diff --git a/public/components/ShowIdeaResponse.scss b/public/components/ShowPostResponse.scsssimilarity index 100%rename from public/components/ShowIdeaResponse.scssrename to public/components/ShowPostResponse.scssdiff --git a/public/components/ShowIdeaResponse.tsx b/public/components/ShowPostResponse.tsxsimilarity index 57%rename from public/components/ShowIdeaResponse.tsxrename to public/components/ShowPostResponse.tsxindex 716e967e9..032ebc020 100644--- a/public/components/ShowIdeaResponse.tsx+++ b/public/components/ShowPostResponse.tsx@@ -1,18 +1,18 @@-import "./ShowIdeaResponse.scss";+import "./ShowPostResponse.scss";import * as React from "react";-import { User, IdeaResponse, IdeaStatus } from "@fider/models";+import { PostResponse, PostStatus } from "@fider/models";import { Gravatar, MultiLineText, Moment, UserName, Segment } from "@fider/components/common";-interface ShowIdeaStatusProps {- status: IdeaStatus;+interface ShowPostStatusProps {+ status: PostStatus;}-export const ShowIdeaStatus = (props: ShowIdeaStatusProps) => {+export const ShowPostStatus = (props: ShowPostStatusProps) => {return <span className={`status-label status-${props.status.slug}`}>{props.status.title}</span>;};-const DuplicateDetails = (props: IdeaResponseProps): JSX.Element | null => {+const DuplicateDetails = (props: PostResponseProps): JSX.Element | null => {if (!props.response) {return null;}@@ -21,21 +21,21 @@ const DuplicateDetails = (props: IdeaResponseProps): JSX.Element | null => {if (!original) {return null;}- const status = IdeaStatus.Get(original.status);+ const status = PostStatus.Get(original.status);return (<div className="content">- <span>↪</span> <a href={`/ideas/${original.number}/${original.slug}`}>{original.title}</a>+ <span>↪</span> <a href={`/posts/${original.number}/${original.slug}`}>{original.title}</a></div>);};-interface IdeaResponseProps {+interface PostResponseProps {status: number;- response: IdeaResponse | null;+ response: PostResponse | null;}-const StatusDetails = (props: IdeaResponseProps): JSX.Element | null => {+const StatusDetails = (props: PostResponseProps): JSX.Element | null => {if (!props.response || !props.response.text) {return null;}@@ -47,15 +47,15 @@ const StatusDetails = (props: IdeaResponseProps): JSX.Element | null => {);};-export const ShowIdeaResponse = (props: IdeaResponseProps): JSX.Element => {- const status = IdeaStatus.Get(props.status);+export const ShowPostResponse = (props: PostResponseProps): JSX.Element => {+ const status = PostStatus.Get(props.status);if (props.response && status.show) {return (<Segment className="l-response">- <ShowIdeaStatus status={status} />+ <ShowPostStatus status={status} /><Gravatar user={props.response.user} size="small" /> <UserName user={props.response.user} />- {status === IdeaStatus.Duplicate ? DuplicateDetails(props) : StatusDetails(props)}+ {status === PostStatus.Duplicate ? DuplicateDetails(props) : StatusDetails(props)}</Segment>);}diff --git a/public/components/ShowTag.tsx b/public/components/ShowTag.tsxindex 1d95fb633..4fc310d14 100644--- a/public/components/ShowTag.tsx+++ b/public/components/ShowTag.tsx@@ -22,7 +22,7 @@ const getRGB = (color: string) => {};};-const idealTextColor = (color: string) => {+const textColor = (color: string) => {const components = getRGB(color);const bgDelta = components.R * 0.299 + components.G * 0.587 + components.B * 0.114;return bgDelta > 140 ? "#333" : "#fff";@@ -41,7 +41,7 @@ export const ShowTag = (props: TagProps) => {className={className}style={{backgroundColor: `#${props.tag.color}`,- color: idealTextColor(props.tag.color)+ color: textColor(props.tag.color)}}>{!props.tag.isPublic && !props.circular && <i className="lock icon" />}diff --git a/public/components/SupportCounter.spec.tsx b/public/components/SupportCounter.spec.tsxindex 0affde324..654f3d6e5 100644--- a/public/components/SupportCounter.spec.tsx+++ b/public/components/SupportCounter.spec.tsx@@ -1,20 +1,20 @@import * as React from "react";import { shallow } from "enzyme";-import { Idea, UserRole, UserStatus, IdeaStatus } from "@fider/models";+import { Post, UserRole, UserStatus, PostStatus } from "@fider/models";import { SupportCounter } from "@fider/components";import { httpMock, fiderMock, rerender } from "@fider/services/testing";-let idea: Idea;+let post: Post;beforeEach(() => {- idea = {+ post = {id: 1,number: 10,slug: "add-typescript",title: "Add TypeScript",description: "",createdOn: "",- status: IdeaStatus.Started.value,+ status: PostStatus.Started.value,user: {id: 5,name: "John",@@ -31,9 +31,9 @@ beforeEach(() => {describe("<SupportCounter />", () => {test("when viewerSupported === true", () => {- idea.viewerSupported = true;- idea.totalSupporters = 9;- const wrapper = shallow(<SupportCounter idea={idea} />);+ post.viewerSupported = true;+ post.totalSupporters = 9;+ const wrapper = shallow(<SupportCounter post={post} />);const button = wrapper.find("button");expect(button.text()).toBe("9");expect(button.hasClass("m-supported")).toBe(true);@@ -41,18 +41,18 @@ describe("<SupportCounter />", () => {});test("when viewerSupported === false", () => {- idea.viewerSupported = false;- idea.totalSupporters = 2;- const wrapper = shallow(<SupportCounter idea={idea} />);+ post.viewerSupported = false;+ post.totalSupporters = 2;+ const wrapper = shallow(<SupportCounter post={post} />);const button = wrapper.find("button");expect(button.text()).toBe("2");expect(button.hasClass("m-supported")).toBe(false);expect(button.hasClass("m-disabled")).toBe(false);});- test("when idea is closed", () => {- idea.status = IdeaStatus.Completed.value;- const wrapper = shallow(<SupportCounter idea={idea} />);+ test("when post is closed", () => {+ post.status = PostStatus.Completed.value;+ const wrapper = shallow(<SupportCounter post={post} />);const button = wrapper.find("button");expect(button.text()).toBe("5");expect(button.hasClass("m-supported")).toBe(false);@@ -64,7 +64,7 @@ describe("<SupportCounter />", () => {const mock = httpMock.alwaysOk();- const wrapper = shallow(<SupportCounter idea={idea} />);+ const wrapper = shallow(<SupportCounter post={post} />);wrapper.find("button").simulate("click");await rerender(wrapper);expect(wrapper.find("SignInModal").length).toBe(1);@@ -76,9 +76,9 @@ describe("<SupportCounter />", () => {const mock = httpMock.alwaysOk();- const wrapper = shallow(<SupportCounter idea={idea} />);+ const wrapper = shallow(<SupportCounter post={post} />);wrapper.find("button").simulate("click");- expect(mock).toHaveBeenCalledWith("/api/ideas/10/support");+ expect(mock).toHaveBeenCalledWith("/api/posts/10/support");expect(mock).toHaveBeenCalledTimes(1);await rerender(wrapper);@@ -86,14 +86,14 @@ describe("<SupportCounter />", () => {});test("click when authenticated and viewerSupported === true", async () => {- idea.viewerSupported = true;+ post.viewerSupported = true;fiderMock.authenticated();const mock = httpMock.alwaysOk();- const wrapper = shallow(<SupportCounter idea={idea} />);+ const wrapper = shallow(<SupportCounter post={post} />);wrapper.find("button").simulate("click");- expect(mock).toHaveBeenCalledWith("/api/ideas/10/unsupport");+ expect(mock).toHaveBeenCalledWith("/api/posts/10/unsupport");expect(mock).toHaveBeenCalledTimes(1);await rerender(wrapper);diff --git a/public/components/SupportCounter.tsx b/public/components/SupportCounter.tsxindex 48061d270..0a4f990c0 100644--- a/public/components/SupportCounter.tsx+++ b/public/components/SupportCounter.tsx@@ -1,12 +1,12 @@import "./SupportCounter.scss";import * as React from "react";-import { Idea, IdeaStatus } from "@fider/models";+import { Post, PostStatus } from "@fider/models";import { actions, device, classSet, Fider } from "@fider/services";import { SignInModal } from "@fider/components";interface SupportCounterProps {- idea: Idea;+ post: Post;}interface SupportCounterState {@@ -19,8 +19,8 @@ export class SupportCounter extends React.Component<SupportCounterProps, Supportconstructor(props: SupportCounterProps) {super(props);this.state = {- supported: props.idea.viewerSupported,- total: props.idea.totalSupporters,+ supported: props.post.viewerSupported,+ total: props.post.totalSupporters,showSignIn: false};}@@ -33,7 +33,7 @@ export class SupportCounter extends React.Component<SupportCounterProps, Supportconst action = this.state.supported ? actions.removeSupport : actions.addSupport;- const response = await action(this.props.idea.number);+ const response = await action(this.props.post.number);if (response.ok) {this.setState(state => ({supported: !state.supported,@@ -43,7 +43,7 @@ export class SupportCounter extends React.Component<SupportCounterProps, Support};public render() {- const status = IdeaStatus.Get(this.props.idea.status);+ const status = PostStatus.Get(this.props.post.status);const className = classSet({"m-supported": !status.closed && this.state.supported,diff --git a/public/components/index.tsx b/public/components/index.tsxindex c1bd75003..c147fefa1 100644--- a/public/components/index.tsx+++ b/public/components/index.tsx@@ -1,4 +1,4 @@-export * from "./ShowIdeaResponse";+export * from "./ShowPostResponse";export * from "./ShowTag";export * from "./SignInModal";export * from "./SupportCounter";diff --git a/public/models/index.ts b/public/models/index.tsindex f94e89c92..be6347622 100644--- a/public/models/index.ts+++ b/public/models/index.ts@@ -1,4 +1,4 @@-export * from "./idea";+export * from "./post";export * from "./identity";export * from "./settings";export * from "./notification";diff --git a/public/models/idea.ts b/public/models/post.tssimilarity index 56%rename from public/models/idea.tsrename to public/models/post.tsindex c5066f281..f26d3f48a 100644--- a/public/models/idea.ts+++ b/public/models/post.ts@@ -1,6 +1,6 @@import { User } from "./identity";-export interface Idea {+export interface Post {id: number;number: number;slug: string;@@ -10,13 +10,13 @@ export interface Idea {status: number;user: User;viewerSupported: boolean;- response: IdeaResponse | null;+ response: PostResponse | null;totalSupporters: number;totalComments: number;tags: string[];}-export class IdeaStatus {+export class PostStatus {constructor(public value: number,public title: string,@@ -26,34 +26,34 @@ export class IdeaStatus {public filterable: boolean) {}- public static Open = new IdeaStatus(0, "Open", "open", false, false, false);- public static Planned = new IdeaStatus(4, "Planned", "planned", true, false, true);- public static Started = new IdeaStatus(1, "Started", "started", true, false, true);- public static Completed = new IdeaStatus(2, "Completed", "completed", true, true, true);- public static Declined = new IdeaStatus(3, "Declined", "declined", true, true, true);- public static Duplicate = new IdeaStatus(5, "Duplicate", "duplicate", true, true, false);- public static Deleted = new IdeaStatus(6, "Deleted", "deleted", false, true, false);+ public static Open = new PostStatus(0, "Open", "open", false, false, false);+ public static Planned = new PostStatus(4, "Planned", "planned", true, false, true);+ public static Started = new PostStatus(1, "Started", "started", true, false, true);+ public static Completed = new PostStatus(2, "Completed", "completed", true, true, true);+ public static Declined = new PostStatus(3, "Declined", "declined", true, true, true);+ public static Duplicate = new PostStatus(5, "Duplicate", "duplicate", true, true, false);+ public static Deleted = new PostStatus(6, "Deleted", "deleted", false, true, false);- public static Get(value: number): IdeaStatus {- for (const status of IdeaStatus.All) {+ public static Get(value: number): PostStatus {+ for (const status of PostStatus.All) {if (status.value === value) {return status;}}- throw new Error(`IdeaStatus not found for value ${value}.`);+ throw new Error(`PostStatus not found for value ${value}.`);}public static All = [- IdeaStatus.Open,- IdeaStatus.Planned,- IdeaStatus.Started,- IdeaStatus.Completed,- IdeaStatus.Duplicate,- IdeaStatus.Declined+ PostStatus.Open,+ PostStatus.Planned,+ PostStatus.Started,+ PostStatus.Completed,+ PostStatus.Duplicate,+ PostStatus.Declined];}-export interface IdeaResponse {+export interface PostResponse {user: User;text: string;respondedOn: Date;diff --git a/public/pages/Administration/components/TagListItem.tsx b/public/pages/Administration/components/TagListItem.tsxindex a0b462051..f0531eeed 100644--- a/public/pages/Administration/components/TagListItem.tsx+++ b/public/pages/Administration/components/TagListItem.tsx@@ -80,7 +80,7 @@ export class TagListItem extends React.Component<TagListItemProps, TagListItemSt<div className="content"><b>Are you sure?</b>{" "}<span>- The tag <ShowTag tag={this.state.tag} /> will be removed from all ideas.+ The tag <ShowTag tag={this.state.tag} /> will be removed from all posts.</span></div><Button className="right" onClick={this.cancelDelete} color="cancel">diff --git a/public/pages/Administration/pages/Export.page.tsx b/public/pages/Administration/pages/Export.page.tsxindex 669c59848..f0d3c06e2 100644--- a/public/pages/Administration/pages/Export.page.tsx+++ b/public/pages/Administration/pages/Export.page.tsx@@ -14,14 +14,14 @@ export class ExportPage extends AdminBasePage<{}, {}> {public content() {return (<Form>- <Field label="Export Ideas">+ <Field label="Export Posts"><p className="info">- Use this button to download a CSV file with all ideas in this site. This can be useful to analyse the data+ Use this button to download a CSV file with all posts in this site. This can be useful to analyse the datawith an external tool or simply to back it up.</p></Field><Field>- <Button color="positive" href="/admin/export/ideas.csv">+ <Button color="positive" href="/admin/export/posts.csv">Download</Button></Field>diff --git a/public/pages/Home/Home.page.scss b/public/pages/Home/Home.page.scssindex edb4fb7e6..f2dad216b 100644--- a/public/pages/Home/Home.page.scss+++ b/public/pages/Home/Home.page.scss@@ -14,7 +14,7 @@}}- .l-ideas-filter {+ .l-post-filter {.counter {font-size: 8px;background-color: $gray-lighter;diff --git a/public/pages/Home/Home.page.tsx b/public/pages/Home/Home.page.tsxindex eb9284b08..f77185245 100644--- a/public/pages/Home/Home.page.tsx+++ b/public/pages/Home/Home.page.tsx@@ -1,14 +1,14 @@import "./Home.page.scss";import * as React from "react";-import { Idea, Tag, IdeaStatus } from "@fider/models";+import { Post, Tag, PostStatus } from "@fider/models";import { MultiLineText } from "@fider/components";-import { IdeaInput, ListIdeas, IdeasContainer } from "./";+import { PostInput, ListPosts, PostsContainer } from "./";import { actions, Fider } from "@fider/services";-import { SimilarIdeas } from "./components/SimilarIdeas";+import { SimilarPosts } from "./components/SimilarPosts";export interface HomePageProps {- ideas: Idea[];+ posts: Post[];tags: Tag[];countPerStatus: { [key: string]: number };}@@ -23,14 +23,14 @@ const Lonely = () => {<p><i className="icon lightbulb outline" aria-hidden="true" /></p>- <p>It's lonely out here. Start by sharing an idea!</p>+ <p>It's lonely out here. Start by sharing a suggestion!</p></div>);};-const defaultWelcomeMessage = `## Welcome to our feedback forum!+const defaultWelcomeMessage = `We'd love to hear what you're thinking about.-We'd love to hear what you're thinking about. What can we do better? This is the place for you to vote, discuss and share ideas.`;+What can we do better? This is the place for you to vote, discuss and share ideas.`;export class HomePage extends React.Component<HomePageProps, HomePageState> {constructor(props: HomePageProps) {@@ -46,7 +46,7 @@ export class HomePage extends React.Component<HomePageProps, HomePageState> {return true;}- if (len === 1 && IdeaStatus.Deleted.value in this.props.countPerStatus) {+ if (len === 1 && PostStatus.Deleted.value in this.props.countPerStatus) {return true;}@@ -67,8 +67,8 @@ export class HomePage extends React.Component<HomePageProps, HomePageState> {text={Fider.session.tenant.welcomeMessage || defaultWelcomeMessage}style="full"/>- <IdeaInput- placeholder={Fider.session.tenant.invitation || "Enter your idea here..."}+ <PostInput+ placeholder={Fider.session.tenant.invitation || "Enter your suggestion here..."}onTitleChanged={this.setTitle}/></div>@@ -76,10 +76,10 @@ export class HomePage extends React.Component<HomePageProps, HomePageState> {{this.isLonely() ? (<Lonely />) : this.state.title ? (- <SimilarIdeas title={this.state.title} tags={this.props.tags} />+ <SimilarPosts title={this.state.title} tags={this.props.tags} />) : (- <IdeasContainer- ideas={this.props.ideas}+ <PostsContainer+ posts={this.props.posts}tags={this.props.tags}countPerStatus={this.props.countPerStatus}/>diff --git a/public/pages/Home/components/ListIdeas.tsx b/public/pages/Home/components/ListIdeas.tsxdeleted file mode 100644index af57cd497..000000000--- a/public/pages/Home/components/ListIdeas.tsx+++ /dev/null@@ -1,69 +0,0 @@-import "./ListIdeas.scss";--import * as React from "react";-import { Idea, Tag, IdeaStatus, CurrentUser } from "@fider/models";-import {- ShowTag,- ShowIdeaResponse,- SupportCounter,- Gravatar,- MultiLineText,- Moment,- ListItem,- List-} from "@fider/components";--interface ListIdeasProps {- ideas?: Idea[];- tags: Tag[];- emptyText: string;-}--const ListIdeaItem = (props: { idea: Idea; user?: CurrentUser; tags: Tag[] }) => {- return (- <ListItem>- <SupportCounter idea={props.idea} />- <div className="c-list-item-content">- {props.idea.totalComments > 0 && (- <div className="info right">- {props.idea.totalComments} <i className="comments outline icon" />- </div>- )}- <a className="c-list-item-title" href={`/ideas/${props.idea.number}/${props.idea.slug}`}>- {props.idea.title}- </a>- <MultiLineText className="c-list-item-description" text={props.idea.description} style="simple" />- <ShowIdeaResponse status={props.idea.status} response={props.idea.response} />- {props.tags.map(tag => <ShowTag key={tag.id} size="tiny" tag={tag} />)}- </div>- </ListItem>- );-};--export class ListIdeas extends React.Component<ListIdeasProps, {}> {- constructor(props: ListIdeasProps) {- super(props);- }-- public render() {- if (!this.props.ideas) {- return null;- }-- if (this.props.ideas.length === 0) {- return <p className="center">{this.props.emptyText}</p>;- }-- return (- <List className="c-idea-list" divided={true}>- {this.props.ideas.map(idea => (- <ListIdeaItem- key={idea.id}- idea={idea}- tags={this.props.tags.filter(tag => idea.tags.indexOf(tag.slug) >= 0)}- />- ))}- </List>- );- }-}diff --git a/public/pages/Home/components/ListIdeas.scss b/public/pages/Home/components/ListPosts.scsssimilarity index 94%rename from public/pages/Home/components/ListIdeas.scssrename to public/pages/Home/components/ListPosts.scssindex 922fe116b..f36f6ff58 100644--- a/public/pages/Home/components/ListIdeas.scss+++ b/public/pages/Home/components/ListPosts.scss@@ -1,6 +1,6 @@@import '~@fider/assets/styles/variables.scss';-.c-idea-list {+.c-post-list {.c-list-item {display: flex;border-top-width: 0.1px !important;@@ -33,7 +33,7 @@}}-.c-idea-list-show-more {+.c-post-list-show-more {cursor: pointer;color: $main-color;margin-left: 55px;diff --git a/public/pages/Home/components/ListPosts.tsx b/public/pages/Home/components/ListPosts.tsxnew file mode 100644index 000000000..5784b02e5--- /dev/null+++ b/public/pages/Home/components/ListPosts.tsx@@ -0,0 +1,69 @@+import "./ListPosts.scss";++import * as React from "react";+import { Post, Tag, PostStatus, CurrentUser } from "@fider/models";+import {+ ShowTag,+ ShowPostResponse,+ SupportCounter,+ Gravatar,+ MultiLineText,+ Moment,+ ListItem,+ List+} from "@fider/components";++interface ListPostsProps {+ posts?: Post[];+ tags: Tag[];+ emptyText: string;+}++const ListPostItem = (props: { post: Post; user?: CurrentUser; tags: Tag[] }) => {+ return (+ <ListItem>+ <SupportCounter post={props.post} />+ <div className="c-list-item-content">+ {props.post.totalComments > 0 && (+ <div className="info right">+ {props.post.totalComments} <i className="comments outline icon" />+ </div>+ )}+ <a className="c-list-item-title" href={`/posts/${props.post.number}/${props.post.slug}`}>+ {props.post.title}+ </a>+ <MultiLineText className="c-list-item-description" text={props.post.description} style="simple" />+ <ShowPostResponse status={props.post.status} response={props.post.response} />+ {props.tags.map(tag => <ShowTag key={tag.id} size="tiny" tag={tag} />)}+ </div>+ </ListItem>+ );+};++export class ListPosts extends React.Component<ListPostsProps, {}> {+ constructor(props: ListPostsProps) {+ super(props);+ }++ public render() {+ if (!this.props.posts) {+ return null;+ }++ if (this.props.posts.length === 0) {+ return <p className="center">{this.props.emptyText}</p>;+ }++ return (+ <List className="c-post-list" divided={true}>+ {this.props.posts.map(post => (+ <ListPostItem+ key={post.id}+ post={post}+ tags={this.props.tags.filter(tag => post.tags.indexOf(tag.slug) >= 0)}+ />+ ))}+ </List>+ );+ }+}diff --git a/public/pages/Home/components/IdeaFilter.tsx b/public/pages/Home/components/PostFilter.tsxsimilarity index 84%rename from public/pages/Home/components/IdeaFilter.tsxrename to public/pages/Home/components/PostFilter.tsxindex 042b89c2a..57bd9ed21 100644--- a/public/pages/Home/components/IdeaFilter.tsx+++ b/public/pages/Home/components/PostFilter.tsx@@ -1,16 +1,16 @@import * as React from "react";-import { Idea, IdeaStatus, CurrentUser } from "@fider/models";+import { Post, PostStatus, CurrentUser } from "@fider/models";import { Dropdown, DropdownItemProps, DropdownProps } from "@fider/components";import { Fider } from "@fider/services";-interface IdeaFilterProps {+interface PostFilterProps {activeFilter: string;countPerStatus: { [key: string]: number };filterChanged: (name: string) => void;}-export class IdeaFilter extends React.Component<IdeaFilterProps, {}> {- constructor(props: IdeaFilterProps) {+export class PostFilter extends React.Component<PostFilterProps, {}> {+ constructor(props: PostFilterProps) {super(props);}@@ -30,7 +30,7 @@ export class IdeaFilter extends React.Component<IdeaFilterProps, {}> {options.push({ text: "my votes", value: "my-votes", content: "My Votes" });}- IdeaStatus.All.filter(s => s.filterable && this.props.countPerStatus[s.value]).forEach(s => {+ PostStatus.All.filter(s => s.filterable && this.props.countPerStatus[s.value]).forEach(s => {options.push({text: s.title.toLowerCase(),value: s.slug,@@ -49,7 +49,7 @@ export class IdeaFilter extends React.Component<IdeaFilterProps, {}> {<>Show{" "}<Dropdown- className="l-ideas-filter"+ className="l-post-filter"header="What do you want to see?"inline={true}options={options}diff --git a/public/pages/Home/components/IdeaInput.tsx b/public/pages/Home/components/PostInput.tsxsimilarity index 85%rename from public/pages/Home/components/IdeaInput.tsxrename to public/pages/Home/components/PostInput.tsxindex 904f72794..ba69aadbb 100644--- a/public/pages/Home/components/IdeaInput.tsx+++ b/public/pages/Home/components/PostInput.tsx@@ -4,12 +4,12 @@ import { SignInModal } from "@fider/components";import { cache, actions, Failure, Fider } from "@fider/services";import { CurrentUser } from "@fider/models";-interface IdeaInputProps {+interface PostInputProps {placeholder: string;onTitleChanged: (title: string) => void;}-interface IdeaInputState {+interface PostInputState {title: string;description: string;focused: boolean;@@ -17,13 +17,13 @@ interface IdeaInputState {error?: Failure;}-const CACHE_TITLE_KEY = "IdeaInput-Title";-const CACHE_DESCRIPTION_KEY = "IdeaInput-Description";+const CACHE_TITLE_KEY = "PostInput-Title";+const CACHE_DESCRIPTION_KEY = "PostInput-Description";-export class IdeaInput extends React.Component<IdeaInputProps, IdeaInputState> {+export class PostInput extends React.Component<PostInputProps, PostInputState> {private title?: HTMLInputElement;- constructor(props: IdeaInputProps) {+ constructor(props: PostInputProps) {super(props);this.state = {title: (Fider.session.isAuthenticated && cache.get(CACHE_TITLE_KEY)) || "",@@ -63,11 +63,11 @@ export class IdeaInput extends React.Component<IdeaInputProps, IdeaInputState> {private submit = async (event: ButtonClickEvent) => {if (this.state.title) {- const result = await actions.createIdea(this.state.title, this.state.description);+ const result = await actions.createPost(this.state.title, this.state.description);if (result.ok) {this.setState({ error: undefined });cache.remove(CACHE_TITLE_KEY, CACHE_DESCRIPTION_KEY);- location.href = `/ideas/${result.data.number}/${result.data.slug}`;+ location.href = `/posts/${result.data.number}/${result.data.slug}`;event.preventEnable();} else if (result.error) {this.setState({ error: result.error });@@ -87,7 +87,7 @@ export class IdeaInput extends React.Component<IdeaInputProps, IdeaInputState> {onChange={this.setDescription}value={this.state.description}minRows={5}- placeholder="Describe your idea (optional)"+ placeholder="Describe your suggestion (optional)"/><Button color="positive" onClick={this.submit}>Submitdiff --git a/public/pages/Home/components/IdeasContainer.tsx b/public/pages/Home/components/PostsContainer.tsxsimilarity index 76%rename from public/pages/Home/components/IdeasContainer.tsxrename to public/pages/Home/components/PostsContainer.tsxindex 29c61ec06..7c0443681 100644--- a/public/pages/Home/components/IdeasContainer.tsx+++ b/public/pages/Home/components/PostsContainer.tsx@@ -1,33 +1,33 @@import * as React from "react";-import { ListIdeas, TagsFilter, IdeaFilter } from "../";+import { ListPosts, TagsFilter, PostFilter } from "../";-import { Idea, Tag, CurrentUser } from "@fider/models";+import { Post, Tag, CurrentUser } from "@fider/models";import { Loader, Field, Input } from "@fider/components";import { actions, navigator, querystring } from "@fider/services";-interface IdeasContainerProps {+interface PostsContainerProps {user?: CurrentUser;- ideas: Idea[];+ posts: Post[];tags: Tag[];countPerStatus: { [key: string]: number };}-interface IdeasContainerState {+interface PostsContainerState {loading: boolean;- ideas?: Idea[];+ posts?: Post[];filter: string;tags: string[];query: string;limit?: number;}-export class IdeasContainer extends React.Component<IdeasContainerProps, IdeasContainerState> {- constructor(props: IdeasContainerProps) {+export class PostsContainer extends React.Component<PostsContainerProps, PostsContainerState> {+ constructor(props: PostsContainerProps) {super(props);this.state = {- ideas: this.props.ideas,+ posts: this.props.posts,loading: false,filter: querystring.get("f"),query: querystring.get("q"),@@ -36,8 +36,8 @@ export class IdeasContainer extends React.Component<IdeasContainerProps, IdeasCo};}- private changeFilterCriteria<K extends keyof IdeasContainerState>(- obj: Pick<IdeasContainerState, K>,+ private changeFilterCriteria<K extends keyof PostsContainerState>(+ obj: Pick<PostsContainerState, K>,reset: boolean): void {this.setState(obj, () => {@@ -51,18 +51,18 @@ export class IdeasContainer extends React.Component<IdeasContainerProps, IdeasCo}));- this.searchIdeas(query, this.state.filter, this.state.limit, this.state.tags, reset);+ this.searchPosts(query, this.state.filter, this.state.limit, this.state.tags, reset);});}private timer?: number;- private async searchIdeas(query: string, filter: string, limit: number | undefined, tags: string[], reset: boolean) {+ private async searchPosts(query: string, filter: string, limit: number | undefined, tags: string[], reset: boolean) {window.clearTimeout(this.timer);- this.setState({ ideas: reset ? undefined : this.state.ideas, loading: true });+ this.setState({ posts: reset ? undefined : this.state.posts, loading: true });this.timer = window.setTimeout(() => {- actions.searchIdeas({ query, filter, limit, tags }).then(response => {+ actions.searchPosts({ query, filter, limit, tags }).then(response => {if (this.state.loading) {- this.setState({ loading: false, ideas: response.data });+ this.setState({ loading: false, posts: response.data });}});}, 200);@@ -94,7 +94,7 @@ export class IdeasContainer extends React.Component<IdeasContainerProps, IdeasCo};private canShowMore = (): boolean => {- return this.state.ideas ? this.state.ideas.length >= (this.state.limit || 30) : false;+ return this.state.posts ? this.state.posts.length >= (this.state.limit || 30) : false;};public render() {@@ -104,7 +104,7 @@ export class IdeasContainer extends React.Component<IdeasContainerProps, IdeasCo{!this.state.query && (<div className="l-filter-col col-sm-7 col-md-8 col-lg-9 mb-2"><Field>- <IdeaFilter+ <PostFilteractiveFilter={this.state.filter}filterChanged={this.handleFilterChanged}countPerStatus={this.props.countPerStatus}@@ -128,15 +128,15 @@ export class IdeasContainer extends React.Component<IdeasContainerProps, IdeasCo/></div></div>- <ListIdeas- ideas={this.state.ideas}+ <ListPosts+ posts={this.state.posts}tags={this.props.tags}emptyText={"No results matched your search, try something different."}/>{this.state.loading && <Loader />}{this.canShowMore() && (- <h5 className="c-idea-list-show-more" onTouchEnd={this.showMore} onClick={this.showMore}>- View more ideas+ <h5 className="c-post-list-show-more" onTouchEnd={this.showMore} onClick={this.showMore}>+ View more posts</h5>)}</>diff --git a/public/pages/Home/components/SimilarIdeas.tsx b/public/pages/Home/components/SimilarPosts.tsxsimilarity index 52%rename from public/pages/Home/components/SimilarIdeas.tsxrename to public/pages/Home/components/SimilarPosts.tsxindex 5326515c3..e6cc25a07 100644--- a/public/pages/Home/components/SimilarIdeas.tsx+++ b/public/pages/Home/components/SimilarPosts.tsx@@ -1,32 +1,32 @@import * as React from "react";-import { Idea, Tag, CurrentUser } from "@fider/models";+import { Post, Tag, CurrentUser } from "@fider/models";import { Heading, Loader } from "@fider/components";-import { ListIdeas } from "./ListIdeas";+import { ListPosts } from "./ListPosts";import { actions } from "@fider/services";-interface SimilarIdeasProps {+interface SimilarPostsProps {title: string;tags: Tag[];user?: CurrentUser;}-interface SimilarIdeasState {+interface SimilarPostsState {title: string;- ideas: Idea[];+ posts: Post[];loading: boolean;}-export class SimilarIdeas extends React.Component<SimilarIdeasProps, SimilarIdeasState> {- constructor(props: SimilarIdeasProps) {+export class SimilarPosts extends React.Component<SimilarPostsProps, SimilarPostsState> {+ constructor(props: SimilarPostsProps) {super(props);this.state = {title: props.title,loading: !!props.title,- ideas: []+ posts: []};}- public static getDerivedStateFromProps(nextProps: SimilarIdeasProps, prevState: SimilarIdeasState) {+ public static getDerivedStateFromProps(nextProps: SimilarPostsProps, prevState: SimilarPostsState) {if (nextProps.title !== prevState.title) {return {loading: true,@@ -36,19 +36,19 @@ export class SimilarIdeas extends React.Component<SimilarIdeasProps, SimilarIdeareturn null;}public componentDidMount() {- this.loadSimilarIdeas();+ this.loadSimilarPosts();}private timer?: number;public componentDidUpdate() {window.clearTimeout(this.timer);- this.timer = window.setTimeout(this.loadSimilarIdeas, 200);+ this.timer = window.setTimeout(this.loadSimilarPosts, 200);}- private loadSimilarIdeas = () => {+ private loadSimilarPosts = () => {if (this.state.loading) {- actions.searchIdeas({ query: this.state.title }).then(x => {- this.setState({ loading: false, ideas: x.data });+ actions.searchPosts({ query: this.state.title }).then(x => {+ this.setState({ loading: false, posts: x.data });});}};@@ -57,8 +57,8 @@ export class SimilarIdeas extends React.Component<SimilarIdeasProps, SimilarIdeareturn (<><Heading- title="Similar ideas"- subtitle="Consider voting on existing ideas instead of posting a new one."+ title="Similar posts"+ subtitle="Consider voting on existing posts instead of posting a new one."icon="lightbulb outline"size="small"dividing={true}@@ -66,10 +66,10 @@ export class SimilarIdeas extends React.Component<SimilarIdeasProps, SimilarIdea{this.state.loading ? (<Loader />) : (- <ListIdeas- ideas={this.state.ideas}+ <ListPosts+ posts={this.state.posts}tags={this.props.tags}- emptyText={`No similar ideas matched '${this.props.title}'.`}+ emptyText={`No similar posts matched '${this.props.title}'.`}/>)}</>diff --git a/public/pages/Home/index.ts b/public/pages/Home/index.tsindex bfea53594..b3e38345f 100644--- a/public/pages/Home/index.ts+++ b/public/pages/Home/index.ts@@ -1,6 +1,6 @@export * from "./Home.page";export * from "./components/TagsFilter";-export * from "./components/IdeaFilter";-export * from "./components/IdeaInput";-export * from "./components/ListIdeas";-export * from "./components/IdeasContainer";+export * from "./components/PostFilter";+export * from "./components/PostInput";+export * from "./components/ListPosts";+export * from "./components/PostsContainer";diff --git a/public/pages/MySettings/components/NotificationSettings.tsx b/public/pages/MySettings/components/NotificationSettings.tsxindex 1b812169a..2800cd439 100644--- a/public/pages/MySettings/components/NotificationSettings.tsx+++ b/public/pages/MySettings/components/NotificationSettings.tsx@@ -97,12 +97,8 @@ export class NotificationSettings extends React.Component<NotificationSettingsPr<div className="notifications-settings"><Segments><Segment>- <span className="event-title">New Idea</span>- {this.info(- "event_notification_new_idea",- "new ideas posted on this site",- "new ideas posted on this site"- )}+ <span className="event-title">New Post</span>+ {this.info("event_notification_new_idea", "new posts on this site", "new posts on this site")}<p>{this.icon("event_notification_new_idea", WebChannel)}{this.icon("event_notification_new_idea", EmailChannel)}@@ -112,8 +108,8 @@ export class NotificationSettings extends React.Component<NotificationSettingsPr<span className="event-title">Discussion</span>{this.info("event_notification_new_comment",- "comments on ideas you've subscribed to",- "comments on all ideas unless individually unsubscribed"+ "comments on posts you've subscribed to",+ "comments on all posts unless individually unsubscribed")}<p>{this.icon("event_notification_new_comment", WebChannel)}@@ -124,8 +120,8 @@ export class NotificationSettings extends React.Component<NotificationSettingsPr<span className="event-title">Status Changed</span>{this.info("event_notification_change_status",- "status change on ideas you've subscribed to",- "status change on all ideas unless individually unsubscribed"+ "status change on posts you've subscribed to",+ "status change on all posts unless individually unsubscribed")}<p>{this.icon("event_notification_change_status", WebChannel)}diff --git a/public/pages/ShowIdea/ShowIdea.page.scss b/public/pages/ShowPost/ShowPost.page.scsssimilarity index 95%rename from public/pages/ShowIdea/ShowIdea.page.scssrename to public/pages/ShowPost/ShowPost.page.scssindex 1c1a51eb5..2bae0c7eb 100644--- a/public/pages/ShowIdea/ShowIdea.page.scss+++ b/public/pages/ShowPost/ShowPost.page.scss@@ -1,8 +1,8 @@@import '~@fider/assets/styles/variables.scss';-#p-show-idea {+#p-show-post {- .idea-header {+ .post-header {width: 100%;h1 {font-weight: 400;@@ -54,7 +54,7 @@}.c-response-form {- .c-idea-search {+ .c-post-search {.support {text-align: center;width: 50px;diff --git a/public/pages/ShowIdea/ShowIdea.page.tsx b/public/pages/ShowPost/ShowPost.page.tsxsimilarity index 71%rename from public/pages/ShowIdea/ShowIdea.page.tsxrename to public/pages/ShowPost/ShowPost.page.tsxindex ae65d0d5c..e7a4f732a 100644--- a/public/pages/ShowIdea/ShowIdea.page.tsx+++ b/public/pages/ShowPost/ShowPost.page.tsx@@ -1,14 +1,14 @@-import "./ShowIdea.page.scss";+import "./ShowPost.page.scss";import * as React from "react";-import { Comment, Idea, Tag } from "@fider/models";+import { Comment, Post, Tag } from "@fider/models";import { actions, Failure, Fider } from "@fider/services";import { TagsPanel, DiscussionPanel, ResponseForm, NotificationsPanel, ModerationPanel } from "./";import {SupportCounter,- ShowIdeaResponse,+ ShowPostResponse,DisplayError,Button,UserName,@@ -22,40 +22,40 @@ import {TextArea} from "@fider/components";-interface ShowIdeaPageProps {- idea: Idea;+interface ShowPostPageProps {+ post: Post;subscribed: boolean;comments: Comment[];tags: Tag[];}-interface ShowIdeaPageState {+interface ShowPostPageState {editMode: boolean;newTitle: string;newDescription: string;error?: Failure;}-export class ShowIdeaPage extends React.Component<ShowIdeaPageProps, ShowIdeaPageState> {- constructor(props: ShowIdeaPageProps) {+export class ShowPostPage extends React.Component<ShowPostPageProps, ShowPostPageState> {+ constructor(props: ShowPostPageProps) {super(props);this.state = {editMode: false,- newTitle: this.props.idea.title,- newDescription: this.props.idea.description+ newTitle: this.props.post.title,+ newDescription: this.props.post.description};}private saveChanges = async () => {- const result = await actions.updateIdea(this.props.idea.number, this.state.newTitle, this.state.newDescription);+ const result = await actions.updatePost(this.props.post.number, this.state.newTitle, this.state.newDescription);if (result.ok) {this.setState({error: undefined,editMode: false});- this.props.idea.title = this.state.newTitle;- this.props.idea.description = this.state.newDescription;+ this.props.post.title = this.state.newTitle;+ this.props.post.description = this.state.newDescription;this.forceUpdate();} else {this.setState({@@ -82,24 +82,24 @@ export class ShowIdeaPage extends React.Component<ShowIdeaPageProps, ShowIdeaPagpublic render() {return (- <div id="p-show-idea" className="page container">+ <div id="p-show-post" className="page container"><div className="header-col"><List><ListItem>- <SupportCounter idea={this.props.idea} />+ <SupportCounter post={this.props.post} />- <div className="idea-header">+ <div className="post-header">{this.state.editMode ? (<Form error={this.state.error}><Input field="title" maxLength={100} value={this.state.newTitle} onChange={this.setNewTitle} /></Form>) : (- <h1>{this.props.idea.title}</h1>+ <h1>{this.props.post.title}</h1>)}<span className="info">- Shared <Moment date={this.props.idea.createdOn} /> by <Gravatar user={this.props.idea.user} />{" "}- <UserName user={this.props.idea.user} />+ Shared <Moment date={this.props.post.createdOn} /> by <Gravatar user={this.props.post.user} />{" "}+ <UserName user={this.props.post.user} /></span></div></ListItem>@@ -113,12 +113,12 @@ export class ShowIdeaPage extends React.Component<ShowIdeaPageProps, ShowIdeaPag) : (<MultiLineTextclassName="description"- text={this.props.idea.description || "No description provided."}+ text={this.props.post.description || "No description provided."}style="simple"/>)}- <ShowIdeaResponse status={this.props.idea.status} response={this.props.idea.response} />+ <ShowPostResponse status={this.props.post.status} response={this.props.post.response} /></div><div className="action-col">@@ -148,18 +148,18 @@ export class ShowIdeaPage extends React.Component<ShowIdeaPageProps, ShowIdeaPag</Button></ListItem><ListItem>- <ResponseForm idea={this.props.idea} />+ <ResponseForm post={this.props.post} /></ListItem></List>)]}- <TagsPanel idea={this.props.idea} tags={this.props.tags} />- <NotificationsPanel idea={this.props.idea} subscribed={this.props.subscribed} />- <ModerationPanel idea={this.props.idea} />+ <TagsPanel post={this.props.post} tags={this.props.tags} />+ <NotificationsPanel post={this.props.post} subscribed={this.props.subscribed} />+ <ModerationPanel post={this.props.post} /></div>- <DiscussionPanel idea={this.props.idea} comments={this.props.comments} />+ <DiscussionPanel post={this.props.post} comments={this.props.comments} /></div>);}diff --git a/public/pages/ShowIdea/components/CommentInput.tsx b/public/pages/ShowPost/components/CommentInput.tsxsimilarity index 93%rename from public/pages/ShowIdea/components/CommentInput.tsxrename to public/pages/ShowPost/components/CommentInput.tsxindex 8fa027963..6c443d0b4 100644--- a/public/pages/ShowIdea/components/CommentInput.tsx+++ b/public/pages/ShowPost/components/CommentInput.tsx@@ -1,14 +1,14 @@import * as React from "react";import * as ReactDOM from "react-dom";-import { Idea, CurrentUser } from "@fider/models";+import { Post, CurrentUser } from "@fider/models";import { Gravatar, UserName, Button, DisplayError, SignInControl, TextArea, Form } from "@fider/components/common";import { SignInModal } from "@fider/components";import { cache, actions, Failure, Fider } from "@fider/services";interface CommentInputProps {- idea: Idea;+ post: Post;}interface CommentInputState {@@ -32,7 +32,7 @@ export class CommentInput extends React.Component<CommentInputProps, CommentInpu}private getCacheKey(): string {- return `${CACHE_TITLE_KEY}${this.props.idea.id}`;+ return `${CACHE_TITLE_KEY}${this.props.post.id}`;}private commentChanged = (content: string) => {@@ -45,7 +45,7 @@ export class CommentInput extends React.Component<CommentInputProps, CommentInpuerror: undefined});- const result = await actions.createComment(this.props.idea.number, this.state.content);+ const result = await actions.createComment(this.props.post.number, this.state.content);if (result.ok) {cache.remove(this.getCacheKey());location.reload();diff --git a/public/pages/ShowIdea/components/Comments.scss b/public/pages/ShowPost/components/Comments.scsssimilarity index 100%rename from public/pages/ShowIdea/components/Comments.scssrename to public/pages/ShowPost/components/Comments.scssdiff --git a/public/pages/ShowIdea/components/DiscussionPanel.tsx b/public/pages/ShowPost/components/DiscussionPanel.tsxsimilarity index 79%rename from public/pages/ShowIdea/components/DiscussionPanel.tsxrename to public/pages/ShowPost/components/DiscussionPanel.tsxindex 774612f0c..af9484afd 100644--- a/public/pages/ShowIdea/components/DiscussionPanel.tsx+++ b/public/pages/ShowPost/components/DiscussionPanel.tsx@@ -1,13 +1,13 @@import "./Comments.scss";import * as React from "react";-import { CurrentUser, Comment, Idea } from "@fider/models";+import { CurrentUser, Comment, Post } from "@fider/models";import { ShowComment, CommentInput } from "../";import { actions } from "@fider/services";interface DiscussionPanelProps {user?: CurrentUser;- idea: Idea;+ post: Post;comments: Comment[];}@@ -21,8 +21,8 @@ export class DiscussionPanel extends React.Component<DiscussionPanelProps, {}> {<div className="comments-col"><div className="c-comment-list"><span className="subtitle">Discussion</span>- {this.props.comments.map(c => <ShowComment key={c.id} idea={this.props.idea} comment={c} />)}- <CommentInput idea={this.props.idea} />+ {this.props.comments.map(c => <ShowComment key={c.id} post={this.props.post} comment={c} />)}+ <CommentInput post={this.props.post} /></div></div>);diff --git a/public/pages/ShowIdea/components/ModerationPanel.tsx b/public/pages/ShowPost/components/ModerationPanel.tsxsimilarity index 90%rename from public/pages/ShowIdea/components/ModerationPanel.tsxrename to public/pages/ShowPost/components/ModerationPanel.tsxindex 1071703ef..32da55d06 100644--- a/public/pages/ShowIdea/components/ModerationPanel.tsx+++ b/public/pages/ShowPost/components/ModerationPanel.tsx@@ -1,10 +1,10 @@import * as React from "react";-import { IdeaStatus, Idea } from "@fider/models";+import { PostStatus, Post } from "@fider/models";import { actions, navigator, Failure, Fider } from "@fider/services";import { Form, Modal, Button, List, ListItem, TextArea } from "@fider/components";interface ModerationPanelProps {- idea: Idea;+ post: Post;}interface ModerationPanelState {@@ -25,7 +25,7 @@ export class ModerationPanel extends React.Component<ModerationPanelProps, Moder}private delete = async () => {- const response = await actions.deleteIdea(this.props.idea.number, this.state.text);+ const response = await actions.deletePost(this.props.post.number, this.state.text);if (response.ok) {await this.closeModal();navigator.goHome();@@ -47,7 +47,7 @@ export class ModerationPanel extends React.Component<ModerationPanelProps, Moder};public render() {- const status = IdeaStatus.Get(this.props.idea.status);+ const status = PostStatus.Get(this.props.post.status);if (!Fider.session.isAuthenticated || !Fider.session.user.isAdministrator || status.closed) {return null;}@@ -60,7 +60,7 @@ export class ModerationPanel extends React.Component<ModerationPanelProps, Moderfield="text"onChange={this.setText}value={this.state.text}- placeholder="Why are you deleting this idea? (optional)"+ placeholder="Why are you deleting this post? (optional)"><span className="info">This operation <strong>cannot</strong> be undone.diff --git a/public/pages/ShowIdea/components/NotificationsPanel.tsx b/public/pages/ShowPost/components/NotificationsPanel.tsxsimilarity index 89%rename from public/pages/ShowIdea/components/NotificationsPanel.tsxrename to public/pages/ShowPost/components/NotificationsPanel.tsxindex c3e2aa2b9..46690c9d9 100644--- a/public/pages/ShowIdea/components/NotificationsPanel.tsx+++ b/public/pages/ShowPost/components/NotificationsPanel.tsx@@ -1,10 +1,10 @@import * as React from "react";-import { CurrentUser, Idea } from "@fider/models";+import { CurrentUser, Post } from "@fider/models";import { Button, List, ListItem } from "@fider/components";import { actions, Fider } from "@fider/services";interface NotificationsPanelProps {- idea: Idea;+ post: Post;subscribed: boolean;}@@ -21,7 +21,7 @@ export class NotificationsPanel extends React.Component<NotificationsPanelProps,private subscribeOrUnsubscribe = async () => {const action = this.state.subscribed ? actions.unsubscribe : actions.subscribe;- const response = await action(this.props.idea.number);+ const response = await action(this.props.post.number);if (response.ok) {this.setState(state => ({subscribed: !state.subscribed@@ -45,9 +45,9 @@ export class NotificationsPanel extends React.Component<NotificationsPanelProps,);const text = this.state.subscribed ? (- <span className="info">You’re receiving notifications about activity on this idea.</span>+ <span className="info">You’re receiving notifications about activity on this post.</span>) : (- <span className="info">You'll not receive any notification about this idea.</span>+ <span className="info">You'll not receive any notification about this post.</span>);return (diff --git a/public/pages/ShowIdea/components/IdeaSearch.tsx b/public/pages/ShowPost/components/PostSearch.tsxsimilarity index 74%rename from public/pages/ShowIdea/components/IdeaSearch.tsxrename to public/pages/ShowPost/components/PostSearch.tsxindex 687e953ec..caef94824 100644--- a/public/pages/ShowIdea/components/IdeaSearch.tsx+++ b/public/pages/ShowPost/components/PostSearch.tsx@@ -1,24 +1,24 @@import * as React from "react";-import { Idea, IdeaStatus } from "@fider/models";+import { Post, PostStatus } from "@fider/models";import { actions } from "@fider/services";import { Dropdown, DropdownProps, DropdownItemProps, DropdownOnSearchChangeData } from "@fider/components";-interface IdeaSearchProps {+interface PostSearchProps {exclude?: number[];- onChanged(ideaNumber: number): void;+ onChanged(postNumber: number): void;}-interface IdeaSearchState {- ideas: Idea[];+interface PostSearchState {+ posts: Post[];}-export class IdeaSearch extends React.Component<IdeaSearchProps, IdeaSearchState> {+export class PostSearch extends React.Component<PostSearchProps, PostSearchState> {private timer?: number;- constructor(props: IdeaSearchProps) {+ constructor(props: PostSearchProps) {super(props);this.state = {- ideas: []+ posts: []};this.search("");}@@ -34,12 +34,12 @@ export class IdeaSearch extends React.Component<IdeaSearchProps, IdeaSearchStateprivate search = (searchQuery: string) => {window.clearTimeout(this.timer);this.timer = window.setTimeout(() => {- actions.searchIdeas({ query: searchQuery }).then(res => {- const ideas =+ actions.searchPosts({ query: searchQuery }).then(res => {+ const posts =this.props.exclude && this.props.exclude.length > 0? res.data.filter(i => this.props.exclude!.indexOf(i.number) === -1): res.data;- this.setState({ ideas });+ this.setState({ posts });});}, 200);};@@ -47,8 +47,8 @@ export class IdeaSearch extends React.Component<IdeaSearchProps, IdeaSearchStateprivate returnAll = (options: DropdownItemProps[], value: string) => options;public render() {- const options = this.state.ideas.map(i => {- const status = IdeaStatus.Get(i.status);+ const options = this.state.posts.map(i => {+ const status = PostStatus.Get(i.status);return {key: i.number,text: i.title,@@ -68,13 +68,13 @@ export class IdeaSearch extends React.Component<IdeaSearchProps, IdeaSearchStatereturn (<Dropdown- className="c-idea-search"+ className="c-post-search"fluid={true}selectOnBlur={false}selection={true}search={this.returnAll}options={options}- placeholder="Search original idea"+ placeholder="Search original post"onChange={this.onChange}onSearchChange={this.onSearchChange}/>diff --git a/public/pages/ShowIdea/components/ResponseForm.tsx b/public/pages/ShowPost/components/ResponseForm.tsxsimilarity index 80%rename from public/pages/ShowIdea/components/ResponseForm.tsxrename to public/pages/ShowPost/components/ResponseForm.tsxindex 44783acae..6abc1f7f1 100644--- a/public/pages/ShowIdea/components/ResponseForm.tsx+++ b/public/pages/ShowPost/components/ResponseForm.tsx@@ -1,13 +1,13 @@import * as React from "react";import { Modal, Button, DisplayError, Textarea, Select, Form, TextArea, Field, SelectOption } from "@fider/components";-import { Comment, Idea, IdeaStatus, User } from "@fider/models";-import { IdeaSearch } from "../";+import { Comment, Post, PostStatus, User } from "@fider/models";+import { PostSearch } from "../";import { actions, Failure } from "@fider/services";interface ResponseFormProps {- idea: Idea;+ post: Post;}interface ResponseFormState {@@ -24,14 +24,14 @@ export class ResponseForm extends React.Component<ResponseFormProps, ResponseForthis.state = {showModal: false,- status: this.props.idea.status,+ status: this.props.post.status,originalNumber: 0,- text: this.props.idea.response ? this.props.idea.response.text : ""+ text: this.props.post.response ? this.props.post.response.text : ""};}private submit = async () => {- const result = await actions.respond(this.props.idea.number, this.state);+ const result = await actions.respond(this.props.post.number, this.state);if (result.ok) {location.reload();} else {@@ -70,7 +70,7 @@ export class ResponseForm extends React.Component<ResponseFormProps, ResponseFor</Button>);- const options = IdeaStatus.All.map(s => ({+ const options = PostStatus.All.map(s => ({value: s.value.toString(),label: s.title}));@@ -82,17 +82,17 @@ export class ResponseForm extends React.Component<ResponseFormProps, ResponseFor<Selectfield="status"label="Status"- defaultValue={this.props.idea.status.toString()}+ defaultValue={this.props.post.status.toString()}options={options}onChange={this.setStatus}/>- {this.state.status === IdeaStatus.Duplicate.value ? (+ {this.state.status === PostStatus.Duplicate.value ? (<><Field>- <IdeaSearch exclude={[this.props.idea.number]} onChanged={this.setOriginalNumber} />+ <PostSearch exclude={[this.props.post.number]} onChanged={this.setOriginalNumber} /></Field><DisplayError fields={["originalNumber"]} error={this.state.error} />- <span className="info">Votes from this idea will be merged into original idea.</span>+ <span className="info">Votes from this post will be merged into original post.</span></>) : (<TextArea@@ -100,7 +100,7 @@ export class ResponseForm extends React.Component<ResponseFormProps, ResponseForonChange={this.setText}value={this.state.text}minRows={5}- placeholder="What's going on with this idea? Let your users know what are your plans..."+ placeholder="What's going on with this post? Let your users know what are your plans..."/>)}</Form>diff --git a/public/pages/ShowIdea/components/ShowComment.tsx b/public/pages/ShowPost/components/ShowComment.tsxsimilarity index 96%rename from public/pages/ShowIdea/components/ShowComment.tsxrename to public/pages/ShowPost/components/ShowComment.tsxindex 45caef2db..5ad1be122 100644--- a/public/pages/ShowIdea/components/ShowComment.tsx+++ b/public/pages/ShowPost/components/ShowComment.tsx@@ -1,10 +1,10 @@import * as React from "react";-import { Comment, CurrentUser, Idea } from "@fider/models";+import { Comment, CurrentUser, Post } from "@fider/models";import { Gravatar, UserName, Moment, Form, TextArea, Button, MultiLineText } from "@fider/components";import { formatDate, Failure, actions, Fider } from "@fider/services";interface ShowCommentProps {- idea: Idea;+ post: Post;comment: Comment;}@@ -45,7 +45,7 @@ export class ShowComment extends React.Component<ShowCommentProps, ShowCommentSt};private saveEdit = async () => {- const response = await actions.updateComment(this.props.idea.number, this.state.comment.id, this.state.newContent);+ const response = await actions.updateComment(this.props.post.number, this.state.comment.id, this.state.newContent);if (response.ok) {this.state.comment.content = this.state.newContent;this.state.comment.editedOn = new Date().toISOString();diff --git a/public/pages/ShowIdea/components/TagListItem.tsx b/public/pages/ShowPost/components/TagListItem.tsxsimilarity index 100%rename from public/pages/ShowIdea/components/TagListItem.tsxrename to public/pages/ShowPost/components/TagListItem.tsxdiff --git a/public/pages/ShowIdea/components/TagsPanel.tsx b/public/pages/ShowPost/components/TagsPanel.tsxsimilarity index 93%rename from public/pages/ShowIdea/components/TagsPanel.tsxrename to public/pages/ShowPost/components/TagsPanel.tsxindex d1562d635..62025ac1e 100644--- a/public/pages/ShowIdea/components/TagsPanel.tsx+++ b/public/pages/ShowPost/components/TagsPanel.tsx@@ -1,11 +1,11 @@import * as React from "react";-import { CurrentUser, Tag, Idea } from "@fider/models";+import { CurrentUser, Tag, Post } from "@fider/models";import { actions, Fider } from "@fider/services";import { ShowTag, List, ListItem } from "@fider/components";import { TagListItem } from "./TagListItem";interface TagsPanelProps {- idea: Idea;+ post: Post;tags: Tag[];}@@ -21,7 +21,7 @@ export class TagsPanel extends React.Component<TagsPanelProps, TagsPanelState> {this.state = {canEdit: Fider.session.isAuthenticated && Fider.session.user.isCollaborator && this.props.tags.length > 0,isEditing: false,- assignedTags: this.props.tags.filter(t => this.props.idea.tags.indexOf(t.slug) >= 0)+ assignedTags: this.props.tags.filter(t => this.props.post.tags.indexOf(t.slug) >= 0)};}@@ -29,12 +29,12 @@ export class TagsPanel extends React.Component<TagsPanelProps, TagsPanelState> {const idx = this.state.assignedTags.indexOf(tag);let assignedTags: Tag[] = [];if (idx >= 0) {- const response = await actions.unassignTag(tag.slug, this.props.idea.number);+ const response = await actions.unassignTag(tag.slug, this.props.post.number);if (response.ok) {assignedTags = this.state.assignedTags.splice(idx, 1) && this.state.assignedTags;}} else {- const response = await actions.assignTag(tag.slug, this.props.idea.number);+ const response = await actions.assignTag(tag.slug, this.props.post.number);if (response.ok) {assignedTags = this.state.assignedTags.concat(tag);}diff --git a/public/pages/ShowIdea/index.ts b/public/pages/ShowPost/index.tssimilarity index 80%rename from public/pages/ShowIdea/index.tsrename to public/pages/ShowPost/index.tsindex 373b553aa..3abbbbd97 100644--- a/public/pages/ShowIdea/index.ts+++ b/public/pages/ShowPost/index.ts@@ -1,8 +1,8 @@-export * from "./ShowIdea.page";+export * from "./ShowPost.page";export * from "./components/CommentInput";export * from "./components/ResponseForm";export * from "./components/ShowComment";-export * from "./components/IdeaSearch";+export * from "./components/PostSearch";export * from "./components/TagsPanel";export * from "./components/ModerationPanel";export * from "./components/NotificationsPanel";diff --git a/public/pages/UI/UIToolkit.page.tsx b/public/pages/UI/UIToolkit.page.tsxindex 8af72b4eb..39f9a64b1 100644--- a/public/pages/UI/UIToolkit.page.tsx+++ b/public/pages/UI/UIToolkit.page.tsx@@ -1,5 +1,5 @@import * as React from "react";-import { CurrentUser, IdeaStatus, UserStatus } from "@fider/models";+import { CurrentUser, PostStatus, UserStatus } from "@fider/models";import {Heading,Button,@@ -11,7 +11,7 @@ import {ShowTag,Segment,Segments,- ShowIdeaStatus,+ ShowPostStatus,Moment,Loader,Form,@@ -233,22 +233,22 @@ export class UIToolkitPage extends React.Component<{}, UIToolkitPageState> {<h1>Statuses</h1><List><ListItem>- <ShowIdeaStatus status={IdeaStatus.Open} />+ <ShowPostStatus status={PostStatus.Open} /></ListItem><ListItem>- <ShowIdeaStatus status={IdeaStatus.Planned} />+ <ShowPostStatus status={PostStatus.Planned} /></ListItem><ListItem>- <ShowIdeaStatus status={IdeaStatus.Started} />+ <ShowPostStatus status={PostStatus.Started} /></ListItem><ListItem>- <ShowIdeaStatus status={IdeaStatus.Duplicate} />+ <ShowPostStatus status={PostStatus.Duplicate} /></ListItem><ListItem>- <ShowIdeaStatus status={IdeaStatus.Completed} />+ <ShowPostStatus status={PostStatus.Completed} /></ListItem><ListItem>- <ShowIdeaStatus status={IdeaStatus.Declined} />+ <ShowPostStatus status={PostStatus.Declined} /></ListItem></List>diff --git a/public/pages/index.ts b/public/pages/index.tsindex fdd2562d9..14898de38 100644--- a/public/pages/index.ts+++ b/public/pages/index.ts@@ -6,5 +6,5 @@ export * from "./CompleteSignInProfile";export * from "./OAuthEcho";export * from "./MySettings";export * from "./MyNotifications";-export * from "./ShowIdea";+export * from "./ShowPost";export * from "./UI";diff --git a/public/router.spec.tsx b/public/router.spec.tsxindex 7cd3c8dfa..342b4f39a 100644--- a/public/router.spec.tsx+++ b/public/router.spec.tsx@@ -1,11 +1,11 @@import { resolveRootComponent } from "./router";-import { HomePage, ShowIdeaPage, InvitationsPage, GeneralSettingsPage, OAuthEchoPage } from "@fider/pages";+import { HomePage, ShowPostPage, InvitationsPage, GeneralSettingsPage, OAuthEchoPage } from "@fider/pages";[{ path: "", expected: HomePage },- { path: "/ideas/123", expected: ShowIdeaPage },- { path: "/ideas/123/the-slug", expected: ShowIdeaPage },- { path: "/ideas" },+ { path: "/posts/123", expected: ShowPostPage },+ { path: "/posts/123/the-slug", expected: ShowPostPage },+ { path: "/posts" },{ path: "/admin", expected: GeneralSettingsPage },{ path: "/admin/invitations", expected: InvitationsPage },{ path: "/oauth/_name/echo", expected: OAuthEchoPage }diff --git a/public/router.tsx b/public/router.tsxindex 371db96a7..eb7508fc4 100644--- a/public/router.tsx+++ b/public/router.tsx@@ -14,7 +14,7 @@ import {ManageAuthenticationPage,ManageTagsPage,OAuthEchoPage,- ShowIdeaPage,+ ShowPostPage,MySettingsPage,MyNotificationsPage,UIToolkitPage@@ -39,7 +39,7 @@ const route = (path: string, component: any, showHeader: boolean = true): PageCoconst pathRegex = [route("", HomePage),- route("/ideas/:number*", ShowIdeaPage),+ route("/posts/:number*", ShowPostPage),route("/admin/members", ManageMembersPage),route("/admin/tags", ManageTagsPage),route("/admin/privacy", PrivacySettingsPage),diff --git a/public/services/actions/idea.ts b/public/services/actions/idea.tsdeleted file mode 100644index bfbdb0800..000000000--- a/public/services/actions/idea.ts+++ /dev/null@@ -1,80 +0,0 @@-import { http, Result, querystring } from "@fider/services";-import { Idea } from "@fider/models";--export const getAllIdeas = async (): Promise<Result<Idea[]>> => {- return await http.get<Idea[]>("/api/ideas/search");-};--export interface SearchIdeasParams {- query?: string;- filter?: string;- limit?: number;- tags?: string[];-}--export const searchIdeas = async (params: SearchIdeasParams): Promise<Result<Idea[]>> => {- return await http.get<Idea[]>(- `/api/ideas/search${querystring.stringify({- t: params.tags,- q: params.query,- f: params.filter,- l: params.limit- })}`- );-};--export const deleteIdea = async (ideaNumber: number, text: string): Promise<Result> => {- return http- .delete(`/api/ideas/${ideaNumber}`, {- text- })- .then(http.event("idea", "delete"));-};--export const addSupport = async (ideaNumber: number): Promise<Result> => {- return http.post(`/api/ideas/${ideaNumber}/support`).then(http.event("idea", "support"));-};--export const removeSupport = async (ideaNumber: number): Promise<Result> => {- return http.post(`/api/ideas/${ideaNumber}/unsupport`).then(http.event("idea", "unsupport"));-};--export const subscribe = async (ideaNumber: number): Promise<Result> => {- return http.post(`/api/ideas/${ideaNumber}/subscribe`).then(http.event("idea", "subscribe"));-};--export const unsubscribe = async (ideaNumber: number): Promise<Result> => {- return http.post(`/api/ideas/${ideaNumber}/unsubscribe`).then(http.event("idea", "unsubscribe"));-};--export const createComment = async (ideaNumber: number, content: string): Promise<Result> => {- return http.post(`/api/ideas/${ideaNumber}/comments`, { content }).then(http.event("comment", "create"));-};--export const updateComment = async (ideaNumber: number, commentId: number, content: string): Promise<Result> => {- return http.post(`/api/ideas/${ideaNumber}/comments/${commentId}`, { content }).then(http.event("comment", "update"));-};--interface SetResponseInput {- status: number;- text: string;- originalNumber: number;-}--export const respond = async (ideaNumber: number, input: SetResponseInput): Promise<Result> => {- return http- .post(`/api/ideas/${ideaNumber}/status`, {- status: input.status,- text: input.text,- originalNumber: input.originalNumber- })- .then(http.event("idea", "respond"));-};--export const createIdea = async (title: string, description: string): Promise<Result<Idea>> => {- return http.post<Idea>(`/api/ideas`, { title, description }).then(http.event("idea", "create"));-};--export const updateIdea = async (ideaNumber: number, title: string, description: string): Promise<Result> => {- return http.post(`/api/ideas/${ideaNumber}`, { title, description }).then(http.event("idea", "update"));-};diff --git a/public/services/actions/index.ts b/public/services/actions/index.tsindex 5a997c828..8a9e074c0 100644--- a/public/services/actions/index.ts+++ b/public/services/actions/index.ts@@ -1,6 +1,6 @@export * from "./user";export * from "./tag";-export * from "./idea";+export * from "./post";export * from "./tenant";export * from "./notification";export * from "./invite";diff --git a/public/services/actions/post.ts b/public/services/actions/post.tsnew file mode 100644index 000000000..2fcfe4fb5--- /dev/null+++ b/public/services/actions/post.ts@@ -0,0 +1,80 @@+import { http, Result, querystring } from "@fider/services";+import { Post } from "@fider/models";++export const getAllPosts = async (): Promise<Result<Post[]>> => {+ return await http.get<Post[]>("/api/posts/search");+};++export interface SearchPostsParams {+ query?: string;+ filter?: string;+ limit?: number;+ tags?: string[];+}++export const searchPosts = async (params: SearchPostsParams): Promise<Result<Post[]>> => {+ return await http.get<Post[]>(+ `/api/posts/search${querystring.stringify({+ t: params.tags,+ q: params.query,+ f: params.filter,+ l: params.limit+ })}`+ );+};++export const deletePost = async (postNumber: number, text: string): Promise<Result> => {+ return http+ .delete(`/api/posts/${postNumber}`, {+ text+ })+ .then(http.event("post", "delete"));+};++export const addSupport = async (postNumber: number): Promise<Result> => {+ return http.post(`/api/posts/${postNumber}/support`).then(http.event("post", "support"));+};++export const removeSupport = async (postNumber: number): Promise<Result> => {+ return http.post(`/api/posts/${postNumber}/unsupport`).then(http.event("post", "unsupport"));+};++export const subscribe = async (postNumber: number): Promise<Result> => {+ return http.post(`/api/posts/${postNumber}/subscribe`).then(http.event("post", "subscribe"));+};++export const unsubscribe = async (postNumber: number): Promise<Result> => {+ return http.post(`/api/posts/${postNumber}/unsubscribe`).then(http.event("post", "unsubscribe"));+};++export const createComment = async (postNumber: number, content: string): Promise<Result> => {+ return http.post(`/api/posts/${postNumber}/comments`, { content }).then(http.event("comment", "create"));+};++export const updateComment = async (postNumber: number, commentId: number, content: string): Promise<Result> => {+ return http.post(`/api/posts/${postNumber}/comments/${commentId}`, { content }).then(http.event("comment", "update"));+};++interface SetResponseInput {+ status: number;+ text: string;+ originalNumber: number;+}++export const respond = async (postNumber: number, input: SetResponseInput): Promise<Result> => {+ return http+ .post(`/api/posts/${postNumber}/status`, {+ status: input.status,+ text: input.text,+ originalNumber: input.originalNumber+ })+ .then(http.event("post", "respond"));+};++export const createPost = async (title: string, description: string): Promise<Result<Post>> => {+ return http.post<Post>(`/api/posts`, { title, description }).then(http.event("post", "create"));+};++export const updatePost = async (postNumber: number, title: string, description: string): Promise<Result> => {+ return http.post(`/api/posts/${postNumber}`, { title, description }).then(http.event("post", "update"));+};diff --git a/public/services/actions/tag.ts b/public/services/actions/tag.tsindex e9e5bb6b2..1f29fca33 100644--- a/public/services/actions/tag.ts+++ b/public/services/actions/tag.ts@@ -13,10 +13,10 @@ export const deleteTag = async (slug: string): Promise<Result> => {return http.delete(`/api/admin/tags/${slug}`).then(http.event("tag", "delete"));};-export const assignTag = async (slug: string, ideaNumber: number): Promise<Result> => {- return http.post(`/api/ideas/${ideaNumber}/tags/${slug}`).then(http.event("tag", "assign"));+export const assignTag = async (slug: string, postNumber: number): Promise<Result> => {+ return http.post(`/api/posts/${postNumber}/tags/${slug}`).then(http.event("tag", "assign"));};-export const unassignTag = async (slug: string, ideaNumber: number): Promise<Result> => {- return http.delete(`/api/ideas/${ideaNumber}/tags/${slug}`).then(http.event("tag", "unassign"));+export const unassignTag = async (slug: string, postNumber: number): Promise<Result> => {+ return http.delete(`/api/posts/${postNumber}/tags/${slug}`).then(http.event("tag", "unassign"));};diff --git a/tests/pages/HomePage.ts b/tests/pages/HomePage.tsindex 0e6adcf9b..b091e8723 100644--- a/tests/pages/HomePage.ts+++ b/tests/pages/HomePage.ts@@ -9,8 +9,8 @@ import {Button,elementIsNotVisible} from "../lib";-import { ShowIdeaPage, FacebookSignInPage } from ".";-import { IdeaList } from "./components";+import { ShowPostPage, FacebookSignInPage } from ".";+import { PostList } from "./components";export class HomePage extends Page {constructor(tab: BrowserTab) {@@ -23,9 +23,9 @@ export class HomePage extends Page {@findBy(".c-menu-item-title") public MenuTitle!: WebComponent;@findBy(".welcome-message") public WelcomeMessage!: WebComponent;- @findBy("#input-title") public IdeaTitle!: TextInput;- @findBy("#input-description") public IdeaDescription!: TextInput;- @findBy(".c-button.m-positive") public SubmitIdea!: Button;+ @findBy("#input-title") public PostTitle!: TextInput;+ @findBy("#input-description") public PostDescription!: TextInput;+ @findBy(".c-button.m-positive") public SubmitPost!: Button;@findBy(".c-menu-item-signin") public UserMenu!: WebComponent;@findBy(".c-unread-count") public UnreadCounter!: WebComponent;@findBy(".c-menu-user-heading") public UserName!: WebComponent;@@ -34,7 +34,7 @@ export class HomePage extends Page {@findBy(".c-modal-window .c-signin-control #input-email") private EmailSignInInput!: TextInput;@findBy(".c-modal-window .c-signin-control .c-button.m-positive") private EmailSignInButton!: TextInput;@findBy(".signout") private SignOut!: Button;- @findBy(".c-idea-list") public IdeaList!: IdeaList;+ @findBy(".c-post-list") public PostList!: PostList;@findBy(".c-modal-window input") private CompleteEmailSignInInput!: TextInput;@findBy(".c-modal-window button") private CompleteEmailSignInButton!: Button;@@ -42,11 +42,11 @@ export class HomePage extends Page {return elementIsVisible("#p-home");}- public async submitNewIdea(title: string, description: string): Promise<void> {- await this.IdeaTitle.type(title);- await this.IdeaDescription.type(description);- await this.SubmitIdea.click();- await this.tab.wait(pageHasLoaded(ShowIdeaPage));+ public async submitNewPost(title: string, description: string): Promise<void> {+ await this.PostTitle.type(title);+ await this.PostDescription.type(description);+ await this.SubmitPost.click();+ await this.tab.wait(pageHasLoaded(ShowPostPage));}public async signOut(): Promise<void> {diff --git a/tests/pages/ShowIdeaPage.ts b/tests/pages/ShowPostPage.tssimilarity index 95%rename from tests/pages/ShowIdeaPage.tsrename to tests/pages/ShowPostPage.tsindex cbb141991..d45281602 100644--- a/tests/pages/ShowIdeaPage.ts+++ b/tests/pages/ShowPostPage.ts@@ -1,12 +1,12 @@import { BrowserTab, Page, WebComponent, TextInput, Button, findBy, elementIsVisible, DropDownList } from "../lib";import { CommentList } from "./components";-export class ShowIdeaPage extends Page {+export class ShowPostPage extends Page {constructor(tab: BrowserTab) {super(tab);}- @findBy(".idea-header h1") public Title!: WebComponent;+ @findBy(".post-header h1") public Title!: WebComponent;@findBy(".description") public Description!: WebComponent;@findBy(".c-segment.l-response .status-label") public Status!: WebComponent;@findBy(".c-segment.l-response .content") public ResponseText!: WebComponent;diff --git a/tests/pages/components/IdeaList.ts b/tests/pages/components/PostList.tssimilarity index 71%rename from tests/pages/components/IdeaList.tsrename to tests/pages/components/PostList.tsindex 3eebc596a..ed4a99eb0 100644--- a/tests/pages/components/IdeaList.ts+++ b/tests/pages/components/PostList.ts@@ -1,7 +1,7 @@import { WebComponent, BrowserTab, pageHasLoaded } from "../../lib";-import { ShowIdeaPage } from "..";+import { ShowPostPage } from "..";-export class IdeaItem {+export class PostItem {public Vote: WebComponent;private Link: WebComponent;@@ -12,14 +12,14 @@ export class IdeaItem {public async navigate(): Promise<void> {await this.Link.click();- await this.tab.wait(pageHasLoaded(ShowIdeaPage));+ await this.tab.wait(pageHasLoaded(ShowPostPage));}}-export class IdeaList {+export class PostList {constructor(protected tab: BrowserTab, public selector: string) {}- private async findIdeaIndex(title: string): Promise<number> {+ private async findPostIndex(title: string): Promise<number> {return this.tab.evaluate<number>((text: string, selector: string) => {const elements = document.querySelectorAll(`${selector} .c-list-item-title`);@@ -34,8 +34,8 @@ export class IdeaList {);}- public async get(title: string): Promise<IdeaItem> {- const idx = await this.findIdeaIndex(title);- return new IdeaItem(this.tab, `${this.selector} > .c-list-item:nth-child(${idx + 1})`);+ public async get(title: string): Promise<PostItem> {+ const idx = await this.findPostIndex(title);+ return new PostItem(this.tab, `${this.selector} > .c-list-item:nth-child(${idx + 1})`);}}diff --git a/tests/pages/components/index.ts b/tests/pages/components/index.tsindex 57b8ae27e..36bc64b4e 100644--- a/tests/pages/components/index.ts+++ b/tests/pages/components/index.ts@@ -1,2 +1,2 @@-export * from "./IdeaList";+export * from "./PostList";export * from "./CommentList";diff --git a/tests/pages/index.ts b/tests/pages/index.tsindex becc958d7..84a37ad93 100644--- a/tests/pages/index.ts+++ b/tests/pages/index.ts@@ -2,22 +2,22 @@ import { HomePage } from "./HomePage";import { SignUpPage } from "./SignUpPage";import { FacebookSignInPage } from "./FacebookSignInPage";import { GeneralSettingsPage } from "./GeneralSettingsPage";-import { ShowIdeaPage } from "./ShowIdeaPage";+import { ShowPostPage } from "./ShowPostPage";import { BrowserTab } from "../lib";-export { SignUpPage, ShowIdeaPage, HomePage, FacebookSignInPage, GeneralSettingsPage };+export { SignUpPage, ShowPostPage, HomePage, FacebookSignInPage, GeneralSettingsPage };export class AllPages {public home: HomePage;public signup: SignUpPage;- public showIdea: ShowIdeaPage;+ public showPost: ShowPostPage;public facebook: FacebookSignInPage;public generalSettings: GeneralSettingsPage;constructor(public tab: BrowserTab) {this.home = new HomePage(tab);this.signup = new SignUpPage(tab);- this.showIdea = new ShowIdeaPage(tab);+ this.showPost = new ShowPostPage(tab);this.facebook = new FacebookSignInPage(tab);this.generalSettings = new GeneralSettingsPage(tab);}diff --git a/tests/scenarios/admin-settings.ts b/tests/scenarios/admin-settings.tsindex 33f8d2863..9db8c2723 100644--- a/tests/scenarios/admin-settings.ts+++ b/tests/scenarios/admin-settings.ts@@ -8,6 +8,6 @@ it("Tab1: User can change general settings", async () => {// Assertawait ensure(ctx.tab1.pages.home.MenuTitle).textIs("Feedback for X");- await ensure(ctx.tab1.pages.home.IdeaTitle).attributeIs("placeholder", "Enter here...");+ await ensure(ctx.tab1.pages.home.PostTitle).attributeIs("placeholder", "Enter here...");await ensure(ctx.tab1.pages.home.WelcomeMessage).textIs("Leave your feedback below");});diff --git a/tests/scenarios/feedback-loop.ts b/tests/scenarios/feedback-loop.tsindex 299836bbd..69bb9bb5f 100644--- a/tests/scenarios/feedback-loop.ts+++ b/tests/scenarios/feedback-loop.ts@@ -8,9 +8,8 @@ import {elementIsVisible,mailgun} from "../lib";-import { HomePage, ShowIdeaPage } from "../pages";+import { HomePage, ShowPostPage } from "../pages";import { ctx } from ".";-import { O_NOCTTY } from "constants";it("Tab1: User is authenticated after sign up", async () => {// Action@@ -23,54 +22,54 @@ it("Tab1: User is authenticated after sign up", async () => {it("Tab1: User doesn't lose what they typed", async () => {// Actionawait ctx.tab1.pages.home.navigate();- await ctx.tab1.pages.home.IdeaTitle.type("My Great Idea");- await ctx.tab1.pages.home.IdeaDescription.type("With an awesome description");- await ctx.tab1.pages.home.IdeaTitle.clear();- await ctx.tab1.pages.home.IdeaTitle.type("My Great Idea has a new title");+ await ctx.tab1.pages.home.PostTitle.type("My Great Post");+ await ctx.tab1.pages.home.PostDescription.type("With an awesome description");+ await ctx.tab1.pages.home.PostTitle.clear();+ await ctx.tab1.pages.home.PostTitle.type("My Great Post has a new title");// Assert- await ensure(ctx.tab1.pages.home.IdeaTitle).textIs("My Great Idea has a new title");- await ensure(ctx.tab1.pages.home.IdeaDescription).textIs("With an awesome description");+ await ensure(ctx.tab1.pages.home.PostTitle).textIs("My Great Post has a new title");+ await ensure(ctx.tab1.pages.home.PostDescription).textIs("With an awesome description");// Actionawait ctx.tab1.pages.home.navigate();// Assert- await ensure(ctx.tab1.pages.home.IdeaTitle).textIs("My Great Idea has a new title");- await ensure(ctx.tab1.pages.home.IdeaDescription).textIs("With an awesome description");+ await ensure(ctx.tab1.pages.home.PostTitle).textIs("My Great Post has a new title");+ await ensure(ctx.tab1.pages.home.PostDescription).textIs("With an awesome description");// Action- await ctx.tab1.pages.home.IdeaDescription.clear();- await ctx.tab1.pages.home.IdeaTitle.clear();+ await ctx.tab1.pages.home.PostDescription.clear();+ await ctx.tab1.pages.home.PostTitle.clear();await ctx.tab1.pages.home.navigate();// Assert- await ensure(ctx.tab1.pages.home.IdeaTitle).textIs("");- await ctx.tab1.wait(elementIsNotVisible(ctx.tab1.pages.home.IdeaDescription));+ await ensure(ctx.tab1.pages.home.PostTitle).textIs("");+ await ctx.tab1.wait(elementIsNotVisible(ctx.tab1.pages.home.PostDescription));});-it("Tab1: Can submit ideas", async () => {+it("Tab1: Can submit Posts", async () => {// Actionawait ctx.tab1.pages.home.navigate();- await ctx.tab1.pages.home.submitNewIdea(+ await ctx.tab1.pages.home.submitNewPost("Add support to TypeScript","Because the language and community is awesome! :)");// Assert- await ensure(ctx.tab1.pages.showIdea.Title).textIs("Add support to TypeScript");- await ensure(ctx.tab1.pages.showIdea.Description).textIs("Because the language and community is awesome! :)");- await ensure(ctx.tab1.pages.showIdea.SupportCounter).textIs("1");+ await ensure(ctx.tab1.pages.showPost.Title).textIs("Add support to TypeScript");+ await ensure(ctx.tab1.pages.showPost.Description).textIs("Because the language and community is awesome! :)");+ await ensure(ctx.tab1.pages.showPost.SupportCounter).textIs("1");});it("Tab1: Can edit title and description", async () => {// Action- await ctx.tab1.pages.showIdea.edit("Support for TypeScript", "Because the language and community is awesome!");+ await ctx.tab1.pages.showPost.edit("Support for TypeScript", "Because the language and community is awesome!");// Assert- await ensure(ctx.tab1.pages.showIdea.Title).textIs("Support for TypeScript");- await ensure(ctx.tab1.pages.showIdea.Description).textIs("Because the language and community is awesome!");- await ensure(ctx.tab1.pages.showIdea.SupportCounter).textIs("1");+ await ensure(ctx.tab1.pages.showPost.Title).textIs("Support for TypeScript");+ await ensure(ctx.tab1.pages.showPost.Description).textIs("Because the language and community is awesome!");+ await ensure(ctx.tab1.pages.showPost.SupportCounter).textIs("1");});it("Tab2: Can login as another user", async () => {@@ -84,46 +83,46 @@ it("Tab2: Can login as another user", async () => {await ensure(ctx.tab2.pages.home.UserName).textIs("Arya Stark");});-it("Tab2: User can vote on idea", async () => {+it("Tab2: User can vote on Post", async () => {// Actionawait ctx.tab2.pages.home.navigate();- const item = await ctx.tab2.pages.home.IdeaList.get("Support for TypeScript");+ const item = await ctx.tab2.pages.home.PostList.get("Support for TypeScript");await item.Vote.click();// Assertawait ensure(item.Vote).textIs("2");});-it("Tab2: Open idea and vote on it", async () => {+it("Tab2: Open Post and vote on it", async () => {// Action- const item = await ctx.tab2.pages.home.IdeaList.get("Support for TypeScript");+ const item = await ctx.tab2.pages.home.PostList.get("Support for TypeScript");await item.navigate();- await ctx.tab2.pages.showIdea.comment("I support this request!");+ await ctx.tab2.pages.showPost.comment("I support this request!");// Assert- await ensure(ctx.tab2.pages.showIdea.Comments).countIs(1);+ await ensure(ctx.tab2.pages.showPost.Comments).countIs(1);});-it("Tab1: Open idea and change status", async () => {+it("Tab1: Open Post and change status", async () => {// Actionawait ctx.tab1.pages.home.navigate();- const item = await ctx.tab1.pages.home.IdeaList.get("Support for TypeScript");+ const item = await ctx.tab1.pages.home.PostList.get("Support for TypeScript");await item.navigate();- await ctx.tab1.pages.showIdea.changeStatus("Started", "This will be delivered on next release.");- await ctx.tab1.wait(elementIsVisible(ctx.tab1.pages.showIdea.Status));+ await ctx.tab1.pages.showPost.changeStatus("Started", "This will be delivered on next release.");+ await ctx.tab1.wait(elementIsVisible(ctx.tab1.pages.showPost.Status));// Assert- await ensure(ctx.tab1.pages.showIdea.Status).textIs("Started");- await ensure(ctx.tab1.pages.showIdea.ResponseText).textIs("This will be delivered on next release.");+ await ensure(ctx.tab1.pages.showPost.Status).textIs("Started");+ await ensure(ctx.tab1.pages.showPost.ResponseText).textIs("This will be delivered on next release.");});it("Tab2: Refresh and see status", async () => {// Action- await ctx.tab2.reload(ShowIdeaPage);+ await ctx.tab2.reload(ShowPostPage);// Assert- await ensure(ctx.tab1.pages.showIdea.Status).textIs("Started");- await ensure(ctx.tab1.pages.showIdea.ResponseText).textIs("This will be delivered on next release.");+ await ensure(ctx.tab1.pages.showPost.Status).textIs("Started");+ await ensure(ctx.tab1.pages.showPost.ResponseText).textIs("This will be delivered on next release.");});it("Tab2: Check notifications", async () => {diff --git a/tests/scenarios/index.ts b/tests/scenarios/index.tsindex 92ea28a14..cbc55acff 100644--- a/tests/scenarios/index.ts+++ b/tests/scenarios/index.ts@@ -8,7 +8,7 @@ import {elementIsVisible,mailgun} from "../lib";-import { HomePage, ShowIdeaPage } from "../pages";+import { HomePage, ShowPostPage } from "../pages";export interface TestContext {browser1: Browser;diff --git a/views/templates/change_status.tpl b/views/templates/change_status.tplindex 150009e1d..c5a4db69c 100644--- a/views/templates/change_status.tpl+++ b/views/templates/change_status.tpl@@ -2,7 +2,7 @@ subject: {{ .title }}body:{{ if .duplicate }}- <i>This idea has been closed as a <strong>{{ .status }}</strong> of {{ .duplicate }}.</i>+ <i>This post has been closed as a <strong>{{ .status }}</strong> of {{ .duplicate }}.</i>{{ else }}<i>Status has changed to <strong>{{ .status }}</strong>.</i> <br />diff --git a/views/templates/new_idea.tpl b/views/templates/new_post.tplsimilarity index 100%rename from views/templates/new_idea.tplrename to views/templates/new_post.tpl