From c17c8ce36d35db03a007a264cc2e507afa9b803e Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sat, 16 Sep 2017 15:47:07 +0200 Subject: [PATCH] Don't check limit twice in TwitterAPIController. --- lib/pleroma/web/twitter_api/twitter_api_controller.ex | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index bca74850c..5297e45c6 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -14,14 +14,12 @@ defmodule Pleroma.Web.TwitterAPI.Controller do end def status_update(%{assigns: %{user: user}} = conn, %{"status" => status_text} = status_data) do - l = status_text |> String.trim |> String.length - if l > 0 && l < 5000 do - media_ids = extract_media_ids(status_data) - {:ok, activity} = TwitterAPI.create_status(user, Map.put(status_data, "media_ids", media_ids)) + with media_ids <- extract_media_ids(status_data), + {:ok, activity} = TwitterAPI.create_status(user, Map.put(status_data, "media_ids", media_ids)) do conn - |> json_reply(200, ActivityRepresenter.to_json(activity, %{user: user})) + |> json(ActivityRepresenter.to_map(activity, %{user: user})) else - empty_status_reply(conn) + _ -> empty_status_reply(conn) end end -- 2.45.2