diff options
author | href <href@random.sh> | 2019-01-15 16:18:18 +0100 |
---|---|---|
committer | href <href@random.sh> | 2019-01-23 11:26:34 +0100 |
commit | 9d63b27dcd61dff61b77b6df0ef8a4cf8d7c87e3 (patch) | |
tree | 98b0ec15d7dcb93d49d11b581ab9fc240159fe25 /lib | |
parent | 28d77e373cbaf0908f86973a873c9bfd6c3221cb (diff) | |
download | pleroma-9d63b27dcd61dff61b77b6df0ef8a4cf8d7c87e3.tar.gz |
Test FlakeID old id compat & Ecto type
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/flake_id.ex | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/pleroma/flake_id.ex b/lib/pleroma/flake_id.ex index 3c72807ca..f23c6d4b0 100644 --- a/lib/pleroma/flake_id.ex +++ b/lib/pleroma/flake_id.ex @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.FlakeId do @moduledoc """ Flake is a decentralized, k-ordered id generation service. @@ -38,6 +42,8 @@ defmodule Pleroma.FlakeId do def from_string(unquote(Kernel.to_string(i))), do: <<0::integer-size(128)>> end + def from_string(flake = <<_::integer-size(128)>>), do: flake + def from_string(string) when is_binary(string) and byte_size(string) < 18 do case Integer.parse(string) do {id, _} -> <<0::integer-size(64), id::integer-size(64)>> |