From c16289fca9140c33d8eb4e76a32be3627f635a64 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Mon, 6 Jan 2025 16:33:04 +0530 Subject: [PATCH] [server] Return correct value for enableJoin flag --- server/ente/public_collection.go | 3 ++- server/pkg/controller/public_collection.go | 1 + server/pkg/repo/public_collection.go | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/server/ente/public_collection.go b/server/ente/public_collection.go index 7a477c4365..78b7190784 100644 --- a/server/ente/public_collection.go +++ b/server/ente/public_collection.go @@ -3,6 +3,7 @@ package ente import ( "database/sql/driver" "encoding/json" + "github.com/ente-io/museum/pkg/utils/time" "github.com/ente-io/stacktrace" ) @@ -85,7 +86,7 @@ type PublicURL struct { Nonce *string `json:"nonce,omitempty"` MemLimit *int64 `json:"memLimit,omitempty"` OpsLimit *int64 `json:"opsLimit,omitempty"` - EnableJoin bool `json:"enableJoinViaLink"` + EnableJoin bool `json:"enableJoin"` } type PublicAccessContext struct { diff --git a/server/pkg/controller/public_collection.go b/server/pkg/controller/public_collection.go index d9b5e29b77..022a08812e 100644 --- a/server/pkg/controller/public_collection.go +++ b/server/pkg/controller/public_collection.go @@ -331,6 +331,7 @@ func (c *PublicCollectionController) GetPublicCollection(ctx *gin.Context, mustA Nonce: publicUrl.Nonce, MemLimit: publicUrl.MemLimit, OpsLimit: publicUrl.OpsLimit, + EnableJoin: publicUrl.EnableJoin, }) } collection.PublicURLs = publicURLsWithLimitedInfo diff --git a/server/pkg/repo/public_collection.go b/server/pkg/repo/public_collection.go index 49918f4c88..f5ae8f2d72 100644 --- a/server/pkg/repo/public_collection.go +++ b/server/pkg/repo/public_collection.go @@ -60,7 +60,7 @@ func (pcr *PublicCollectionRepository) DisableSharing(ctx context.Context, cID i // GetCollectionToActivePublicURLMap will return map of collectionID to PublicURLs which are not disabled yet. // Note: The url could be expired or deviceLimit is already reached func (pcr *PublicCollectionRepository) GetCollectionToActivePublicURLMap(ctx context.Context, collectionIDs []int64) (map[int64][]ente.PublicURL, error) { - rows, err := pcr.DB.QueryContext(ctx, `SELECT collection_id, access_token, valid_till, device_limit, enable_download, enable_collect, pw_nonce, mem_limit, ops_limit FROM + rows, err := pcr.DB.QueryContext(ctx, `SELECT collection_id, access_token, valid_till, device_limit, enable_download, enable_collect, enable_join, pw_nonce, mem_limit, ops_limit FROM public_collection_tokens WHERE collection_id = ANY($1) and is_disabled = FALSE`, pq.Array(collectionIDs)) if err != nil { @@ -77,7 +77,7 @@ func (pcr *PublicCollectionRepository) GetCollectionToActivePublicURLMap(ctx con var accessToken string var nonce *string var opsLimit, memLimit *int64 - if err = rows.Scan(&collectionID, &accessToken, &publicUrl.ValidTill, &publicUrl.DeviceLimit, &publicUrl.EnableDownload, &publicUrl.EnableCollect, &nonce, &memLimit, &opsLimit); err != nil { + if err = rows.Scan(&collectionID, &accessToken, &publicUrl.ValidTill, &publicUrl.DeviceLimit, &publicUrl.EnableDownload, &publicUrl.EnableCollect, &publicUrl.EnableJoin, &nonce, &memLimit, &opsLimit); err != nil { return nil, stacktrace.Propagate(err, "") } publicUrl.URL = pcr.GetAlbumUrl(accessToken)