diff options
-rw-r--r-- | docs/Pleroma-API.md | 1 | ||||
-rw-r--r-- | lib/pleroma/flake_id.ex | 21 |
2 files changed, 4 insertions, 18 deletions
diff --git a/docs/Pleroma-API.md b/docs/Pleroma-API.md index da58babf9..0c4586dd3 100644 --- a/docs/Pleroma-API.md +++ b/docs/Pleroma-API.md @@ -15,6 +15,7 @@ Request parameters can be passed via [query strings](https://en.wikipedia.org/wi * Params: none * Response: JSON * Example response: `{"kalsarikannit_f":"/finmoji/128px/kalsarikannit_f-128.png","perkele":"/finmoji/128px/perkele-128.png","blobdab":"/emoji/blobdab.png","happiness":"/finmoji/128px/happiness-128.png"}` +* Note: Same data as Mastodon API’s `/api/v1/custom_emojis` but in a different format ## `/api/pleroma/follow_import` ### Imports your follows, for example from a Mastodon CSV file. diff --git a/lib/pleroma/flake_id.ex b/lib/pleroma/flake_id.ex index 69482f69a..69ab8ccf9 100644 --- a/lib/pleroma/flake_id.ex +++ b/lib/pleroma/flake_id.ex @@ -94,7 +94,7 @@ defmodule Pleroma.FlakeId do @impl GenServer def init([]) do - {:ok, %FlakeId{node: mac(), time: time()}} + {:ok, %FlakeId{node: worker_id(), time: time()}} end @impl GenServer @@ -165,23 +165,8 @@ defmodule Pleroma.FlakeId do 1_000_000_000 * mega_seconds + seconds * 1000 + :erlang.trunc(micro_seconds / 1000) end - def mac do - {:ok, addresses} = :inet.getifaddrs() - - macids = - Enum.reduce(addresses, [], fn {_iface, attrs}, acc -> - case attrs[:hwaddr] do - [0, 0, 0 | _] -> acc - mac when is_list(mac) -> [mac_to_worker_id(mac) | acc] - _ -> acc - end - end) - - List.first(macids) - end - - def mac_to_worker_id(mac) do - <<worker::integer-size(48)>> = :binary.list_to_bin(mac) + defp worker_id() do + <<worker::integer-size(48)>> = :crypto.strong_rand_bytes(6) worker end end |