diff options
author | Haelwenn <contact+git.pleroma.social@hacktivis.me> | 2019-01-31 10:16:11 +0000 |
---|---|---|
committer | Haelwenn <contact+git.pleroma.social@hacktivis.me> | 2019-01-31 10:16:11 +0000 |
commit | 00d43333735acbcadc1dd04ff793f4ce6e8eecb1 (patch) | |
tree | 27959dec7a5ae46c194ed7b47156e4877a736a0b /lib/pleroma/user.ex | |
parent | 5f40f4f74d96da7b54394e8d6fa29f00cd0c63fd (diff) | |
parent | cda1470e02100bfcdcbd128fd08d0af64dca7271 (diff) | |
download | pleroma-00d43333735acbcadc1dd04ff793f4ce6e8eecb1.tar.gz |
Merge branch 'features/glitch-soc-frontend' into 'develop'
Features/glitch soc frontend
See merge request pleroma/pleroma!192
Diffstat (limited to 'lib/pleroma/user.ex')
-rw-r--r-- | lib/pleroma/user.ex | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index bd797db40..60d1d4811 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -39,6 +39,7 @@ defmodule Pleroma.User do field(:follower_address, :string) field(:search_rank, :float, virtual: true) field(:tags, {:array, :string}, default: []) + field(:bookmarks, {:array, :string}, default: []) field(:last_refreshed_at, :naive_datetime) has_many(:notifications, Notification) embeds_one(:info, Pleroma.User.Info) @@ -1161,6 +1162,22 @@ defmodule Pleroma.User do updated_user end + def bookmark(%User{} = user, status_id) do + bookmarks = Enum.uniq(user.bookmarks ++ [status_id]) + update_bookmarks(user, bookmarks) + end + + def unbookmark(%User{} = user, status_id) do + bookmarks = Enum.uniq(user.bookmarks -- [status_id]) + update_bookmarks(user, bookmarks) + end + + def update_bookmarks(%User{} = user, bookmarks) do + user + |> change(%{bookmarks: bookmarks}) + |> update_and_set_cache + end + defp normalize_tags(tags) do [tags] |> List.flatten() |