From: rinpatch Date: Sat, 18 May 2019 10:37:38 +0000 (+0300) Subject: Resolve merge conflicts and remove IO.inspects X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=5ece901af3e887664653c79c5e61618cc5cf0ecf;p=akkoma Resolve merge conflicts and remove IO.inspects --- 5ece901af3e887664653c79c5e61618cc5cf0ecf diff --cc lib/pleroma/web/activity_pub/utils.ex index de91fa03f,ca8a0844b..63454e3f7 --- a/lib/pleroma/web/activity_pub/utils.ex +++ b/lib/pleroma/web/activity_pub/utils.ex @@@ -19,7 -19,9 +19,9 @@@ defmodule Pleroma.Web.ActivityPub.Util require Logger - @supported_object_types ["Article", "Note", "Video", "Page"] + @supported_object_types ["Article", "Note", "Video", "Page", "Question"] + @supported_report_states ~w(open closed resolved) + @valid_visibilities ~w(public unlisted private direct) # Some implementations send the actor URI as the actor field, others send the entire actor object, # so figure out what the actor's URI is based on what we have. diff --cc lib/pleroma/web/common_api/common_api.ex index 335ae70b0,5a312d673..bc8f80389 --- a/lib/pleroma/web/common_api/common_api.ex +++ b/lib/pleroma/web/common_api/common_api.ex @@@ -166,7 -171,7 +172,8 @@@ defmodule Pleroma.Web.CommonAPI d tags, cw, cc, - sensitive ++ sensitive, + poll ), object <- Map.put( diff --cc lib/pleroma/web/common_api/utils.ex index 13cdffbbd,d93c0d46e..2ea997789 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@@ -102,48 -102,6 +102,47 @@@ defmodule Pleroma.Web.CommonAPI.Utils d end end + def make_poll_data( + %{"poll" => %{"options" => options, "expires_in" => expires_in}} = data, + mentions, + tags + ) + when is_list(options) and is_integer(expires_in) do + content_type = get_content_type(data["content_type"]) + # XXX: There is probably a more performant/cleaner way to do this + {poll, {mentions, tags}} = + Enum.map_reduce(options, {mentions, tags}, fn option, {mentions, tags} -> + # TODO: Custom emoji + {option, mentions_merge, tags_merge} = format_input(option, content_type) + mentions = mentions ++ mentions_merge + tags = tags ++ tags_merge + + {%{ + "name" => option, + "type" => "Note", + "replies" => %{"type" => "Collection", "totalItems" => 0} + }, {mentions, tags}} + end) + + end_time = + NaiveDateTime.utc_now() + |> NaiveDateTime.add(expires_in) + |> NaiveDateTime.to_iso8601() + + poll = + if Pleroma.Web.ControllerHelper.truthy_param?(data["poll"]["multiple"]) do + %{"type" => "Question", "anyOf" => poll, "closed" => end_time} + else + %{"type" => "Question", "oneOf" => poll, "closed" => end_time} + end + + {poll, mentions, tags} + end + - def make_poll_data(data, mentions, tags) do - IO.inspect(data, label: "data") ++ def make_poll_data(_data, mentions, tags) do + {%{}, mentions, tags} + end + def make_content_html( status, attachments, @@@ -266,10 -224,8 +265,9 @@@ tags, cw \\ nil, cc \\ [], - sensitive \\ false ++ sensitive \\ false, + merge \\ %{} ) do - IO.inspect(merge, label: "merge") - object = %{ "type" => "Note", "to" => to, @@@ -282,17 -239,12 +281,15 @@@ "tag" => tags |> Enum.map(fn {_, tag} -> tag end) |> Enum.uniq() } - with false <- is_nil(in_reply_to), - %Object{} = in_reply_to_object <- Object.normalize(in_reply_to) do - Map.put(object, "inReplyTo", in_reply_to_object.data["id"]) - else - _ -> object - end + object = - if in_reply_to do - in_reply_to_object = Object.normalize(in_reply_to) - - object - |> Map.put("inReplyTo", in_reply_to_object.data["id"]) ++ with false <- is_nil(in_reply_to), ++ %Object{} = in_reply_to_object <- Object.normalize(in_reply_to) do ++ Map.put(object, "inReplyTo", in_reply_to_object.data["id"]) + else - object ++ _ -> object + end + + Map.merge(object, merge) end def format_naive_asctime(date) do