Jelajahi Sumber

show report page only if report email is configured

Pouria Ezzati 1 tahun lalu
induk
melakukan
3174b18155

+ 1 - 0
server/handlers/locals.handler.js

@@ -27,6 +27,7 @@ function config(req, res, next) {
   res.locals.server_ip_address = env.SERVER_IP_ADDRESS;
   res.locals.disallow_registration = env.DISALLOW_REGISTRATION;
   res.locals.mail_enabled = env.MAIL_ENABLED;
+  res.locals.report_email = env.REPORT_EMAIL;
   next();
 }
 

+ 5 - 1
server/handlers/renders.handler.js

@@ -74,6 +74,10 @@ async function banned(req, res) {
 }
 
 async function report(req, res) {
+  if (!env.REPORT_EMAIL) {
+    res.redirect("/");
+    return;
+  }
   res.render("report", {
     title: "Report abuse",
   });
@@ -261,7 +265,7 @@ async function getReportEmail(req, res) {
     throw new utils.CustomError("No report email is available.", 400);
   }
   res.render("partials/report/email", {
-    report_email: env.REPORT_EMAIL.replace("@", "[at]")
+    report_email_address: env.REPORT_EMAIL.replace("@", "[at]")
   });
 }
 

+ 5 - 2
server/views/partials/footer.hbs

@@ -2,8 +2,11 @@
   <p>
     Made with love by <a href="https://thedevs.network" title="The Devs" target="_blank" rel="noopener noreferrer">The Devs</a>. <span>|</span> 
     <a href="https://github.com/thedevs-network/kutt" title="GitHub" target="_blank" rel="noopener noreferrer">GitHub</a> <span>|</span> 
-    <a href="/terms" title="Terms of Service">Terms of Service</a> <span>|</span>
-    <a href="/report" title="Report abuse">Report Abuse</a> 
+    <a href="/terms" title="Terms of Service">Terms of Service</a>
+    {{#if report_email}} 
+     <span>|</span>
+     <a href="/report" title="Report abuse">Report Abuse</a>
+    {{/if}}
     {{#if contact_email}}
       <span>|</span> 
       <button class="link" hx-get="/get-support-email" hx-swap="outerHTML">

+ 7 - 5
server/views/partials/header.hbs

@@ -10,11 +10,13 @@
           GitHub
         </a>
       </li>
-      <li>
-        <a class="nav" href="/report" title="Report abuse">
-          Report
-        </a>
-      </li>
+      {{#if report_email}}
+        <li>
+          <a class="nav" href="/report" title="Report abuse">
+            Report
+          </a>
+        </li>
+      {{/if}}
     </ul>
   </div>
   <nav>

+ 2 - 2
server/views/partials/report/email.hbs

@@ -1,5 +1,5 @@
 <div id="report-email">
-  {{#unless report_email}}
+  {{#unless report_email_address}}
     <button 
       class="link"
       hx-get="/get-report-email"
@@ -12,6 +12,6 @@
       show email address
     </button>
   {{else}}
-    {{report_email}}
+    {{report_email_address}}
   {{/unless}}
 </div>