[WEB-5607] fix: sites feature flag endpoint to return response similar to cloud (#5033)
* fix: update feature flag response handling to return specific flag value * refactor: simplify feature flag response handling and update payload key * fix: enable response caching for feature flag endpoint * fix: handle expiration parameter in S3Storage class for presigned URLs
This commit is contained in:
@@ -8,6 +8,7 @@ import json
|
||||
import hmac
|
||||
from datetime import datetime
|
||||
from urllib.parse import urlparse
|
||||
|
||||
# Third party imports
|
||||
import boto3
|
||||
from botocore.exceptions import ClientError
|
||||
@@ -19,6 +20,7 @@ from plane.utils.exception_logger import log_exception
|
||||
from storages.backends.s3boto3 import S3Boto3Storage
|
||||
from plane.utils.host import base_host
|
||||
|
||||
|
||||
class S3Storage(S3Boto3Storage):
|
||||
file_overwrite = True
|
||||
|
||||
@@ -164,6 +166,9 @@ class S3Storage(S3Boto3Storage):
|
||||
scheme = url.scheme
|
||||
host = url.netloc
|
||||
|
||||
if expiration is None:
|
||||
expiration = self.signed_url_expiration
|
||||
|
||||
# Create download parameters
|
||||
download_params = {
|
||||
"object_name": object_name,
|
||||
@@ -180,7 +185,6 @@ class S3Storage(S3Boto3Storage):
|
||||
# Base64 encode the parameters
|
||||
encoded_params = base64.urlsafe_b64encode(json.dumps(download_params).encode()).decode()
|
||||
|
||||
|
||||
return f"{scheme}://{host}/api/assets/proxy-download/{encoded_params}/"
|
||||
|
||||
def generate_presigned_url(
|
||||
|
||||
@@ -71,7 +71,7 @@ type WorkspaceSyncPayload struct {
|
||||
type GetFlagsPayload struct {
|
||||
WorkspaceSlug string `json:"workspace_slug"`
|
||||
UserID string `json:"user_id"`
|
||||
FeatureKey string `json:"feature_key"`
|
||||
FeatureKey string `json:"flag_key"`
|
||||
}
|
||||
|
||||
type EncyptedFlagData struct {
|
||||
|
||||
@@ -225,9 +225,7 @@ func handleWorkspaceFeatureFlag(ctx *fiber.Ctx, api prime_api.IPrimeMonitorApi,
|
||||
record = db.Db.Model(&db.Flags{}).Where("license_id = ? AND version = ?", license.ID, APP_VERSION).First(&flags)
|
||||
if record.Error != nil {
|
||||
ctx.Status(fiber.StatusOK).JSON(fiber.Map{
|
||||
"values": map[string]bool{
|
||||
payload.FeatureKey: false,
|
||||
},
|
||||
"values": false,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
@@ -241,9 +239,7 @@ func handleWorkspaceFeatureFlag(ctx *fiber.Ctx, api prime_api.IPrimeMonitorApi,
|
||||
}, &decryptedFlags)
|
||||
if err != nil {
|
||||
ctx.Status(fiber.StatusOK).JSON(fiber.Map{
|
||||
"values": map[string]bool{
|
||||
payload.FeatureKey: false,
|
||||
},
|
||||
"values": false,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
@@ -251,17 +247,13 @@ func handleWorkspaceFeatureFlag(ctx *fiber.Ctx, api prime_api.IPrimeMonitorApi,
|
||||
flagValue, ok := decryptedFlags[payload.FeatureKey]
|
||||
if !ok {
|
||||
ctx.JSON(fiber.Map{
|
||||
"values": map[string]bool{
|
||||
payload.FeatureKey: false,
|
||||
},
|
||||
"values": false,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
ctx.JSON(fiber.Map{
|
||||
"values": map[string]interface{}{
|
||||
payload.FeatureKey: flagValue,
|
||||
},
|
||||
"values": flagValue,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user