Skip to content

Commit

Permalink
feat(notifications): finish migrating gql functionality (#3821)
Browse files Browse the repository at this point in the history
- move settings ownership from account to user
- complete notification mutations migration
- add notification settings to user
  • Loading branch information
UncleSamtoshi authored Jan 12, 2024
1 parent ac43ce0 commit 93a01a0
Show file tree
Hide file tree
Showing 27 changed files with 694 additions and 424 deletions.
33 changes: 31 additions & 2 deletions bats/core/notifications/notifications.bats
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,36 @@ setup_file() {
jq -n \
'{input: { channel: "PUSH" }}')

exec_graphql "$token_name" 'account-disable-notification-channel-alt' "$variables"
channel_enabled="$(graphql_output '.data.accountDisableNotificationChannelAlt.notificationSettings.push.enabled')"
exec_graphql "$token_name" 'user-disable-notification-channel' "$variables"
channel_enabled="$(graphql_output '.data.userDisableNotificationChannel.notificationSettings.push.enabled')"

[[ "$channel_enabled" == "false" ]] || exit 1

# Ensure notification settings exist on user
exec_graphql "$token_name" 'user-notification-settings'
user_channel_enabled="$(graphql_output '.data.me.notificationSettings.push.enabled')"

[[ "$user_channel_enabled" == "false" ]] || exit 1


exec_graphql "$token_name" 'user-enable-notification-channel' "$variables"
channel_enabled="$(graphql_output '.data.userEnableNotificationChannel.notificationSettings.push.enabled')"
[[ "$channel_enabled" == "true" ]] || exit 1
}

@test "notifications: disable/enable notification category" {
token_name='alice'

variables=$(
jq -n \
'{input: { channel: "PUSH", category: "CIRCLES" }}')

exec_graphql "$token_name" 'user-disable-notification-category' "$variables"
disabled_category="$(graphql_output '.data.userDisableNotificationCategory.notificationSettings.push.disabledCategories[0]')"

[[ "$disabled_category" == "CIRCLES" ]] || exit 1

exec_graphql "$token_name" 'user-enable-notification-category' "$variables"
disabled_length="$(graphql_output '.data.userEnableNotificationCategory.notificationSettings.push.disabledCategories | length')"
[[ "$disabled_length" == "0" ]] || exit 1
}
10 changes: 0 additions & 10 deletions bats/gql/account-disable-notification-channel-alt.gql

This file was deleted.

12 changes: 12 additions & 0 deletions bats/gql/user-disable-notification-category.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
mutation userDisableNotificationCategory(
$input: UserDisableNotificationCategoryInput!
) {
userDisableNotificationCategory(input: $input) {
notificationSettings {
push {
enabled
disabledCategories
}
}
}
}
12 changes: 12 additions & 0 deletions bats/gql/user-disable-notification-channel.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
mutation userDisableNotificationChannel(
$input: UserDisableNotificationChannelInput!
) {
userDisableNotificationChannel(input: $input) {
notificationSettings {
push {
enabled
disabledCategories
}
}
}
}
12 changes: 12 additions & 0 deletions bats/gql/user-enable-notification-category.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
mutation userEnableNotificationCategory(
$input: UserEnableNotificationCategoryInput!
) {
userEnableNotificationCategory(input: $input) {
notificationSettings {
push {
enabled
disabledCategories
}
}
}
}
12 changes: 12 additions & 0 deletions bats/gql/user-enable-notification-channel.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
mutation userEnableNotificationChannel(
$input: UserEnableNotificationChannelInput!
) {
userEnableNotificationChannel(input: $input) {
notificationSettings {
push {
enabled
disabledCategories
}
}
}
}
10 changes: 10 additions & 0 deletions bats/gql/user-notification-settings.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
query userNotificationSettings {
me {
id
notificationSettings {
push {
enabled
}
}
}
}

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
CREATE TABLE account_notification_settings (
CREATE TABLE user_notification_settings (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
galoy_account_id VARCHAR UNIQUE NOT NULL,
galoy_user_id VARCHAR UNIQUE NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

CREATE TABLE account_notification_settings_events (
id UUID REFERENCES account_notification_settings(id) NOT NULL,
CREATE TABLE user_notification_settings_events (
id UUID REFERENCES user_notification_settings(id) NOT NULL,
sequence INT NOT NULL,
event_type VARCHAR NOT NULL,
event JSONB NOT NULL,
Expand Down
Loading

0 comments on commit 93a01a0

Please sign in to comment.