Skip to content

Commit 0f30e32

Browse files
authored
Merge branch 'main' into fix-escape
2 parents 133e796 + 67ca548 commit 0f30e32

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+320
-73
lines changed

app/actions/post.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package actions
22

33
import (
44
"context"
5+
"regexp"
6+
"strings"
57
"time"
68

79
"github.com/getfider/fider/app/models/dto"
@@ -64,11 +66,14 @@ func (action *CreateNewPost) IsAuthorized(ctx context.Context, user *entity.User
6466
func (action *CreateNewPost) Validate(ctx context.Context, user *entity.User) *validate.Result {
6567
result := validate.Success()
6668

67-
if action.Title == "" {
69+
re := regexp.MustCompile(`\s+`)
70+
normalizedTitle := strings.TrimSpace(re.ReplaceAllString(action.Title, " "))
71+
72+
if normalizedTitle == "" {
6873
result.AddFieldFailure("title", propertyIsRequired(ctx, "title"))
69-
} else if len(action.Title) < 10 {
74+
} else if len(normalizedTitle) < 10 {
7075
result.AddFieldFailure("title", i18n.T(ctx, "validation.custom.descriptivetitle"))
71-
} else if len(action.Title) > 100 {
76+
} else if len(normalizedTitle) > 100 {
7277
result.AddFieldFailure("title", propertyMaxStringLen(ctx, "title", 100))
7378
} else if env.Config.PostCreationWithTagsEnabled && len(action.TagSlugs) != len(action.Tags) {
7479
result.AddFieldFailure("tags", propertyIsInvalid(ctx, "tags"))

app/handlers/apiv1/post.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ func SearchPosts() web.HandlerFunc {
2929
if myVotesOnly, err := c.QueryParamAsBool("myvotes"); err == nil {
3030
searchPosts.MyVotesOnly = myVotesOnly
3131
}
32+
if noTagsOnly, err := c.QueryParamAsBool("notags"); err == nil {
33+
searchPosts.NoTagsOnly = noTagsOnly
34+
}
35+
if myPostsOnly, err := c.QueryParamAsBool("myposts"); err == nil {
36+
searchPosts.MyPostsOnly = myPostsOnly
37+
}
3238
searchPosts.SetStatusesFromStrings(c.QueryParamAsArray("statuses"))
3339

3440
if err := bus.Dispatch(c, searchPosts); err != nil {

app/handlers/post.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ func Index() web.HandlerFunc {
2828
searchPosts.MyVotesOnly = myVotesOnly
2929
}
3030

31+
if noTagsOnly, err := c.QueryParamAsBool("notags"); err == nil {
32+
searchPosts.NoTagsOnly = noTagsOnly
33+
}
34+
35+
if myPostsOnly, err := c.QueryParamAsBool("myposts"); err == nil {
36+
searchPosts.MyPostsOnly = myPostsOnly
37+
}
38+
3139
searchPosts.SetStatusesFromStrings(c.QueryParamAsArray("statuses"))
3240
getAllTags := &query.GetAllTags{}
3341
countPerStatus := &query.CountPostPerStatus{}

app/models/query/post.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ type SearchPosts struct {
4040
Statuses []enum.PostStatus
4141
Tags []string
4242
MyVotesOnly bool
43+
NoTagsOnly bool
44+
MyPostsOnly bool
4345

4446
Result []*entity.Post
4547
}

app/services/sqlstore/postgres/billing.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ func lockExpiredTenants(ctx context.Context, c *cmd.LockExpiredTenants) error {
115115
FROM tenants t
116116
INNER JOIN tenants_billing tb
117117
ON t.id = tb.tenant_id
118-
WHERE t.status <> $1
118+
WHERE t.status <> $1 AND t.status <> $2
119119
AND (
120-
(tb.status = $2 AND trial_ends_at <= $4)
121-
OR (tb.status = $3 AND subscription_ends_at <= $4)
122-
)`, enum.TenantLocked, enum.BillingTrial, enum.BillingCancelled, now)
120+
(tb.status = $3 AND trial_ends_at <= $5)
121+
OR (tb.status = $4 AND subscription_ends_at <= $5)
122+
)`, enum.TenantLocked, enum.TenantDisabled, enum.BillingTrial, enum.BillingCancelled, now)
123123
if err != nil {
124124
return errors.Wrap(err, "failed to get expired trial/cancelled tenants")
125125
}

app/services/sqlstore/postgres/common.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ func getViewData(query query.SearchPosts) (string, []enum.PostStatus, string) {
8787
sort = "((COALESCE(recent_votes_count, 0)*5 + COALESCE(recent_comments_count, 0) *3)-1) / pow((EXTRACT(EPOCH FROM current_timestamp - created_at)/3600) + 2, 1.4)"
8888
}
8989

90+
if query.NoTagsOnly {
91+
condition += " AND tags = '{}'"
92+
}
93+
9094
if len(query.Tags) > 0 {
9195
condition += " AND tags && $3"
9296
}

app/services/sqlstore/postgres/post.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,12 @@ func searchPosts(ctx context.Context, q *query.SearchPosts) error {
466466
}), ToTSQuery(q.Query), SanitizeString(q.Query))
467467
} else {
468468
condition, statuses, sort := getViewData(*q)
469+
470+
if q.MyPostsOnly {
471+
condition += " AND user_id = " + strconv.Itoa(user.ID)
472+
473+
}
474+
469475
sql := fmt.Sprintf(`
470476
SELECT * FROM (%s) AS q
471477
WHERE 1 = 1 %s

locale/ar/client.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@
4444
"home.form.defaultwelcomemessage": "يسعدنا سماع أفكارك.\n\nكيف يمكننا أن نكون أفضل؟ هذا هو المكان المناسب للتصويت والمناقشة ومشاركة الأفكار.",
4545
"home.lonely.suggestion": "ننصح بإنشاء <0>٣ اقتراحات على الأقل</0> قبل مشاركة هذا الموقع. المحتوى المبدئي مهم لجذب جمهورك.",
4646
"home.lonely.text": "لم يتم إنشاء منشورات بعد.",
47+
"home.postfilter.label.myactivity": "",
48+
"home.postfilter.label.status": "",
4749
"home.postfilter.label.view": "عرض",
4850
"home.postfilter.option.mostdiscussed": "الأكثر مناقشة",
4951
"home.postfilter.option.mostwanted": "الأكثر طلبا",
52+
"home.postfilter.option.myposts": "",
5053
"home.postfilter.option.myvotes": "تصويتي",
54+
"home.postfilter.option.notags": "",
5155
"home.postfilter.option.recent": "الأحدث",
5256
"home.postfilter.option.trending": "الشائع",
5357
"home.postinput.description.placeholder": "صف اقتراحك (اختياري)",
@@ -158,6 +162,7 @@
158162
"newpost.modal.title": "شارك بفكرتك...",
159163
"newpost.modal.title.label": "أعط فكرتك عنوانًا",
160164
"newpost.modal.title.placeholder": "شيء قصير وموجز، لخصه في بضع كلمات",
165+
"pDgeaz": "",
161166
"page.backhome": "خذني إلى <0>{0}</0> الصفحة الرئيسية.",
162167
"page.notinvited.text": "لم نتمكن من العثور على حساب لعنوان بريدك الإلكتروني.",
163168
"page.notinvited.title": "لم تتم دعوتك",
@@ -198,4 +203,4 @@
198203
"validation.custom.maxattachments": "يُسمح بحد أقصى {number} من المرفقات.",
199204
"validation.custom.maximagesize": "يجب أن يكون حجم الصورة أصغر من {kilobytes}KB.",
200205
"{count, plural, one {# tag} other {# tags}}": "{count, plural, zero {}one {# وسم} two {# وسوم} few {# وسوم} many {# وسوم} other {# وسوم}}"
201-
}
206+
}

locale/de/client.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@
4444
"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.",
4545
"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.",
4646
"home.lonely.text": "Es wurden noch keine Beiträge erstellt.",
47+
"home.postfilter.label.myactivity": "Meine Aktivität",
48+
"home.postfilter.label.status": "Status",
4749
"home.postfilter.label.view": "Anzeigen",
4850
"home.postfilter.option.mostdiscussed": "Am häufigsten diskutiert",
4951
"home.postfilter.option.mostwanted": "Meist gefragt",
52+
"home.postfilter.option.myposts": "Meine Beiträge",
5053
"home.postfilter.option.myvotes": "Meine Stimmen",
54+
"home.postfilter.option.notags": "Nicht getaggt",
5155
"home.postfilter.option.recent": "Neueste",
5256
"home.postfilter.option.trending": "Beliebt",
5357
"home.postinput.description.placeholder": "Beschreibe deinen Vorschlag (optional)",
@@ -158,6 +162,7 @@
158162
"newpost.modal.title": "Teile deine Idee ...",
159163
"newpost.modal.title.label": "Gib deiner Idee einen Titel",
160164
"newpost.modal.title.placeholder": "Eine kurze und knappe Zusammenfassung in wenigen Worten",
165+
"pDgeaz": "",
161166
"page.backhome": "Zurück zur <0>{0}</0> Homepage.",
162167
"page.notinvited.text": "Wir konnten kein Account für deine E-Mail-Adresse finden.",
163168
"page.notinvited.title": "Nicht eingeladen",
@@ -198,4 +203,4 @@
198203
"validation.custom.maxattachments": "Es sind maximal {number} Anhänge zulässig.",
199204
"validation.custom.maximagesize": "Die Bildgröße muss kleiner als {kilobytes}KB sein.",
200205
"{count, plural, one {# tag} other {# tags}}": "{count, plural, one {# Tag} other {# Tags}}"
201-
}
206+
}

locale/el/client.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@
4444
"home.form.defaultwelcomemessage": "Θα θέλαμε πολύ να ακούσουμε τι σκέφτεστε.\n\nΤι μπορούμε να κάνουμε καλύτερα; Αυτό είναι το μέρος για να ψηφίσετε, να συζητήσετε και να μοιραστείτε ιδέες.",
4545
"home.lonely.suggestion": "Συνιστάται να δημιουργείσετε εδώ <0>τουλάχιστον 3</0> προτάσεις πριν από την κοινή χρήση αυτής της ιστοσελίδας. Το αρχικό περιεχόμενο είναι σημαντικό να αρχίσετε να προσελκύετε το κοινό σας.",
4646
"home.lonely.text": "Δεν έχουν δημιουργηθεί αναρτήσεις ακόμα.",
47+
"home.postfilter.label.myactivity": "",
48+
"home.postfilter.label.status": "",
4749
"home.postfilter.label.view": "Προβολή",
4850
"home.postfilter.option.mostdiscussed": "Πιο συζητημένα",
4951
"home.postfilter.option.mostwanted": "Πιο ενδιαφέροντα",
52+
"home.postfilter.option.myposts": "",
5053
"home.postfilter.option.myvotes": "Οι Ψήφοι Μου",
54+
"home.postfilter.option.notags": "",
5155
"home.postfilter.option.recent": "Πρόσφατα",
5256
"home.postfilter.option.trending": "Δημοφιλή",
5357
"home.postinput.description.placeholder": "Περιγράψτε την πρότασή σας (προαιρετικό)",
@@ -158,6 +162,7 @@
158162
"newpost.modal.title": "Μοιραστείτε την ιδέα σας...",
159163
"newpost.modal.title.label": "Δώστε έναν τίτλο στην ιδέα σας",
160164
"newpost.modal.title.placeholder": "Κάτι σύντομο και περιεκτικό, συνοψίστε το σε λίγες λέξεις",
165+
"pDgeaz": "",
161166
"page.backhome": "Επιστρέψτε με στην αρχική σελίδα <0>{0}</0>.",
162167
"page.notinvited.text": "Δεν μπορέσαμε να βρούμε λογαριασμό για τη διεύθυνση email σας.",
163168
"page.notinvited.title": "Δεν έχει προσκληθεί",
@@ -198,4 +203,4 @@
198203
"validation.custom.maxattachments": "Επιτρέπονται έως {number} συνημμένα.",
199204
"validation.custom.maximagesize": "Το μέγεθος της εικόνας πρέπει να είναι μικρότερο από {kilobytes}KB.",
200205
"{count, plural, one {# tag} other {# tags}}": "{count, plural, one {# ετικέτα} other {# ετικέτες}}"
201-
}
206+
}

0 commit comments

Comments
 (0)