BBS: add post favourite feature

This commit is contained in:
duponin 2022-05-22 02:39:38 +02:00
parent a4659d993d
commit fffd9059d6

View file

@ -93,6 +93,7 @@ defmodule Pleroma.BBS.Handler 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 @@ defmodule Pleroma.BBS.Handler 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