mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Merge pull request #1510 from Human-Connection/1506-anonymize_deleted_user
1506 Anonymize deleted user also for moderators
This commit is contained in:
commit
80d1e03c03
@ -2,7 +2,7 @@ import { applyMiddleware } from 'graphql-middleware'
|
|||||||
import CONFIG from './../config'
|
import CONFIG from './../config'
|
||||||
|
|
||||||
import activityPub from './activityPubMiddleware'
|
import activityPub from './activityPubMiddleware'
|
||||||
import softDelete from './softDeleteMiddleware'
|
import softDelete from './softDelete/softDeleteMiddleware'
|
||||||
import sluggify from './sluggifyMiddleware'
|
import sluggify from './sluggifyMiddleware'
|
||||||
import excerpt from './excerptMiddleware'
|
import excerpt from './excerptMiddleware'
|
||||||
import dateTime from './dateTimeMiddleware'
|
import dateTime from './dateTimeMiddleware'
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import Factory from '../seed/factories'
|
import Factory from '../../seed/factories'
|
||||||
import { gql } from '../jest/helpers'
|
import { gql } from '../../jest/helpers'
|
||||||
import { neode as getNeode, getDriver } from '../bootstrap/neo4j'
|
import { neode as getNeode, getDriver } from '../../bootstrap/neo4j'
|
||||||
import createServer from '../server'
|
import createServer from '../../server'
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
|
|
||||||
const factory = Factory()
|
const factory = Factory()
|
||||||
@ -59,7 +59,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapGetters, mapMutations } from 'vuex'
|
import { mapGetters, mapMutations } from 'vuex'
|
||||||
import HcUser from '~/components/User'
|
import HcUser from '~/components/User/User'
|
||||||
import ContentMenu from '~/components/ContentMenu'
|
import ContentMenu from '~/components/ContentMenu'
|
||||||
import ContentViewer from '~/components/Editor/ContentViewer'
|
import ContentViewer from '~/components/Editor/ContentViewer'
|
||||||
import HcEditCommentForm from '~/components/EditCommentForm/EditCommentForm'
|
import HcEditCommentForm from '~/components/EditCommentForm/EditCommentForm'
|
||||||
|
|||||||
@ -34,6 +34,7 @@ describe('CommentList.vue', () => {
|
|||||||
}
|
}
|
||||||
store = new Vuex.Store({
|
store = new Vuex.Store({
|
||||||
getters: {
|
getters: {
|
||||||
|
'auth/isModerator': () => false,
|
||||||
'auth/user': () => {
|
'auth/user': () => {
|
||||||
return {}
|
return {}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -86,6 +86,7 @@ describe('ContributionForm.vue', () => {
|
|||||||
'editor/placeholder': () => {
|
'editor/placeholder': () => {
|
||||||
return 'some cool placeholder'
|
return 'some cool placeholder'
|
||||||
},
|
},
|
||||||
|
'auth/isModerator': () => false,
|
||||||
'auth/user': () => {
|
'auth/user': () => {
|
||||||
return {
|
return {
|
||||||
id: '4711',
|
id: '4711',
|
||||||
|
|||||||
@ -79,7 +79,7 @@ import locales from '~/locales'
|
|||||||
import PostMutations from '~/graphql/PostMutations.js'
|
import PostMutations from '~/graphql/PostMutations.js'
|
||||||
import HcCategoriesSelect from '~/components/CategoriesSelect/CategoriesSelect'
|
import HcCategoriesSelect from '~/components/CategoriesSelect/CategoriesSelect'
|
||||||
import HcTeaserImage from '~/components/TeaserImage/TeaserImage'
|
import HcTeaserImage from '~/components/TeaserImage/TeaserImage'
|
||||||
import HcUser from '~/components/User'
|
import HcUser from '~/components/User/User'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
|||||||
@ -55,6 +55,7 @@ describe('FilterPosts.vue', () => {
|
|||||||
}
|
}
|
||||||
getters = {
|
getters = {
|
||||||
'postsFilter/isActive': () => false,
|
'postsFilter/isActive': () => false,
|
||||||
|
'auth/isModerator': () => false,
|
||||||
'auth/user': () => {
|
'auth/user': () => {
|
||||||
return { id: 'u34' }
|
return { id: 'u34' }
|
||||||
},
|
},
|
||||||
|
|||||||
@ -33,13 +33,6 @@ describe('PostCard', () => {
|
|||||||
disabled: false,
|
disabled: false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
store = new Vuex.Store({
|
|
||||||
getters: {
|
|
||||||
'auth/user': () => {
|
|
||||||
return {}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
stubs = {
|
stubs = {
|
||||||
NuxtLink: RouterLinkStub,
|
NuxtLink: RouterLinkStub,
|
||||||
}
|
}
|
||||||
@ -56,6 +49,7 @@ describe('PostCard', () => {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
getters = {
|
getters = {
|
||||||
|
'auth/isModerator': () => false,
|
||||||
'auth/user': () => {
|
'auth/user': () => {
|
||||||
return {}
|
return {}
|
||||||
},
|
},
|
||||||
@ -64,6 +58,7 @@ describe('PostCard', () => {
|
|||||||
|
|
||||||
describe('shallowMount', () => {
|
describe('shallowMount', () => {
|
||||||
Wrapper = () => {
|
Wrapper = () => {
|
||||||
|
store = new Vuex.Store({ getters })
|
||||||
return shallowMount(PostCard, {
|
return shallowMount(PostCard, {
|
||||||
store,
|
store,
|
||||||
propsData,
|
propsData,
|
||||||
|
|||||||
@ -69,7 +69,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import HcUser from '~/components/User'
|
import HcUser from '~/components/User/User'
|
||||||
import ContentMenu from '~/components/ContentMenu'
|
import ContentMenu from '~/components/ContentMenu'
|
||||||
import HcCategory from '~/components/Category'
|
import HcCategory from '~/components/Category'
|
||||||
import HcRibbon from '~/components/Ribbon'
|
import HcRibbon from '~/components/Ribbon'
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { mount, createLocalVue, RouterLinkStub } from '@vue/test-utils'
|
import { mount, createLocalVue, RouterLinkStub } from '@vue/test-utils'
|
||||||
import User from './index'
|
import User from './User.vue'
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex'
|
||||||
import VTooltip from 'v-tooltip'
|
import VTooltip from 'v-tooltip'
|
||||||
import Filters from '~/plugins/vue-filters'
|
import Filters from '~/plugins/vue-filters'
|
||||||
@ -67,6 +67,30 @@ describe('User', () => {
|
|||||||
expect(wrapper.text()).toMatch('Tilda Swinton')
|
expect(wrapper.text()).toMatch('Tilda Swinton')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('user is deleted', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
propsData.user.deleted = true
|
||||||
|
})
|
||||||
|
|
||||||
|
it('renders anonymous user', () => {
|
||||||
|
const wrapper = Wrapper()
|
||||||
|
expect(wrapper.text()).not.toMatch('Tilda Swinton')
|
||||||
|
expect(mocks.$t).toHaveBeenCalledWith('profile.userAnonym')
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('even if the current user is a moderator', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
getters['auth/isModerator'] = () => true
|
||||||
|
})
|
||||||
|
|
||||||
|
it('renders anonymous user', () => {
|
||||||
|
const wrapper = Wrapper()
|
||||||
|
expect(wrapper.text()).not.toMatch('Tilda Swinton')
|
||||||
|
expect(mocks.$t).toHaveBeenCalledWith('profile.userAnonym')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('user is disabled', () => {
|
describe('user is disabled', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
propsData.user.disabled = true
|
propsData.user.disabled = true
|
||||||
@ -1,25 +1,17 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-if="!user || ((user.disabled || user.deleted) && !isModerator)">
|
<div class="user" v-if="displayAnonymous">
|
||||||
<div
|
<hc-avatar />
|
||||||
style="display: inline-block; float: left; margin-right: 4px; height: 100%; vertical-align: middle;"
|
<div>
|
||||||
>
|
<b class="username">{{ $t('profile.userAnonym') }}</b>
|
||||||
<hc-avatar />
|
|
||||||
</div>
|
|
||||||
<div style="display: inline-block; height: 100%; vertical-align: middle;">
|
|
||||||
<b class="username" style="vertical-align: middle;">{{ $t('profile.userAnonym') }}</b>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<dropdown v-else :class="{ 'disabled-content': user.disabled }" placement="top-start" offset="0">
|
<dropdown v-else :class="{ 'disabled-content': user.disabled }" placement="top-start" offset="0">
|
||||||
<template slot="default" slot-scope="{ openMenu, closeMenu, isOpen }">
|
<template slot="default" slot-scope="{ openMenu, closeMenu, isOpen }">
|
||||||
<nuxt-link :to="userLink" :class="['user', isOpen && 'active']">
|
<nuxt-link :to="userLink" :class="['user', isOpen && 'active']">
|
||||||
<div @mouseover="openMenu(true)" @mouseleave="closeMenu(true)">
|
<div @mouseover="openMenu(true)" @mouseleave="closeMenu(true)">
|
||||||
<div
|
<hc-avatar :user="user" />
|
||||||
style="display: inline-block; float: left; margin-right: 4px; height: 100%; vertical-align: middle;"
|
<div>
|
||||||
>
|
<b class="username">{{ userName | truncate(18) }}</b>
|
||||||
<hc-avatar :user="user" />
|
|
||||||
</div>
|
|
||||||
<div style="display: inline-block; height: 100%; vertical-align: middle;">
|
|
||||||
<b class="username" style="vertical-align: middle;">{{ userName | truncate(18) }}</b>
|
|
||||||
</div>
|
</div>
|
||||||
<!-- Time -->
|
<!-- Time -->
|
||||||
<div v-if="dateTime" style="display: inline;">
|
<div v-if="dateTime" style="display: inline;">
|
||||||
@ -125,6 +117,10 @@ export default {
|
|||||||
itsMe() {
|
itsMe() {
|
||||||
return this.user.slug === this.$store.getters['auth/user'].slug
|
return this.user.slug === this.$store.getters['auth/user'].slug
|
||||||
},
|
},
|
||||||
|
displayAnonymous() {
|
||||||
|
const { user, isModerator } = this
|
||||||
|
return !user || user.deleted || (user.disabled && !isModerator)
|
||||||
|
},
|
||||||
userLink() {
|
userLink() {
|
||||||
const { id, slug } = this.user
|
const { id, slug } = this.user
|
||||||
if (!(id && slug)) return ''
|
if (!(id && slug)) return ''
|
||||||
@ -139,6 +135,14 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
.avatar {
|
||||||
|
display: inline-block;
|
||||||
|
float: left;
|
||||||
|
margin-right: 4px;
|
||||||
|
height: 100%;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
.user {
|
.user {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
position: relative;
|
position: relative;
|
||||||
@ -1,10 +1,12 @@
|
|||||||
import { config, mount, createLocalVue, RouterLinkStub } from '@vue/test-utils'
|
import { config, mount, createLocalVue, RouterLinkStub } from '@vue/test-utils'
|
||||||
import Notification from './Notification'
|
import Notification from './Notification.vue'
|
||||||
import Styleguide from '@human-connection/styleguide'
|
import Styleguide from '@human-connection/styleguide'
|
||||||
import Filters from '~/plugins/vue-filters'
|
import Filters from '~/plugins/vue-filters'
|
||||||
|
import Vuex from 'vuex'
|
||||||
|
|
||||||
const localVue = createLocalVue()
|
const localVue = createLocalVue()
|
||||||
|
|
||||||
|
localVue.use(Vuex)
|
||||||
localVue.use(Styleguide)
|
localVue.use(Styleguide)
|
||||||
localVue.use(Filters)
|
localVue.use(Filters)
|
||||||
|
|
||||||
@ -12,6 +14,7 @@ config.stubs['client-only'] = '<span><slot /></span>'
|
|||||||
|
|
||||||
describe('Notification', () => {
|
describe('Notification', () => {
|
||||||
let stubs
|
let stubs
|
||||||
|
let getters
|
||||||
let mocks
|
let mocks
|
||||||
let propsData
|
let propsData
|
||||||
let wrapper
|
let wrapper
|
||||||
@ -23,11 +26,21 @@ describe('Notification', () => {
|
|||||||
stubs = {
|
stubs = {
|
||||||
NuxtLink: RouterLinkStub,
|
NuxtLink: RouterLinkStub,
|
||||||
}
|
}
|
||||||
|
getters = {
|
||||||
|
'auth/user': () => {
|
||||||
|
return {}
|
||||||
|
},
|
||||||
|
'auth/isModerator': () => false,
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const Wrapper = () => {
|
const Wrapper = () => {
|
||||||
|
const store = new Vuex.Store({
|
||||||
|
getters,
|
||||||
|
})
|
||||||
return mount(Notification, {
|
return mount(Notification, {
|
||||||
stubs,
|
stubs,
|
||||||
|
store,
|
||||||
mocks,
|
mocks,
|
||||||
propsData,
|
propsData,
|
||||||
localVue,
|
localVue,
|
||||||
|
|||||||
@ -33,7 +33,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import HcUser from '~/components/User'
|
import HcUser from '~/components/User/User'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Notification',
|
name: 'Notification',
|
||||||
|
|||||||
@ -26,6 +26,7 @@ describe('NotificationList.vue', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
store = new Vuex.Store({
|
store = new Vuex.Store({
|
||||||
getters: {
|
getters: {
|
||||||
|
'auth/isModerator': () => false,
|
||||||
'auth/user': () => {
|
'auth/user': () => {
|
||||||
return {}
|
return {}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -79,7 +79,7 @@ import ContentViewer from '~/components/Editor/ContentViewer'
|
|||||||
import HcCategory from '~/components/Category'
|
import HcCategory from '~/components/Category'
|
||||||
import HcTag from '~/components/Tag'
|
import HcTag from '~/components/Tag'
|
||||||
import ContentMenu from '~/components/ContentMenu'
|
import ContentMenu from '~/components/ContentMenu'
|
||||||
import HcUser from '~/components/User'
|
import HcUser from '~/components/User/User'
|
||||||
import HcShoutButton from '~/components/ShoutButton.vue'
|
import HcShoutButton from '~/components/ShoutButton.vue'
|
||||||
import HcCommentForm from '~/components/CommentForm/CommentForm'
|
import HcCommentForm from '~/components/CommentForm/CommentForm'
|
||||||
import HcCommentList from '~/components/CommentList/CommentList'
|
import HcCommentList from '~/components/CommentList/CommentList'
|
||||||
|
|||||||
@ -68,6 +68,7 @@ describe('ProfileSlug', () => {
|
|||||||
}
|
}
|
||||||
mocks.$store = {
|
mocks.$store = {
|
||||||
getters: {
|
getters: {
|
||||||
|
'auth/isModerator': () => false,
|
||||||
'auth/user': {
|
'auth/user': {
|
||||||
id: 'u23',
|
id: 'u23',
|
||||||
},
|
},
|
||||||
|
|||||||
@ -258,7 +258,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import uniqBy from 'lodash/uniqBy'
|
import uniqBy from 'lodash/uniqBy'
|
||||||
import User from '~/components/User'
|
import User from '~/components/User/User'
|
||||||
import HcPostCard from '~/components/PostCard'
|
import HcPostCard from '~/components/PostCard'
|
||||||
import HcFollowButton from '~/components/FollowButton.vue'
|
import HcFollowButton from '~/components/FollowButton.vue'
|
||||||
import HcCountTo from '~/components/CountTo.vue'
|
import HcCountTo from '~/components/CountTo.vue'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user