@@ -80,8 +80,8 @@ func updateTenantSettings(ctx context.Context, c *cmd.UpdateTenantSettings) erro
8080 c .Logo .BlobKey = ""
8181 }
8282
83- query := "UPDATE tenants SET name = $1, invitation = $2, welcome_message = $3, welcome_header = $4, cname = $5, logo_bkey = $6, locale = $7 WHERE id = $8 "
84- _ , err := trx .Execute (query , c .Title , c .Invitation , c .WelcomeMessage , c .WelcomeHeader , c .CNAME , c .Logo .BlobKey , c .Locale , tenant .ID )
83+ query := "UPDATE tenants SET name = $1, invitation = $2, welcome_message = $3, welcome_header = $4, cname = $5, logo_bkey = $6, locale = $7, default_sort = $8 WHERE id = $9 "
84+ _ , err := trx .Execute (query , c .Title , c .Invitation , c .WelcomeMessage , c .WelcomeHeader , c .CNAME , c .Logo .BlobKey , c .Locale , c . DefaultSort , tenant .ID )
8585 if err != nil {
8686 return errors .Wrap (err , "failed update tenant settings" )
8787 }
@@ -91,6 +91,7 @@ func updateTenantSettings(ctx context.Context, c *cmd.UpdateTenantSettings) erro
9191 tenant .CNAME = c .CNAME
9292 tenant .WelcomeMessage = c .WelcomeMessage
9393 tenant .WelcomeHeader = c .WelcomeHeader
94+ tenant .DefaultSort = c .DefaultSort
9495
9596 return nil
9697 })
@@ -189,8 +190,8 @@ func createTenant(ctx context.Context, c *cmd.CreateTenant) error {
189190
190191 var id int
191192 err := trx .Get (& id ,
192- `INSERT INTO tenants (name, subdomain, created_at, cname, invitation, welcome_message, status, is_private, custom_css, logo_bkey, locale, is_email_auth_allowed, is_feed_enabled, prevent_indexing, is_moderation_enabled)
193- VALUES ($1, $2, $3, '', '', '', $4, false, '', '', $5, true, true, true, false)
193+ `INSERT INTO tenants (name, subdomain, created_at, cname, invitation, welcome_message, status, is_private, custom_css, logo_bkey, locale, is_email_auth_allowed, is_feed_enabled, prevent_indexing, is_moderation_enabled, default_sort )
194+ VALUES ($1, $2, $3, '', '', '', $4, false, '', '', $5, true, true, true, false, 'trending' )
194195 RETURNING id` , c .Name , c .Subdomain , now , c .Status , env .Config .Locale )
195196 if err != nil {
196197 return err
@@ -207,13 +208,13 @@ func getFirstTenant(ctx context.Context, q *query.GetFirstTenant) error {
207208 return using (ctx , func (trx * dbx.Trx , _ * entity.Tenant , _ * entity.User ) error {
208209 tenant := dbEntities.Tenant {}
209210
210- err := trx .Get (& tenant , `
211- SELECT t.id, t.name, t.subdomain, t.cname, t.invitation, t.locale, t.welcome_message, t.welcome_header, t.status, t.is_private, t.logo_bkey, t.custom_css, t.allowed_schemes, t.is_email_auth_allowed, t.is_feed_enabled, t.is_moderation_enabled, t.prevent_indexing, t.is_pro,
212- (b.paddle_subscription_id IS NOT NULL AND b.stripe_subscription_id IS NULL) AS has_paddle_subscription
213- FROM tenants t
214- LEFT JOIN tenants_billing b ON b.tenant_id = t.id
215- ORDER BY t.id LIMIT 1
216- ` )
211+ err := trx .Get (& tenant , `
212+ SELECT t.id, t.name, t.subdomain, t.cname, t.invitation, t.locale, t.welcome_message, t.welcome_header, t.status, t.is_private, t.logo_bkey, t.custom_css, t.allowed_schemes, t.is_email_auth_allowed, t.is_feed_enabled, t.is_moderation_enabled, t.prevent_indexing, t.is_pro, t.default_sort ,
213+ (b.paddle_subscription_id IS NOT NULL AND b.stripe_subscription_id IS NULL) AS has_paddle_subscription
214+ FROM tenants t
215+ LEFT JOIN tenants_billing b ON b.tenant_id = t.id
216+ ORDER BY t.id LIMIT 1
217+ ` )
217218 if err != nil {
218219 return errors .Wrap (err , "failed to get first tenant" )
219220 }
@@ -227,14 +228,14 @@ func getTenantByDomain(ctx context.Context, q *query.GetTenantByDomain) error {
227228 return using (ctx , func (trx * dbx.Trx , _ * entity.Tenant , _ * entity.User ) error {
228229 tenant := dbEntities.Tenant {}
229230
230- err := trx .Get (& tenant , `
231- SELECT t.id, t.name, t.subdomain, t.cname, t.invitation, t.locale, t.welcome_message, t.welcome_header, t.status, t.is_private, t.logo_bkey, t.custom_css, t.allowed_schemes, t.is_email_auth_allowed, t.is_feed_enabled, t.is_moderation_enabled, t.prevent_indexing, t.is_pro,
232- (b.paddle_subscription_id IS NOT NULL AND b.stripe_subscription_id IS NULL) AS has_paddle_subscription
233- FROM tenants t
234- LEFT JOIN tenants_billing b ON b.tenant_id = t.id
235- WHERE t.subdomain = $1 OR t.subdomain = $2 OR t.cname = $3
236- ORDER BY t.cname DESC
237- ` , env .Subdomain (q .Domain ), q .Domain , q .Domain )
231+ err := trx .Get (& tenant , `
232+ SELECT t.id, t.name, t.subdomain, t.cname, t.invitation, t.locale, t.welcome_message, t.welcome_header, t.status, t.is_private, t.logo_bkey, t.custom_css, t.allowed_schemes, t.is_email_auth_allowed, t.is_feed_enabled, t.is_moderation_enabled, t.prevent_indexing, t.is_pro, t.default_sort ,
233+ (b.paddle_subscription_id IS NOT NULL AND b.stripe_subscription_id IS NULL) AS has_paddle_subscription
234+ FROM tenants t
235+ LEFT JOIN tenants_billing b ON b.tenant_id = t.id
236+ WHERE t.subdomain = $1 OR t.subdomain = $2 OR t.cname = $3
237+ ORDER BY t.cname DESC
238+ ` , env .Subdomain (q .Domain ), q .Domain , q .Domain )
238239 if err != nil {
239240 return errors .Wrap (err , "failed to get tenant with domain '%s'" , q .Domain )
240241 }
0 commit comments