fix: Only link to user if the account still exists

This commit is contained in:
Daniel Kempkens 2023-08-29 20:33:38 +02:00
parent f23b6904c9
commit 953f2c3950
Signed by: daniel
SSH key fingerprint: SHA256:Ks/MyhQYcPRQiwMKLAKquWCdCPe3JXlb1WttgnAoSeM
5 changed files with 7 additions and 4 deletions

View file

@ -17,6 +17,9 @@ defmodule BdfrBrowser.RenderUtils do
|> Earmark.as_html!()
end
def link_to_user(name) when name in ~w([deleted] DELETED), do: name
def link_to_user(name), do: "<a href=\"/user/#{name}\">#{name}</a>"
# Helper
defp maybe_insert_image(<<"mxc://reddit.com/", filename::binary>> = msg, replacement) do

View file

@ -9,7 +9,7 @@
<% end %>
<footer class="blockquote-footer">
<a href="/user/<%= comment.author %>"><%= comment.author %></a>,
<%= BdfrBrowser.RenderUtils.link_to_user(comment.author) %>,
<small><%= DateTime.to_iso8601(comment.posted_at) %></small>
</footer>
</blockquote>

View file

@ -13,7 +13,7 @@
<%= BdfrBrowser.RenderUtils.message(message.message) %>
<footer class="blockquote-footer">
<a href="/user/<%= message.author %>"><%= message.author %></a>,
<%= BdfrBrowser.RenderUtils.link_to_user(message.author) %>,
<small><%= DateTime.to_iso8601(message.posted_at) %></small>
<%= unless is_nil(message.bookmark) do %>

View file

@ -1,7 +1,7 @@
<h2><%= post.title %></h2>
<p>
<small><a href="/user/<%= post.author %>"><%= post.author %></a></small>
<small><%= BdfrBrowser.RenderUtils.link_to_user(post.author) %></small>
-
<small><%= DateTime.to_iso8601(post.posted_at) %></small>
-

View file

@ -46,7 +46,7 @@
<%= BdfrBrowser.RenderUtils.comment(comment.body) %>
<footer class="blockquote-footer">
<a href="/user/<%= comment.author %>"><%= comment.author %></a>,
<%= BdfrBrowser.RenderUtils.link_to_user(comment.author) %>,
<a href="/r/<%= comment.subreddit %>/<%= comment.post_date %>/<%= comment.post_id %>"><%= comment.post_title %></a>,
<a href="/r/<%= comment.subreddit %>/<%= comment.post_date %>/"><%= comment.subreddit %></a>,
<small><%= DateTime.to_iso8601(comment.posted_at) %></small>