diff --git a/daemon.py b/daemon.py index 3e6aac753..5691cd80a 100644 --- a/daemon.py +++ b/daemon.py @@ -136,6 +136,7 @@ from webapp_timeline import htmlInboxBlogs from webapp_timeline import htmlInboxNews from webapp_timeline import htmlInboxFeatures from webapp_timeline import htmlOutbox +from webapp_moderation import htmlAccountInfo from webapp_moderation import htmlModeration from webapp_moderation import htmlModerationInfo from webapp_create_post import htmlNewPost @@ -1440,10 +1441,27 @@ class PubServer(BaseHTTPRequestHandler): moderationText = \ urllib.parse.unquote_plus(modText.strip()) elif moderationStr.startswith('submitInfo'): - msg = htmlModerationInfo(self.server.cssCache, - self.server.translate, - baseDir, httpPrefix, - nickname) + searchHandle = \ + urllib.parse.unquote_plus(moderationStr.strip()) + if searchHandle: + if '@' not in searchHandle: + searchHandle = None + if searchHandle: + msg = \ + htmlAccountInfo(self.server.cssCache, + self.server.translate, + baseDir, httpPrefix, + nickname, + self.server.domain, + self.server.port, + searchHandle, + self.server.debug) + else: + msg = \ + htmlModerationInfo(self.server.cssCache, + self.server.translate, + baseDir, httpPrefix, + nickname) msg = msg.encode('utf-8') self._login_headers('text/html', len(msg), callingDomain) @@ -10978,6 +10996,42 @@ class PubServer(BaseHTTPRequestHandler): 'show blogs 2 done', 'show shares 2 done') + # block a domain from htmlAccountInfo + if authorized and '/users/' in self.path and \ + '/accountinfo?blockdomain=' in self.path: + nickname = self.path.split('/users/')[1] + if '/' in nickname: + nickname = nickname.split('/')[0] + if not isModerator(self.server.baseDir, nickname): + self._400() + return + blockDomain = self.path.split('/accountinfo?blockdomain=')[1] + blockDomain = urllib.parse.unquote_plus(blockDomain.strip()) + addGlobalBlock(self.server.baseDir, nickname, blockDomain) + self.server.GETbusy = False + # TODO this should go back to the account info screen + self._redirect_headers('/users/' + nickname + '/moderation', + cookie, callingDomain) + return + + # unblock a domain from htmlAccountInfo + if authorized and '/users/' in self.path and \ + '/accountinfo?unblockdomain=' in self.path: + nickname = self.path.split('/users/')[1] + if '/' in nickname: + nickname = nickname.split('/')[0] + if not isModerator(self.server.baseDir, nickname): + self._400() + return + blockDomain = self.path.split('/accountinfo?unblockdomain=')[1] + blockDomain = urllib.parse.unquote_plus(blockDomain.strip()) + removeGlobalBlock(self.server.baseDir, nickname, blockDomain) + self.server.GETbusy = False + # TODO this should go back to the account info screen + self._redirect_headers('/users/' + nickname + '/moderation', + cookie, callingDomain) + return + # get the bookmarks timeline for a given person if self.path.endswith('/tlbookmarks') or \ '/tlbookmarks?page=' in self.path or \ diff --git a/epicyon-profile.css b/epicyon-profile.css index 94309a067..083a7fc62 100644 --- a/epicyon-profile.css +++ b/epicyon-profile.css @@ -930,6 +930,10 @@ div.container { overflow: hidden; } +.accountInfoDomains { + margin: 0 10%; +} + @media screen and (min-width: 400px) { body, html { background-color: var(--main-bg-color); diff --git a/epicyon.py b/epicyon.py index 59c0e2cd5..37df367e9 100644 --- a/epicyon.py +++ b/epicyon.py @@ -526,8 +526,8 @@ if args.posts: if args.postDomains: if '@' not in args.postDomains: if '/users/' in args.postDomains: - postsNickname = getNicknameFromActor(args.posts) - postsDomain, postsPort = getDomainFromActor(args.posts) + postsNickname = getNicknameFromActor(args.postDomains) + postsDomain, postsPort = getDomainFromActor(args.postDomains) args.postDomains = postsNickname + '@' + postsDomain if postsPort: if postsPort != 80 and postsPort != 443: @@ -565,8 +565,9 @@ if args.postDomainsBlocked: # given handle but which are globally blocked on this instance if '@' not in args.postDomainsBlocked: if '/users/' in args.postDomainsBlocked: - postsNickname = getNicknameFromActor(args.posts) - postsDomain, postsPort = getDomainFromActor(args.posts) + postsNickname = getNicknameFromActor(args.postDomainsBlocked) + postsDomain, postsPort = \ + getDomainFromActor(args.postDomainsBlocked) args.postDomainsBlocked = postsNickname + '@' + postsDomain if postsPort: if postsPort != 80 and postsPort != 443: diff --git a/translations/ar.json b/translations/ar.json index 2a96a612f..8ce52a2f5 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -339,5 +339,7 @@ "Select the edit icon to add RSS feeds": "حدد رمز التحرير لإضافة موجز ويب لـ RSS", "Select the edit icon to add web links": "حدد رمز التحرير لإضافة روابط الويب", "Hashtag Categories RSS Feed": "Hashtag Categories RSS Feed", - "Ask about a shared item.": "اسأل عن عنصر مشترك." + "Ask about a shared item.": "اسأل عن عنصر مشترك.", + "Account Information": "معلومات الحساب", + "This account interacts with the following instances": "يتفاعل هذا الحساب مع الحالات التالية" } diff --git a/translations/ca.json b/translations/ca.json index 7ff65aab7..7e9b2d8a7 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -339,5 +339,7 @@ "Select the edit icon to add RSS feeds": "Seleccioneu la icona d'edició per afegir canals RSS", "Select the edit icon to add web links": "Seleccioneu la icona d'edició per afegir enllaços web", "Hashtag Categories RSS Feed": "Feed RSS de categories de hashtag", - "Ask about a shared item.": "Pregunteu sobre un element compartit." + "Ask about a shared item.": "Pregunteu sobre un element compartit.", + "Account Information": "Informació del compte", + "This account interacts with the following instances": "Aquest compte interactua amb les instàncies següents" } diff --git a/translations/cy.json b/translations/cy.json index b10bb537e..a0c996809 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -339,5 +339,7 @@ "Select the edit icon to add RSS feeds": "Dewiswch yr eicon golygu i ychwanegu porthwyr RSS", "Select the edit icon to add web links": "Dewiswch yr eicon golygu i ychwanegu dolenni gwe", "Hashtag Categories RSS Feed": "Categorïau Hashtag RSS Feed", - "Ask about a shared item.": "Gofynnwch am eitem a rennir." + "Ask about a shared item.": "Gofynnwch am eitem a rennir.", + "Account Information": "Gwybodaeth Gyfrif", + "This account interacts with the following instances": "Mae'r cyfrif hwn yn rhyngweithio â'r achosion canlynol" } diff --git a/translations/de.json b/translations/de.json index ebd9e4e5a..f9eac6115 100644 --- a/translations/de.json +++ b/translations/de.json @@ -339,5 +339,7 @@ "Select the edit icon to add RSS feeds": "Wählen Sie das Bearbeitungssymbol, um RSS-Feeds hinzuzufügen", "Select the edit icon to add web links": "Wählen Sie das Bearbeitungssymbol, um Weblinks hinzuzufügen", "Hashtag Categories RSS Feed": "Hashtag Kategorien RSS Feed", - "Ask about a shared item.": "Fragen Sie nach einem gemeinsamen Artikel." + "Ask about a shared item.": "Fragen Sie nach einem gemeinsamen Artikel.", + "Account Information": "Kontoinformationen", + "This account interacts with the following instances": "Dieses Konto interagiert mit den folgenden Instanzen" } diff --git a/translations/en.json b/translations/en.json index 45e450a1e..b17f8b92b 100644 --- a/translations/en.json +++ b/translations/en.json @@ -339,5 +339,7 @@ "Select the edit icon to add RSS feeds": "Select the edit icon to add RSS feeds", "Select the edit icon to add web links": "Select the edit icon to add web links", "Hashtag Categories RSS Feed": "Hashtag Categories RSS Feed", - "Ask about a shared item.": "Ask about a shared item." + "Ask about a shared item.": "Ask about a shared item.", + "Account Information": "Account Information", + "This account interacts with the following instances": "This account interacts with the following instances" } diff --git a/translations/es.json b/translations/es.json index 12e541e78..4c970fe79 100644 --- a/translations/es.json +++ b/translations/es.json @@ -339,5 +339,7 @@ "Select the edit icon to add RSS feeds": "Seleccione el icono de edición para agregar fuentes RSS", "Select the edit icon to add web links": "Seleccione el icono de edición para agregar enlaces web", "Hashtag Categories RSS Feed": "Feed RSS de categorías de hashtags", - "Ask about a shared item.": "Pregunte por un elemento compartido." + "Ask about a shared item.": "Pregunte por un elemento compartido.", + "Account Information": "Información de la cuenta", + "This account interacts with the following instances": "Esta cuenta interactúa con las siguientes instancias" } diff --git a/translations/fr.json b/translations/fr.json index 7816fc8f8..167940b2a 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -339,5 +339,7 @@ "Select the edit icon to add RSS feeds": "Sélectionnez l'icône d'édition pour ajouter des flux RSS", "Select the edit icon to add web links": "Sélectionnez l'icône de modification pour ajouter des liens Web", "Hashtag Categories RSS Feed": "Flux RSS des catégories Hashtag", - "Ask about a shared item.": "Renseignez-vous sur un élément partagé." + "Ask about a shared item.": "Renseignez-vous sur un élément partagé.", + "Account Information": "Information sur le compte", + "This account interacts with the following instances": "Ce compte interagit avec les instances suivantes" } diff --git a/translations/ga.json b/translations/ga.json index ac41d0205..13e51eada 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -339,5 +339,7 @@ "Select the edit icon to add RSS feeds": "Roghnaigh an deilbhín eagar chun fothaí RSS a chur leis", "Select the edit icon to add web links": "Roghnaigh an deilbhín eagar chun naisc ghréasáin a chur leis", "Hashtag Categories RSS Feed": "Catagóirí Hashtag RSS Feed", - "Ask about a shared item.": "Fiafraigh faoi earra roinnte." + "Ask about a shared item.": "Fiafraigh faoi earra roinnte.", + "Account Information": "Faisnéis Chuntais", + "This account interacts with the following instances": "Idirghníomhaíonn an cuntas seo leis na cásanna seo a leanas" } diff --git a/translations/hi.json b/translations/hi.json index 65fec21ff..40ddfc5f6 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -339,5 +339,7 @@ "Select the edit icon to add RSS feeds": "RSS फ़ीड जोड़ने के लिए संपादन आइकन का चयन करें", "Select the edit icon to add web links": "वेब लिंक जोड़ने के लिए संपादन आइकन का चयन करें", "Hashtag Categories RSS Feed": "हैशटैग श्रेणियाँ आरएसएस फ़ीड", - "Ask about a shared item.": "एक साझा आइटम के बारे में पूछें।" + "Ask about a shared item.": "एक साझा आइटम के बारे में पूछें।", + "Account Information": "खाते की जानकारी", + "This account interacts with the following instances": "यह खाता निम्नलिखित उदाहरणों के साथ सहभागिता करता है" } diff --git a/translations/it.json b/translations/it.json index fabd4f973..5ab6e0dbc 100644 --- a/translations/it.json +++ b/translations/it.json @@ -339,5 +339,7 @@ "Select the edit icon to add RSS feeds": "Seleziona l'icona di modifica per aggiungere feed RSS", "Select the edit icon to add web links": "Seleziona l'icona di modifica per aggiungere link web", "Hashtag Categories RSS Feed": "Feed RSS delle categorie hashtag", - "Ask about a shared item.": "Chiedi informazioni su un elemento condiviso." + "Ask about a shared item.": "Chiedi informazioni su un elemento condiviso.", + "Account Information": "Informazioni account", + "This account interacts with the following instances": "Questo account interagisce con le seguenti istanze" } diff --git a/translations/ja.json b/translations/ja.json index 7bed89c46..3afb8aff8 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -339,5 +339,7 @@ "Select the edit icon to add RSS feeds": "編集アイコンを選択してRSSフィードを追加します", "Select the edit icon to add web links": "編集アイコンを選択してWebリンクを追加します", "Hashtag Categories RSS Feed": "ハッシュタグカテゴリRSSフィード", - "Ask about a shared item.": "共有アイテムについて質問します。" + "Ask about a shared item.": "共有アイテムについて質問します。", + "Account Information": "口座情報", + "This account interacts with the following instances": "このアカウントは、次のインスタンスと相互作用します" } diff --git a/translations/oc.json b/translations/oc.json index a224b833a..9f8a92a0e 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -335,5 +335,7 @@ "Select the edit icon to add RSS feeds": "Select the edit icon to add RSS feeds", "Select the edit icon to add web links": "Select the edit icon to add web links", "Hashtag Categories RSS Feed": "Hashtag Categories RSS Feed", - "Ask about a shared item.": "Ask about a shared item." + "Ask about a shared item.": "Ask about a shared item.", + "Account Information": "Account Information", + "This account interacts with the following instances": "This account interacts with the following instances" } diff --git a/translations/pt.json b/translations/pt.json index 305243eac..53af4b8d6 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -339,5 +339,7 @@ "Select the edit icon to add RSS feeds": "Selecione o ícone de edição para adicionar feeds RSS", "Select the edit icon to add web links": "Selecione o ícone de edição para adicionar links da web", "Hashtag Categories RSS Feed": "Feed RSS das categorias de hashtag", - "Ask about a shared item.": "Pergunte sobre um item compartilhado." + "Ask about a shared item.": "Pergunte sobre um item compartilhado.", + "Account Information": "Informação da conta", + "This account interacts with the following instances": "Esta conta interage com as seguintes instâncias" } diff --git a/translations/ru.json b/translations/ru.json index 3c0155cea..e44e037f5 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -339,5 +339,7 @@ "Select the edit icon to add RSS feeds": "Щелкните значок редактирования, чтобы добавить RSS-каналы", "Select the edit icon to add web links": "Щелкните значок редактирования, чтобы добавить веб-ссылки", "Hashtag Categories RSS Feed": "RSS-канал категорий хэштегов", - "Ask about a shared item.": "Спросите об общем элементе." + "Ask about a shared item.": "Спросите об общем элементе.", + "Account Information": "Информация об аккаунте", + "This account interacts with the following instances": "Этот аккаунт взаимодействует со следующими экземплярами" } diff --git a/translations/zh.json b/translations/zh.json index 470be2cd5..f12a444da 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -339,5 +339,7 @@ "Select the edit icon to add RSS feeds": "选择编辑图标以添加RSS feed", "Select the edit icon to add web links": "选择编辑图标以添加Web链接", "Hashtag Categories RSS Feed": "标签类别RSS提要", - "Ask about a shared item.": "询问共享项目。" + "Ask about a shared item.": "询问共享项目。", + "Account Information": "帐户信息", + "This account interacts with the following instances": "此帐户与以下实例进行交互" } diff --git a/webapp_moderation.py b/webapp_moderation.py index 78a36881a..9d24db302 100644 --- a/webapp_moderation.py +++ b/webapp_moderation.py @@ -7,9 +7,13 @@ __email__ = "bob@freedombone.net" __status__ = "Production" import os +from utils import getNicknameFromActor +from utils import getDomainFromActor +from posts import getPublicPostDomains from webapp_timeline import htmlTimeline from webapp_utils import htmlHeaderWithExternalStyle from webapp_utils import htmlFooter +from blocking import isBlockedDomain def htmlModeration(cssCache: {}, defaultTimeline: str, @@ -44,6 +48,63 @@ def htmlModeration(cssCache: {}, defaultTimeline: str, authorized) +def htmlAccountInfo(cssCache: {}, translate: {}, + baseDir: str, httpPrefix: str, + nickname: str, domain: str, port: int, + searchHandle: str, debug: bool) -> str: + """Shows which domains a search handle interacts with. + This screen is shown if a moderator enters a handle and selects info + on the moderation screen + """ + msgStr1 = 'This account interacts with the following instances' + + infoForm = '' + cssFilename = baseDir + '/epicyon-profile.css' + if os.path.isfile(baseDir + '/epicyon.css'): + cssFilename = baseDir + '/epicyon.css' + + infoForm = htmlHeaderWithExternalStyle(cssFilename) + + searchNickname = getNicknameFromActor(searchHandle) + searchDomain, searchPort = getDomainFromActor(searchHandle) + + infoForm += \ + '

' + \ + translate['Account Information'] + \ + ': ' + searchNickname + '@' + searchDomain + \ + '



' + + infoForm += translate[msgStr1] + '


' + + proxyType = 'tor' + domainList = [] + domainList = getPublicPostDomains(None, + baseDir, searchNickname, searchDomain, + proxyType, searchPort, + httpPrefix, debug, + __version__, domainList) + infoForm += '
' + usersPath = '/users/' + nickname + '/accountinfo' + for postDomain in domainList: + infoForm += '' + postDomain + ' ' + if isBlockedDomain(postDomain): + infoForm += \ + '' + infoForm += '' + else: + infoForm += \ + '' + infoForm += '' + infoForm += '
' + + infoForm += '
' + infoForm += htmlFooter() + return infoForm + + def htmlModerationInfo(cssCache: {}, translate: {}, baseDir: str, httpPrefix: str, nickname: str) -> str: @@ -51,6 +112,7 @@ def htmlModerationInfo(cssCache: {}, translate: {}, 'These are globally blocked for all accounts on this instance' msgStr2 = \ 'Any blocks or suspensions made by moderators will be shown here.' + infoForm = '' cssFilename = baseDir + '/epicyon-profile.css' if os.path.isfile(baseDir + '/epicyon.css'): @@ -61,7 +123,7 @@ def htmlModerationInfo(cssCache: {}, translate: {}, infoForm += \ '

' + \ translate['Moderation Information'] + \ - '

' + '
' infoShown = False suspendedFilename = baseDir + '/accounts/suspended.txt'