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
kaniini
pleroma
Commits
813d2eaa
Commit
813d2eaa
authored
7 years ago
by
eal
Browse files
Options
Downloads
Patches
Plain Diff
Add mastodon API endpoint for follow
parent
52935167
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
+27
-4
27 additions, 4 deletions
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
lib/pleroma/web/router.ex
+2
-0
2 additions, 0 deletions
lib/pleroma/web/router.ex
with
29 additions
and
4 deletions
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
+
27
−
4
View file @
813d2eaa
...
...
@@ -269,11 +269,13 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
end
end
def
follow
(%{
assigns:
%{
user:
follower
}}
=
conn
,
%{
"id"
=>
id
}
)
do
with
%
User
{}
=
followed
<-
Repo
.
get
(
U
ser
,
id
),
{
:ok
,
follower
}
<-
User
.
follow
(
follower
,
followed
),
{
:ok
,
activity
}
<-
ActivityPub
.
follow
(
follower
,
followed
)
do
def
follow
(%{
assigns:
%{
user:
follower
}}
=
conn
,
params
)
do
with
{
:ok
,
%
User
{}
=
followed
}
<-
get
_u
ser
(
params
),
{
:ok
,
follower
}
<-
User
.
follow
(
follower
,
followed
),
{
:ok
,
activity
}
<-
ActivityPub
.
follow
(
follower
,
followed
)
do
render
conn
,
AccountView
,
"relationship.json"
,
%{
user:
follower
,
target:
followed
}
else
err
->
err
end
end
...
...
@@ -338,4 +340,25 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
Logger
.
debug
(
"Unimplemented, returning an empty array"
)
json
(
conn
,
[])
end
defp
get_user
(
params
)
do
case
params
do
%{
"uri"
=>
uri
}
->
case
target
=
Repo
.
get_by
(
User
,
nickname:
uri
)
do
nil
->
{
:error
,
"No user with such nickname"
}
_
->
{
:ok
,
target
}
end
%{
"id"
=>
id
}
->
case
target
=
Repo
.
get
(
User
,
id
)
do
nil
->
{
:error
,
"No user with such id"
}
_
->
{
:ok
,
target
}
end
_
->
{
:error
,
"You need to specify uri or id"
}
end
end
end
This diff is collapsed.
Click to expand it.
lib/pleroma/web/router.ex
+
2
−
0
View file @
813d2eaa
...
...
@@ -62,6 +62,8 @@ defmodule Pleroma.Web.Router do
post
"/accounts/:id/mute"
,
MastodonAPIController
,
:relationship_noop
post
"/accounts/:id/unmute"
,
MastodonAPIController
,
:relationship_noop
post
"/follows"
,
MastodonAPIController
,
:follow
get
"/blocks"
,
MastodonAPIController
,
:empty_array
get
"/domain_blocks"
,
MastodonAPIController
,
:empty_array
get
"/follow_requests"
,
MastodonAPIController
,
:empty_array
...
...
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