Explorar o código

A few (self hosting) improvements

Fabio Widmer %!s(int64=5) %!d(string=hai) anos
pai
achega
8e71e8e7f4
Modificáronse 4 ficheiros con 21 adicións e 5 borrados
  1. 2 0
      app/config.py
  2. 13 2
      app/models.py
  3. 3 0
      example.env
  4. 3 3
      templates/footer.html

+ 2 - 0
app/config.py

@@ -252,6 +252,8 @@ if LOCAL_FILE_UPLOAD:
 
 LANDING_PAGE_URL = os.environ.get("LANDING_PAGE_URL") or "https://simplelogin.io"
 
+STATUS_PAGE_URL = os.environ.get("STATUS_PAGE_URL") or "https://status.simplelogin.io"
+
 # Loading PGP keys when mail_handler runs. To be used locally when init_app is not called.
 LOAD_PGP_EMAIL_HANDLER = "LOAD_PGP_EMAIL_HANDLER" in os.environ
 

+ 13 - 2
app/models.py

@@ -1078,7 +1078,18 @@ class Contact(db.Model, ModelMixin):
         """
 
         # Prefer using contact name if possible
+        user = self.user
         name = self.name
+        email = self.website_email
+
+        if (
+            not user
+            or not SenderFormatEnum.has_value(user.sender_format)
+            or user.sender_format == SenderFormatEnum.AT.value
+        ):
+            email = email.replace("@", " at ")
+        elif user.sender_format == SenderFormatEnum.A.value:
+            email = email.replace("@", "(a)")
 
         # if no name, try to parse it from website_from
         if not name and self.website_from:
@@ -1098,9 +1109,9 @@ class Contact(db.Model, ModelMixin):
             name = name.replace('"', "")
 
         if name:
-            name = name + " | " + self.website_email.replace("@", " at ")
+            name = name + " | " + email
         else:
-            name = self.website_email.replace("@", " at ")
+            name = email
 
         # cannot use formataddr here as this field is for email client, not for MTA
         return f'"{name}" <{self.reply_email}>'

+ 3 - 0
example.env

@@ -135,6 +135,9 @@ FACEBOOK_CLIENT_SECRET=to_fill
 # The landing page
 # LANDING_PAGE_URL=https://simplelogin.io
 
+# The status page
+# STATUS_PAGE_URL=https://status.simplelogin.io
+
 # Used when querying info on Apple API
 # APPLE_API_SECRET=secret
 # MACAPP_APPLE_API_SECRET=secret

+ 3 - 3
templates/footer.html

@@ -5,7 +5,7 @@
         <div class="row align-items-center">
           <div class="col-auto">
             <ul class="list-inline list-inline-dots mb-0">
-              <li class="list-inline-item"><a href="https://simplelogin.io" target="_blank" rel="noopener">
+              <li class="list-inline-item"><a href="{{LANDING_PAGE_URL}}" target="_blank" rel="noopener">
                 Website <i class="fe fe-external-link"></i>
               </a></li>
               <li class="list-inline-item"><a href="https://trello.com/b/4d6A69I4/open-roadmap" target="_blank" rel="noopener">
@@ -14,10 +14,10 @@
               <li class="list-inline-item"><a href="https://docs.simplelogin.io" target="_blank" rel="noopener">
                 Developer Documentation <i class="fe fe-external-link"></i>
               </a></li>
-              <li class="list-inline-item"><a href="https://status.simplelogin.io" target="_blank" rel="noopener">
+              <li class="list-inline-item"><a href="{{STATUS_PAGE_URL}}" target="_blank" rel="noopener">
                 Status <i class="fe fe-external-link"></i>
               </a></li>
-              <li class="list-inline-item"><a href="mailto:hi@simplelogin.io">Contact Us
+              <li class="list-inline-item"><a href="mailto:{{SUPPORT_EMAIL}}">Contact Us
                 <i class="fe fe-external-link"></i></a></li>
               <li class="list-inline-item intro-step-0">
                 <a onclick="startIntro()"