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
csaurus
pleroma
Commits
b502d798
Commit
b502d798
authored
7 years ago
by
dtluna
Browse files
Options
Downloads
Patches
Plain Diff
Add Follow Activity representer
parent
8075bada
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/twitter_api/representers/activity_representer.ex
+14
-0
14 additions, 0 deletions
...roma/web/twitter_api/representers/activity_representer.ex
lib/pleroma/web/twitter_api/twitter_api.ex
+8
-5
8 additions, 5 deletions
lib/pleroma/web/twitter_api/twitter_api.ex
with
22 additions
and
5 deletions
lib/pleroma/web/twitter_api/representers/activity_representer.ex
+
14
−
0
View file @
b502d798
...
...
@@ -3,6 +3,20 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
alias
Pleroma
.
Web
.
TwitterAPI
.
Representers
.
{
UserRepresenter
,
ObjectRepresenter
}
alias
Pleroma
.
Activity
def
to_map
(%
Activity
{
data:
%{
"type"
=>
"Follow"
}}
=
activity
,
%{
user:
user
}
=
opts
)
do
%{
"id"
=>
activity
.
id
,
"user"
=>
UserRepresenter
.
to_map
(
user
,
opts
),
"attentions"
=>
[],
"statusnet_html"
=>
""
,
# TODO: add summary
"text"
=>
""
,
"is_local"
=>
true
,
"is_post_verb"
=>
false
,
"created_at"
=>
get_in
(
activity
.
data
,
[
"published"
]),
"in_reply_to_status_id"
=>
nil
,
}
end
def
to_map
(%
Activity
{}
=
activity
,
%{
user:
user
}
=
opts
)
do
content
=
get_in
(
activity
.
data
,
[
"object"
,
"content"
])
published
=
get_in
(
activity
.
data
,
[
"object"
,
"published"
])
...
...
This diff is collapsed.
Click to expand it.
lib/pleroma/web/twitter_api/twitter_api.ex
+
8
−
5
View file @
b502d798
...
...
@@ -6,8 +6,6 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
import
Ecto
.
Query
def
create_status
(
user
=
%
User
{},
data
=
%{})
do
date
=
DateTime
.
utc_now
()
|>
DateTime
.
to_iso8601
attachments
=
Enum
.
map
(
data
[
"media_ids"
]
||
[],
fn
(
media_id
)
->
Repo
.
get
(
Object
,
media_id
)
.
data
end
)
...
...
@@ -35,11 +33,11 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
"type"
=>
"Note"
,
"to"
=>
to
,
"content"
=>
content_html
,
"published"
=>
date
,
"published"
=>
make_
date
,
"context"
=>
context
,
"attachment"
=>
attachments
},
"published"
=>
date
,
"published"
=>
make_
date
,
"context"
=>
context
}
...
...
@@ -107,7 +105,8 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
{
:ok
,
activity
}
<-
ActivityPub
.
insert
(%{
"type"
=>
"Follow"
,
"actor"
=>
follower
.
ap_id
,
"object"
=>
followed
.
ap_id
"object"
=>
followed
.
ap_id
,
"published"
=>
make_date
})
do
{
:ok
,
follower
,
followed
,
activity
}
...
...
@@ -183,4 +182,8 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
mentioned_users
=
Repo
.
all
(
from
user
in
User
,
where:
user
.
ap_id
in
^
activity
.
data
[
"to"
])
ActivityRepresenter
.
to_map
(
activity
,
Map
.
merge
(
opts
,
%{
user:
user
,
mentioned:
mentioned_users
}))
end
defp
make_date
do
DateTime
.
utc_now
()
|>
DateTime
.
to_iso8601
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