[fedi] comment/instance/user moderation

This commit is contained in:
les
2019-11-13 10:56:01 +01:00
parent fe9057e343
commit c944541d04
20 changed files with 545 additions and 177 deletions

View File

@@ -17,7 +17,7 @@
ul.tags(v-if='showTags && event.tags')
li(v-for='tag in event.tags' :key='tag') {{tag}}
li(v-if='settings.enable_federation && event.comments && event.comments.length') <u>{{$tc('common.comments', event.comments.length)}}</u>
li(v-if='settings.enable_federation && event.comments && event.comments.length') <u>{{$tc('common.resources', event.comments.length)}}</u>
</template>
<script>
import { mapState, mapActions } from 'vuex'

View File

@@ -66,8 +66,8 @@ export default {
try {
this.loading = true
await this.$auth.loginWith('local', { data: { email: this.email, password: this.password } })
const user = await this.$axios.get('/auth/user')
this.$auth.setUser(user.data)
const user = await this.$axios.$get('/auth/user')
this.$auth.setUser(user)
this.loading = false
Message({ message: this.$t('login.ok'), showClose: true, type: 'success' })
this.close()

View File

@@ -13,33 +13,56 @@
span.ml-1(slot='reference')
i.el-icon-info
el-form-item(v-show='enable_federation' :label="$t('admin.disable_gamification')")
el-form-item(v-show='enable_federation' :label="$t('admin.hide_boost_bookmark')")
el-switch(v-model='disable_gamification')
el-popover(:content="$t('admin.disable_gamification_help')" trigger='hover')
el-popover(:content="$t('admin.hide_boost_bookmark_help')" trigger='hover')
span.ml-1(slot='reference')
i.el-icon-info
el-row(v-if='enable_federation')
el-col(:span='12')
el-divider {{$t('common.instances')}}
el-table(:data='paginatedInstances' small @row-click='instanceSelected')
el-table-column(label='Domain' width='200')
template(slot-scope='data')
span(slot='reference') <img class='instance_thumb' :src="data.row.data.thumbnail"/> {{data.row.domain}}
el-table-column(label='Name' width='100')
template(slot-scope='data')
span(slot='reference') {{data.row.name}}
el-table-column(label='Users' width='70')
template(slot-scope='data')
span(slot='reference') {{data.row.users}}
el-table-column(:label="$t('common.actions')" width='100')
template(slot-scope='data')
el-button-group
el-button(size='mini'
:type='data.row.blocked?"danger":"warning"'
@click='toggleBlock(data.row)') {{data.row.blocked?$t('admin.unblock'):$t('admin.block')}}
client-only
el-pagination(v-if='enable_federation && instances.length>perPage' :page-size='perPage' :currentPage.sync='instancePage' :total='instances.length')
el-col(:span='12')
el-divider {{$t('common.users')}}
el-table(:data='paginatedSelectedUsers' small)
el-table-column(label='User' width='200')
template(slot-scope='data')
span(slot='reference') <img v-if='data.row.object.icon' class='instance_thumb' :src="data.row.object.icon.url"/>
a(:href='data.row.object.id' target='_blank') {{data.row.object.name}}
el-table-column(:label="$t('admin.comments')" width='70')
template(slot-scope='data')
span {{data.row.comments.length}}
el-table-column(:label="$t('common.actions')" width='200')
template(slot-scope='data')
el-button-group
el-button(size='mini'
:type='data.row.blocked?"danger":"warning"'
@click='toggleUserBlock(data.row)') {{data.row.blocked?$t('admin.unblock'):$t('admin.block')}}
client-only
el-pagination(v-if='enable_federation && instances.length>perPage' :page-size='perPage' :currentPage.sync='instancePage' :total='instances.length')
el-divider(v-if='enable_federation') {{$t('common.instances')}}
el-table(v-if='enable_federation' :data='paginatedInstances' small)
el-table-column(label='Domain' width='250')
template(slot-scope='data')
span(slot='reference') <img class='instance_thumb' :src="data.row.data.thumbnail"/> {{data.row.domain}}
el-table-column(label='Name' width='150')
template(slot-scope='data')
span(slot='reference') {{data.row.name}}
el-table-column(label='Users' width='150')
template(slot-scope='data')
span(slot='reference') {{data.row.users}}
el-table-column(:label="$t('common.actions')" width='200')
template(slot-scope='data')
el-button-group
el-button(size='mini'
:type='data.row.blocked?"danger":"warning"'
@click='toggleBlock(data.row)') {{data.row.blocked?$t('admin.unblock_instance'):$t('admin.block_instance')}}
client-only
el-pagination(v-if='enable_federation && instances.length>perPage' :page-size='perPage' :currentPage.sync='instancePage' :total='instances.length')
</template>
<script>
@@ -51,14 +74,24 @@ export default {
data () {
return {
perPage: 10,
instancePage: 1
instancePage: 1,
userPage: 1,
selectedInstance: null,
users: [],
}
},
methods: {
...mapActions(['setSetting']),
async instanceSelected (instance) {
this.users = await this.$axios.$get(`/instances/${instance.domain}`)
},
async toggleBlock (instance) {
await this.$axios.post('/instances/toggle_block', { instance: instance.domain, blocked: !instance.blocked })
instance.blocked = !instance.blocked
},
async toggleUserBlock (user) {
await this.$axios.post('/instances/toggle_user_block', { user_id: user.ap_id })
user.blocked = !user.blocked
}
},
computed: {
@@ -67,6 +100,10 @@ export default {
return this.instances.slice((this.instancePage - 1) * this.perPage,
this.instancePage * this.perPage)
},
paginatedSelectedUsers () {
return this.users.slice((this.userPage - 1) * this.perPage,
this.userPage * this.perPage)
},
enable_federation: {
get () { return this.settings.enable_federation },
set (value) { this.setSetting({ key: 'enable_federation', value }) }