BBS: add post favourite feature

This commit is contained in:
duponin 2022-05-22 02:39:38 +02:00
parent a4659d993d
commit fffd9059d6
1 changed files with 14 additions and 0 deletions

View File

@ -93,6 +93,7 @@ def handle_command(state, "help") do
IO.puts("t <id> - Show a thread from the given id")
IO.puts("n - Show notifications")
IO.puts("n read - Mark all notifactions as read")
IO.puts("f <id> - Favourites the post with the given id")
IO.puts("quit - Quit")
state
@ -167,6 +168,19 @@ def handle_command(%{user: user} = state, "p " <> text) do
state
end
def handle_command(%{user: user} = state, "f " <> id) do
id = String.trim(id)
with %Activity{} = activity <- Activity.get_by_id(id),
{:ok, _activity} <- CommonAPI.favorite(user, activity) do
IO.puts("Favourited!")
else
_e -> IO.puts("Could not Favourite...")
end
state
end
def handle_command(state, "home") do
user = state.user