aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorduponin <pwet@dupon.in>2022-05-19 00:56:20 +0200
committerduponin <pwet@dupon.in>2022-05-19 00:56:20 +0200
commit5086d6d5e9ff68d6a7a82fd3ad6dbc0bad0b599c (patch)
tree0c50178ccee0f1462283c3260a315a7cdb280fc0
parent39c47073a3c6fd3da068d5a4c9def18f3847ff32 (diff)
downloadpleroma-5086d6d5e9ff68d6a7a82fd3ad6dbc0bad0b599c.tar.gz
add thread show in BBS frontend
-rw-r--r--lib/pleroma/bbs/handler.ex28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/pleroma/bbs/handler.ex b/lib/pleroma/bbs/handler.ex
index 47f5a920e..f1ac0c687 100644
--- 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)