Import follows csv from profile screen

merge-requests/30/head
Bob Mottram 2022-07-21 10:58:28 +01:00
parent 8c522a78b7
commit 1cda2d740e
28 changed files with 83 additions and 31 deletions

View File

@ -1411,7 +1411,8 @@ def save_media_in_form_post(media_bytes, debug: bool,
'ogg': 'audio/ogg', 'ogg': 'audio/ogg',
'opus': 'audio/opus', 'opus': 'audio/opus',
'flac': 'audio/flac', 'flac': 'audio/flac',
'zip': 'application/zip' 'zip': 'application/zip',
'csv': 'text/csv'
} }
detected_extension = None detected_extension = None
for extension, content_type in extension_list.items(): 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() svg_str = svg_str.decode()
if dangerous_svg(svg_str, False): if dangerous_svg(svg_str, False):
return None, None 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: try:
with open(filename, 'wb') as fp_media: with open(filename, 'wb') as fp_media:

View File

@ -5505,6 +5505,7 @@ class PubServer(BaseHTTPRequestHandler):
'banner', 'search_banner', 'banner', 'search_banner',
'instanceLogo', 'instanceLogo',
'left_col_image', 'right_col_image', 'left_col_image', 'right_col_image',
'submitImportFollows'
'submitImportTheme' 'submitImportTheme'
) )
profile_media_types_uploaded = {} profile_media_types_uploaded = {}
@ -5518,18 +5519,18 @@ class PubServer(BaseHTTPRequestHandler):
if debug: if debug:
print('DEBUG: profile update extracting ' + m_type + print('DEBUG: profile update extracting ' + m_type +
' image, zip or font from POST') ' image, zip, csv or font from POST')
media_bytes, post_bytes = \ media_bytes, post_bytes = \
extract_media_in_form_post(post_bytes, boundary, m_type) extract_media_in_form_post(post_bytes, boundary, m_type)
if media_bytes: if media_bytes:
if debug: if debug:
print('DEBUG: profile update ' + m_type + print('DEBUG: profile update ' + m_type +
' image, zip or font was found. ' + ' image, zip, csv or font was found. ' +
str(len(media_bytes)) + ' bytes') str(len(media_bytes)) + ' bytes')
else: else:
if debug: if debug:
print('DEBUG: profile update, no ' + m_type + 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 continue
# Note: a .temp extension is used here so that at no # Note: a .temp extension is used here so that at no
@ -5549,6 +5550,10 @@ class PubServer(BaseHTTPRequestHandler):
except OSError: except OSError:
print('EX: _profile_edit unable to delete ' + print('EX: _profile_edit unable to delete ' +
filename_base) filename_base)
elif m_type == 'submitImportFollows':
filename_base = \
acct_dir(base_dir, nickname, domain) + \
'/import_following.csv'
else: else:
filename_base = \ filename_base = \
acct_dir(base_dir, nickname, domain) + \ acct_dir(base_dir, nickname, domain) + \
@ -5559,10 +5564,18 @@ class PubServer(BaseHTTPRequestHandler):
filename_base) filename_base)
if filename: if filename:
print('Profile update POST ' + m_type + print('Profile update POST ' + m_type +
' media, zip or font filename is ' + filename) ' media, zip, csv or font filename is ' + filename)
else: else:
print('Profile update, no ' + m_type + 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 continue
if m_type == 'submitImportTheme': if m_type == 'submitImportTheme':

View File

@ -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 Follows": "يتبع الاستيراد"
} }

View File

@ -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 Follows": "আমদানি অনুসরণ করে"
} }

View File

@ -570,5 +570,6 @@
"Content warnings will be added for the following": "S'afegiran advertències de contingut per al següent", "Content warnings will be added for the following": "S'afegiran advertències de contingut per al següent",
"nowplaying": "arajugant", "nowplaying": "arajugant",
"NowPlaying": "AraJugant", "NowPlaying": "AraJugant",
"Import and Export": "Importació i Exportació" "Import and Export": "Importació i Exportació",
"Import Follows": "Segueix la importació"
} }

View File

@ -570,5 +570,6 @@
"Content warnings will be added for the following": "Bydd rhybuddion cynnwys yn cael eu hychwanegu ar gyfer y canlynol", "Content warnings will be added for the following": "Bydd rhybuddion cynnwys yn cael eu hychwanegu ar gyfer y canlynol",
"nowplaying": "nawrynchwarae", "nowplaying": "nawrynchwarae",
"NowPlaying": "NawrYnChwarae", "NowPlaying": "NawrYnChwarae",
"Import and Export": "Mewnforio ac Allforio" "Import and Export": "Mewnforio ac Allforio",
"Import Follows": "Mewnforio Dilyn"
} }

View File

@ -570,5 +570,6 @@
"Content warnings will be added for the following": "Inhaltswarnungen werden für Folgendes hinzugefügt", "Content warnings will be added for the following": "Inhaltswarnungen werden für Folgendes hinzugefügt",
"nowplaying": "läuftgerade", "nowplaying": "läuftgerade",
"NowPlaying": "LäuftGerade", "NowPlaying": "LäuftGerade",
"Import and Export": "Import und Export" "Import and Export": "Import und Export",
"Import Follows": "Import folgt"
} }

View File

@ -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 Follows": "Ακολουθεί εισαγωγή"
} }

View File

@ -570,5 +570,6 @@
"Content warnings will be added for the following": "Content warnings will be added for the following", "Content warnings will be added for the following": "Content warnings will be added for the following",
"nowplaying": "nowplaying", "nowplaying": "nowplaying",
"NowPlaying": "NowPlaying", "NowPlaying": "NowPlaying",
"Import and Export": "Import and Export" "Import and Export": "Import and Export",
"Import Follows": "Import Follows"
} }

View File

@ -570,5 +570,6 @@
"Content warnings will be added for the following": "Se agregarán advertencias de contenido para lo siguiente", "Content warnings will be added for the following": "Se agregarán advertencias de contenido para lo siguiente",
"nowplaying": "jugandoahora", "nowplaying": "jugandoahora",
"NowPlaying": "JugandoAhora", "NowPlaying": "JugandoAhora",
"Import and Export": "Importar y exportar" "Import and Export": "Importar y exportar",
"Import Follows": "Importar seguimientos"
} }

View File

@ -570,5 +570,6 @@
"Content warnings will be added for the following": "Des avertissements de contenu seront ajoutés pour les éléments suivants", "Content warnings will be added for the following": "Des avertissements de contenu seront ajoutés pour les éléments suivants",
"nowplaying": "lectureencours", "nowplaying": "lectureencours",
"NowPlaying": "LectureEnCours", "NowPlaying": "LectureEnCours",
"Import and Export": "Importer et exporter" "Import and Export": "Importer et exporter",
"Import Follows": "Importer suit"
} }

View File

@ -570,5 +570,6 @@
"Content warnings will be added for the following": "Cuirfear rabhaidh ábhair leis maidir leis na nithe seo a leanas", "Content warnings will be added for the following": "Cuirfear rabhaidh ábhair leis maidir leis na nithe seo a leanas",
"nowplaying": "anoisagimirt", "nowplaying": "anoisagimirt",
"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"
} }

View File

@ -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 Follows": "आयात का अनुसरण करता है"
} }

View File

@ -570,5 +570,6 @@
"Content warnings will be added for the following": "Verranno aggiunti avvisi sui contenuti per quanto segue", "Content warnings will be added for the following": "Verranno aggiunti avvisi sui contenuti per quanto segue",
"nowplaying": "ora giocando", "nowplaying": "ora giocando",
"NowPlaying": "OraGiocando", "NowPlaying": "OraGiocando",
"Import and Export": "Importazione e esportazione" "Import and Export": "Importazione e esportazione",
"Import Follows": "Importa segue"
} }

View File

@ -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 Follows": "インポートフォロー"
} }

View File

@ -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 Follows": "가져오기 팔로우"
} }

View File

@ -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", "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",
"NowPlaying": "NihaDilîze", "NowPlaying": "NihaDilîze",
"Import and Export": "Import û Export" "Import and Export": "Import û Export",
"Import Follows": "Import Follows"
} }

View File

@ -570,5 +570,6 @@
"Content warnings will be added for the following": "Er worden inhoudswaarschuwingen toegevoegd voor het volgende:", "Content warnings will be added for the following": "Er worden inhoudswaarschuwingen toegevoegd voor het volgende:",
"nowplaying": "nuaanhetspelen", "nowplaying": "nuaanhetspelen",
"NowPlaying": "NuAanHetSpelen", "NowPlaying": "NuAanHetSpelen",
"Import and Export": "Importeren en exporteren" "Import and Export": "Importeren en exporteren",
"Import Follows": "Volgt importeren"
} }

View File

@ -566,5 +566,6 @@
"Content warnings will be added for the following": "Content warnings will be added for the following", "Content warnings will be added for the following": "Content warnings will be added for the following",
"nowplaying": "nowplaying", "nowplaying": "nowplaying",
"NowPlaying": "NowPlaying", "NowPlaying": "NowPlaying",
"Import and Export": "Import and Export" "Import and Export": "Import and Export",
"Import Follows": "Import Follows"
} }

View File

@ -570,5 +570,6 @@
"Content warnings will be added for the following": "Ostrzeżenia dotyczące treści zostaną dodane do następujących", "Content warnings will be added for the following": "Ostrzeżenia dotyczące treści zostaną dodane do następujących",
"nowplaying": "terazgra", "nowplaying": "terazgra",
"NowPlaying": "TerazGra", "NowPlaying": "TerazGra",
"Import and Export": "Importuj i eksportuj" "Import and Export": "Importuj i eksportuj",
"Import Follows": "Importuj obserwuje"
} }

View File

@ -570,5 +570,6 @@
"Content warnings will be added for the following": "Avisos de conteúdo serão adicionados para os seguintes", "Content warnings will be added for the following": "Avisos de conteúdo serão adicionados para os seguintes",
"nowplaying": "agorajogando", "nowplaying": "agorajogando",
"NowPlaying": "AgoraJogando", "NowPlaying": "AgoraJogando",
"Import and Export": "Importar e exportar" "Import and Export": "Importar e exportar",
"Import Follows": "Importar seguidores"
} }

View File

@ -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 Follows": "Импорт подписок"
} }

View File

@ -570,5 +570,6 @@
"Content warnings will be added for the following": "Maonyo ya maudhui yataongezwa kwa yafuatayo", "Content warnings will be added for the following": "Maonyo ya maudhui yataongezwa kwa yafuatayo",
"nowplaying": "inachezasasa", "nowplaying": "inachezasasa",
"NowPlaying": "InachezaSasa", "NowPlaying": "InachezaSasa",
"Import and Export": "Ingiza na Hamisha" "Import and Export": "Ingiza na Hamisha",
"Import Follows": "Ingiza Inafuata"
} }

View File

@ -570,5 +570,6 @@
"Content warnings will be added for the following": "Aşağıdakiler için içerik uyarıları eklenecek", "Content warnings will be added for the following": "Aşağıdakiler için içerik uyarıları eklenecek",
"nowplaying": "şimdioynuyor", "nowplaying": "şimdioynuyor",
"NowPlaying": "ŞimdiOynuyor", "NowPlaying": "ŞimdiOynuyor",
"Import and Export": "İthalat ve ihracat" "Import and Export": "İthalat ve ihracat",
"Import Follows": "Takipleri İçe Aktar"
} }

View File

@ -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 Follows": "Імпорт слідує"
} }

View File

@ -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 Follows": "אַרייַנפיר גייט"
} }

View File

@ -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 Follows": "导入关注"
} }

View File

@ -2003,6 +2003,14 @@ def _html_edit_profile_import_export(nickname: str, domain: str,
"""Contact Information section of edit profile screen """Contact Information section of edit profile screen
""" """
edit_profile_form = begin_edit_section(translate['Import and Export']) edit_profile_form = begin_edit_section(translate['Import and Export'])
edit_profile_form += \
'<p><label class="labels">' + \
translate['Import Follows'] + '</label>\n'
edit_profile_form += '<input type="file" id="import_follows" '
edit_profile_form += 'name="submitImportFollows" '
edit_profile_form += 'accept=".csv"></p>\n'
edit_profile_form += \ edit_profile_form += \
'<p><a href="/users/' + nickname + \ '<p><a href="/users/' + nickname + \
'/followingaccounts"><label class="labels">' + \ '/followingaccounts"><label class="labels">' + \