BBS: add post favourite feature
This commit is contained in:
parent
a4659d993d
commit
fffd9059d6
|
@ -93,6 +93,7 @@ def handle_command(state, "help") do
|
||||||
IO.puts("t <id> - Show a thread from the given id")
|
IO.puts("t <id> - Show a thread from the given id")
|
||||||
IO.puts("n - Show notifications")
|
IO.puts("n - Show notifications")
|
||||||
IO.puts("n read - Mark all notifactions as read")
|
IO.puts("n read - Mark all notifactions as read")
|
||||||
|
IO.puts("f <id> - Favourites the post with the given id")
|
||||||
IO.puts("quit - Quit")
|
IO.puts("quit - Quit")
|
||||||
|
|
||||||
state
|
state
|
||||||
|
@ -167,6 +168,19 @@ def handle_command(%{user: user} = state, "p " <> text) do
|
||||||
state
|
state
|
||||||
end
|
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
|
def handle_command(state, "home") do
|
||||||
user = state.user
|
user = state.user
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue