From: Roger Braun <roger@rogerbraun.net>
Date: Tue, 12 Sep 2017 09:28:12 +0000 (+0200)
Subject: Use hash of attachment url as id.
X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=b58b35bf5619bd3b4d89a224e3b032c230c01884;p=akkoma

Use hash of attachment url as id.

Pretty hacky, let's see if we can get away with this.
---

diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex
index 686ffd29d..bf9862419 100644
--- a/lib/pleroma/web/mastodon_api/views/status_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/status_view.ex
@@ -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,
diff --git a/test/web/mastodon_api/status_view_test.exs b/test/web/mastodon_api/status_view_test.exs
index a12fc8244..2eb27009b 100644
--- a/test/web/mastodon_api/status_view_test.exs
+++ b/test/web/mastodon_api/status_view_test.exs
@@ -65,7 +65,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
     }
 
     expected = %{
-      id: 6,
+      id: 1638338801,
       type: "image",
       url: "someurl",
       remote_url: "someurl",