From 597f8b74cbca1bdf6ffed8e96f298b0105ddd442 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Mon, 27 Jun 2022 00:36:00 +0200 Subject: [PATCH] Fix everyone showing up as anonymous outside of moderation view --- app/helpers/application_helper/title_methods.rb | 5 ++++- app/helpers/user_helper.rb | 4 ++-- app/views/answerbox/_header.haml | 2 +- app/views/inbox/_entry.haml | 2 +- app/views/question/_question.haml | 5 +++-- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/helpers/application_helper/title_methods.rb b/app/helpers/application_helper/title_methods.rb index 7de1ca72..890d664b 100644 --- a/app/helpers/application_helper/title_methods.rb +++ b/app/helpers/application_helper/title_methods.rb @@ -27,7 +27,10 @@ module ApplicationHelper::TitleMethods def question_title(question) context_user = question.answers&.first&.user if question.direct - name = user_screen_name question.user, context_user: context_user, author_identifier: question.author_identifier, url: false + name = user_screen_name question.user, + context_user: context_user, + author_identifier: question.author_is_anonymous ? question.author_identifier : nil, + url: false generate_title name, "asked", question.content end diff --git a/app/helpers/user_helper.rb b/app/helpers/user_helper.rb index 9a33751a..9c940856 100644 --- a/app/helpers/user_helper.rb +++ b/app/helpers/user_helper.rb @@ -41,7 +41,7 @@ module UserHelper sanitize(context_user&.profile&.anon_display_name.presence || APP_CONFIG["anonymous_name"], tags: []) end - def anonymous?(user, anonymous) - user.nil? || anonymous + def anonymous?(user, author_identifier) + user.nil? || author_identifier.present? end end diff --git a/app/views/answerbox/_header.haml b/app/views/answerbox/_header.haml index 3e96efdc..8dda7f0c 100644 --- a/app/views/answerbox/_header.haml +++ b/app/views/answerbox/_header.haml @@ -25,7 +25,7 @@ %h6.text-muted.media-heading.answerbox__question-user - if a.question.author_is_anonymous %i.fa.fa-user-secret{ title: t('.anon_hint') } - = raw t('views.answerbox.asked', user: user_screen_name(a.question.user, context_user: a.user, author_identifier: a.question.author_identifier), time: time_tooltip(a.question)) + = raw t('views.answerbox.asked', user: user_screen_name(a.question.user, context_user: a.user, author_identifier: a.question.author_is_anonymous ? a.question.author_identifier: nil), time: time_tooltip(a.question)) - if !a.question.author_is_anonymous && !a.question.direct · %a{ href: show_user_question_path(a.question.user.screen_name, a.question.id) } diff --git a/app/views/inbox/_entry.haml b/app/views/inbox/_entry.haml index 439c1b25..6e314e63 100644 --- a/app/views/inbox/_entry.haml +++ b/app/views/inbox/_entry.haml @@ -8,7 +8,7 @@ %h6.text-muted.media-heading.answerbox__question-user - if i.question.author_is_anonymous %i.fa.fa-user-secret{ title: t('.anon_hint') } - = t(".asked_html", user: user_screen_name(i.question.user, context_user: i.user, author_identifier: i.question.author_identifier), time: time_tooltip(i.question)) + = t(".asked_html", user: user_screen_name(i.question.user, context_user: i.user, author_identifier: i.question.author_is_anonymous ? i.question.author_identifier : nil), time: time_tooltip(i.question)) - if !i.question.author_is_anonymous && i.question.answer_count.positive? · %a{ href: show_user_question_path(i.question.user.screen_name, i.question.id) } diff --git a/app/views/question/_question.haml b/app/views/question/_question.haml index 0a3677fa..89449dea 100644 --- a/app/views/question/_question.haml +++ b/app/views/question/_question.haml @@ -26,8 +26,9 @@ %i.fa.fa-exclamation-triangle = t 'views.actions.report' %h6.text-muted.media-heading.answerbox__question-user + - identifier = question.author_is_anonymous ? question.author_identifier : nil - if hidden - = user_screen_name question.user, author_identifier: question.author_identifier, url: false + = user_screen_name question.user, author_identifier: identifier, url: false - else - = raw t('views.answerbox.asked', user: user_screen_name(question.user, author_identifier: question.author_identifier), time: time_tooltip(question)) + = raw t('views.answerbox.asked', user: user_screen_name(question.user, author_identifier: identifier), time: time_tooltip(question)) .answerbox__question-text= question_markdown question.content