Commit 9d7c3190 authored by lain's avatar lain
Browse files

Get create activity from created object id.

This is useful for Ostatus federation because ostatus doesn't have
different ids for objects and activities...
parent 11ea0864
......@@ -18,4 +18,9 @@ def all_by_object_ap_id(ap_id) do
Repo.all(from activity in Activity,
where: fragment("? @> ?",, ^%{object: %{id: ap_id}}))
def get_create_activity_by_object_ap_id(ap_id) do activity in Activity,
where: fragment("? @> ?",, ^%{type: "Create", object: %{id: ap_id}}))
......@@ -15,4 +15,11 @@ test "returns activities by it's objects AP ids" do
assert activity == found_activity
test "returns the activity that created an object" do
activity = insert(:note_activity)
found_activity = Pleroma.Activity.get_create_activity_by_object_ap_id(["object"]["id"])
assert activity == found_activity
......@@ -22,7 +22,7 @@ test "returns a feed of the last 20 items of the user" do
|> :xmerl.export_simple_content(:xmerl_xml)
expected = """
<feed xmlns="" xmlns:activity="" xmlns:poco="" xmlns:ostatus="">
<feed xmlns="" xmlns:thr="" xmlns:activity="" xmlns:poco="" xmlns:ostatus="">
<title>#{user.nickname}'s timeline</title>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment