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
normandy
pleroma
Commits
b574d97c
Commit
b574d97c
authored
6 years ago
by
Ivan Tashkinov
Browse files
Options
Downloads
Patches
Plain Diff
[#468] Added support for `push` OAuth scope (Mastodon 2.4+).
parent
6fe7acd5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
+11
-1
11 additions, 1 deletion
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
lib/pleroma/web/router.ex
+8
-0
8 additions, 0 deletions
lib/pleroma/web/router.ex
test/support/factory.ex
+1
-1
1 addition, 1 deletion
test/support/factory.ex
with
20 additions
and
2 deletions
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
+
11
−
1
View file @
b574d97c
...
...
@@ -1273,15 +1273,25 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
defp
get_or_make_app
()
do
find_attrs
=
%{
client_name:
@local_mastodon_name
,
redirect_uris:
"."
}
scopes
=
[
"read"
,
"write"
,
"follow"
,
"push"
]
with
%
App
{}
=
app
<-
Repo
.
get_by
(
App
,
find_attrs
)
do
{
:ok
,
app
}
=
if
app
.
scopes
==
scopes
do
{
:ok
,
app
}
else
app
|>
Ecto
.
Changeset
.
change
(%{
scopes:
scopes
})
|>
Repo
.
update
()
end
{
:ok
,
app
}
else
_e
->
cs
=
App
.
register_changeset
(
%
App
{},
Map
.
put
(
find_attrs
,
:scopes
,
[
"read"
,
"write"
,
"follow"
]
)
Map
.
put
(
find_attrs
,
:scopes
,
scopes
)
)
Repo
.
insert
(
cs
)
...
...
This diff is collapsed.
Click to expand it.
lib/pleroma/web/router.ex
+
8
−
0
View file @
b574d97c
...
...
@@ -93,6 +93,10 @@ defmodule Pleroma.Web.Router do
plug
(
Pleroma
.
Plugs
.
OAuthScopesPlug
,
%{
scopes:
[
"follow"
]})
end
pipeline
:oauth_push
do
plug
(
Pleroma
.
Plugs
.
OAuthScopesPlug
,
%{
scopes:
[
"push"
]})
end
pipeline
:well_known
do
plug
(
:accepts
,
[
"json"
,
"jrd+json"
,
"xml"
,
"xrd+xml"
])
end
...
...
@@ -290,6 +294,10 @@ defmodule Pleroma.Web.Router do
post
(
"/domain_blocks"
,
MastodonAPIController
,
:block_domain
)
delete
(
"/domain_blocks"
,
MastodonAPIController
,
:unblock_domain
)
end
scope
[]
do
pipe_through
(
:oauth_push
)
post
(
"/push/subscription"
,
MastodonAPIController
,
:create_push_subscription
)
get
(
"/push/subscription"
,
MastodonAPIController
,
:get_push_subscription
)
...
...
This diff is collapsed.
Click to expand it.
test/support/factory.ex
+
1
−
1
View file @
b574d97c
...
...
@@ -214,7 +214,7 @@ defmodule Pleroma.Factory do
%
Pleroma
.
Web
.
OAuth
.
App
{
client_name:
"Some client"
,
redirect_uris:
"https://example.com/callback"
,
scopes:
[
"read"
,
"write"
,
"follow"
],
scopes:
[
"read"
,
"write"
,
"follow"
,
"push"
],
website:
"https://example.com"
,
client_id:
"aaabbb=="
,
client_secret:
"aaa;/&bbb"
...
...
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