activitypub: upload: pass through an upload limit if one is provided
authorWilliam Pitcock <nenolod@dereferenced.org>
Mon, 29 Oct 2018 16:30:12 +0000 (16:30 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Mon, 29 Oct 2018 16:43:05 +0000 (16:43 +0000)
config/config.exs
lib/pleroma/web/activity_pub/activity_pub.ex

index 2d2cdda45eeb5f918be6ed471da90534a6745f64..3abb6e6950ba75ee0ffe4f68045d44ec85f691ef 100644 (file)
@@ -84,6 +84,9 @@ config :pleroma, :instance,
   description: "A Pleroma instance, an alternative fediverse server",
   limit: 5000,
   upload_limit: 16_000_000,
+  avatar_upload_limit: 2_000_000,
+  background_upload_limit: 4_000_000,
+  banner_upload_limit: 4_000_000,
   registrations_open: true,
   federating: true,
   allow_relay: true,
index 4b8b6eb5213721dee264d9bb653b630d43661721..537b99f31dbc96a818d75b21e583661c30f45072 100644 (file)
@@ -575,9 +575,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
     |> Enum.reverse()
   end
 
-  def upload(file) do
-    data = Upload.store(file, Application.get_env(:pleroma, :instance)[:dedupe_media])
-    Repo.insert(%Object{data: data})
+  def upload(file, size_limit \\ nil) do
+    with data <-
+           Upload.store(file, Application.get_env(:pleroma, :instance)[:dedupe_media], size_limit),
+         false <- is_nil(data) do
+      Repo.insert(%Object{data: data})
+    end
   end
 
   def user_data_from_user_object(data) do