Skip to content

armgit / fider

Public Imported from GitHub
0

Open platform to collect and prioritize feedback

Moderation items added to filter.

Matt Roberts8b08aba52a05
diff --git a/app/handlers/apiv1/post.go b/app/handlers/apiv1/post.go
index 3018e73e6..e47a22e2f 100644
--- a/app/handlers/apiv1/post.go
+++ b/app/handlers/apiv1/post.go
@@ -21,10 +21,11 @@ func SearchPosts() web.HandlerFunc {
viewQueryParams = "all" // Set default value to "all" if not provided
}
searchPosts := &query.SearchPosts{
- Query: c.QueryParam("query"),
- View: viewQueryParams,
- Limit: c.QueryParam("limit"),
- Tags: c.QueryParamAsArray("tags"),
+ Query: c.QueryParam("query"),
+ View: viewQueryParams,
+ Limit: c.QueryParam("limit"),
+ Tags: c.QueryParamAsArray("tags"),
+ ModerationFilter: c.QueryParam("moderation"),
}
if myVotesOnly, err := c.QueryParamAsBool("myvotes"); err == nil {
searchPosts.MyVotesOnly = myVotesOnly
diff --git a/app/models/query/post.go b/app/models/query/post.go
index 5e9dde5fb..e87621cf9 100644
--- a/app/models/query/post.go
+++ b/app/models/query/post.go
@@ -34,14 +34,15 @@ type GetPostByNumber struct {
}
type SearchPosts struct {
- Query string
- View string
- Limit string
- Statuses []enum.PostStatus
- Tags []string
- MyVotesOnly bool
- NoTagsOnly bool
- MyPostsOnly bool
+ Query string
+ View string
+ Limit string
+ Statuses []enum.PostStatus
+ Tags []string
+ MyVotesOnly bool
+ NoTagsOnly bool
+ MyPostsOnly bool
+ ModerationFilter string // "pending", "approved", or empty (all)
Result []*entity.Post
}
diff --git a/app/services/sqlstore/postgres/post.go b/app/services/sqlstore/postgres/post.go
index b49dc17be..ed01419b3 100644
--- a/app/services/sqlstore/postgres/post.go
+++ b/app/services/sqlstore/postgres/post.go
@@ -305,7 +305,7 @@ func detectPostLanguage(title, description string) string {
func getPostByID(ctx context.Context, q *query.GetPostByID) error {
return using(ctx, func(trx *dbx.Trx, tenant *entity.Tenant, user *entity.User) error {
- post, err := querySinglePost(ctx, trx, buildPostQuery(user, "p.tenant_id = $1 AND p.id = $2"), tenant.ID, q.PostID)
+ post, err := querySinglePost(ctx, trx, buildSinglePostQuery(user, "p.tenant_id = $1 AND p.id = $2"), tenant.ID, q.PostID)
if err != nil {
return errors.Wrap(err, "failed to get post with id '%d'", q.PostID)
}
@@ -316,7 +316,7 @@ func getPostByID(ctx context.Context, q *query.GetPostByID) error {
func getPostBySlug(ctx context.Context, q *query.GetPostBySlug) error {
return using(ctx, func(trx *dbx.Trx, tenant *entity.Tenant, user *entity.User) error {
- post, err := querySinglePost(ctx, trx, buildPostQuery(user, "p.tenant_id = $1 AND p.slug = $2"), tenant.ID, q.Slug)
+ post, err := querySinglePost(ctx, trx, buildSinglePostQuery(user, "p.tenant_id = $1 AND p.slug = $2"), tenant.ID, q.Slug)
if err != nil {
return errors.Wrap(err, "failed to get post with slug '%s'", q.Slug)
}
@@ -327,7 +327,7 @@ func getPostBySlug(ctx context.Context, q *query.GetPostBySlug) error {
func getPostByNumber(ctx context.Context, q *query.GetPostByNumber) error {
return using(ctx, func(trx *dbx.Trx, tenant *entity.Tenant, user *entity.User) error {
- post, err := querySinglePost(ctx, trx, buildPostQuery(user, "p.tenant_id = $1 AND p.number = $2"), tenant.ID, q.Number)
+ post, err := querySinglePost(ctx, trx, buildSinglePostQuery(user, "p.tenant_id = $1 AND p.number = $2"), tenant.ID, q.Number)
if err != nil {
return errors.Wrap(err, "failed to get post with number '%d'", q.Number)
}
@@ -362,7 +362,7 @@ func preprocessSearchQuery(query string) string {
func findSimilarPosts(ctx context.Context, q *query.FindSimilarPosts) error {
return using(ctx, func(trx *dbx.Trx, tenant *entity.Tenant, user *entity.User) error {
- innerQuery := buildPostQuery(user, "p.tenant_id = $1 AND p.status = ANY($2)")
+ innerQuery := buildPostQuery(user, "p.tenant_id = $1 AND p.status = ANY($2)", "")
filteredQuery := preprocessSearchQuery(q.Query)
@@ -416,7 +416,7 @@ func findSimilarPosts(ctx context.Context, q *query.FindSimilarPosts) error {
func searchPosts(ctx context.Context, q *query.SearchPosts) error {
return using(ctx, func(trx *dbx.Trx, tenant *entity.Tenant, user *entity.User) error {
- innerQuery := buildPostQuery(user, "p.tenant_id = $1 AND p.status = ANY($2)")
+ innerQuery := buildPostQuery(user, "p.tenant_id = $1 AND p.status = ANY($2)", q.ModerationFilter)
if q.Tags == nil {
q.Tags = []string{}
@@ -518,7 +518,7 @@ func querySinglePost(ctx context.Context, trx *dbx.Trx, query string, args ...an
return post.ToModel(ctx), nil
}
-func buildPostQuery(user *entity.User, filter string) string {
+func buildPostQuery(user *entity.User, filter string, moderationFilter string) string {
tagCondition := `AND tags.is_public = true`
if user != nil && user.IsCollaborator() {
tagCondition = ``
@@ -528,13 +528,50 @@ func buildPostQuery(user *entity.User, filter string) string {
hasVotedSubQuery = fmt.Sprintf("(SELECT true FROM post_votes WHERE post_id = p.id AND user_id = %d)", user.ID)
}
- // Add approval filtering based on user permissions
+ // Add approval filtering based on moderation filter and user permissions
+ approvalFilter := ""
+
+ // If user is a collaborator and has specified a moderation filter, apply it
+ if user != nil && user.IsCollaborator() && moderationFilter != "" {
+ if moderationFilter == "pending" {
+ // Show only unapproved posts
+ approvalFilter = " AND p.is_approved = false"
+ } else if moderationFilter == "approved" {
+ // Show only approved posts
+ approvalFilter = " AND p.is_approved = true"
+ }
+ // If moderationFilter is neither "pending" nor "approved", show all posts (no filter)
+ } else if user != nil {
+ // Regular authenticated users can see approved posts + their own unapproved posts
+ approvalFilter = fmt.Sprintf(" AND (p.is_approved = true OR p.user_id = %d)", user.ID)
+ } else {
+ // Anonymous users can only see approved posts
+ approvalFilter = " AND p.is_approved = true"
+ }
+
+ combinedFilter := filter + approvalFilter
+ return fmt.Sprintf(sqlSelectPostsWhere, tagCondition, hasVotedSubQuery, combinedFilter)
+}
+
+// buildSinglePostQuery is used for fetching individual posts (by ID, slug, or number)
+// Collaborators can view any post for moderation purposes
+func buildSinglePostQuery(user *entity.User, filter string) string {
+ tagCondition := `AND tags.is_public = true`
+ if user != nil && user.IsCollaborator() {
+ tagCondition = ``
+ }
+ hasVotedSubQuery := "null"
+ if user != nil {
+ hasVotedSubQuery = fmt.Sprintf("(SELECT true FROM post_votes WHERE post_id = p.id AND user_id = %d)", user.ID)
+ }
+
+ // Approval filtering for single post views
approvalFilter := ""
if user != nil && user.IsCollaborator() {
- // Admins and collaborators can see all posts
+ // Collaborators can view any post (for moderation purposes)
approvalFilter = ""
} else if user != nil {
- // Regular users can see approved posts + their own unapproved posts
+ // Regular authenticated users can see approved posts + their own unapproved posts
approvalFilter = fmt.Sprintf(" AND (p.is_approved = true OR p.user_id = %d)", user.ID)
} else {
// Anonymous users can only see approved posts
diff --git a/locale/ar/client.json b/locale/ar/client.json
index 51c0150a4..d8a9f031a 100644
--- a/locale/ar/client.json
+++ b/locale/ar/client.json
@@ -51,9 +51,12 @@
"home.form.defaultwelcomemessage": "يسعدنا سماع أفكارك.\n\nكيف يمكننا أن نكون أفضل؟ هذا هو المكان المناسب للتصويت والمناقشة ومشاركة الأفكار.",
"home.lonely.suggestion": "ننصح بإنشاء <0>٣ اقتراحات على الأقل</0> قبل مشاركة هذا الموقع. المحتوى المبدئي مهم لجذب جمهورك.",
"home.lonely.text": "لم يتم إنشاء منشورات بعد.",
+ "home.postfilter.label.moderation": "",
"home.postfilter.label.myactivity": "ملك",
"home.postfilter.label.status": "حالة",
"home.postfilter.label.view": "عرض",
+ "home.postfilter.moderation.approved": "",
+ "home.postfilter.moderation.pending": "",
"home.postfilter.option.mostdiscussed": "الأكثر مناقشة",
"home.postfilter.option.mostwanted": "الأكثر طلبا",
"home.postfilter.option.myposts": "منشوراتي",
diff --git a/locale/de/client.json b/locale/de/client.json
index 1164ed1c5..d459d488a 100644
--- a/locale/de/client.json
+++ b/locale/de/client.json
@@ -49,9 +49,12 @@
"home.form.defaultwelcomemessage": "Wir würden gerne erfahren, worüber Du nachdenkst.\n\nWas können wir verbessern? Hier kannst Du abstimmen, diskutieren und neue Ideen vorschlagen.",
"home.lonely.suggestion": "Es wird empfohlen, dass du <0>mindestens 3</0> Vorschläge hier erstellst, bevor du diese Seite teilst. Der anfängliche Inhalt ist wichtig, um die Interaktion mit deiner Zielgruppe zu fördern.",
"home.lonely.text": "Es wurden noch keine Beiträge erstellt.",
+ "home.postfilter.label.moderation": "",
"home.postfilter.label.myactivity": "Meine Aktivität",
"home.postfilter.label.status": "Status",
"home.postfilter.label.view": "Anzeigen",
+ "home.postfilter.moderation.approved": "",
+ "home.postfilter.moderation.pending": "",
"home.postfilter.option.mostdiscussed": "Am häufigsten diskutiert",
"home.postfilter.option.mostwanted": "Meist gefragt",
"home.postfilter.option.myposts": "Meine Beiträge",
diff --git a/locale/el/client.json b/locale/el/client.json
index f21909e7f..8779c3ec0 100644
--- a/locale/el/client.json
+++ b/locale/el/client.json
@@ -49,9 +49,12 @@
"home.form.defaultwelcomemessage": "Θα θέλαμε πολύ να ακούσουμε τι σκέφτεστε.\n\nΤι μπορούμε να κάνουμε καλύτερα; Αυτό είναι το μέρος για να ψηφίσετε, να συζητήσετε και να μοιραστείτε ιδέες.",
"home.lonely.suggestion": "Συνιστάται να δημιουργείσετε εδώ <0>τουλάχιστον 3</0> προτάσεις πριν από την κοινή χρήση αυτής της ιστοσελίδας. Το αρχικό περιεχόμενο είναι σημαντικό να αρχίσετε να προσελκύετε το κοινό σας.",
"home.lonely.text": "Δεν έχουν δημιουργηθεί αναρτήσεις ακόμα.",
+ "home.postfilter.label.moderation": "",
"home.postfilter.label.myactivity": "Ιδιος",
"home.postfilter.label.status": "Κατάσταση",
"home.postfilter.label.view": "Προβολή",
+ "home.postfilter.moderation.approved": "",
+ "home.postfilter.moderation.pending": "",
"home.postfilter.option.mostdiscussed": "Πιο συζητημένα",
"home.postfilter.option.mostwanted": "Πιο ενδιαφέροντα",
"home.postfilter.option.myposts": "Οι αναρτήσεις μου",
diff --git a/locale/en/client.json b/locale/en/client.json
index 74d00560f..6b40cf90a 100644
--- a/locale/en/client.json
+++ b/locale/en/client.json
@@ -51,9 +51,12 @@
"home.form.defaultwelcomemessage": "We'd love to hear what you're thinking about.\n\nWhat can we do better? This is the place for you to vote, discuss and share ideas.",
"home.lonely.suggestion": "It's recommended that you create <0>at least 3</0> suggestions here before sharing this site. The initial content is important to start engaging your audience.",
"home.lonely.text": "No posts have been created yet.",
+ "home.postfilter.label.moderation": "Moderation",
"home.postfilter.label.myactivity": "Own",
"home.postfilter.label.status": "Status",
"home.postfilter.label.view": "View",
+ "home.postfilter.moderation.approved": "Approved",
+ "home.postfilter.moderation.pending": "Pending",
"home.postfilter.option.mostdiscussed": "Most Discussed",
"home.postfilter.option.mostwanted": "Most Wanted",
"home.postfilter.option.myposts": "My Posts",
diff --git a/locale/es-ES/client.json b/locale/es-ES/client.json
index a24d7087e..1fa8bfee3 100644
--- a/locale/es-ES/client.json
+++ b/locale/es-ES/client.json
@@ -51,9 +51,12 @@
"home.form.defaultwelcomemessage": "Nos encantaría escuchar lo que estás pensando.\n\n¿Qué podemos hacer mejor? Este es el lugar para que votes, discutas y compartas ideas.",
"home.lonely.suggestion": "Se recomienda que cree <0>al menos 3</0> sugerencias aquí antes de compartir este sitio. El contenido inicial es importante para empezar a atraer a su audiencia.",
"home.lonely.text": "No se han creado publicaciones todavía.",
+ "home.postfilter.label.moderation": "",
"home.postfilter.label.myactivity": "Propio",
"home.postfilter.label.status": "Estado",
"home.postfilter.label.view": "Vista",
+ "home.postfilter.moderation.approved": "",
+ "home.postfilter.moderation.pending": "",
"home.postfilter.option.mostdiscussed": "Más Discutidos",
"home.postfilter.option.mostwanted": "Más Deseados",
"home.postfilter.option.myposts": "Mis publicaciones",
diff --git a/locale/fa/client.json b/locale/fa/client.json
index bda3b2b06..9ac51c63e 100644
--- a/locale/fa/client.json
+++ b/locale/fa/client.json
@@ -49,9 +49,12 @@
"home.form.defaultwelcomemessage": "مایلیم بدانیم به چه می‌اندیشید.\n\nچه کاری می‌توانیم بهتر انجام دهیم؟ اینجا جایی است برای رأی دادن، بحث و به‌اشتراک‌گذاری ایده‌ها.",
"home.lonely.suggestion": "توصیه می‌شود قبل از به‌اشتراک‌گذاری این سایت، <0>حداقل ۳</0> پیشنهاد ایجاد کنید. محتوای اولیه برای جذب مخاطبان شما مهم است.",
"home.lonely.text": "هنوز هیچ پستی ایجاد نشده است.",
+ "home.postfilter.label.moderation": "",
"home.postfilter.label.myactivity": "مال خود",
"home.postfilter.label.status": "وضعیت",
"home.postfilter.label.view": "نمایش",
+ "home.postfilter.moderation.approved": "",
+ "home.postfilter.moderation.pending": "",
"home.postfilter.option.mostdiscussed": "بیشترین بحث",
"home.postfilter.option.mostwanted": "بیشترین خواسته",
"home.postfilter.option.myposts": "پست‌های من",
diff --git a/locale/fr/client.json b/locale/fr/client.json
index 36a485728..009108cbe 100644
--- a/locale/fr/client.json
+++ b/locale/fr/client.json
@@ -49,9 +49,12 @@
"home.form.defaultwelcomemessage": "Nous aimerions savoir ce que vous pensez.\n\nQue pouvons-nous faire de mieux ? C'est ici que vous pouvez voter, discuter et partager vos idées.",
"home.lonely.suggestion": "Il est recommandé de créer <0>au moins 3</0> suggestions avant de partager ce site. Le contenu initial est important pour commencer à engager votre public.",
"home.lonely.text": "Aucun message n'a encore été créé.",
+ "home.postfilter.label.moderation": "",
"home.postfilter.label.myactivity": "Propre",
"home.postfilter.label.status": "Statut",
"home.postfilter.label.view": "Afficher",
+ "home.postfilter.moderation.approved": "",
+ "home.postfilter.moderation.pending": "",
"home.postfilter.option.mostdiscussed": "Les plus discutés",
"home.postfilter.option.mostwanted": "Les plus votées",
"home.postfilter.option.myposts": "Mes publications",
diff --git a/locale/it/client.json b/locale/it/client.json
index d705038bf..f0487db1b 100644
--- a/locale/it/client.json
+++ b/locale/it/client.json
@@ -49,9 +49,12 @@
"home.form.defaultwelcomemessage": "Ci piacerebbe sentire quello che stai pensando.\n\nChe cosa possiamo fare meglio? Questo è il posto per voi per votare, discutere e condividere idee.",
"home.lonely.suggestion": "Si consiglia di creare <0>almeno 3</0> suggerimenti qui prima di condividere questo sito. Il contenuto iniziale è importante per iniziare ad coinvolgere il pubblico.",
"home.lonely.text": "Non sono stati inviati messaggi.",
+ "home.postfilter.label.moderation": "",
"home.postfilter.label.myactivity": "Possedere",
"home.postfilter.label.status": "Stato",
"home.postfilter.label.view": "Visualizza",
+ "home.postfilter.moderation.approved": "",
+ "home.postfilter.moderation.pending": "",
"home.postfilter.option.mostdiscussed": "Più discussi",
"home.postfilter.option.mostwanted": "I più votati",
"home.postfilter.option.myposts": "I miei post",
diff --git a/locale/ja/client.json b/locale/ja/client.json
index 8d1875db8..3bda1d633 100644
--- a/locale/ja/client.json
+++ b/locale/ja/client.json
@@ -49,9 +49,12 @@
"home.form.defaultwelcomemessage": "皆さんが考えていることをお聞きかせください。\n\nどう改善できますでしょうか? ここでは、あなたが投票、議論、アイデアを共有する場所です。",
"home.lonely.suggestion": "このサイトを共有する前に、<0>少なくとも3</0>の提案をここで作成することをお勧めします。最初のコンテンツは、ユーザーを引き付けるために重要です。",
"home.lonely.text": "投稿がまだ作成されていません。",
+ "home.postfilter.label.moderation": "",
"home.postfilter.label.myactivity": "自分の",
"home.postfilter.label.status": "状態",
"home.postfilter.label.view": "表示",
+ "home.postfilter.moderation.approved": "",
+ "home.postfilter.moderation.pending": "",
"home.postfilter.option.mostdiscussed": "最も議論されたもの",
"home.postfilter.option.mostwanted": "最も人気のあるもの",
"home.postfilter.option.myposts": "私の投稿",
diff --git a/locale/nl/client.json b/locale/nl/client.json
index 5f9790748..86dc5fc6f 100644
--- a/locale/nl/client.json
+++ b/locale/nl/client.json
@@ -49,9 +49,12 @@
"home.form.defaultwelcomemessage": "We horen graag waar je aan denkt.\n\nWat kunnen we beter doen? Dit is de plek waar je op ideeën kunt stemmen en reageren, en ook je eigen ideeën kunt delen.",
"home.lonely.suggestion": "Het is aanbevolen om <0>tenminste 3 ideeën</0> aan te maken voor het delen van de site. De initiële inhoud is belangrijk om jouw publiek te motiveren om deel te nemen.",
"home.lonely.text": "Er zijn nog geen berichten aangemaakt.",
+ "home.postfilter.label.moderation": "",
"home.postfilter.label.myactivity": "Eigen",
"home.postfilter.label.status": "",
"home.postfilter.label.view": "Bekijk",
+ "home.postfilter.moderation.approved": "",
+ "home.postfilter.moderation.pending": "",
"home.postfilter.option.mostdiscussed": "Meest besproken",
"home.postfilter.option.mostwanted": "Meeste stemmen",
"home.postfilter.option.myposts": "Mijn berichten",
diff --git a/locale/pl/client.json b/locale/pl/client.json
index 59dddbfc8..f5cf0f648 100644
--- a/locale/pl/client.json
+++ b/locale/pl/client.json
@@ -49,9 +49,12 @@
"home.form.defaultwelcomemessage": "Chcemy się dowiedzieć o czym myślisz.\n\nCo możemy poprawić? To jest miejsce, w którym możesz głosować, dyskutować i dzielić się pomysłami.",
"home.lonely.suggestion": "Zaleca się stworzenie tutaj <0>co najmniej 3</0> sugestii przed udostępnieniem tej witryny. Początkowa zawartość jest ważna do zaangażowania swoich odbiorców.",
"home.lonely.text": "Nie stworzono jeszcze żadnych postów.",
+ "home.postfilter.label.moderation": "",
"home.postfilter.label.myactivity": "Własny",
"home.postfilter.label.status": "",
"home.postfilter.label.view": "Widok",
+ "home.postfilter.moderation.approved": "",
+ "home.postfilter.moderation.pending": "",
"home.postfilter.option.mostdiscussed": "Najczęściej dyskutowane",
"home.postfilter.option.mostwanted": "Najbardziej Pożądane",
"home.postfilter.option.myposts": "Moje posty",
diff --git a/locale/pt-BR/client.json b/locale/pt-BR/client.json
index 1e40df05a..3a704005d 100644
--- a/locale/pt-BR/client.json
+++ b/locale/pt-BR/client.json
@@ -49,9 +49,12 @@
"home.form.defaultwelcomemessage": "Gostaríamos de ouvir sobre o que você está pensando.\n\nO que podemos fazer melhor? Este é o lugar para você votar, discutir e compartilhar ideias.",
"home.lonely.suggestion": "É recomendável que você crie <0>pelo menos 3</0> sugestões aqui antes de compartilhar este site. O conteúdo inicial é importante para começar a engajar seu público.",
"home.lonely.text": "Nenhuma postagem foi criada ainda.",
+ "home.postfilter.label.moderation": "",
"home.postfilter.label.myactivity": "Ter",
"home.postfilter.label.status": "",
"home.postfilter.label.view": "Visualizar",
+ "home.postfilter.moderation.approved": "",
+ "home.postfilter.moderation.pending": "",
"home.postfilter.option.mostdiscussed": "Mais Discutidos",
"home.postfilter.option.mostwanted": "Mais Desejados",
"home.postfilter.option.myposts": "Minhas postagens",
diff --git a/locale/ru/client.json b/locale/ru/client.json
index bff9d4841..faab41302 100644
--- a/locale/ru/client.json
+++ b/locale/ru/client.json
@@ -49,9 +49,12 @@
"home.form.defaultwelcomemessage": "Мы хотели бы услышать ваше мнение. \n\nКак мы можем улучшиться? Здесь можно голосовать, обсуждать и делиться идеями.",
"home.lonely.suggestion": "Советуем создать <0>хотя бы 3</0> предложения перед публикацией этого сайта. Это важно для большего вовлечения аудитории.",
"home.lonely.text": "Здесь пока нет постов.",
+ "home.postfilter.label.moderation": "",
"home.postfilter.label.myactivity": "Собственный",
"home.postfilter.label.status": "Статус",
"home.postfilter.label.view": "Просмотреть",
+ "home.postfilter.moderation.approved": "",
+ "home.postfilter.moderation.pending": "",
"home.postfilter.option.mostdiscussed": "Наиболее обсуждаемые",
"home.postfilter.option.mostwanted": "Наиболее востребованные",
"home.postfilter.option.myposts": "Мои сообщения",
diff --git a/locale/sk/client.json b/locale/sk/client.json
index d051eef1a..bcb98787c 100644
--- a/locale/sk/client.json
+++ b/locale/sk/client.json
@@ -49,9 +49,12 @@
"home.form.defaultwelcomemessage": "Radi by sme počuli, čo máte na mysli.\n\nČo môžeme urobiť lepšie? Tu môžete hlasovať, diskutovať a zdieľať nápady.",
"home.lonely.suggestion": "Pred zdieľaním tejto stránky tu odporúčame vytvoriť <0> aspoň 3 </0> návrhy. Počiatočný obsah je dôležitý, aby ste mohli zaujať publikum.",
"home.lonely.text": "Zatiaľ neboli vytvorené žiadne príspevky.",
+ "home.postfilter.label.moderation": "",
"home.postfilter.label.myactivity": "Vlastniť",
"home.postfilter.label.status": "Stav",
"home.postfilter.label.view": "Prehľad",
+ "home.postfilter.moderation.approved": "",
+ "home.postfilter.moderation.pending": "",
"home.postfilter.option.mostdiscussed": "Najviac diskutované",
"home.postfilter.option.mostwanted": "Najhľadanejšie",
"home.postfilter.option.myposts": "Moje príspevky",
diff --git a/locale/sv-SE/client.json b/locale/sv-SE/client.json
index 1eba266b9..201c7a7de 100644
--- a/locale/sv-SE/client.json
+++ b/locale/sv-SE/client.json
@@ -49,9 +49,12 @@
"home.form.defaultwelcomemessage": "Vi vill gärna höra vad du tänker på.\n\nVad kan vi göra bättre? Detta är platsen för dig att rösta, diskutera och dela idéer.",
"home.lonely.suggestion": "Vi rekommenderar att du skapar <0>minst 3</0> förslag här innan du börjar dela den här webbplatsen. Det initiala innehållet är viktigt för att engagera dina besökare.",
"home.lonely.text": "Det finns inte några inlägg ännu.",
+ "home.postfilter.label.moderation": "",
"home.postfilter.label.myactivity": "Egen",
"home.postfilter.label.status": "",
"home.postfilter.label.view": "Visa",
+ "home.postfilter.moderation.approved": "",
+ "home.postfilter.moderation.pending": "",
"home.postfilter.option.mostdiscussed": "Mest diskuterade",
"home.postfilter.option.mostwanted": "Mest önskade",
"home.postfilter.option.myposts": "Mina inlägg",
diff --git a/locale/tr/client.json b/locale/tr/client.json
index 2ba0c0688..26aceed5c 100644
--- a/locale/tr/client.json
+++ b/locale/tr/client.json
@@ -49,9 +49,12 @@
"home.form.defaultwelcomemessage": "Ne düşündüğünüzü öğrenmeyi çok isteriz.\n\nKendimizi nasıl geliştirebiliriz? Burada önerileri oylayabilir, tartışabilir ya da paylaşabilirsiniz.",
"home.lonely.suggestion": "Siteyi paylaşmadan önce buraya <0>en az 3</0> öneri girmenizi tavsiye ederiz. İlk içerikler, hedef kitlenizin etkileşime geçmesi için önemlidir.",
"home.lonely.text": "Henüz hiç öneri oluşturulmadı.",
+ "home.postfilter.label.moderation": "",
"home.postfilter.label.myactivity": "Sahip olmak",
"home.postfilter.label.status": "Durum",
"home.postfilter.label.view": "Görünüm",
+ "home.postfilter.moderation.approved": "",
+ "home.postfilter.moderation.pending": "",
"home.postfilter.option.mostdiscussed": "En Tartışılan",
"home.postfilter.option.mostwanted": "En Talep Edilen",
"home.postfilter.option.myposts": "Yazılarım",
diff --git a/locale/zh-CN/client.json b/locale/zh-CN/client.json
index 9e992ad1b..c902baba1 100644
--- a/locale/zh-CN/client.json
+++ b/locale/zh-CN/client.json
@@ -49,9 +49,12 @@
"home.form.defaultwelcomemessage": "我们很想听听你在想什么。\n\n我们能做得更好吗?这是您投票、讨论和分享想法的地方.",
"home.lonely.suggestion": "建议您在共享此网站之前,在此处创建<0>至少3个</0>建议。初始内容对于开始吸引观众很重要.",
"home.lonely.text": "尚未创建任何帖子.",
+ "home.postfilter.label.moderation": "",
"home.postfilter.label.myactivity": "自己的",
"home.postfilter.label.status": "地位",
"home.postfilter.label.view": "看板",
+ "home.postfilter.moderation.approved": "",
+ "home.postfilter.moderation.pending": "",
"home.postfilter.option.mostdiscussed": "讨论最多",
"home.postfilter.option.mostwanted": "投票最多",
"home.postfilter.option.myposts": "我的帖子",
diff --git a/public/pages/Home/components/PostFilter.tsx b/public/pages/Home/components/PostFilter.tsx
index 0e739ab98..1ad77cd9a 100644
--- a/public/pages/Home/components/PostFilter.tsx
+++ b/public/pages/Home/components/PostFilter.tsx
@@ -9,7 +9,7 @@ import { FilterState } from "./PostsContainer"
import "./PostFilter.scss"
-type FilterType = "tag" | "status" | "myVotes" | "noTags" | "myPosts"
+type FilterType = "tag" | "status" | "myVotes" | "noTags" | "myPosts" | "moderation"
interface OptionItem {
value: string | boolean
@@ -47,11 +47,14 @@ const FilterStateToFilterItems = (filterState: FilterState): FilterItem[] => {
if (filterState.myPosts) {
filterItems.push({ type: "myPosts", value: true })
}
+ if (filterState.moderation) {
+ filterItems.push({ type: "moderation", value: filterState.moderation })
+ }
return filterItems
}
const FilterItemsToFilterState = (filterItems: FilterItem[]): FilterState => {
- const filterState: FilterState = { tags: [], statuses: [], myVotes: false, noTags: false, myPosts: false }
+ const filterState: FilterState = { tags: [], statuses: [], myVotes: false, noTags: false, myPosts: false, moderation: "" }
filterItems.forEach((i) => {
if (i.type === "tag") {
filterState.tags.push(i.value as string)
@@ -63,6 +66,8 @@ const FilterItemsToFilterState = (filterItems: FilterItem[]): FilterState => {
filterState.noTags = true
} else if (i.type === "myPosts") {
filterState.myPosts = true
+ } else if (i.type === "moderation") {
+ filterState.moderation = i.value as string
}
})
return filterState
@@ -88,6 +93,12 @@ export const PostFilter = (props: PostFilterProps) => {
if (fider.session.isAuthenticated) {
options.push({ value: true, label: i18n._({ id: "home.postfilter.option.myvotes", message: "My Votes" }), type: "myVotes" })
options.push({ value: true, label: i18n._({ id: "home.postfilter.option.myposts", message: "My Posts" }), type: "myPosts" })
+
+ // Add moderation filter for collaborators and admins
+ if (fider.session.user.isCollaborator) {
+ options.push({ value: "pending", label: i18n._({ id: "home.postfilter.moderation.pending", message: "Pending" }), type: "moderation" })
+ options.push({ value: "approved", label: i18n._({ id: "home.postfilter.moderation.approved", message: "Approved" }), type: "moderation" })
+ }
}
PostStatus.All.filter((s) => s.filterable && props.countPerStatus[s.value]).forEach((s) => {
@@ -168,6 +179,8 @@ export const PostFilter = (props: PostFilterProps) => {
<FilterGroupSection title={i18n._({ id: "home.postfilter.label.myactivity", message: "My activity" })} type={["myVotes", "myPosts"]} />
+ <FilterGroupSection title={i18n._({ id: "home.postfilter.label.moderation", message: "Moderation" })} type={["moderation"]} />
+
<FilterGroupSection title={i18n._({ id: "home.postfilter.label.status", message: "Status" })} type={["status"]} />
<FilterGroupSection title={i18n._({ id: "label.tags", message: "Tags" })} type={["noTags", "tag"]} />
diff --git a/public/pages/Home/components/PostsContainer.tsx b/public/pages/Home/components/PostsContainer.tsx
index 7f0c0b0ab..93c13deea 100644
--- a/public/pages/Home/components/PostsContainer.tsx
+++ b/public/pages/Home/components/PostsContainer.tsx
@@ -35,6 +35,7 @@ export interface FilterState {
myVotes: boolean
myPosts: boolean
noTags: boolean
+ moderation: string
}
export class PostsContainer extends React.Component<PostsContainerProps, PostsContainerState> {
@@ -54,6 +55,7 @@ export class PostsContainer extends React.Component<PostsContainerProps, PostsCo
myVotes: querystring.get("myvotes") === "true",
myPosts: querystring.get("myposts") === "true",
noTags: querystring.get("notags") === "true",
+ moderation: querystring.get("moderation") || "",
},
limit: querystring.getNumber("limit"),
}
@@ -69,6 +71,7 @@ export class PostsContainer extends React.Component<PostsContainerProps, PostsCo
myvotes: this.state.filterState.myVotes ? "true" : undefined,
myposts: this.state.filterState.myPosts ? "true" : undefined,
notags: this.state.filterState.noTags ? "true" : undefined,
+ moderation: this.state.filterState.moderation || undefined,
query,
view: this.state.view,
limit: this.state.limit,
@@ -84,6 +87,7 @@ export class PostsContainer extends React.Component<PostsContainerProps, PostsCo
this.state.filterState.myVotes,
this.state.filterState.myPosts,
this.state.filterState.noTags,
+ this.state.filterState.moderation,
reset
)
})
@@ -99,12 +103,13 @@ export class PostsContainer extends React.Component<PostsContainerProps, PostsCo
myVotes: boolean,
myPosts: boolean,
noTags: boolean,
+ moderation: string,
reset: boolean
) {
window.clearTimeout(this.timer)
this.setState({ posts: reset ? undefined : this.state.posts, loading: true })
this.timer = window.setTimeout(() => {
- actions.searchPosts({ query, view: view, limit, tags, statuses, myVotes, myPosts, noTags }).then((response) => {
+ actions.searchPosts({ query, view: view, limit, tags, statuses, myVotes, myPosts, noTags, moderation }).then((response) => {
if (response.ok && this.state.loading) {
this.setState({ loading: false, posts: response.data })
}
diff --git a/public/services/actions/post.ts b/public/services/actions/post.ts
index 04596cb17..0d5d605e5 100644
--- a/public/services/actions/post.ts
+++ b/public/services/actions/post.ts
@@ -14,6 +14,7 @@ export interface SearchPostsParams {
noTags?: boolean
myPosts?: boolean
statuses?: string[]
+ moderation?: string
}
export const searchPosts = async (params: SearchPostsParams): Promise<Result<Post[]>> => {
@@ -23,6 +24,7 @@ export const searchPosts = async (params: SearchPostsParams): Promise<Result<Pos
query: params.query,
view: params.view,
limit: params.limit,
+ moderation: params.moderation,
})
if (params.myVotes) {
qsParams += `&myvotes=true`