commit: 5086d6d5e9ff68d6a7a82fd3ad6dbc0bad0b599c
parent 39c47073a3c6fd3da068d5a4c9def18f3847ff32
Author: duponin <pwet@dupon.in>
Date: Thu, 19 May 2022 00:56:20 +0200
add thread show in BBS frontend
Diffstat:
1 file changed, 28 insertions(+), 0 deletions(-)
diff --git a/lib/pleroma/bbs/handler.ex b/lib/pleroma/bbs/handler.ex
@@ -53,6 +53,7 @@ defmodule Pleroma.BBS.Handler do
IO.puts("home - Show the home timeline")
IO.puts("p <text> - Post the given text")
IO.puts("r <id> <text> - Reply to the post with the given id")
+ IO.puts("t <id> - Show a thread from the given id")
IO.puts("quit - Quit")
state
@@ -73,6 +74,33 @@ defmodule Pleroma.BBS.Handler do
state
end
+ def handle_command(%{user: user} = state, "t " <> activity_id) do
+ with %Activity{} = activity <- Activity.get_by_id(activity_id) do
+ activities =
+ ActivityPub.fetch_activities_for_context(activity.data["context"], %{
+ blocking_user: user,
+ user: user,
+ exclude_id: activity.id
+ })
+
+ case activities do
+ [] ->
+ activity_id
+ |> Activity.get_by_id()
+ |> puts_activity()
+
+ _ ->
+ activities
+ |> Enum.reverse()
+ |> Enum.each(&puts_activity/1)
+ end
+ else
+ _e -> IO.puts("An error occured when trying to show the thread...")
+ end
+
+ state
+ end
+
def handle_command(%{user: user} = state, "p " <> text) do
text = String.trim(text)