From 1cda2d740ec1b36c25681e798f2c23a684ac8e70 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 21 Jul 2022 10:58:28 +0100 Subject: [PATCH] Import follows csv from profile screen --- content.py | 8 +++++++- daemon.py | 23 ++++++++++++++++++----- translations/ar.json | 3 ++- translations/bn.json | 3 ++- translations/ca.json | 3 ++- translations/cy.json | 3 ++- translations/de.json | 3 ++- translations/el.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/ko.json | 3 ++- translations/ku.json | 3 ++- translations/nl.json | 3 ++- translations/oc.json | 3 ++- translations/pl.json | 3 ++- translations/pt.json | 3 ++- translations/ru.json | 3 ++- translations/sw.json | 3 ++- translations/tr.json | 3 ++- translations/uk.json | 3 ++- translations/yi.json | 3 ++- translations/zh.json | 3 ++- webapp_profile.py | 8 ++++++++ 28 files changed, 83 insertions(+), 31 deletions(-) diff --git a/content.py b/content.py index 29aa60d4b..f4b5efe60 100644 --- a/content.py +++ b/content.py @@ -1411,7 +1411,8 @@ def save_media_in_form_post(media_bytes, debug: bool, 'ogg': 'audio/ogg', 'opus': 'audio/opus', 'flac': 'audio/flac', - 'zip': 'application/zip' + 'zip': 'application/zip', + 'csv': 'text/csv' } detected_extension = None for extension, content_type in extension_list.items(): @@ -1468,6 +1469,11 @@ def save_media_in_form_post(media_bytes, debug: bool, svg_str = svg_str.decode() if dangerous_svg(svg_str, False): return None, None + elif detected_extension == 'csv': + csv_str = media_bytes[start_pos:] + csv_str = svg_str.decode() + if ',' not in csv_str: + return None, None try: with open(filename, 'wb') as fp_media: diff --git a/daemon.py b/daemon.py index 686866010..c3997eb6e 100644 --- a/daemon.py +++ b/daemon.py @@ -5505,6 +5505,7 @@ class PubServer(BaseHTTPRequestHandler): 'banner', 'search_banner', 'instanceLogo', 'left_col_image', 'right_col_image', + 'submitImportFollows' 'submitImportTheme' ) profile_media_types_uploaded = {} @@ -5518,18 +5519,18 @@ class PubServer(BaseHTTPRequestHandler): if debug: print('DEBUG: profile update extracting ' + m_type + - ' image, zip or font from POST') + ' image, zip, csv or font from POST') media_bytes, post_bytes = \ extract_media_in_form_post(post_bytes, boundary, m_type) if media_bytes: if debug: print('DEBUG: profile update ' + m_type + - ' image, zip or font was found. ' + + ' image, zip, csv or font was found. ' + str(len(media_bytes)) + ' bytes') else: if debug: print('DEBUG: profile update, no ' + m_type + - ' image, zip or font was found in POST') + ' image, zip, csv or font was found in POST') continue # Note: a .temp extension is used here so that at no @@ -5549,6 +5550,10 @@ class PubServer(BaseHTTPRequestHandler): except OSError: print('EX: _profile_edit unable to delete ' + filename_base) + elif m_type == 'submitImportFollows': + filename_base = \ + acct_dir(base_dir, nickname, domain) + \ + '/import_following.csv' else: filename_base = \ acct_dir(base_dir, nickname, domain) + \ @@ -5559,10 +5564,18 @@ class PubServer(BaseHTTPRequestHandler): filename_base) if filename: print('Profile update POST ' + m_type + - ' media, zip or font filename is ' + filename) + ' media, zip, csv or font filename is ' + filename) else: print('Profile update, no ' + m_type + - ' media, zip or font filename in POST') + ' media, zip, csv or font filename in POST') + continue + + if m_type == 'submitImportFollows': + if os.path.isfile(filename_base): + print(nickname + ' imported follows csv') + else: + print('WARN: failed to import follows from csv for ' + + nickname) continue if m_type == 'submitImportTheme': diff --git a/translations/ar.json b/translations/ar.json index e314205fc..ed8db5f38 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -570,5 +570,6 @@ "Content warnings will be added for the following": "ستتم إضافة تحذيرات المحتوى لما يلي", "nowplaying": "الان العب", "NowPlaying": "الان العب", - "Import and Export": "استيراد وتصدير" + "Import and Export": "استيراد وتصدير", + "Import Follows": "يتبع الاستيراد" } diff --git a/translations/bn.json b/translations/bn.json index 18c83f201..16ebc04e9 100644 --- a/translations/bn.json +++ b/translations/bn.json @@ -570,5 +570,6 @@ "Content warnings will be added for the following": "নিম্নলিখিত জন্য বিষয়বস্তু সতর্কতা যোগ করা হবে", "nowplaying": "এখন চলছে", "NowPlaying": "এখন চলছে", - "Import and Export": "আমদানি এবং রপ্তানি" + "Import and Export": "আমদানি এবং রপ্তানি", + "Import Follows": "আমদানি অনুসরণ করে" } diff --git a/translations/ca.json b/translations/ca.json index 70fd73081..984363360 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -570,5 +570,6 @@ "Content warnings will be added for the following": "S'afegiran advertències de contingut per al següent", "nowplaying": "arajugant", "NowPlaying": "AraJugant", - "Import and Export": "Importació i Exportació" + "Import and Export": "Importació i Exportació", + "Import Follows": "Segueix la importació" } diff --git a/translations/cy.json b/translations/cy.json index 691a6352e..fc1506d12 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -570,5 +570,6 @@ "Content warnings will be added for the following": "Bydd rhybuddion cynnwys yn cael eu hychwanegu ar gyfer y canlynol", "nowplaying": "nawrynchwarae", "NowPlaying": "NawrYnChwarae", - "Import and Export": "Mewnforio ac Allforio" + "Import and Export": "Mewnforio ac Allforio", + "Import Follows": "Mewnforio Dilyn" } diff --git a/translations/de.json b/translations/de.json index 0961227c0..3acf03d1b 100644 --- a/translations/de.json +++ b/translations/de.json @@ -570,5 +570,6 @@ "Content warnings will be added for the following": "Inhaltswarnungen werden für Folgendes hinzugefügt", "nowplaying": "läuftgerade", "NowPlaying": "LäuftGerade", - "Import and Export": "Import und Export" + "Import and Export": "Import und Export", + "Import Follows": "Import folgt" } diff --git a/translations/el.json b/translations/el.json index 86895f005..72b231aa8 100644 --- a/translations/el.json +++ b/translations/el.json @@ -570,5 +570,6 @@ "Content warnings will be added for the following": "Θα προστεθούν προειδοποιήσεις περιεχομένου για τα ακόλουθα", "nowplaying": "τώραπαίζει", "NowPlaying": "ΤώραΠαίζει", - "Import and Export": "Εισάγω και εξάγω" + "Import and Export": "Εισάγω και εξάγω", + "Import Follows": "Ακολουθεί εισαγωγή" } diff --git a/translations/en.json b/translations/en.json index da9fd9a5c..9aa14b443 100644 --- a/translations/en.json +++ b/translations/en.json @@ -570,5 +570,6 @@ "Content warnings will be added for the following": "Content warnings will be added for the following", "nowplaying": "nowplaying", "NowPlaying": "NowPlaying", - "Import and Export": "Import and Export" + "Import and Export": "Import and Export", + "Import Follows": "Import Follows" } diff --git a/translations/es.json b/translations/es.json index c8b992c5b..12229db9e 100644 --- a/translations/es.json +++ b/translations/es.json @@ -570,5 +570,6 @@ "Content warnings will be added for the following": "Se agregarán advertencias de contenido para lo siguiente", "nowplaying": "jugandoahora", "NowPlaying": "JugandoAhora", - "Import and Export": "Importar y exportar" + "Import and Export": "Importar y exportar", + "Import Follows": "Importar seguimientos" } diff --git a/translations/fr.json b/translations/fr.json index fb5c7d630..19d2f1e08 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -570,5 +570,6 @@ "Content warnings will be added for the following": "Des avertissements de contenu seront ajoutés pour les éléments suivants", "nowplaying": "lectureencours", "NowPlaying": "LectureEnCours", - "Import and Export": "Importer et exporter" + "Import and Export": "Importer et exporter", + "Import Follows": "Importer suit" } diff --git a/translations/ga.json b/translations/ga.json index e0a9db521..07fd0ac95 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -570,5 +570,6 @@ "Content warnings will be added for the following": "Cuirfear rabhaidh ábhair leis maidir leis na nithe seo a leanas", "nowplaying": "anoisagimirt", "NowPlaying": "AnoisAgImirt", - "Import and Export": "Iompórtáil agus Easpórtáil" + "Import and Export": "Iompórtáil agus Easpórtáil", + "Import Follows": "Leanann Iompórtáil" } diff --git a/translations/hi.json b/translations/hi.json index 04279fab9..d918f0c5c 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -570,5 +570,6 @@ "Content warnings will be added for the following": "निम्नलिखित के लिए सामग्री चेतावनियां जोड़ दी जाएंगी", "nowplaying": "अब खेल रहे हैं", "NowPlaying": "अब खेल रहे हैं", - "Import and Export": "आयात और निर्यात" + "Import and Export": "आयात और निर्यात", + "Import Follows": "आयात का अनुसरण करता है" } diff --git a/translations/it.json b/translations/it.json index 0e0e63159..5628bde65 100644 --- a/translations/it.json +++ b/translations/it.json @@ -570,5 +570,6 @@ "Content warnings will be added for the following": "Verranno aggiunti avvisi sui contenuti per quanto segue", "nowplaying": "ora giocando", "NowPlaying": "OraGiocando", - "Import and Export": "Importazione e esportazione" + "Import and Export": "Importazione e esportazione", + "Import Follows": "Importa segue" } diff --git a/translations/ja.json b/translations/ja.json index 5560b16eb..841ae9a2e 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -570,5 +570,6 @@ "Content warnings will be added for the following": "以下のコンテンツ警告が追加されます", "nowplaying": "再生中", "NowPlaying": "再生中", - "Import and Export": "インポートとエクスポート" + "Import and Export": "インポートとエクスポート", + "Import Follows": "インポートフォロー" } diff --git a/translations/ko.json b/translations/ko.json index 1a5616e52..3219cc6b1 100644 --- a/translations/ko.json +++ b/translations/ko.json @@ -570,5 +570,6 @@ "Content warnings will be added for the following": "다음에 대한 콘텐츠 경고가 추가됩니다.", "nowplaying": "지금 재생", "NowPlaying": "지금 재생", - "Import and Export": "가져오기 및 내보내기" + "Import and Export": "가져오기 및 내보내기", + "Import Follows": "가져오기 팔로우" } diff --git a/translations/ku.json b/translations/ku.json index 47b2996ea..3bea33b45 100644 --- a/translations/ku.json +++ b/translations/ku.json @@ -570,5 +570,6 @@ "Content warnings will be added for the following": "Hişyariyên naverokê dê ji bo jêrîn werin zêdekirin", "nowplaying": "nihadilîze", "NowPlaying": "NihaDilîze", - "Import and Export": "Import û Export" + "Import and Export": "Import û Export", + "Import Follows": "Import Follows" } diff --git a/translations/nl.json b/translations/nl.json index a237c02ce..83133657f 100644 --- a/translations/nl.json +++ b/translations/nl.json @@ -570,5 +570,6 @@ "Content warnings will be added for the following": "Er worden inhoudswaarschuwingen toegevoegd voor het volgende:", "nowplaying": "nuaanhetspelen", "NowPlaying": "NuAanHetSpelen", - "Import and Export": "Importeren en exporteren" + "Import and Export": "Importeren en exporteren", + "Import Follows": "Volgt importeren" } diff --git a/translations/oc.json b/translations/oc.json index aade46efe..0f442a0cc 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -566,5 +566,6 @@ "Content warnings will be added for the following": "Content warnings will be added for the following", "nowplaying": "nowplaying", "NowPlaying": "NowPlaying", - "Import and Export": "Import and Export" + "Import and Export": "Import and Export", + "Import Follows": "Import Follows" } diff --git a/translations/pl.json b/translations/pl.json index a101196e7..edb23dfac 100644 --- a/translations/pl.json +++ b/translations/pl.json @@ -570,5 +570,6 @@ "Content warnings will be added for the following": "Ostrzeżenia dotyczące treści zostaną dodane do następujących", "nowplaying": "terazgra", "NowPlaying": "TerazGra", - "Import and Export": "Importuj i eksportuj" + "Import and Export": "Importuj i eksportuj", + "Import Follows": "Importuj obserwuje" } diff --git a/translations/pt.json b/translations/pt.json index 7b3890038..7829ba381 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -570,5 +570,6 @@ "Content warnings will be added for the following": "Avisos de conteúdo serão adicionados para os seguintes", "nowplaying": "agorajogando", "NowPlaying": "AgoraJogando", - "Import and Export": "Importar e exportar" + "Import and Export": "Importar e exportar", + "Import Follows": "Importar seguidores" } diff --git a/translations/ru.json b/translations/ru.json index bd64a7eab..af2e9a37a 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -570,5 +570,6 @@ "Content warnings will be added for the following": "Предупреждения о содержании будут добавлены для следующих", "nowplaying": "сейчасиграет", "NowPlaying": "СейчасИграет", - "Import and Export": "Импорт и экспорт" + "Import and Export": "Импорт и экспорт", + "Import Follows": "Импорт подписок" } diff --git a/translations/sw.json b/translations/sw.json index e24ca61a5..e2848196c 100644 --- a/translations/sw.json +++ b/translations/sw.json @@ -570,5 +570,6 @@ "Content warnings will be added for the following": "Maonyo ya maudhui yataongezwa kwa yafuatayo", "nowplaying": "inachezasasa", "NowPlaying": "InachezaSasa", - "Import and Export": "Ingiza na Hamisha" + "Import and Export": "Ingiza na Hamisha", + "Import Follows": "Ingiza Inafuata" } diff --git a/translations/tr.json b/translations/tr.json index fc195d6b0..a967b9c9c 100644 --- a/translations/tr.json +++ b/translations/tr.json @@ -570,5 +570,6 @@ "Content warnings will be added for the following": "Aşağıdakiler için içerik uyarıları eklenecek", "nowplaying": "şimdioynuyor", "NowPlaying": "ŞimdiOynuyor", - "Import and Export": "İthalat ve ihracat" + "Import and Export": "İthalat ve ihracat", + "Import Follows": "Takipleri İçe Aktar" } diff --git a/translations/uk.json b/translations/uk.json index 202ea9d55..4bf851e7d 100644 --- a/translations/uk.json +++ b/translations/uk.json @@ -570,5 +570,6 @@ "Content warnings will be added for the following": "Попередження про вміст буде додано для наступних", "nowplaying": "заразграє", "NowPlaying": "ЗаразГрає", - "Import and Export": "Імпорт та експорт" + "Import and Export": "Імпорт та експорт", + "Import Follows": "Імпорт слідує" } diff --git a/translations/yi.json b/translations/yi.json index 33a188989..4145faad2 100644 --- a/translations/yi.json +++ b/translations/yi.json @@ -570,5 +570,6 @@ "Content warnings will be added for the following": "אינהאַלט וואָרנינגז וועט זיין מוסיף פֿאַר די פאלגענדע", "nowplaying": "איצט פּלייַינג", "NowPlaying": "איצט פּלייַינג", - "Import and Export": "אַרייַנפיר און עקספּאָרט" + "Import and Export": "אַרייַנפיר און עקספּאָרט", + "Import Follows": "אַרייַנפיר גייט" } diff --git a/translations/zh.json b/translations/zh.json index 928ce8e37..702a1019f 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -570,5 +570,6 @@ "Content warnings will be added for the following": "将为以下内容添加内容警告", "nowplaying": "现在玩", "NowPlaying": "现在玩", - "Import and Export": "进出口" + "Import and Export": "进出口", + "Import Follows": "导入关注" } diff --git a/webapp_profile.py b/webapp_profile.py index 70a739a85..585a2741b 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -2003,6 +2003,14 @@ def _html_edit_profile_import_export(nickname: str, domain: str, """Contact Information section of edit profile screen """ edit_profile_form = begin_edit_section(translate['Import and Export']) + + edit_profile_form += \ + '

\n' + edit_profile_form += '