Add external links to twapi.

This commit is contained in:
Roger Braun 2017-06-25 12:07:08 +02:00
parent 429992fcc9
commit 1c074efeaf
2 changed files with 10 additions and 8 deletions

View file

@ -23,7 +23,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
"user" => UserView.render("show.json", %{user: user, for: opts[:for]}), "user" => UserView.render("show.json", %{user: user, for: opts[:for]}),
"statusnet_html" => text, "statusnet_html" => text,
"text" => text, "text" => text,
"is_local" => true, "is_local" => activity.local,
"is_post_verb" => false, "is_post_verb" => false,
"uri" => "tag:#{activity.data["id"]}:objectType=note", "uri" => "tag:#{activity.data["id"]}:objectType=note",
"created_at" => created_at, "created_at" => created_at,
@ -44,7 +44,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
"user" => UserView.render("show.json", %{user: user, for: opts[:for]}), "user" => UserView.render("show.json", %{user: user, for: opts[:for]}),
"statusnet_html" => text, "statusnet_html" => text,
"text" => text, "text" => text,
"is_local" => true, "is_local" => activity.local,
"is_post_verb" => false, "is_post_verb" => false,
"uri" => "tag:#{activity.data["id"]}:objectType=Favourite", "uri" => "tag:#{activity.data["id"]}:objectType=Favourite",
"created_at" => created_at, "created_at" => created_at,
@ -64,7 +64,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
"attentions" => [], "attentions" => [],
"statusnet_html" => text, "statusnet_html" => text,
"text" => text, "text" => text,
"is_local" => true, "is_local" => activity.local,
"is_post_verb" => false, "is_post_verb" => false,
"created_at" => created_at, "created_at" => created_at,
"in_reply_to_status_id" => nil, "in_reply_to_status_id" => nil,
@ -93,7 +93,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
"user" => UserView.render("show.json", %{user: user, for: opts[:for]}), "user" => UserView.render("show.json", %{user: user, for: opts[:for]}),
"statusnet_html" => HtmlSanitizeEx.basic_html(content) |> Formatter.finmojifiy, "statusnet_html" => HtmlSanitizeEx.basic_html(content) |> Formatter.finmojifiy,
"text" => HtmlSanitizeEx.strip_tags(content), "text" => HtmlSanitizeEx.strip_tags(content),
"is_local" => true, "is_local" => activity.local,
"is_post_verb" => true, "is_post_verb" => true,
"created_at" => created_at, "created_at" => created_at,
"in_reply_to_status_id" => object["inReplyToStatusId"], "in_reply_to_status_id" => object["inReplyToStatusId"],
@ -104,7 +104,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
"repeat_num" => announcement_count, "repeat_num" => announcement_count,
"favorited" => to_boolean(favorited), "favorited" => to_boolean(favorited),
"repeated" => to_boolean(repeated), "repeated" => to_boolean(repeated),
"external_url" => activity.data["id"], "external_url" => object["external_url"],
"tags" => activity.data["object"]["tag"] || [] "tags" => activity.data["object"]["tag"] || []
} }
end end

View file

@ -93,6 +93,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
"attachment" => [ "attachment" => [
object object
], ],
"external_url" => "some url",
"like_count" => 5, "like_count" => 5,
"announcement_count" => 3, "announcement_count" => 3,
"context" => "2hu", "context" => "2hu",
@ -100,14 +101,15 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
}, },
"published" => date, "published" => date,
"context" => "2hu" "context" => "2hu"
} },
local: false
} }
expected_status = %{ expected_status = %{
"id" => activity.id, "id" => activity.id,
"user" => UserView.render("show.json", %{user: user, for: follower}), "user" => UserView.render("show.json", %{user: user, for: follower}),
"is_local" => true, "is_local" => false,
"statusnet_html" => HtmlSanitizeEx.basic_html(content_html), "statusnet_html" => HtmlSanitizeEx.basic_html(content_html),
"text" => content, "text" => content,
"is_post_verb" => true, "is_post_verb" => true,
@ -124,7 +126,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
"repeat_num" => 3, "repeat_num" => 3,
"favorited" => false, "favorited" => false,
"repeated" => false, "repeated" => false,
"external_url" => activity.data["id"], "external_url" => "some url",
"tags" => ["content", "mentioning", "nsfw"] "tags" => ["content", "mentioning", "nsfw"]
} }