diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js
index fa252e59..c4214744 100644
--- a/src/components/user_settings/user_settings.js
+++ b/src/components/user_settings/user_settings.js
@@ -242,6 +242,14 @@ const UserSettings = {
}
})
},
+ importBlocks (file) {
+ return this.$store.state.api.backendInteractor.importBlocks(file)
+ .then((status) => {
+ if (!status) {
+ throw new Error('failed')
+ }
+ })
+ },
/* This function takes an Array of Users
* and outputs a file with all the addresses for the user to download
*/
diff --git a/src/components/user_settings/user_settings.vue b/src/components/user_settings/user_settings.vue
index fc40bdc0..520a3d8a 100644
--- a/src/components/user_settings/user_settings.vue
+++ b/src/components/user_settings/user_settings.vue
@@ -180,6 +180,11 @@
{{$t('settings.follow_export_processing')}}
+
+
{{$t('settings.block_import')}}
+
{{$t('settings.import_blocks_from_a_csv_file')}}
+
+
diff --git a/src/i18n/en.json b/src/i18n/en.json
index 34d252b2..d4ec1134 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -131,6 +131,9 @@
"avatarRadius": "Avatars",
"background": "Background",
"bio": "Bio",
+ "block_import": "Block import",
+ "block_import_error": "Error importing blocks",
+ "blocks_imported": "Blocks imported! Processing them will take a while.",
"blocks_tab": "Blocks",
"btnRadius": "Buttons",
"cBlue": "Blue (Reply, follow)",
@@ -174,6 +177,7 @@
"hide_post_stats": "Hide post statistics (e.g. the number of favorites)",
"hide_user_stats": "Hide user statistics (e.g. the number of followers)",
"hide_filtered_statuses": "Hide filtered statuses",
+ "import_blocks_from_a_csv_file": "Import blocks from a csv file",
"import_followers_from_a_csv_file": "Import follows from a csv file",
"import_theme": "Load preset",
"inputRadius": "Input fields",
diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js
index dbcde41d..a6892959 100644
--- a/src/services/api/api.service.js
+++ b/src/services/api/api.service.js
@@ -9,6 +9,7 @@ const BANNER_UPDATE_URL = '/api/account/update_profile_banner.json'
const PROFILE_UPDATE_URL = '/api/account/update_profile.json'
const EXTERNAL_PROFILE_URL = '/api/externalprofile/show.json'
const QVITTER_USER_NOTIFICATIONS_READ_URL = '/api/qvitter/statuses/notifications/read.json'
+const BLOCKS_IMPORT_URL = '/api/pleroma/blocks_import'
const FOLLOW_IMPORT_URL = '/api/pleroma/follow_import'
const DELETE_ACCOUNT_URL = '/api/pleroma/delete_account'
const CHANGE_PASSWORD_URL = '/api/pleroma/change_password'
@@ -634,6 +635,17 @@ const uploadMedia = ({formData, credentials}) => {
.then((data) => parseAttachment(data))
}
+const importBlocks = ({file, credentials}) => {
+ const formData = new FormData()
+ formData.append('list', file)
+ return fetch(BLOCKS_IMPORT_URL, {
+ body: formData,
+ method: 'POST',
+ headers: authHeaders(credentials)
+ })
+ .then((response) => response.ok)
+}
+
const importFollows = ({file, credentials}) => {
const formData = new FormData()
formData.append('list', file)
@@ -778,6 +790,7 @@ const apiService = {
updateProfile,
updateBanner,
externalProfile,
+ importBlocks,
importFollows,
deleteAccount,
changePassword,
diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js
index 726c8ced..3256a921 100644
--- a/src/services/backend_interactor_service/backend_interactor_service.js
+++ b/src/services/backend_interactor_service/backend_interactor_service.js
@@ -107,6 +107,7 @@ const backendInteractorService = (credentials) => {
const updateProfile = ({params}) => apiService.updateProfile({credentials, params})
const externalProfile = (profileUrl) => apiService.externalProfile({profileUrl, credentials})
+ const importBlocks = (file) => apiService.importBlocks({file, credentials})
const importFollows = (file) => apiService.importFollows({file, credentials})
const deleteAccount = ({password}) => apiService.deleteAccount({credentials, password})
@@ -147,6 +148,7 @@ const backendInteractorService = (credentials) => {
updateBanner,
updateProfile,
externalProfile,
+ importBlocks,
importFollows,
deleteAccount,
changePassword,