forked from AkkomaGang/akkoma-fe
added import/export mutes
This commit is contained in:
parent
fa2b680855
commit
947d7cd6f2
5 changed files with 57 additions and 11 deletions
|
@ -1,4 +0,0 @@
|
||||||
{
|
|
||||||
"target": "https://aqueous-sea-10253.herokuapp.com/",
|
|
||||||
"staticConfigPreference": false
|
|
||||||
}
|
|
|
@ -1,6 +1,7 @@
|
||||||
import Importer from 'src/components/importer/importer.vue'
|
import Importer from 'src/components/importer/importer.vue'
|
||||||
import Exporter from 'src/components/exporter/exporter.vue'
|
import Exporter from 'src/components/exporter/exporter.vue'
|
||||||
import Checkbox from 'src/components/checkbox/checkbox.vue'
|
import Checkbox from 'src/components/checkbox/checkbox.vue'
|
||||||
|
import { mapState } from 'vuex'
|
||||||
|
|
||||||
const DataImportExportTab = {
|
const DataImportExportTab = {
|
||||||
data () {
|
data () {
|
||||||
|
@ -18,21 +19,26 @@ const DataImportExportTab = {
|
||||||
Checkbox
|
Checkbox
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
user () {
|
...mapState({
|
||||||
return this.$store.state.users.currentUser
|
backendInteractor: (state) => state.api.backendInteractor,
|
||||||
}
|
user: (state) => state.users.currentUser
|
||||||
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getFollowsContent () {
|
getFollowsContent () {
|
||||||
return this.$store.state.api.backendInteractor.exportFriends({ id: this.$store.state.users.currentUser.id })
|
return this.backendInteractor.exportFriends({ id: this.user.id })
|
||||||
.then(this.generateExportableUsersContent)
|
.then(this.generateExportableUsersContent)
|
||||||
},
|
},
|
||||||
getBlocksContent () {
|
getBlocksContent () {
|
||||||
return this.$store.state.api.backendInteractor.fetchBlocks()
|
return this.backendInteractor.fetchBlocks()
|
||||||
|
.then(this.generateExportableUsersContent)
|
||||||
|
},
|
||||||
|
getMutesContent () {
|
||||||
|
return this.backendInteractor.fetchMutes()
|
||||||
.then(this.generateExportableUsersContent)
|
.then(this.generateExportableUsersContent)
|
||||||
},
|
},
|
||||||
importFollows (file) {
|
importFollows (file) {
|
||||||
return this.$store.state.api.backendInteractor.importFollows({ file })
|
return this.backendInteractor.importFollows({ file })
|
||||||
.then((status) => {
|
.then((status) => {
|
||||||
if (!status) {
|
if (!status) {
|
||||||
throw new Error('failed')
|
throw new Error('failed')
|
||||||
|
@ -40,7 +46,15 @@ const DataImportExportTab = {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
importBlocks (file) {
|
importBlocks (file) {
|
||||||
return this.$store.state.api.backendInteractor.importBlocks({ file })
|
return this.backendInteractor.importBlocks({ file })
|
||||||
|
.then((status) => {
|
||||||
|
if (!status) {
|
||||||
|
throw new Error('failed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
importMutes (file) {
|
||||||
|
return this.backendInteractor.importMutes({ file })
|
||||||
.then((status) => {
|
.then((status) => {
|
||||||
if (!status) {
|
if (!status) {
|
||||||
throw new Error('failed')
|
throw new Error('failed')
|
||||||
|
|
|
@ -36,6 +36,23 @@
|
||||||
:export-button-label="$t('settings.block_export_button')"
|
:export-button-label="$t('settings.block_export_button')"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="setting-item">
|
||||||
|
<h2>{{ $t('settings.mute_import') }}</h2>
|
||||||
|
<p>{{ $t('settings.import_mutes_from_a_csv_file') }}</p>
|
||||||
|
<Importer
|
||||||
|
:submit-handler="importMutes"
|
||||||
|
:success-message="$t('settings.mutes_imported')"
|
||||||
|
:error-message="$t('settings.mute_import_error')"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="setting-item">
|
||||||
|
<h2>{{ $t('settings.mute_export') }}</h2>
|
||||||
|
<Exporter
|
||||||
|
:get-content="getMutesContent"
|
||||||
|
filename="mutes.csv"
|
||||||
|
:export-button-label="$t('settings.mute_export_button')"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -276,6 +276,12 @@
|
||||||
"block_import": "Block import",
|
"block_import": "Block import",
|
||||||
"block_import_error": "Error importing blocks",
|
"block_import_error": "Error importing blocks",
|
||||||
"blocks_imported": "Blocks imported! Processing them will take a while.",
|
"blocks_imported": "Blocks imported! Processing them will take a while.",
|
||||||
|
"mute_export": "Mute export",
|
||||||
|
"mute_export_button": "Export your mutes to a csv file",
|
||||||
|
"mute_import": "Mute import",
|
||||||
|
"mute_import_error": "Error importing mutes",
|
||||||
|
"mutes_imported": "Mutes imported! Processing them will take a while.",
|
||||||
|
"import_mutes_from_a_csv_file": "Import mutes from a csv file",
|
||||||
"blocks_tab": "Blocks",
|
"blocks_tab": "Blocks",
|
||||||
"bot": "This is a bot account",
|
"bot": "This is a bot account",
|
||||||
"btnRadius": "Buttons",
|
"btnRadius": "Buttons",
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { parseStatus, parseUser, parseNotification, parseAttachment, parseChat,
|
||||||
import { RegistrationError, StatusCodeError } from '../errors/errors'
|
import { RegistrationError, StatusCodeError } from '../errors/errors'
|
||||||
|
|
||||||
/* eslint-env browser */
|
/* eslint-env browser */
|
||||||
|
const MUTES_IMPORT_URL = '/api/pleroma/mutes_import'
|
||||||
const BLOCKS_IMPORT_URL = '/api/pleroma/blocks_import'
|
const BLOCKS_IMPORT_URL = '/api/pleroma/blocks_import'
|
||||||
const FOLLOW_IMPORT_URL = '/api/pleroma/follow_import'
|
const FOLLOW_IMPORT_URL = '/api/pleroma/follow_import'
|
||||||
const DELETE_ACCOUNT_URL = '/api/pleroma/delete_account'
|
const DELETE_ACCOUNT_URL = '/api/pleroma/delete_account'
|
||||||
|
@ -710,6 +711,17 @@ const setMediaDescription = ({ id, description, credentials }) => {
|
||||||
}).then((data) => parseAttachment(data))
|
}).then((data) => parseAttachment(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const importMutes = ({ file, credentials }) => {
|
||||||
|
const formData = new FormData()
|
||||||
|
formData.append('list', file)
|
||||||
|
return fetch(MUTES_IMPORT_URL, {
|
||||||
|
body: formData,
|
||||||
|
method: 'POST',
|
||||||
|
headers: authHeaders(credentials)
|
||||||
|
})
|
||||||
|
.then((response) => response.ok)
|
||||||
|
}
|
||||||
|
|
||||||
const importBlocks = ({ file, credentials }) => {
|
const importBlocks = ({ file, credentials }) => {
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
formData.append('list', file)
|
formData.append('list', file)
|
||||||
|
@ -1280,6 +1292,7 @@ const apiService = {
|
||||||
getCaptcha,
|
getCaptcha,
|
||||||
updateProfileImages,
|
updateProfileImages,
|
||||||
updateProfile,
|
updateProfile,
|
||||||
|
importMutes,
|
||||||
importBlocks,
|
importBlocks,
|
||||||
importFollows,
|
importFollows,
|
||||||
deleteAccount,
|
deleteAccount,
|
||||||
|
|
Loading…
Reference in a new issue