Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pleroma
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jeff
pleroma
Commits
7facbb2b
Verified
Commit
7facbb2b
authored
6 years ago
by
href
Browse files
Options
Downloads
Patches
Plain Diff
Push.Subscription: convert base64 to base64 urlsafe
parent
324933a0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/pleroma/web/push/subscription.ex
+12
-2
12 additions, 2 deletions
lib/pleroma/web/push/subscription.ex
with
12 additions
and
2 deletions
lib/pleroma/web/push/subscription.ex
+
12
−
2
View file @
7facbb2b
...
...
@@ -37,8 +37,8 @@ defmodule Pleroma.Web.Push.Subscription do
user_id:
user
.
id
,
token_id:
token
.
id
,
endpoint:
endpoint
,
key_auth:
key_auth
,
key_p256dh:
key_p256dh
,
key_auth:
ensure_base64_urlsafe
(
key_auth
)
,
key_p256dh:
ensure_base64_urlsafe
(
key_p256dh
)
,
data:
alerts
(
params
)
})
end
...
...
@@ -63,4 +63,14 @@ defmodule Pleroma.Web.Push.Subscription do
sub
->
Repo
.
delete
(
sub
)
end
end
# Some webpush clients (e.g. iOS Toot!) use an non urlsafe base64 as an encoding for the key.
# However, the web push rfs specify to use base64 urlsafe, and the `web_push_encryption` library we use
# requires the key to be properly encoded. So we just convert base64 to urlsafe base64.
defp
ensure_base64_urlsafe
(
string
)
do
string
|>
String
.
replace
(
"+"
,
"-"
)
|>
String
.
replace
(
"/"
,
"_"
)
|>
String
.
replace
(
"="
,
""
)
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment