From 03044b9819cd4e57c24446132fc863e2eb0769cc Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 2 Jan 2021 11:37:24 +0000 Subject: [PATCH] Show follows you status on person options --- follow.py | 10 +++++----- translations/ar.json | 3 ++- translations/ca.json | 3 ++- translations/cy.json | 3 ++- translations/de.json | 3 ++- translations/en.json | 3 ++- translations/es.json | 3 ++- translations/fr.json | 3 ++- translations/ga.json | 3 ++- translations/hi.json | 3 ++- translations/it.json | 3 ++- translations/ja.json | 3 ++- translations/oc.json | 3 ++- translations/pt.json | 3 ++- translations/ru.json | 3 ++- translations/zh.json | 3 ++- webapp_person_options.py | 9 +++++++++ 17 files changed, 44 insertions(+), 20 deletions(-) diff --git a/follow.py b/follow.py index ca7fb1637..25e4124ac 100644 --- a/follow.py +++ b/follow.py @@ -175,8 +175,8 @@ def followerOfPerson(baseDir: str, nickname: str, domain: str, federationList, debug, 'followers.txt') -def _isFollowerOfPerson(baseDir: str, nickname: str, domain: str, - followerNickname: str, followerDomain: str) -> bool: +def isFollowerOfPerson(baseDir: str, nickname: str, domain: str, + followerNickname: str, followerDomain: str) -> bool: """is the given nickname a follower of followerNickname? """ if ':' in domain: @@ -663,9 +663,9 @@ def receiveFollowRequest(session, baseDir: str, httpPrefix: str, baseDir + '/accounts/' + handleToFollow) return True - if _isFollowerOfPerson(baseDir, - nicknameToFollow, domainToFollowFull, - nickname, domainFull): + if isFollowerOfPerson(baseDir, + nicknameToFollow, domainToFollowFull, + nickname, domainFull): if debug: print('DEBUG: ' + nickname + '@' + domain + ' is already a follower of ' + diff --git a/translations/ar.json b/translations/ar.json index c0288c1e5..7cda02d25 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -349,5 +349,6 @@ "Unfilter words": "الكلمات غير المصفاة", "Show Accounts": "إظهار الحسابات", "Peertube Instances": "مثيلات Peertube", - "Show video previews for the following Peertube sites.": "إظهار معاينات الفيديو لمواقع Peertube التالية." + "Show video previews for the following Peertube sites.": "إظهار معاينات الفيديو لمواقع Peertube التالية.", + "Follows you": "يتبعك" } diff --git a/translations/ca.json b/translations/ca.json index ffc4725d9..d17bbc050 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -349,5 +349,6 @@ "Unfilter words": "Paraules sense filtre", "Show Accounts": "Mostra comptes", "Peertube Instances": "Instàncies de Peertube", - "Show video previews for the following Peertube sites.": "Mostra les previsualitzacions de vídeo dels següents llocs de Peertube." + "Show video previews for the following Peertube sites.": "Mostra les previsualitzacions de vídeo dels següents llocs de Peertube.", + "Follows you": "Et segueix" } diff --git a/translations/cy.json b/translations/cy.json index cd659af7a..8db9b525b 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -349,5 +349,6 @@ "Unfilter words": "Geiriau di-hid", "Show Accounts": "Dangos Cyfrifon", "Peertube Instances": "Camau Peertube", - "Show video previews for the following Peertube sites.": "Dangos rhagolygon fideo ar gyfer y safleoedd Peertube canlynol." + "Show video previews for the following Peertube sites.": "Dangos rhagolygon fideo ar gyfer y safleoedd Peertube canlynol.", + "Follows you": "Yn eich dilyn chi" } diff --git a/translations/de.json b/translations/de.json index e0e757b7d..a82a4aaa7 100644 --- a/translations/de.json +++ b/translations/de.json @@ -349,5 +349,6 @@ "Unfilter words": "Wörter herausfiltern", "Show Accounts": "Konten anzeigen", "Peertube Instances": "Peertube-Instanzen", - "Show video previews for the following Peertube sites.": "Zeigen Sie eine Videovorschau für die folgenden Peertube-Websites an." + "Show video previews for the following Peertube sites.": "Zeigen Sie eine Videovorschau für die folgenden Peertube-Websites an.", + "Follows you": "Folgt dir" } diff --git a/translations/en.json b/translations/en.json index 6ea42b2c6..9e93dcb82 100644 --- a/translations/en.json +++ b/translations/en.json @@ -349,5 +349,6 @@ "Unfilter words": "Unfilter words", "Show Accounts": "Show Accounts", "Peertube Instances": "Peertube Instances", - "Show video previews for the following Peertube sites.": "Show video previews for the following Peertube sites." + "Show video previews for the following Peertube sites.": "Show video previews for the following Peertube sites.", + "Follows you": "Follows you" } diff --git a/translations/es.json b/translations/es.json index 49293f2e5..edc36088f 100644 --- a/translations/es.json +++ b/translations/es.json @@ -349,5 +349,6 @@ "Unfilter words": "Palabras sin filtrar", "Show Accounts": "Mostrar cuentas", "Peertube Instances": "Instancias de Peertube", - "Show video previews for the following Peertube sites.": "Muestre vistas previas de video para los siguientes sitios de Peertube." + "Show video previews for the following Peertube sites.": "Muestre vistas previas de video para los siguientes sitios de Peertube.", + "Follows you": "Te sigue" } diff --git a/translations/fr.json b/translations/fr.json index ede3e55fa..838d18388 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -349,5 +349,6 @@ "Unfilter words": "Mots non filtrés", "Show Accounts": "Afficher les comptes", "Peertube Instances": "Instances Peertube", - "Show video previews for the following Peertube sites.": "Afficher des aperçus vidéo pour les sites Peertube suivants." + "Show video previews for the following Peertube sites.": "Afficher des aperçus vidéo pour les sites Peertube suivants.", + "Follows you": "Vous suit" } diff --git a/translations/ga.json b/translations/ga.json index af58fe18d..396d3ae8d 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -349,5 +349,6 @@ "Unfilter words": "Focail neamhleithleacha", "Show Accounts": "Taispeáin Cuntais", "Peertube Instances": "Imeachtaí Peertube", - "Show video previews for the following Peertube sites.": "Taispeáin réamhamharcanna físe do na suíomhanna Peertube seo a leanas." + "Show video previews for the following Peertube sites.": "Taispeáin réamhamharcanna físe do na suíomhanna Peertube seo a leanas.", + "Follows you": "Leanann tú" } diff --git a/translations/hi.json b/translations/hi.json index 9c0f78c50..05878a580 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -349,5 +349,6 @@ "Unfilter words": "अनफ़िल्टर शब्द", "Show Accounts": "खाते दिखाएं", "Peertube Instances": "Peertube उदाहरण", - "Show video previews for the following Peertube sites.": "निम्नलिखित Peertube साइटों के लिए वीडियो पूर्वावलोकन दिखाएं।" + "Show video previews for the following Peertube sites.": "निम्नलिखित Peertube साइटों के लिए वीडियो पूर्वावलोकन दिखाएं।", + "Follows you": "आपका पीछा करता है" } diff --git a/translations/it.json b/translations/it.json index 36b2fdc10..72d777ee1 100644 --- a/translations/it.json +++ b/translations/it.json @@ -349,5 +349,6 @@ "Unfilter words": "Parole non filtrate", "Show Accounts": "Mostra account", "Peertube Instances": "Istanze di Peertube", - "Show video previews for the following Peertube sites.": "Mostra le anteprime dei video per i seguenti siti Peertube." + "Show video previews for the following Peertube sites.": "Mostra le anteprime dei video per i seguenti siti Peertube.", + "Follows you": "Ti segue" } diff --git a/translations/ja.json b/translations/ja.json index 079f7bd07..6287b1ab7 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -349,5 +349,6 @@ "Unfilter words": "単語のフィルタリングを解除する", "Show Accounts": "アカウントを表示する", "Peertube Instances": "Peertubeインスタンス", - "Show video previews for the following Peertube sites.": "次のPeertubeサイトのビデオプレビューを表示します。" + "Show video previews for the following Peertube sites.": "次のPeertubeサイトのビデオプレビューを表示します。", + "Follows you": "あなたについていきます" } diff --git a/translations/oc.json b/translations/oc.json index 2b7e26f7e..eb198fb68 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -345,5 +345,6 @@ "Unfilter words": "Unfilter words", "Show Accounts": "Show Accounts", "Peertube Instances": "Peertube Instances", - "Show video previews for the following Peertube sites.": "Show video previews for the following Peertube sites." + "Show video previews for the following Peertube sites.": "Show video previews for the following Peertube sites.", + "Follows you": "Follows you" } diff --git a/translations/pt.json b/translations/pt.json index 67b1f3891..dfa17dc02 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -349,5 +349,6 @@ "Unfilter words": "Palavras sem filtro", "Show Accounts": "Mostrar contas", "Peertube Instances": "Instâncias Peertube", - "Show video previews for the following Peertube sites.": "Mostrar visualizações de vídeo para os seguintes sites Peertube." + "Show video previews for the following Peertube sites.": "Mostrar visualizações de vídeo para os seguintes sites Peertube.", + "Follows you": "Segue você" } diff --git a/translations/ru.json b/translations/ru.json index 3236b46fa..855c07f52 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -349,5 +349,6 @@ "Unfilter words": "Не фильтровать слова", "Show Accounts": "Показать счета", "Peertube Instances": "Экземпляры Peertube", - "Show video previews for the following Peertube sites.": "Показать превью видео для следующих сайтов Peertube." + "Show video previews for the following Peertube sites.": "Показать превью видео для следующих сайтов Peertube.", + "Follows you": "Следует за вами" } diff --git a/translations/zh.json b/translations/zh.json index fe7a8e92e..a2be25403 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -349,5 +349,6 @@ "Unfilter words": "未过滤字词", "Show Accounts": "显示帐户", "Peertube Instances": "Peertube实例", - "Show video previews for the following Peertube sites.": "显示以下Peertube网站的视频预览。" + "Show video previews for the following Peertube sites.": "显示以下Peertube网站的视频预览。", + "Follows you": "跟着你" } diff --git a/webapp_person_options.py b/webapp_person_options.py index 60ecc2eff..30d623e0e 100644 --- a/webapp_person_options.py +++ b/webapp_person_options.py @@ -18,6 +18,7 @@ from utils import removeHtml from utils import getDomainFromActor from utils import getNicknameFromActor from blocking import isBlocked +from follow import isFollowerOfPerson from follow import isFollowingActor from followingCalendar import receivingCalendarEvents from webapp_utils import htmlHeaderWithExternalStyle @@ -62,6 +63,7 @@ def htmlPersonOptions(defaultTimeline: str, blockStr = 'Block' nickname = None optionsNickname = None + followsYou = False if originPathStr.startswith('/users/'): nickname = originPathStr.split('/users/')[1] if '/' in nickname: @@ -77,6 +79,10 @@ def htmlPersonOptions(defaultTimeline: str, optionsNickname = getNicknameFromActor(optionsActor) optionsDomainFull = getFullDomain(optionsDomain, optionsPort) + followsYou = \ + isFollowerOfPerson(baseDir, + nickname, domain, + optionsNickname, optionsDomainFull) if isBlocked(baseDir, nickname, domain, optionsNickname, optionsDomainFull): blockStr = 'Block' @@ -120,6 +126,9 @@ def htmlPersonOptions(defaultTimeline: str, optionsStr += \ '

' + translate['Options for'] + \ ' @' + handleShown + '

\n' + if followsYou: + optionsStr += \ + '

' + translate['Follows you'] + '

\n' if emailAddress: optionsStr += \ '

' + translate['Email'] + \