Skip to content

Commit e6a084d

Browse files
authored
fix: handle clearing in app settings (#228)
1 parent 1a73c94 commit e6a084d

File tree

2 files changed

+34
-9
lines changed

2 files changed

+34
-9
lines changed

app.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@ type AppSettings struct {
1414
XiaomiConfig *XiaomiConfigRequest `json:"xiaomi_config,omitempty"`
1515
HuaweiConfig *HuaweiConfigRequest `json:"huawei_config,omitempty"`
1616
PushConfig *PushConfigRequest `json:"push_config,omitempty"`
17-
WebhookURL string `json:"webhook_url,omitempty"`
17+
WebhookURL *string `json:"webhook_url,omitempty"`
1818
MultiTenantEnabled *bool `json:"multi_tenant_enabled,omitempty"`
1919
AsyncURLEnrichEnabled *bool `json:"async_url_enrich_enabled,omitempty"`
2020
AutoTranslationEnabled *bool `json:"auto_translation_enabled,omitempty"`
2121
Grants map[string][]string `json:"grants,omitempty"`
2222
MigratePermissionsToV2 *bool `json:"migrate_permissions_to_v2,omitempty"`
23-
PermissionVersion string `json:"permission_version,omitempty"`
23+
PermissionVersion *string `json:"permission_version,omitempty"`
2424
FileUploadConfig *FileUploadConfig `json:"file_upload_config,omitempty"`
2525
ImageUploadConfig *FileUploadConfig `json:"image_upload_config,omitempty"`
2626
ImageModerationLabels []string `json:"image_moderation_labels,omitempty"`
2727
ImageModerationEnabled *bool `json:"image_moderation_enabled,omitempty"`
2828
RemindersInterval int `json:"reminders_interval,omitempty"`
29-
BeforeMessageSendHookURL string `json:"before_message_send_hook_url,omitempty"`
30-
CustomActionHandlerURL string `json:"custom_action_handler_url,omitempty"`
29+
BeforeMessageSendHookURL *string `json:"before_message_send_hook_url,omitempty"`
30+
CustomActionHandlerURL *string `json:"custom_action_handler_url,omitempty"`
3131
UserSearchDisallowedRoles []string `json:"user_search_disallowed_roles,omitempty"`
32-
EnforceUniqueUsernames string `json:"enforce_unique_usernames,omitempty"`
33-
SqsURL string `json:"sqs_url,omitempty"`
34-
SqsKey string `json:"sqs_key,omitempty"`
35-
SqsSecret string `json:"sqs_secret,omitempty"`
32+
EnforceUniqueUsernames *string `json:"enforce_unique_usernames,omitempty"`
33+
SqsURL *string `json:"sqs_url,omitempty"`
34+
SqsKey *string `json:"sqs_key,omitempty"`
35+
SqsSecret *string `json:"sqs_secret,omitempty"`
3636
WebhookEvents []string `json:"webhook_events,omitempty"`
3737
ChannelHideMembersOnly *bool `json:"channel_hide_members_only,omitempty"`
3838
}
@@ -58,7 +58,7 @@ func (a *AppSettings) SetFirebaseConfig(c FirebaseConfigRequest) *AppSettings {
5858
}
5959

6060
func (a *AppSettings) SetWebhookURL(s string) *AppSettings {
61-
a.WebhookURL = s
61+
a.WebhookURL = &s
6262
return a
6363
}
6464

app_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,31 @@ func TestClient_UpdateAppSettings(t *testing.T) {
2727
require.NoError(t, err)
2828
}
2929

30+
func TestClient_UpdateAppSettingsClearing(t *testing.T) {
31+
c := initClient(t)
32+
ctx := context.Background()
33+
34+
sqsURL := "https://example.com"
35+
sqsKey := "some key"
36+
sqsSecret := "some secret"
37+
38+
settings := NewAppSettings()
39+
settings.SqsURL = &sqsURL
40+
settings.SqsKey = &sqsKey
41+
settings.SqsSecret = &sqsSecret
42+
43+
_, err := c.UpdateAppSettings(ctx, settings)
44+
require.NoError(t, err)
45+
46+
sqsURL = ""
47+
settings.SqsURL = &sqsURL
48+
_, err = c.UpdateAppSettings(ctx, settings)
49+
require.NoError(t, err)
50+
51+
s, err := c.GetAppConfig(ctx)
52+
require.Equal(t, *settings.SqsURL, s.App.SqsURL)
53+
}
54+
3055
func TestClient_CheckSqs(t *testing.T) {
3156
c := initClient(t)
3257
ctx := context.Background()

0 commit comments

Comments
 (0)