Use hash of attachment url as id.
authorRoger Braun <roger@rogerbraun.net>
Tue, 12 Sep 2017 09:28:12 +0000 (11:28 +0200)
committerRoger Braun <roger@rogerbraun.net>
Tue, 12 Sep 2017 09:28:12 +0000 (11:28 +0200)
Pretty hacky, let's see if we can get away with this.

lib/pleroma/web/mastodon_api/views/status_view.ex
test/web/mastodon_api/status_view_test.exs

index 686ffd29de26e6d4db5f2c6c554095ff163f591d..bf9862419c0a5ebc29f66127aabb037011aa9735 100644 (file)
@@ -61,8 +61,10 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
       true -> "unknown"
     end
 
+    << hash_id::32, _rest::binary >> = :crypto.hash(:md5, href)
+
     %{
-      id: attachment["uuid"],
+      id: attachment["id"] || hash_id,
       url: href,
       remote_url: href,
       preview_url: href,
index a12fc8244db58e4082de7e9a24d7dbf3d99c6678..2eb27009b0c93886b3c1a017b7dada025e6d6cb6 100644 (file)
@@ -65,7 +65,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
     }
 
     expected = %{
-      id: 6,
+      id: 1638338801,
       type: "image",
       url: "someurl",
       remote_url: "someurl",