Merge remote-tracking branch 'pleroma/develop' into feature/disable-account
This commit is contained in:
commit
e8c2f9a73a
705 changed files with 4242 additions and 66080 deletions
|
|
@ -75,7 +75,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
|
|||
|
||||
def remote_follow(%{assigns: %{user: user}} = conn, %{"acct" => acct}) do
|
||||
if is_status?(acct) do
|
||||
{:ok, object} = ActivityPub.fetch_object_from_id(acct)
|
||||
{:ok, object} = Pleroma.Object.Fetcher.fetch_object_from_id(acct)
|
||||
%Activity{id: activity_id} = Activity.get_create_by_object_ap_id(object.data["id"])
|
||||
redirect(conn, to: "/notice/#{activity_id}")
|
||||
else
|
||||
|
|
@ -101,7 +101,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
|
|||
end
|
||||
|
||||
defp is_status?(acct) do
|
||||
case ActivityPub.fetch_and_contain_remote_object_from_id(acct) do
|
||||
case Pleroma.Object.Fetcher.fetch_and_contain_remote_object_from_id(acct) do
|
||||
{:ok, %{"type" => type}} when type in ["Article", "Note", "Video", "Page", "Question"] ->
|
||||
true
|
||||
|
||||
|
|
@ -286,7 +286,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
|
|||
emoji =
|
||||
Emoji.get_all()
|
||||
|> Enum.map(fn {short_code, path, tags} ->
|
||||
{short_code, %{image_url: path, tags: String.split(tags, ",")}}
|
||||
{short_code, %{image_url: path, tags: tags}}
|
||||
end)
|
||||
|> Enum.into(%{})
|
||||
|
||||
|
|
@ -304,7 +304,12 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
|
|||
end
|
||||
|
||||
def follow_import(%{assigns: %{user: follower}} = conn, %{"list" => list}) do
|
||||
with followed_identifiers <- String.split(list),
|
||||
with lines <- String.split(list, "\n"),
|
||||
followed_identifiers <-
|
||||
Enum.map(lines, fn line ->
|
||||
String.split(line, ",") |> List.first()
|
||||
end)
|
||||
|> List.delete("Account address"),
|
||||
{:ok, _} = Task.start(fn -> User.follow_import(follower, followed_identifiers) end) do
|
||||
json(conn, "job started")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@
|
|||
|
||||
defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.Mailer
|
||||
alias Pleroma.Emails.Mailer
|
||||
alias Pleroma.Emails.UserEmail
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.User
|
||||
alias Pleroma.UserEmail
|
||||
alias Pleroma.UserInviteToken
|
||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||
alias Pleroma.Web.CommonAPI
|
||||
|
|
@ -269,6 +269,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
|
|||
|
||||
defp parse_int(_, default), do: default
|
||||
|
||||
# TODO: unify the search query with MastoAPI one and do only pagination here
|
||||
def search(_user, %{"q" => query} = params) do
|
||||
limit = parse_int(params["rpp"], 20)
|
||||
page = parse_int(params["page"], 1)
|
||||
|
|
@ -276,13 +277,13 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
|
|||
|
||||
q =
|
||||
from(
|
||||
a in Activity,
|
||||
[a, o] in Activity.with_preloaded_object(Activity),
|
||||
where: fragment("?->>'type' = 'Create'", a.data),
|
||||
where: "https://www.w3.org/ns/activitystreams#Public" in a.recipients,
|
||||
where:
|
||||
fragment(
|
||||
"to_tsvector('english', ?->'object'->>'content') @@ plainto_tsquery('english', ?)",
|
||||
a.data,
|
||||
"to_tsvector('english', ?->>'content') @@ plainto_tsquery('english', ?)",
|
||||
o.data,
|
||||
^query
|
||||
),
|
||||
limit: ^limit,
|
||||
|
|
|
|||
|
|
@ -224,15 +224,17 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do
|
|||
|
||||
def render(
|
||||
"activity.json",
|
||||
%{activity: %{data: %{"type" => "Create", "object" => object}} = activity} = opts
|
||||
%{activity: %{data: %{"type" => "Create", "object" => object_id}} = activity} = opts
|
||||
) do
|
||||
user = get_user(activity.data["actor"], opts)
|
||||
|
||||
created_at = object["published"] |> Utils.date_to_asctime()
|
||||
like_count = object["like_count"] || 0
|
||||
announcement_count = object["announcement_count"] || 0
|
||||
favorited = opts[:for] && opts[:for].ap_id in (object["likes"] || [])
|
||||
repeated = opts[:for] && opts[:for].ap_id in (object["announcements"] || [])
|
||||
object = Object.normalize(object_id)
|
||||
|
||||
created_at = object.data["published"] |> Utils.date_to_asctime()
|
||||
like_count = object.data["like_count"] || 0
|
||||
announcement_count = object.data["announcement_count"] || 0
|
||||
favorited = opts[:for] && opts[:for].ap_id in (object.data["likes"] || [])
|
||||
repeated = opts[:for] && opts[:for].ap_id in (object.data["announcements"] || [])
|
||||
pinned = activity.id in user.info.pinned_activities
|
||||
|
||||
attentions =
|
||||
|
|
@ -245,12 +247,12 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do
|
|||
|
||||
conversation_id = get_context_id(activity, opts)
|
||||
|
||||
tags = activity.data["object"]["tag"] || []
|
||||
possibly_sensitive = activity.data["object"]["sensitive"] || Enum.member?(tags, "nsfw")
|
||||
tags = object.data["tag"] || []
|
||||
possibly_sensitive = object.data["sensitive"] || Enum.member?(tags, "nsfw")
|
||||
|
||||
tags = if possibly_sensitive, do: Enum.uniq(["nsfw" | tags]), else: tags
|
||||
|
||||
{summary, content} = render_content(object)
|
||||
{summary, content} = render_content(object.data)
|
||||
|
||||
html =
|
||||
content
|
||||
|
|
@ -259,7 +261,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do
|
|||
activity,
|
||||
"twitterapi:content"
|
||||
)
|
||||
|> Formatter.emojify(object["emoji"])
|
||||
|> Formatter.emojify(object.data["emoji"])
|
||||
|
||||
text =
|
||||
if content do
|
||||
|
|
@ -284,33 +286,33 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do
|
|||
|
||||
%{
|
||||
"id" => activity.id,
|
||||
"uri" => activity.data["object"]["id"],
|
||||
"uri" => object.data["id"],
|
||||
"user" => UserView.render("show.json", %{user: user, for: opts[:for]}),
|
||||
"statusnet_html" => html,
|
||||
"text" => text,
|
||||
"is_local" => activity.local,
|
||||
"is_post_verb" => true,
|
||||
"created_at" => created_at,
|
||||
"in_reply_to_status_id" => object["inReplyToStatusId"],
|
||||
"in_reply_to_status_id" => reply_parent && reply_parent.id,
|
||||
"in_reply_to_screen_name" => reply_user && reply_user.nickname,
|
||||
"in_reply_to_profileurl" => User.profile_url(reply_user),
|
||||
"in_reply_to_ostatus_uri" => reply_user && reply_user.ap_id,
|
||||
"in_reply_to_user_id" => reply_user && reply_user.id,
|
||||
"statusnet_conversation_id" => conversation_id,
|
||||
"attachments" => (object["attachment"] || []) |> ObjectRepresenter.enum_to_list(opts),
|
||||
"attachments" => (object.data["attachment"] || []) |> ObjectRepresenter.enum_to_list(opts),
|
||||
"attentions" => attentions,
|
||||
"fave_num" => like_count,
|
||||
"repeat_num" => announcement_count,
|
||||
"favorited" => !!favorited,
|
||||
"repeated" => !!repeated,
|
||||
"pinned" => pinned,
|
||||
"external_url" => object["external_url"] || object["id"],
|
||||
"external_url" => object.data["external_url"] || object.data["id"],
|
||||
"tags" => tags,
|
||||
"activity_type" => "post",
|
||||
"possibly_sensitive" => possibly_sensitive,
|
||||
"visibility" => StatusView.get_visibility(object),
|
||||
"summary" => summary,
|
||||
"summary_html" => summary |> Formatter.emojify(object["emoji"]),
|
||||
"summary_html" => summary |> Formatter.emojify(object.data["emoji"]),
|
||||
"card" => card,
|
||||
"muted" => CommonAPI.thread_muted?(user, activity) || User.mutes?(opts[:for], user)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue