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
f97c8e43
Commit
f97c8e43
authored
8 years ago
by
lain
Browse files
Options
Downloads
Patches
Plain Diff
Add utility functions for objects and activities.
parent
4cac3854
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/pleroma/activity.ex
+12
-0
12 additions, 0 deletions
lib/pleroma/activity.ex
test/activity_test.exs
+18
-0
18 additions, 0 deletions
test/activity_test.exs
test/object_test.exs
+11
-0
11 additions, 0 deletions
test/object_test.exs
with
41 additions
and
0 deletions
lib/pleroma/activity.ex
+
12
−
0
View file @
f97c8e43
defmodule
Pleroma
.
Activity
do
use
Ecto
.
Schema
alias
Pleroma
.
{
Repo
,
Activity
}
import
Ecto
.
Query
schema
"activities"
do
field
:data
,
:map
timestamps
()
end
def
get_by_ap_id
(
ap_id
)
do
Repo
.
one
(
from
activity
in
Activity
,
where:
fragment
(
"? @> ?"
,
activity
.
data
,
^
%{
id:
ap_id
}))
end
def
all_by_object_ap_id
(
ap_id
)
do
Repo
.
all
(
from
activity
in
Activity
,
where:
fragment
(
"? @> ?"
,
activity
.
data
,
^
%{
object:
%{
id:
ap_id
}}))
end
end
This diff is collapsed.
Click to expand it.
test/activity_test.exs
0 → 100644
+
18
−
0
View file @
f97c8e43
defmodule
Pleroma
.
ActivityTest
do
use
Pleroma
.
DataCase
import
Pleroma
.
Factory
test
"returns an activity by it's AP id"
do
activity
=
insert
(
:note_activity
)
found_activity
=
Pleroma
.
Activity
.
get_by_ap_id
(
activity
.
data
[
"id"
])
assert
activity
==
found_activity
end
test
"returns activities by it's objects AP ids"
do
activity
=
insert
(
:note_activity
)
[
found_activity
]
=
Pleroma
.
Activity
.
all_by_object_ap_id
(
activity
.
data
[
"object"
][
"id"
])
assert
activity
==
found_activity
end
end
This diff is collapsed.
Click to expand it.
test/object_test.exs
0 → 100644
+
11
−
0
View file @
f97c8e43
defmodule
Pleroma
.
ObjectTest
do
use
Pleroma
.
DataCase
import
Pleroma
.
Factory
test
"returns an object by it's AP id"
do
object
=
insert
(
:note
)
found_object
=
Pleroma
.
Object
.
get_by_ap_id
(
object
.
data
[
"id"
])
assert
object
==
found_object
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