fix(push): fix push subscriptions registration

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2023-08-23 12:12:54 +02:00
parent 7cc4abd47b
commit fdf87ea991
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
2 changed files with 9 additions and 7 deletions

View file

@ -32,9 +32,8 @@ export async function subscribeUserToPush(): Promise<PushSubscription | null> {
}; };
const registration = await navigator.serviceWorker.ready; const registration = await navigator.serviceWorker.ready;
try { try {
const pushSubscription = await registration.pushManager.subscribe( const pushSubscription =
subscribeOptions await registration.pushManager.subscribe(subscribeOptions);
);
console.debug("Received PushSubscription: ", pushSubscription); console.debug("Received PushSubscription: ", pushSubscription);
resolve(pushSubscription); resolve(pushSubscription);
} catch (e) { } catch (e) {

View file

@ -4,6 +4,7 @@ defmodule Mobilizon.GraphQL.Schema.Users.PushSubscription do
""" """
use Absinthe.Schema.Notation use Absinthe.Schema.Notation
alias Mobilizon.GraphQL.Resolvers.PushSubscription alias Mobilizon.GraphQL.Resolvers.PushSubscription
alias Mobilizon.Users.User
# object :push_subscription do # object :push_subscription do
# field(:id, :id) # field(:id, :id)
@ -29,8 +30,9 @@ defmodule Mobilizon.GraphQL.Schema.Users.PushSubscription do
middleware(Rajska.QueryAuthorization, middleware(Rajska.QueryAuthorization,
permit: :user, permit: :user,
scope: false, scope: User,
rule: :"write:user:setting:push" rule: :"write:user:setting:push",
args: %{}
) )
resolve(&PushSubscription.register_push_subscription/3) resolve(&PushSubscription.register_push_subscription/3)
@ -41,8 +43,9 @@ defmodule Mobilizon.GraphQL.Schema.Users.PushSubscription do
middleware(Rajska.QueryAuthorization, middleware(Rajska.QueryAuthorization,
permit: :user, permit: :user,
scope: false, scope: User,
rule: :"write:user:setting:push" rule: :"write:user:setting:push",
args: %{}
) )
resolve(&PushSubscription.unregister_push_subscription/3) resolve(&PushSubscription.unregister_push_subscription/3)