From fdf87ea991b1d406b28dbd0c8807908939070c8b Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 23 Aug 2023 12:12:54 +0200 Subject: [PATCH] fix(push): fix push subscriptions registration Signed-off-by: Thomas Citharel --- js/src/services/push-subscription.ts | 5 ++--- lib/graphql/schema/users/push_subscription.ex | 11 +++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/js/src/services/push-subscription.ts b/js/src/services/push-subscription.ts index 0abb0d3c4..437a5867d 100644 --- a/js/src/services/push-subscription.ts +++ b/js/src/services/push-subscription.ts @@ -32,9 +32,8 @@ export async function subscribeUserToPush(): Promise { }; const registration = await navigator.serviceWorker.ready; try { - const pushSubscription = await registration.pushManager.subscribe( - subscribeOptions - ); + const pushSubscription = + await registration.pushManager.subscribe(subscribeOptions); console.debug("Received PushSubscription: ", pushSubscription); resolve(pushSubscription); } catch (e) { diff --git a/lib/graphql/schema/users/push_subscription.ex b/lib/graphql/schema/users/push_subscription.ex index 9565199de..6824ea59d 100644 --- a/lib/graphql/schema/users/push_subscription.ex +++ b/lib/graphql/schema/users/push_subscription.ex @@ -4,6 +4,7 @@ defmodule Mobilizon.GraphQL.Schema.Users.PushSubscription do """ use Absinthe.Schema.Notation alias Mobilizon.GraphQL.Resolvers.PushSubscription + alias Mobilizon.Users.User # object :push_subscription do # field(:id, :id) @@ -29,8 +30,9 @@ defmodule Mobilizon.GraphQL.Schema.Users.PushSubscription do middleware(Rajska.QueryAuthorization, permit: :user, - scope: false, - rule: :"write:user:setting:push" + scope: User, + rule: :"write:user:setting:push", + args: %{} ) resolve(&PushSubscription.register_push_subscription/3) @@ -41,8 +43,9 @@ defmodule Mobilizon.GraphQL.Schema.Users.PushSubscription do middleware(Rajska.QueryAuthorization, permit: :user, - scope: false, - rule: :"write:user:setting:push" + scope: User, + rule: :"write:user:setting:push", + args: %{} ) resolve(&PushSubscription.unregister_push_subscription/3)