Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F5902329
activity.ex
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
activity.ex
View Options
defmodule
Pleroma.Activity
do
use
Ecto.Schema
alias
Pleroma
.
{
Repo
,
Activity
,
Notification
}
import
Ecto.Query
schema
"activities"
do
field
:data
,
:map
field
:local
,
:boolean
,
default
:
true
field
:actor
,
:string
has_many
:notifications
,
Notification
,
on_delete
:
:delete_all
timestamps
()
end
def
get_by_ap_id
(
ap_id
)
do
Repo
.
one
(
from
activity
in
Activity
,
where
:
fragment
(
"(?)->>'id' = ?"
,
activity
.
data
,
^
to_string
(
ap_id
)))
end
# TODO:
# Go through these and fix them everywhere.
# Wrong name, only returns create activities
def
all_by_object_ap_id_q
(
ap_id
)
do
from
activity
in
Activity
,
where
:
fragment
(
"coalesce((?)->'object'->>'id', (?)->>'object') = ?"
,
activity
.
data
,
activity
.
data
,
^
to_string
(
ap_id
)),
where
:
fragment
(
"(?)->>'type' = 'Create'"
,
activity
.
data
)
end
# Wrong name, returns all.
def
all_non_create_by_object_ap_id_q
(
ap_id
)
do
from
activity
in
Activity
,
where
:
fragment
(
"coalesce((?)->'object'->>'id', (?)->>'object') = ?"
,
activity
.
data
,
activity
.
data
,
^
to_string
(
ap_id
))
end
# Wrong name plz fix thx
def
all_by_object_ap_id
(
ap_id
)
do
Repo
.
all
(
all_by_object_ap_id_q
(
ap_id
))
end
def
get_create_activity_by_object_ap_id
(
ap_id
)
do
Repo
.
one
(
from
activity
in
Activity
,
where
:
fragment
(
"coalesce((?)->'object'->>'id', (?)->>'object') = ?"
,
activity
.
data
,
activity
.
data
,
^
to_string
(
ap_id
)),
where
:
fragment
(
"(?)->>'type' = 'Create'"
,
activity
.
data
))
end
end
File Metadata
Details
Attached
Mime Type
text/x-ruby
Expires
Thu, Aug 14, 8:44 PM (2 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
378417
Default Alt Text
activity.ex (1 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment