From 1991f2bf88612c4bd33a3eaf7a7548bc43d4ab5b Mon Sep 17 00:00:00 2001
From: Miss Pasture <miss@pasture.moe>
Date: Wed, 16 Jun 2021 17:52:37 -0400
Subject: [PATCH] add options to change alternate twitter domain label and show
 'about instance' on profiles

---
 VARIABLES.md                                      |  8 ++++++--
 .../Settings/InstanceSettings.cs                  |  5 +++++
 src/BirdsiteLive.Domain/UserService.cs            | 15 +++++++++------
 src/BirdsiteLive/appsettings.json                 |  4 +++-
 4 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/VARIABLES.md b/VARIABLES.md
index 0a11ed7..8928513 100644
--- a/VARIABLES.md
+++ b/VARIABLES.md
@@ -47,8 +47,10 @@ If both whitelisting and blacklisting are set, only the whitelisting will be act
 * `Instance:ResolveMentionsInProfiles` (default: true) to enable or disable mentions parsing in profile's description. Resolving it will consume more User's API calls since newly discovered account can also contain references to others accounts as well. On a big instance it is recommended to disable it.
 * `Instance:PublishReplies` (default: false) to enable or disable replies publishing.
 * `Instance:UnlistedTwitterAccounts` (default: null) to enable unlisted publication for selected twitter accounts, separated by `;` (please limit this to brands and other public profiles).
-* `Instance:TwitterDomain` (default: twitter.com) redirect to a different domain (i.e. a Nitter instance) instead of Twitter
-* `Instance:InfoBanner` (default: '') text to show in a banner on the front page
+* `Instance:TwitterDomain` (default: twitter.com) redirect to a different domain (i.e. a Nitter instance) instead of Twitter in most areas
+* `Instance:TwitterDomainLabel` (default: "") if TwitterDomain is set, use this label on profile pages instead of the domain itself (i.e. you can set this to "Nitter" to show that on profiles instead of "twiiit.com")
+* `Instance:InfoBanner` (default: "") text to show in a banner on the front page
+* `Instance:ShowAboutInstanceOnProfiles` (default: true) show "About [instance name]" on profiles with a link to /About
 
 # Docker Compose full example
 
@@ -81,7 +83,9 @@ services:
 +           - Instance:PublishReplies=true
 +           - Instance:UnlistedTwitterAccounts=cocacola;twitter
 +           - Instance:TwitterDomain=twiiit.com
++           - Instance:TwitterDomainLabel=Nitter
 +           - Instance:InfoBanner=This is my BirdsiteLIVE instance. There are many like it, but this one is mine.
++           - Instance:ShowAboutInstanceOnProfiles=true
         networks:
         [...]
 
diff --git a/src/BirdsiteLive.Common/Settings/InstanceSettings.cs b/src/BirdsiteLive.Common/Settings/InstanceSettings.cs
index 7338aae..c2426e3 100644
--- a/src/BirdsiteLive.Common/Settings/InstanceSettings.cs
+++ b/src/BirdsiteLive.Common/Settings/InstanceSettings.cs
@@ -14,5 +14,10 @@
         public string TwitterDomain { get; set; }
 
         public string InfoBanner { get; set; }
+
+        public string TwitterDomainLabel { get; set; }
+
+        public bool ShowAboutInstanceOnProfiles { get; set; }
+
     }
 }
\ No newline at end of file
diff --git a/src/BirdsiteLive.Domain/UserService.cs b/src/BirdsiteLive.Domain/UserService.cs
index a00790d..ba9fee5 100644
--- a/src/BirdsiteLive.Domain/UserService.cs
+++ b/src/BirdsiteLive.Domain/UserService.cs
@@ -79,7 +79,7 @@ namespace BirdsiteLive.Domain
             attachments.Add(new UserAttachment
             {
                 type = "PropertyValue",
-                name = _instanceSettings.TwitterDomain,
+                name = _instanceSettings.TwitterDomainLabel != "" ? _instanceSettings.TwitterDomainLabel : _instanceSettings.TwitterDomain,
                 value = $"<a href=\"https://{_instanceSettings.TwitterDomain}/{acct}\" rel=\"me nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisible\">https://</span><span class=\"ellipsis\">{_instanceSettings.TwitterDomain}/{acct}</span></a>"
             });
 
@@ -93,12 +93,15 @@ namespace BirdsiteLive.Domain
                 });
             }
 
-            attachments.Add(new UserAttachment
+            if (_instanceSettings.ShowAboutInstanceOnProfiles)
             {
-                type = "PropertyValue",
-                name = $"About {_instanceSettings.Name}",
-                value = $"<a href=\"https://{_instanceSettings.Domain}/About\" rel=\"nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisible\">https://</span><span class=\"ellipsis\">{_instanceSettings.Domain}/About</span></a>"
-            });
+                attachments.Add(new UserAttachment
+                {
+                    type = "PropertyValue",
+                    name = $"About {_instanceSettings.Name}",
+                    value = $"<a href=\"https://{_instanceSettings.Domain}/About\" rel=\"nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisible\">https://</span><span class=\"ellipsis\">{_instanceSettings.Domain}/About</span></a>"
+                });
+            }
 
             var user = new Actor
             {
diff --git a/src/BirdsiteLive/appsettings.json b/src/BirdsiteLive/appsettings.json
index 2989082..42d292c 100644
--- a/src/BirdsiteLive/appsettings.json
+++ b/src/BirdsiteLive/appsettings.json
@@ -23,7 +23,9 @@
     "MaxUsersCapacity": 1500,
     "UnlistedTwitterAccounts": null,
     "TwitterDomain": "twitter.com",
-    "InfoBanner": ""
+    "TwitterDomainLabel": "",
+    "InfoBanner": "",
+    "ShowAboutInstanceOnProfiles": true
   },
   "Db": {
     "Type": "postgres",
