Resolve merge conflicts and remove IO.inspects
authorrinpatch <rinpatch@sdf.org>
Sat, 18 May 2019 10:37:38 +0000 (13:37 +0300)
committerrinpatch <rinpatch@sdf.org>
Sat, 18 May 2019 10:37:38 +0000 (13:37 +0300)
1  2 
lib/pleroma/web/activity_pub/transmogrifier.ex
lib/pleroma/web/activity_pub/utils.ex
lib/pleroma/web/common_api/common_api.ex
lib/pleroma/web/common_api/utils.ex
lib/pleroma/web/mastodon_api/views/status_view.ex
test/web/mastodon_api/mastodon_api_controller_test.exs

index de91fa03f69137af43b9be0ec4bf37d155cb36ca,ca8a0844be1e4840b7d384d64a4a815e2adaaba6..63454e3f70a1fda6567b9f5773ff435c5b348280
@@@ -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.
index 335ae70b023b4413459513d80adabe7a273a4a49,5a312d673fe9cd793c235d0e1b018412d029cba6..bc8f80389526a221286c0a18327807e02b302992
@@@ -166,7 -171,7 +172,8 @@@ defmodule Pleroma.Web.CommonAPI d
               tags,
               cw,
               cc,
 -             sensitive
++             sensitive,
 +             poll
             ),
           object <-
             Map.put(
index 13cdffbbd00eeb394174f114596f0e1e35d8f4a6,d93c0d46e5962ba93bc2796a738ac294dbbcd656..2ea997789a3b2aedb352440735449502b38f44f0
@@@ -102,48 -102,6 +102,47 @@@ defmodule Pleroma.Web.CommonAPI.Utils d
      end
    end
  
-   def make_poll_data(data, mentions, tags) do
-     IO.inspect(data, label: "data")
 +  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
 +    {%{}, mentions, tags}
 +  end
 +
    def make_content_html(
          status,
          attachments,
          tags,
          cw \\ nil,
          cc \\ [],
 -        sensitive \\ false
++        sensitive \\ false,
 +        merge \\ %{}
        ) do
-     IO.inspect(merge, label: "merge")
      object = %{
        "type" => "Note",
        "to" => to,
        "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