From eacf6ab0a588fa6cd04daeb193c9d147a695944f Mon Sep 17 00:00:00 2001
From: Shadowfacts
Date: Thu, 26 Aug 2021 10:13:53 -0400
Subject: [PATCH] Fix timestamps for certain activity types
---
.../templates/frontend/_action_status.html.eex | 4 ++--
.../frontend/_follow_notification.html.eex | 2 +-
.../templates/frontend/_status.html.eex | 2 +-
lib/clacks_web/views/frontend_view.ex | 16 ++++++++++++++++
4 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/lib/clacks_web/templates/frontend/_action_status.html.eex b/lib/clacks_web/templates/frontend/_action_status.html.eex
index a6dc4f4..f9515ac 100644
--- a/lib/clacks_web/templates/frontend/_action_status.html.eex
+++ b/lib/clacks_web/templates/frontend/_action_status.html.eex
@@ -11,7 +11,7 @@
<%= past_tense %> by <%= @action_actor.data["preferredUsername"] %>
-
+
diff --git a/lib/clacks_web/templates/frontend/_follow_notification.html.eex b/lib/clacks_web/templates/frontend/_follow_notification.html.eex
index e950e35..ba07e82 100644
--- a/lib/clacks_web/templates/frontend/_follow_notification.html.eex
+++ b/lib/clacks_web/templates/frontend/_follow_notification.html.eex
@@ -4,7 +4,7 @@
Followed by <%= @actor.data["preferredUsername"] %>
-
+
diff --git a/lib/clacks_web/templates/frontend/_status.html.eex b/lib/clacks_web/templates/frontend/_status.html.eex
index e344045..e76f58c 100644
--- a/lib/clacks_web/templates/frontend/_status.html.eex
+++ b/lib/clacks_web/templates/frontend/_status.html.eex
@@ -13,7 +13,7 @@
-
+
" class="status-permalink u-url">Permalink
diff --git a/lib/clacks_web/views/frontend_view.ex b/lib/clacks_web/views/frontend_view.ex
index b7e4c82..06444a8 100644
--- a/lib/clacks_web/views/frontend_view.ex
+++ b/lib/clacks_web/views/frontend_view.ex
@@ -82,6 +82,22 @@ defmodule ClacksWeb.FrontendView do
end
end
+ @spec iso_datetime(datetime :: String.t() | DateTime.t() | NaiveDateTime.t() | Activity.t()) ::
+ String.t()
+
+ def iso_datetime(str) when is_binary(str) do
+ str
+ end
+
+ def iso_datetime(%Activity{data: data, inserted_at: inserted_at}) do
+ iso_datetime(Map.get(data, "published", inserted_at))
+ end
+
+ def iso_datetime(%{__struct__: struct} = datetime)
+ when struct == DateTime or struct == NaiveDateTime do
+ Timex.format!(datetime, "{ISO:Extended:Z}")
+ end
+
@spec prev_page_path(conn :: Plug.Conn.t(), [
Activity.t() | {Activity.t(), Actor.t()} | Notification.t()
]) ::