mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 23:35:58 +00:00
Convert block/unblock to blacklist/whitelist
- at the moment, we have implemented blocked like we want the blacklist/whitelistUserContent to be, with the exception that is should not be both ways. If I blacklist a user's content, they still see my content in their news feed.
This commit is contained in:
parent
df4c469c5c
commit
c297b83f87
@ -99,7 +99,7 @@ export default shield(
|
||||
Badge: allow,
|
||||
PostsEmotionsCountByEmotion: allow,
|
||||
PostsEmotionsByCurrentUser: isAuthenticated,
|
||||
blockedUsers: isAuthenticated,
|
||||
blacklistedUsers: isAuthenticated,
|
||||
notifications: isAuthenticated,
|
||||
Donations: isAuthenticated,
|
||||
},
|
||||
@ -135,8 +135,8 @@ export default shield(
|
||||
resetPassword: allow,
|
||||
AddPostEmotions: isAuthenticated,
|
||||
RemovePostEmotions: isAuthenticated,
|
||||
block: isAuthenticated,
|
||||
unblock: isAuthenticated,
|
||||
blacklistUserContent: isAuthenticated,
|
||||
whitelistUserContent: isAuthenticated,
|
||||
markAsRead: isAuthenticated,
|
||||
AddEmailAddress: isAuthenticated,
|
||||
VerifyEmailAddress: isAuthenticated,
|
||||
|
||||
@ -78,6 +78,12 @@ module.exports = {
|
||||
target: 'User',
|
||||
direction: 'out',
|
||||
},
|
||||
blacklisted: {
|
||||
type: 'relationship',
|
||||
relationship: 'BLACKLISTED',
|
||||
target: 'User',
|
||||
direction: 'out',
|
||||
},
|
||||
notifications: {
|
||||
type: 'relationship',
|
||||
relationship: 'NOTIFIED',
|
||||
|
||||
@ -1,24 +1,21 @@
|
||||
import uuid from 'uuid/v4'
|
||||
import { neo4jgraphql } from 'neo4j-graphql-js'
|
||||
import fileUpload from './fileUpload'
|
||||
import { getBlockedUsers, getBlockedByUsers } from './users.js'
|
||||
import { getBlacklistedUsers } from './users.js'
|
||||
import { mergeWith, isArray, isEmpty } from 'lodash'
|
||||
import { UserInputError } from 'apollo-server'
|
||||
import Resolver from './helpers/Resolver'
|
||||
|
||||
const filterForBlockedUsers = async (params, context) => {
|
||||
const filterForBlacklistedUsers = async (params, context) => {
|
||||
if (!context.user) return params
|
||||
const [blockedUsers, blockedByUsers] = await Promise.all([
|
||||
getBlockedUsers(context),
|
||||
getBlockedByUsers(context),
|
||||
])
|
||||
const badIds = [...blockedByUsers.map(b => b.id), ...blockedUsers.map(b => b.id)]
|
||||
if (!badIds.length) return params
|
||||
const [blacklistedUsers] = await Promise.all([getBlacklistedUsers(context)])
|
||||
const blacklistedUsersIds = [...blacklistedUsers.map(user => user.id)]
|
||||
if (!blacklistedUsersIds.length) return params
|
||||
|
||||
params.filter = mergeWith(
|
||||
params.filter,
|
||||
{
|
||||
author_not: { id_in: badIds },
|
||||
author_not: { id_in: blacklistedUsersIds },
|
||||
},
|
||||
(objValue, srcValue) => {
|
||||
if (isArray(objValue)) {
|
||||
@ -42,16 +39,16 @@ const maintainPinnedPosts = params => {
|
||||
export default {
|
||||
Query: {
|
||||
Post: async (object, params, context, resolveInfo) => {
|
||||
params = await filterForBlockedUsers(params, context)
|
||||
params = await filterForBlacklistedUsers(params, context)
|
||||
params = await maintainPinnedPosts(params)
|
||||
return neo4jgraphql(object, params, context, resolveInfo)
|
||||
},
|
||||
findPosts: async (object, params, context, resolveInfo) => {
|
||||
params = await filterForBlockedUsers(params, context)
|
||||
params = await filterForBlacklistedUsers(params, context)
|
||||
return neo4jgraphql(object, params, context, resolveInfo)
|
||||
},
|
||||
profilePagePosts: async (object, params, context, resolveInfo) => {
|
||||
params = await filterForBlockedUsers(params, context)
|
||||
params = await filterForBlacklistedUsers(params, context)
|
||||
return neo4jgraphql(object, params, context, resolveInfo)
|
||||
},
|
||||
PostsEmotionsCountByEmotion: async (object, params, context, resolveInfo) => {
|
||||
|
||||
@ -8,42 +8,26 @@ import createOrUpdateLocations from './users/location'
|
||||
|
||||
const neode = getNeode()
|
||||
|
||||
export const getBlockedUsers = async context => {
|
||||
export const getBlacklistedUsers = async context => {
|
||||
const { neode } = context
|
||||
const userModel = neode.model('User')
|
||||
let blockedUsers = neode
|
||||
let blacklistedUsers = neode
|
||||
.query()
|
||||
.match('user', userModel)
|
||||
.where('user.id', context.user.id)
|
||||
.relationship(userModel.relationships().get('blocked'))
|
||||
.to('blocked', userModel)
|
||||
.return('blocked')
|
||||
blockedUsers = await blockedUsers.execute()
|
||||
blockedUsers = blockedUsers.records.map(r => r.get('blocked').properties)
|
||||
return blockedUsers
|
||||
}
|
||||
|
||||
export const getBlockedByUsers = async context => {
|
||||
if (context.user.role === 'moderator' || context.user.role === 'admin') return []
|
||||
const { neode } = context
|
||||
const userModel = neode.model('User')
|
||||
let blockedByUsers = neode
|
||||
.query()
|
||||
.match('user', userModel)
|
||||
.relationship(userModel.relationships().get('blocked'))
|
||||
.to('blocked', userModel)
|
||||
.where('blocked.id', context.user.id)
|
||||
.return('user')
|
||||
blockedByUsers = await blockedByUsers.execute()
|
||||
blockedByUsers = blockedByUsers.records.map(r => r.get('user').properties)
|
||||
return blockedByUsers
|
||||
.relationship(userModel.relationships().get('blacklisted'))
|
||||
.to('blacklisted', userModel)
|
||||
.return('blacklisted')
|
||||
blacklistedUsers = await blacklistedUsers.execute()
|
||||
blacklistedUsers = blacklistedUsers.records.map(r => r.get('blacklisted').properties)
|
||||
return blacklistedUsers
|
||||
}
|
||||
|
||||
export default {
|
||||
Query: {
|
||||
blockedUsers: async (object, args, context, resolveInfo) => {
|
||||
blacklistedUsers: async (object, args, context, resolveInfo) => {
|
||||
try {
|
||||
return getBlockedUsers(context)
|
||||
return getBlacklistedUsers(context)
|
||||
} catch (e) {
|
||||
throw new UserInputError(e.message)
|
||||
}
|
||||
@ -72,6 +56,36 @@ export default {
|
||||
},
|
||||
},
|
||||
Mutation: {
|
||||
blacklistUserContent: async (_parent, params, context, _resolveInfo) => {
|
||||
const { user: currentUser } = context
|
||||
if (currentUser.id === params.id) return null
|
||||
await neode.cypher(
|
||||
`
|
||||
MATCH(u:User {id: $currentUser.id})-[previousRelationship:FOLLOWS]->(b:User {id: $params.id})
|
||||
DELETE previousRelationship
|
||||
`,
|
||||
{ currentUser, params },
|
||||
)
|
||||
const [user, blacklistedUser] = await Promise.all([
|
||||
neode.find('User', currentUser.id),
|
||||
neode.find('User', params.id),
|
||||
])
|
||||
await user.relateTo(blacklistedUser, 'blacklisted')
|
||||
return blacklistedUser.toJson()
|
||||
},
|
||||
whitelistUserContent: async (_parent, params, context, _resolveInfo) => {
|
||||
const { user: currentUser } = context
|
||||
if (currentUser.id === params.id) return null
|
||||
await neode.cypher(
|
||||
`
|
||||
MATCH(u:User {id: $currentUser.id})-[previousRelationship:BLACKLISTED]->(b:User {id: $params.id})
|
||||
DELETE previousRelationship
|
||||
`,
|
||||
{ currentUser, params },
|
||||
)
|
||||
const whitelistedUser = await neode.find('User', params.id)
|
||||
return whitelistedUser.toJson()
|
||||
},
|
||||
block: async (object, args, context, resolveInfo) => {
|
||||
const { user: currentUser } = context
|
||||
if (currentUser.id === args.id) return null
|
||||
@ -217,6 +231,8 @@ export default {
|
||||
'MATCH (this)<-[:FOLLOWS]-(u:User {id: $cypherParams.currentUserId}) RETURN COUNT(u) >= 1',
|
||||
isBlocked:
|
||||
'MATCH (this)<-[:BLOCKED]-(u:User {id: $cypherParams.currentUserId}) RETURN COUNT(u) >= 1',
|
||||
isBlacklisted:
|
||||
'MATCH (this)<-[:BLACKLISTED]-(u:User {id: $cypherParams.currentUserId}) RETURN COUNT(u) >= 1',
|
||||
},
|
||||
count: {
|
||||
contributionsCount:
|
||||
|
||||
@ -9,7 +9,7 @@ const factory = Factory()
|
||||
const neode = getNeode()
|
||||
|
||||
let currentUser
|
||||
let blockedUser
|
||||
let blacklistedUser
|
||||
let authenticatedUser
|
||||
let server
|
||||
|
||||
@ -33,15 +33,15 @@ afterEach(async () => {
|
||||
await factory.cleanDatabase()
|
||||
})
|
||||
|
||||
describe('blockedUsers', () => {
|
||||
let blockedUserQuery
|
||||
describe('blacklistedUsers', () => {
|
||||
let blacklistedUserQuery
|
||||
beforeEach(() => {
|
||||
blockedUserQuery = gql`
|
||||
blacklistedUserQuery = gql`
|
||||
query {
|
||||
blockedUsers {
|
||||
blacklistedUsers {
|
||||
id
|
||||
name
|
||||
isBlocked
|
||||
isBlacklisted
|
||||
}
|
||||
}
|
||||
`
|
||||
@ -49,34 +49,34 @@ describe('blockedUsers', () => {
|
||||
|
||||
it('throws permission error', async () => {
|
||||
const { query } = createTestClient(server)
|
||||
const result = await query({ query: blockedUserQuery })
|
||||
const result = await query({ query: blacklistedUserQuery })
|
||||
expect(result.errors[0]).toHaveProperty('message', 'Not Authorised!')
|
||||
})
|
||||
|
||||
describe('authenticated and given a blocked user', () => {
|
||||
describe('authenticated and given a blacklisted user', () => {
|
||||
beforeEach(async () => {
|
||||
currentUser = await neode.create('User', {
|
||||
name: 'Current User',
|
||||
id: 'u1',
|
||||
})
|
||||
blockedUser = await neode.create('User', {
|
||||
name: 'Blocked User',
|
||||
blacklistedUser = await neode.create('User', {
|
||||
name: 'Blacklisted User',
|
||||
id: 'u2',
|
||||
})
|
||||
await currentUser.relateTo(blockedUser, 'blocked')
|
||||
await currentUser.relateTo(blacklistedUser, 'blacklisted')
|
||||
authenticatedUser = await currentUser.toJson()
|
||||
})
|
||||
|
||||
it('returns a list of blocked users', async () => {
|
||||
it('returns a list of blacklisted users', async () => {
|
||||
const { query } = createTestClient(server)
|
||||
await expect(query({ query: blockedUserQuery })).resolves.toEqual(
|
||||
await expect(query({ query: blacklistedUserQuery })).resolves.toEqual(
|
||||
expect.objectContaining({
|
||||
data: {
|
||||
blockedUsers: [
|
||||
blacklistedUsers: [
|
||||
{
|
||||
name: 'Blocked User',
|
||||
name: 'Blacklisted User',
|
||||
id: 'u2',
|
||||
isBlocked: true,
|
||||
isBlacklisted: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
@ -86,28 +86,28 @@ describe('blockedUsers', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('block', () => {
|
||||
let blockAction
|
||||
describe('blacklistUserContent', () => {
|
||||
let blacklistAction
|
||||
|
||||
beforeEach(() => {
|
||||
currentUser = undefined
|
||||
blockAction = variables => {
|
||||
blacklistAction = variables => {
|
||||
const { mutate } = createTestClient(server)
|
||||
const blockMutation = gql`
|
||||
const blacklistUserContentMutation = gql`
|
||||
mutation($id: ID!) {
|
||||
block(id: $id) {
|
||||
blacklistUserContent(id: $id) {
|
||||
id
|
||||
name
|
||||
isBlocked
|
||||
isBlacklisted
|
||||
}
|
||||
}
|
||||
`
|
||||
return mutate({ mutation: blockMutation, variables })
|
||||
return mutate({ mutation: blacklistUserContentMutation, variables })
|
||||
}
|
||||
})
|
||||
|
||||
it('throws permission error', async () => {
|
||||
const result = await blockAction({ id: 'u2' })
|
||||
const result = await blacklistAction({ id: 'u2' })
|
||||
expect(result.errors[0]).toHaveProperty('message', 'Not Authorised!')
|
||||
})
|
||||
|
||||
@ -120,45 +120,47 @@ describe('block', () => {
|
||||
authenticatedUser = await currentUser.toJson()
|
||||
})
|
||||
|
||||
describe('block yourself', () => {
|
||||
describe('blacklist yourself', () => {
|
||||
it('returns null', async () => {
|
||||
await expect(blockAction({ id: 'u1' })).resolves.toEqual(
|
||||
expect.objectContaining({ data: { block: null } }),
|
||||
await expect(blacklistAction({ id: 'u1' })).resolves.toEqual(
|
||||
expect.objectContaining({ data: { blacklistUserContent: null } }),
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('block not existing user', () => {
|
||||
describe('blacklist not existing user', () => {
|
||||
it('returns null', async () => {
|
||||
await expect(blockAction({ id: 'u2' })).resolves.toEqual(
|
||||
expect.objectContaining({ data: { block: null } }),
|
||||
await expect(blacklistAction({ id: 'u2' })).resolves.toEqual(
|
||||
expect.objectContaining({ data: { blacklistUserContent: null } }),
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('given a to-be-blocked user', () => {
|
||||
describe('given a to-be-blacklisted user', () => {
|
||||
beforeEach(async () => {
|
||||
blockedUser = await neode.create('User', {
|
||||
name: 'Blocked User',
|
||||
blacklistedUser = await neode.create('User', {
|
||||
name: 'Blacklisted User',
|
||||
id: 'u2',
|
||||
})
|
||||
})
|
||||
|
||||
it('blocks a user', async () => {
|
||||
await expect(blockAction({ id: 'u2' })).resolves.toEqual(
|
||||
it('blacklists a user', async () => {
|
||||
await expect(blacklistAction({ id: 'u2' })).resolves.toEqual(
|
||||
expect.objectContaining({
|
||||
data: { block: { id: 'u2', name: 'Blocked User', isBlocked: true } },
|
||||
data: {
|
||||
blacklistUserContent: { id: 'u2', name: 'Blacklisted User', isBlacklisted: true },
|
||||
},
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
it('unfollows the user', async () => {
|
||||
await currentUser.relateTo(blockedUser, 'following')
|
||||
await currentUser.relateTo(blacklistedUser, 'following')
|
||||
const queryUser = gql`
|
||||
query {
|
||||
User(id: "u2") {
|
||||
id
|
||||
isBlocked
|
||||
isBlacklisted
|
||||
followedByCurrentUser
|
||||
}
|
||||
}
|
||||
@ -166,18 +168,18 @@ describe('block', () => {
|
||||
const { query } = createTestClient(server)
|
||||
await expect(query({ query: queryUser })).resolves.toEqual(
|
||||
expect.objectContaining({
|
||||
data: { User: [{ id: 'u2', isBlocked: false, followedByCurrentUser: true }] },
|
||||
data: { User: [{ id: 'u2', isBlacklisted: false, followedByCurrentUser: true }] },
|
||||
}),
|
||||
)
|
||||
await blockAction({ id: 'u2' })
|
||||
await blacklistAction({ id: 'u2' })
|
||||
await expect(query({ query: queryUser })).resolves.toEqual(
|
||||
expect.objectContaining({
|
||||
data: { User: [{ id: 'u2', isBlocked: true, followedByCurrentUser: false }] },
|
||||
data: { User: [{ id: 'u2', isBlacklisted: true, followedByCurrentUser: false }] },
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
describe('given both the current user and the to-be-blocked user write a post', () => {
|
||||
describe('given both the current user and the to-be-blacklisted user write a post', () => {
|
||||
let postQuery
|
||||
|
||||
beforeEach(async () => {
|
||||
@ -187,11 +189,11 @@ describe('block', () => {
|
||||
})
|
||||
const post2 = await neode.create('Post', {
|
||||
id: 'p23',
|
||||
title: 'A post written by the blocked user',
|
||||
title: 'A post written by the blacklisted user',
|
||||
})
|
||||
await Promise.all([
|
||||
post1.relateTo(currentUser, 'author'),
|
||||
post2.relateTo(blockedUser, 'author'),
|
||||
post2.relateTo(blacklistedUser, 'author'),
|
||||
])
|
||||
postQuery = gql`
|
||||
query {
|
||||
@ -223,9 +225,9 @@ describe('block', () => {
|
||||
},
|
||||
{
|
||||
id: 'p23',
|
||||
title: 'A post written by the blocked user',
|
||||
title: 'A post written by the blacklisted user',
|
||||
author: {
|
||||
name: 'Blocked User',
|
||||
name: 'Blacklisted User',
|
||||
id: 'u2',
|
||||
},
|
||||
},
|
||||
@ -238,12 +240,12 @@ describe('block', () => {
|
||||
describe('from the perspective of the current user', () => {
|
||||
it('both posts are in the newsfeed', bothPostsAreInTheNewsfeed)
|
||||
|
||||
describe('but if the current user blocks the other user', () => {
|
||||
describe('but if the current user blacklists the other user', () => {
|
||||
beforeEach(async () => {
|
||||
await currentUser.relateTo(blockedUser, 'blocked')
|
||||
await currentUser.relateTo(blacklistedUser, 'blacklisted')
|
||||
})
|
||||
|
||||
it("the blocked user's post won't show up in the newsfeed of the current user", async () => {
|
||||
it("the blacklisted user's post won't show up in the newsfeed of the current user", async () => {
|
||||
const { query } = createTestClient(server)
|
||||
await expect(query({ query: postQuery })).resolves.toEqual(
|
||||
expect.objectContaining({
|
||||
@ -262,29 +264,34 @@ describe('block', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('from the perspective of the blocked user', () => {
|
||||
describe('from the perspective of the blacklisted user', () => {
|
||||
beforeEach(async () => {
|
||||
authenticatedUser = await blockedUser.toJson()
|
||||
authenticatedUser = await blacklistedUser.toJson()
|
||||
})
|
||||
|
||||
it('both posts are in the newsfeed', bothPostsAreInTheNewsfeed)
|
||||
describe('but if the current user blocks the other user', () => {
|
||||
describe('but if the current user blacklists the other user', () => {
|
||||
beforeEach(async () => {
|
||||
await currentUser.relateTo(blockedUser, 'blocked')
|
||||
await currentUser.relateTo(blacklistedUser, 'blacklisted')
|
||||
})
|
||||
|
||||
it("the current user's post won't show up in the newsfeed of the blocked user", async () => {
|
||||
it("the current user's post will show up in the newsfeed of the blacklisted user", async () => {
|
||||
const { query } = createTestClient(server)
|
||||
await expect(query({ query: postQuery })).resolves.toEqual(
|
||||
expect.objectContaining({
|
||||
data: {
|
||||
Post: [
|
||||
Post: expect.arrayContaining([
|
||||
{
|
||||
id: 'p23',
|
||||
title: 'A post written by the blocked user',
|
||||
author: { name: 'Blocked User', id: 'u2' },
|
||||
title: 'A post written by the blacklisted user',
|
||||
author: { name: 'Blacklisted User', id: 'u2' },
|
||||
},
|
||||
],
|
||||
{
|
||||
id: 'p12',
|
||||
title: 'A post written by the current user',
|
||||
author: { name: 'Current User', id: 'u1' },
|
||||
},
|
||||
]),
|
||||
},
|
||||
}),
|
||||
)
|
||||
@ -296,28 +303,28 @@ describe('block', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('unblock', () => {
|
||||
let unblockAction
|
||||
describe('whitelistUserContent', () => {
|
||||
let whitelistAction
|
||||
|
||||
beforeEach(() => {
|
||||
currentUser = undefined
|
||||
unblockAction = variables => {
|
||||
whitelistAction = variables => {
|
||||
const { mutate } = createTestClient(server)
|
||||
const unblockMutation = gql`
|
||||
const whitelistUserContentMutation = gql`
|
||||
mutation($id: ID!) {
|
||||
unblock(id: $id) {
|
||||
whitelistUserContent(id: $id) {
|
||||
id
|
||||
name
|
||||
isBlocked
|
||||
isBlacklisted
|
||||
}
|
||||
}
|
||||
`
|
||||
return mutate({ mutation: unblockMutation, variables })
|
||||
return mutate({ mutation: whitelistUserContentMutation, variables })
|
||||
}
|
||||
})
|
||||
|
||||
it('throws permission error', async () => {
|
||||
const result = await unblockAction({ id: 'u2' })
|
||||
const result = await whitelistAction({ id: 'u2' })
|
||||
expect(result.errors[0]).toHaveProperty('message', 'Not Authorised!')
|
||||
})
|
||||
|
||||
@ -330,59 +337,69 @@ describe('unblock', () => {
|
||||
authenticatedUser = await currentUser.toJson()
|
||||
})
|
||||
|
||||
describe('unblock yourself', () => {
|
||||
describe('whitelist yourself', () => {
|
||||
it('returns null', async () => {
|
||||
await expect(unblockAction({ id: 'u1' })).resolves.toEqual(
|
||||
expect.objectContaining({ data: { unblock: null } }),
|
||||
await expect(whitelistAction({ id: 'u1' })).resolves.toEqual(
|
||||
expect.objectContaining({ data: { whitelistUserContent: null } }),
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('unblock not-existing user', () => {
|
||||
describe('whitelist not-existing user', () => {
|
||||
it('returns null', async () => {
|
||||
await expect(unblockAction({ id: 'lksjdflksfdj' })).resolves.toEqual(
|
||||
expect.objectContaining({ data: { unblock: null } }),
|
||||
await expect(whitelistAction({ id: 'lksjdflksfdj' })).resolves.toEqual(
|
||||
expect.objectContaining({ data: { whitelistUserContent: null } }),
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('given another user', () => {
|
||||
beforeEach(async () => {
|
||||
blockedUser = await neode.create('User', {
|
||||
name: 'Blocked User',
|
||||
blacklistedUser = await neode.create('User', {
|
||||
name: 'Blacklisted User',
|
||||
id: 'u2',
|
||||
})
|
||||
})
|
||||
|
||||
describe('unblocking a not yet blocked user', () => {
|
||||
describe('whitelisting a not yet blacklisted user', () => {
|
||||
it('does not hurt', async () => {
|
||||
await expect(unblockAction({ id: 'u2' })).resolves.toEqual(
|
||||
await expect(whitelistAction({ id: 'u2' })).resolves.toEqual(
|
||||
expect.objectContaining({
|
||||
data: { unblock: { id: 'u2', name: 'Blocked User', isBlocked: false } },
|
||||
data: {
|
||||
whitelistUserContent: { id: 'u2', name: 'Blacklisted User', isBlacklisted: false },
|
||||
},
|
||||
}),
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('given a blocked user', () => {
|
||||
describe('given a blacklisted user', () => {
|
||||
beforeEach(async () => {
|
||||
await currentUser.relateTo(blockedUser, 'blocked')
|
||||
await currentUser.relateTo(blacklistedUser, 'blacklisted')
|
||||
})
|
||||
|
||||
it('unblocks a user', async () => {
|
||||
await expect(unblockAction({ id: 'u2' })).resolves.toEqual(
|
||||
it('whitelists a user', async () => {
|
||||
await expect(whitelistAction({ id: 'u2' })).resolves.toEqual(
|
||||
expect.objectContaining({
|
||||
data: { unblock: { id: 'u2', name: 'Blocked User', isBlocked: false } },
|
||||
data: {
|
||||
whitelistUserContent: { id: 'u2', name: 'Blacklisted User', isBlacklisted: false },
|
||||
},
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
describe('unblocking twice', () => {
|
||||
describe('whitelisting twice', () => {
|
||||
it('has no effect', async () => {
|
||||
await unblockAction({ id: 'u2' })
|
||||
await expect(unblockAction({ id: 'u2' })).resolves.toEqual(
|
||||
await whitelistAction({ id: 'u2' })
|
||||
await expect(whitelistAction({ id: 'u2' })).resolves.toEqual(
|
||||
expect.objectContaining({
|
||||
data: { unblock: { id: 'u2', name: 'Blocked User', isBlocked: false } },
|
||||
data: {
|
||||
whitelistUserContent: {
|
||||
id: 'u2',
|
||||
name: 'Blacklisted User',
|
||||
isBlacklisted: false,
|
||||
},
|
||||
},
|
||||
}),
|
||||
)
|
||||
})
|
||||
@ -75,6 +75,13 @@ type User {
|
||||
"""
|
||||
)
|
||||
|
||||
isBlacklisted: Boolean! @cypher(
|
||||
statement: """
|
||||
MATCH (this)<-[: BLACKLISTED]-(u: User { id: $cypherParams.currentUserId})
|
||||
RETURN COUNT(u) >= 1
|
||||
"""
|
||||
)
|
||||
|
||||
# contributions: [WrittenPost]!
|
||||
# contributions2(first: Int = 10, offset: Int = 0): [WrittenPost2]!
|
||||
# @cypher(
|
||||
@ -160,7 +167,7 @@ type Query {
|
||||
filter: _UserFilter
|
||||
): [User]
|
||||
|
||||
blockedUsers: [User]
|
||||
blacklistedUsers: [User]
|
||||
currentUser: User
|
||||
}
|
||||
|
||||
@ -185,7 +192,8 @@ type Mutation {
|
||||
|
||||
DeleteUser(id: ID!, resource: [Deletable]): User
|
||||
|
||||
|
||||
blacklistUserContent(id: ID!): User
|
||||
whitelistUserContent(id: ID!): User
|
||||
block(id: ID!): User
|
||||
unblock(id: ID!): User
|
||||
}
|
||||
|
||||
@ -226,6 +226,10 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
||||
dewey.relateTo(huey, 'following'),
|
||||
louie.relateTo(jennyRostock, 'following'),
|
||||
|
||||
huey.relateTo(dagobert, 'blacklisted'),
|
||||
dewey.relateTo(dagobert, 'blacklisted'),
|
||||
louie.relateTo(dagobert, 'blacklisted'),
|
||||
|
||||
dagobert.relateTo(huey, 'blocked'),
|
||||
dagobert.relateTo(dewey, 'blocked'),
|
||||
dagobert.relateTo(louie, 'blocked'),
|
||||
|
||||
@ -7,7 +7,7 @@ import { gql } from '../../../backend/src/helpers/jest'
|
||||
let lastReportTitle
|
||||
let davidIrvingPostTitle = 'The Truth about the Holocaust'
|
||||
let davidIrvingPostSlug = 'the-truth-about-the-holocaust'
|
||||
let annoyingUserWhoBlockedModeratorTitle = 'Fake news'
|
||||
let annoyingUserWhoBlacklistedModeratorTitle = 'Fake news'
|
||||
|
||||
const savePostTitle = $post => {
|
||||
return $post
|
||||
@ -147,9 +147,9 @@ Then('I see all the reported posts including the one from above', () => {
|
||||
})
|
||||
})
|
||||
|
||||
Then('I see all the reported posts including from the user who blocked me', () => {
|
||||
Then('I see all the reported posts including from the user who blacklisted me', () => {
|
||||
cy.get('table tbody').within(() => {
|
||||
cy.contains('tr', annoyingUserWhoBlockedModeratorTitle)
|
||||
cy.contains('tr', annoyingUserWhoBlacklistedModeratorTitle)
|
||||
})
|
||||
})
|
||||
|
||||
@ -159,9 +159,9 @@ Then('each list item links to the post page', () => {
|
||||
})
|
||||
|
||||
Then('I can visit the post page', () => {
|
||||
cy.contains(annoyingUserWhoBlockedModeratorTitle).click()
|
||||
cy.contains(annoyingUserWhoBlacklistedModeratorTitle).click()
|
||||
cy.location('pathname').should('contain', '/post')
|
||||
.get('h3').should('contain', annoyingUserWhoBlockedModeratorTitle)
|
||||
.get('h3').should('contain', annoyingUserWhoBlacklistedModeratorTitle)
|
||||
})
|
||||
|
||||
When("they have a post someone has reported", () => {
|
||||
|
||||
@ -420,17 +420,17 @@ Given("there is an annoying user called {string}", name => {
|
||||
});
|
||||
});
|
||||
|
||||
Given("there is an annoying user who has blocked me", () => {
|
||||
Given("there is an annoying user who has blacklisted me", () => {
|
||||
cy.neode()
|
||||
.first("User", {
|
||||
role: 'moderator'
|
||||
})
|
||||
.then(blocked => {
|
||||
.then(blacklisted => {
|
||||
cy.neode()
|
||||
.first("User", {
|
||||
id: 'annoying-user'
|
||||
})
|
||||
.relateTo(blocked, "blocked");
|
||||
.relateTo(blacklisted, "blacklisted");
|
||||
});
|
||||
});
|
||||
|
||||
@ -514,17 +514,17 @@ Given("I wrote a post {string}", title => {
|
||||
});
|
||||
});
|
||||
|
||||
When("I block the user {string}", name => {
|
||||
When("I blacklist the user {string}", name => {
|
||||
cy.neode()
|
||||
.first("User", {
|
||||
name
|
||||
})
|
||||
.then(blocked => {
|
||||
.then(blacklisted => {
|
||||
cy.neode()
|
||||
.first("User", {
|
||||
name: narratorParams.name
|
||||
})
|
||||
.relateTo(blocked, "blocked");
|
||||
.relateTo(blacklisted, "blacklisted");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ Feature: Report and Moderate
|
||||
Given we have the following user accounts:
|
||||
| id | name |
|
||||
| u67 | David Irving |
|
||||
| annoying-user | I'm gonna block Moderators and Admins HA HA HA |
|
||||
| annoying-user | I'm gonna blacklist Moderators and Admins HA HA HA |
|
||||
|
||||
Given we have the following posts in our database:
|
||||
| authorId | id | title | content |
|
||||
@ -58,16 +58,16 @@ Feature: Report and Moderate
|
||||
Then I see all the reported posts including the one from above
|
||||
And each list item links to the post page
|
||||
|
||||
Scenario: Review reported posts of a user who's blocked a moderator
|
||||
Scenario: Review reported posts of a user who's blacklisted a moderator
|
||||
Given somebody reported the following posts:
|
||||
| submitterEmail | resourceId | reasonCategory | reasonDescription |
|
||||
| p2.submitter@example.org | p2 | other | Offensive content |
|
||||
And my user account has the role "moderator"
|
||||
And there is an annoying user who has blocked me
|
||||
And there is an annoying user who has blacklisted me
|
||||
And I am logged in
|
||||
When I click on the avatar menu in the top right corner
|
||||
And I click on "Moderation"
|
||||
Then I see all the reported posts including from the user who blocked me
|
||||
Then I see all the reported posts including from the user who blacklisted me
|
||||
And I can visit the post page
|
||||
|
||||
Scenario: Normal user can't see the moderation page
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Feature: Block a User
|
||||
Feature: Blacklist a User
|
||||
As a user
|
||||
I'd like to have a button to block another user
|
||||
I'd like to have a button to blacklist another user
|
||||
To prevent him from seeing and interacting with my contributions and also to avoid seeing his/her posts
|
||||
|
||||
Background:
|
||||
@ -8,36 +8,36 @@ Feature: Block a User
|
||||
And there is an annoying user called "Spammy Spammer"
|
||||
And I am logged in
|
||||
|
||||
Scenario: Block a user
|
||||
Scenario: Blacklist a user
|
||||
Given I am on the profile page of the annoying user
|
||||
When I click on "Block user" from the content menu in the user info box
|
||||
And I navigate to my "Blocked users" settings page
|
||||
When I click on "Blacklist user" from the content menu in the user info box
|
||||
And I navigate to my "Blacklisted users" settings page
|
||||
Then I can see the following table:
|
||||
| Avatar | Name |
|
||||
| | Spammy Spammer |
|
||||
|
||||
Scenario: Block a previously followed user
|
||||
Scenario: Blacklist a previously followed user
|
||||
Given I follow the user "Spammy Spammer"
|
||||
And "Spammy Spammer" wrote a post "Spam Spam Spam"
|
||||
When I visit the profile page of the annoying user
|
||||
And I click on "Block user" from the content menu in the user info box
|
||||
And I click on "Blacklist user" from the content menu in the user info box
|
||||
Then the list of posts of this user is empty
|
||||
And nobody is following the user profile anymore
|
||||
|
||||
Scenario: Posts of blocked users are filtered from search results
|
||||
Scenario: Posts of blacklisted users are filtered from search results
|
||||
Given we have the following posts in our database:
|
||||
| id | title | content |
|
||||
| im-not-blocked | Post that should be seen | cause I'm not blocked |
|
||||
| im-not-blacklisted | Post that should be seen | cause I'm not blacklisted |
|
||||
Given "Spammy Spammer" wrote a post "Spam Spam Spam"
|
||||
When I search for "Spam"
|
||||
Then I should see the following posts in the select dropdown:
|
||||
| title |
|
||||
| Spam Spam Spam |
|
||||
When I block the user "Spammy Spammer"
|
||||
When I blacklist the user "Spammy Spammer"
|
||||
And I refresh the page
|
||||
And I search for "Spam"
|
||||
Then the search has no results
|
||||
But I search for "not blocked"
|
||||
But I search for "not blacklisted"
|
||||
Then I should see the following posts in the select dropdown:
|
||||
| title |
|
||||
| Post that should be seen |
|
||||
@ -1,4 +1,4 @@
|
||||
Feature: Block a User
|
||||
Feature: Blacklist a User
|
||||
As a user
|
||||
I'd like to have a button to block another user
|
||||
To prevent him from seeing and interacting with my contributions and also to avoid seeing his/her posts
|
||||
@ -7,7 +7,7 @@ Feature: Block a User
|
||||
Given I have a user account
|
||||
And there is an annoying user called "Spammy Spammer"
|
||||
|
||||
Scenario Outline: Blocked users cannot see each others posts
|
||||
Scenario Outline: Blacklisted users cannot see each others posts
|
||||
Given "Spammy Spammer" wrote a post "Spam Spam Spam"
|
||||
And I wrote a post "I hate spammers"
|
||||
And I block the user "Spammy Spammer"
|
||||
@ -407,49 +407,49 @@ describe('ContentMenu.vue', () => {
|
||||
).toBe('/settings')
|
||||
})
|
||||
|
||||
it('can block other users', () => {
|
||||
it('can blacklist other users', () => {
|
||||
const wrapper = openContentMenu({
|
||||
isOwner: false,
|
||||
resourceType: 'user',
|
||||
resource: {
|
||||
id: 'd23a4265-f5f7-4e17-9f86-85f714b4b9f8',
|
||||
isBlocked: false,
|
||||
isBlacklisted: false,
|
||||
},
|
||||
})
|
||||
wrapper
|
||||
.findAll('.ds-menu-item')
|
||||
.filter(item => item.text() === 'settings.blocked-users.block')
|
||||
.filter(item => item.text() === 'settings.blacklisted-users.blacklist')
|
||||
.at(0)
|
||||
.trigger('click')
|
||||
expect(wrapper.emitted('block')).toEqual([
|
||||
expect(wrapper.emitted('blacklist')).toEqual([
|
||||
[
|
||||
{
|
||||
id: 'd23a4265-f5f7-4e17-9f86-85f714b4b9f8',
|
||||
isBlocked: false,
|
||||
isBlacklisted: false,
|
||||
},
|
||||
],
|
||||
])
|
||||
})
|
||||
|
||||
it('can unblock blocked users', () => {
|
||||
it('can whitelist blacklisted users', () => {
|
||||
const wrapper = openContentMenu({
|
||||
isOwner: false,
|
||||
resourceType: 'user',
|
||||
resource: {
|
||||
id: 'd23a4265-f5f7-4e17-9f86-85f714b4b9f8',
|
||||
isBlocked: true,
|
||||
isBlacklisted: true,
|
||||
},
|
||||
})
|
||||
wrapper
|
||||
.findAll('.ds-menu-item')
|
||||
.filter(item => item.text() === 'settings.blocked-users.unblock')
|
||||
.filter(item => item.text() === 'settings.blacklisted-users.whitelist')
|
||||
.at(0)
|
||||
.trigger('click')
|
||||
expect(wrapper.emitted('unblock')).toEqual([
|
||||
expect(wrapper.emitted('whitelist')).toEqual([
|
||||
[
|
||||
{
|
||||
id: 'd23a4265-f5f7-4e17-9f86-85f714b4b9f8',
|
||||
isBlocked: true,
|
||||
isBlacklisted: true,
|
||||
},
|
||||
],
|
||||
])
|
||||
|
||||
@ -150,19 +150,19 @@ export default {
|
||||
icon: 'edit',
|
||||
})
|
||||
} else {
|
||||
if (this.resource.isBlocked) {
|
||||
if (this.resource.isBlacklisted) {
|
||||
routes.push({
|
||||
label: this.$t(`settings.blocked-users.unblock`),
|
||||
label: this.$t(`settings.blacklisted-users.whitelist`),
|
||||
callback: () => {
|
||||
this.$emit('unblock', this.resource)
|
||||
this.$emit('whitelist', this.resource)
|
||||
},
|
||||
icon: 'user-plus',
|
||||
})
|
||||
} else {
|
||||
routes.push({
|
||||
label: this.$t(`settings.blocked-users.block`),
|
||||
label: this.$t(`settings.blacklisted-users.blacklist`),
|
||||
callback: () => {
|
||||
this.$emit('block', this.resource)
|
||||
this.$emit('blacklist', this.resource)
|
||||
},
|
||||
icon: 'user-times',
|
||||
})
|
||||
|
||||
@ -48,7 +48,7 @@ export const user = {
|
||||
],
|
||||
followedByCount: 0,
|
||||
followedByCurrentUser: false,
|
||||
isBlocked: false,
|
||||
isBlacklisted: false,
|
||||
followedBy: [],
|
||||
socialMedia: [],
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@ export default i18n => {
|
||||
locationName
|
||||
createdAt
|
||||
followedByCurrentUser
|
||||
isBlocked
|
||||
isBlacklisted
|
||||
following(first: 7) {
|
||||
...user
|
||||
...userCounts
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const BlockedUsers = () => {
|
||||
export const blacklistedUsers = () => {
|
||||
return gql`
|
||||
{
|
||||
blockedUsers {
|
||||
blacklistedUsers {
|
||||
id
|
||||
name
|
||||
slug
|
||||
@ -16,26 +16,26 @@ export const BlockedUsers = () => {
|
||||
`
|
||||
}
|
||||
|
||||
export const Block = () => {
|
||||
export const blacklistUserContent = () => {
|
||||
return gql`
|
||||
mutation($id: ID!) {
|
||||
block(id: $id) {
|
||||
blacklistUserContent(id: $id) {
|
||||
id
|
||||
name
|
||||
isBlocked
|
||||
isBlacklisted
|
||||
followedByCurrentUser
|
||||
}
|
||||
}
|
||||
`
|
||||
}
|
||||
|
||||
export const Unblock = () => {
|
||||
export const whitelistUserContent = () => {
|
||||
return gql`
|
||||
mutation($id: ID!) {
|
||||
unblock(id: $id) {
|
||||
whitelistUserContent(id: $id) {
|
||||
id
|
||||
name
|
||||
isBlocked
|
||||
isBlacklisted
|
||||
followedByCurrentUser
|
||||
}
|
||||
}
|
||||
@ -145,7 +145,7 @@
|
||||
"successAdd": "Social-Media hinzugefügt. Profil aktualisiert!",
|
||||
"successDelete": "Social-Media gelöscht. Profil aktualisiert!"
|
||||
},
|
||||
"blocked-users": {
|
||||
"blacklisted-users": {
|
||||
"name": "Blockierte Benutzer",
|
||||
"explanation": {
|
||||
"intro": "Wenn ein anderer Benutzer von dir blockiert wurde, dann passiert folgendes:",
|
||||
@ -158,12 +158,12 @@
|
||||
"columns": {
|
||||
"name": "Name",
|
||||
"slug": "Alias",
|
||||
"unblock": "Entsperren"
|
||||
"whitelist": "Entsperren"
|
||||
},
|
||||
"empty": "Bislang hast du niemanden blockiert.",
|
||||
"how-to": "Du kannst andere Benutzer auf deren Profilseite über das Inhaltsmenü blockieren.",
|
||||
"block": "Nutzer blockieren",
|
||||
"unblock": "Nutzer entblocken",
|
||||
"blacklist": "Nutzer blockieren",
|
||||
"whitelist": "Nutzer entblocken",
|
||||
"unblocked": "{name} ist wieder entsperrt"
|
||||
},
|
||||
"privacy": {
|
||||
@ -485,7 +485,7 @@
|
||||
},
|
||||
"teaserImage": {
|
||||
"cropperConfirm": "Bestätigen"
|
||||
},
|
||||
},
|
||||
"inappropriatePicture" : "Dieses Bild kann für einige Menschen unangemessen sein.",
|
||||
"inappropriatePictureText" : "Wann soll ein Foto versteckt werden"
|
||||
},
|
||||
|
||||
@ -309,26 +309,26 @@
|
||||
"successAdd": "Added social media. Updated user profile!",
|
||||
"successDelete": "Deleted social media. Updated user profile!"
|
||||
},
|
||||
"blocked-users": {
|
||||
"name": "Blocked users",
|
||||
"blacklisted-users": {
|
||||
"name": "Blacklisted users",
|
||||
"explanation": {
|
||||
"intro": "If another user has been blocked by you, this is what happens:",
|
||||
"your-perspective": "The blocked person's posts will no longer appear in your news feed.",
|
||||
"their-perspective": "Vice versa: The blocked person will also no longer see your posts in their news feed.",
|
||||
"search": "Posts of blocked people disappear from your search results.",
|
||||
"notifications": "Blocked users will no longer receive notifications if they are mentioned in your posts.",
|
||||
"closing": "This should be sufficient for now so that blocked users can no longer bother you."
|
||||
"intro": "If another user has been blacklisted by you, this is what happens:",
|
||||
"your-perspective": "The blacklisted person's posts will no longer appear in your news feed.",
|
||||
"their-perspective": "However: The blacklisted person will still be able to see your posts in their news feed.",
|
||||
"search": "Posts of blacklisted people disappear from your search results.",
|
||||
"notifications": "Blacklisted users will still receive notifications if they are mentioned in your posts.",
|
||||
"closing": "This should be sufficient for filtering out content from blacklisted users."
|
||||
},
|
||||
"columns": {
|
||||
"name": "Name",
|
||||
"slug": "Slug",
|
||||
"unblock": "Unblock"
|
||||
"whitelist": "Whitelist"
|
||||
},
|
||||
"empty": "So far, you have not blocked anybody.",
|
||||
"how-to": "You can block other users on their profile page via the content menu.",
|
||||
"block": "Block user",
|
||||
"unblock": "Unblock user",
|
||||
"unblocked": "{name} is unblocked again"
|
||||
"empty": "So far, you have not blacklisted anybody.",
|
||||
"how-to": "You can blacklist other users on their profile page via the content menu.",
|
||||
"blacklist": "Blacklist user",
|
||||
"whitelist": "Whitelist user",
|
||||
"whitelisted": "{name} is whitelisted again"
|
||||
}
|
||||
},
|
||||
"admin": {
|
||||
|
||||
@ -145,7 +145,7 @@
|
||||
"successAdd": "Social-Media agregó. Perfil actualizado!",
|
||||
"successDelete": "Social-Media borrado. Perfil actualizado!"
|
||||
},
|
||||
"blocked-users": {
|
||||
"blacklisted-users": {
|
||||
"name": "Usuarios bloqueados",
|
||||
"explanation": {
|
||||
"intro": "Si otro usuario ha sido bloqueado por usted, esto es lo que sucede:",
|
||||
@ -158,12 +158,12 @@
|
||||
"columns": {
|
||||
"name": "Nombre",
|
||||
"slug": "Alias",
|
||||
"unblock": "Desbloquear"
|
||||
"whitelist": "Desbloquear"
|
||||
},
|
||||
"empty": "Hasta ahora, no ha bloqueado a nadie.",
|
||||
"how-to": "Puede bloquear a otros usuarios en la página de perfil de aquellos a través del menú de contenido.",
|
||||
"block": "Bloquear usuario",
|
||||
"unblock": "Desbloquear usuario",
|
||||
"blacklist": "Bloquear usuario",
|
||||
"whitelist": "Desbloquear usuario",
|
||||
"unblocked": "{name} está desbloqueado nuevamente"
|
||||
},
|
||||
"privacy": {
|
||||
|
||||
@ -145,7 +145,7 @@
|
||||
"successAdd": "Les médias sociaux ont été ajoutés. Profil mis à jour !",
|
||||
"successDelete": "Médias sociaux supprimé. Profil mis à jour !"
|
||||
},
|
||||
"blocked-users": {
|
||||
"blacklisted-users": {
|
||||
"name": "Utilisateurs bloqués",
|
||||
"explanation": {
|
||||
"intro": "Si vous avez bloqué un autre utilisateur, voici ce qui se passe:",
|
||||
@ -158,12 +158,12 @@
|
||||
"columns": {
|
||||
"name": "Nom",
|
||||
"slug": "Slug",
|
||||
"unblock": ""
|
||||
"whitelist": ""
|
||||
},
|
||||
"empty": "Jusqu'à présent, vous n'avez bloqué personne.",
|
||||
"how-to": "Vous pouvez bloquer d'autres utilisateurs sur leur page de profil via le menu de contenu.",
|
||||
"block": "Bloquer l'utilisateur",
|
||||
"unblock": "Débloquer l'utilisateur",
|
||||
"blacklist": "Bloquer l'utilisateur",
|
||||
"whitelist": "Débloquer l'utilisateur",
|
||||
"unblocked": "{name} est à nouveau débloqué"
|
||||
},
|
||||
"privacy": {
|
||||
|
||||
@ -145,7 +145,7 @@
|
||||
"successAdd": "Social media aggiunti. \nProfilo utente aggiornato ",
|
||||
"successDelete": "Social media cancellati. Profilo utente aggiornato!"
|
||||
},
|
||||
"blocked-users": {
|
||||
"blacklisted-users": {
|
||||
"name": "",
|
||||
"explanation": {
|
||||
"intro": "",
|
||||
@ -158,12 +158,12 @@
|
||||
"columns": {
|
||||
"name": "",
|
||||
"slug": "",
|
||||
"unblock": ""
|
||||
"whitelist": ""
|
||||
},
|
||||
"empty": "",
|
||||
"how-to": "",
|
||||
"block": "",
|
||||
"unblock": "",
|
||||
"blacklist": "",
|
||||
"whitelist": "",
|
||||
"unblocked": ""
|
||||
},
|
||||
"privacy": {
|
||||
|
||||
@ -145,7 +145,7 @@
|
||||
"successAdd": "Mídias sociais adicionadas. Perfil de usuário atualizado!",
|
||||
"successDelete": "Mídias sociais removidas. Perfil de usuário atualizado!"
|
||||
},
|
||||
"blocked-users": {
|
||||
"blacklisted-users": {
|
||||
"name": "Usuários bloqueados",
|
||||
"explanation": {
|
||||
"intro": "Se outro usuário foi bloqueado por você, isto é o que acontece:",
|
||||
@ -158,12 +158,12 @@
|
||||
"columns": {
|
||||
"name": "Nome",
|
||||
"slug": "Slug",
|
||||
"unblock": "Desbloquear"
|
||||
"whitelist": "Desbloquear"
|
||||
},
|
||||
"empty": "Até agora, você não bloqueou ninguém.",
|
||||
"how-to": "Você pode bloquear outros usuários em suas páginas de perfil através do menu de conteúdo.",
|
||||
"block": "Bloquear usuário",
|
||||
"unblock": "Desbloquear usuário",
|
||||
"blacklist": "Bloquear usuário",
|
||||
"whitelist": "Desbloquear usuário",
|
||||
"unblocked": "{name} está desbloqueado novamente"
|
||||
},
|
||||
"privacy": {
|
||||
@ -749,4 +749,4 @@
|
||||
"donate-now": "Doe agora",
|
||||
"amount-of-total": "{amount} dos {total} € foram coletados"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -596,12 +596,12 @@
|
||||
"placeholder": "Поиск"
|
||||
},
|
||||
"settings": {
|
||||
"blocked-users": {
|
||||
"block": "Блокировать",
|
||||
"blacklisted-users": {
|
||||
"blacklist": "Блокировать",
|
||||
"columns": {
|
||||
"name": "Имя",
|
||||
"slug": "Псевдоним",
|
||||
"unblock": "Разблокировать"
|
||||
"whitelist": "Разблокировать"
|
||||
},
|
||||
"empty": "Вы пока никого не блокировали.",
|
||||
"explanation": {
|
||||
@ -614,7 +614,7 @@
|
||||
},
|
||||
"how-to": "Вы можете блокировать других пользователей на странице их профиля с помощью меню профиля.",
|
||||
"name": "Заблокированные пользователи",
|
||||
"unblock": "Разблокировать пользователей",
|
||||
"whitelist": "Разблокировать пользователей",
|
||||
"unblocked": "{name} - снова разблокирован"
|
||||
},
|
||||
"data": {
|
||||
@ -811,4 +811,4 @@
|
||||
"submitted": "Успешная загрузка!"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,8 +22,8 @@
|
||||
:resource="user"
|
||||
:is-owner="myProfile"
|
||||
class="user-content-menu"
|
||||
@block="block"
|
||||
@unblock="unblock"
|
||||
@blacklist="blacklist"
|
||||
@whitelist="whitelist"
|
||||
/>
|
||||
</client-only>
|
||||
<ds-space margin="small">
|
||||
@ -67,14 +67,14 @@
|
||||
<ds-space margin="small">
|
||||
<template v-if="!myProfile">
|
||||
<hc-follow-button
|
||||
v-if="!user.isBlocked"
|
||||
v-if="!user.isBlacklisted"
|
||||
:follow-id="user.id"
|
||||
:is-followed="user.followedByCurrentUser"
|
||||
@optimistic="optimisticFollow"
|
||||
@update="updateFollow"
|
||||
/>
|
||||
<ds-button v-else fullwidth @click="unblock(user)">
|
||||
{{ $t('settings.blocked-users.unblock') }}
|
||||
<ds-button v-else fullwidth @click="whitelistUserContent(user)">
|
||||
{{ $t('settings.blacklisted-users.whitelist') }}
|
||||
</ds-button>
|
||||
</template>
|
||||
</ds-space>
|
||||
@ -285,7 +285,7 @@ import MasonryGrid from '~/components/MasonryGrid/MasonryGrid.vue'
|
||||
import MasonryGridItem from '~/components/MasonryGrid/MasonryGridItem.vue'
|
||||
import { profilePagePosts } from '~/graphql/PostQuery'
|
||||
import UserQuery from '~/graphql/User'
|
||||
import { Block, Unblock } from '~/graphql/settings/BlockedUsers'
|
||||
import { blacklistUserContent, whitelistUserContent } from '~/graphql/settings/BlacklistedUsers'
|
||||
import PostMutations from '~/graphql/PostMutations'
|
||||
import UpdateQuery from '~/components/utils/UpdateQuery'
|
||||
|
||||
@ -398,14 +398,14 @@ export default {
|
||||
this.posts = []
|
||||
this.hasMore = true
|
||||
},
|
||||
async block(user) {
|
||||
await this.$apollo.mutate({ mutation: Block(), variables: { id: user.id } })
|
||||
async blacklistUserContent(user) {
|
||||
await this.$apollo.mutate({ mutation: blacklistUserContent(), variables: { id: user.id } })
|
||||
this.$apollo.queries.User.refetch()
|
||||
this.resetPostList()
|
||||
this.$apollo.queries.profilePagePosts.refetch()
|
||||
},
|
||||
async unblock(user) {
|
||||
await this.$apollo.mutate({ mutation: Unblock(), variables: { id: user.id } })
|
||||
async whitelistUserContent(user) {
|
||||
await this.$apollo.mutate({ mutation: whitelistUserContent(), variables: { id: user.id } })
|
||||
this.$apollo.queries.User.refetch()
|
||||
this.resetPostList()
|
||||
this.$apollo.queries.profilePagePosts.refetch()
|
||||
|
||||
@ -40,8 +40,8 @@ export default {
|
||||
path: `/settings/my-social-media`,
|
||||
},
|
||||
{
|
||||
name: this.$t('settings.blocked-users.name'),
|
||||
path: `/settings/blocked-users`,
|
||||
name: this.$t('settings.blacklisted-users.name'),
|
||||
path: `/settings/blacklisted-users`,
|
||||
},
|
||||
{
|
||||
name: this.$t('settings.embeds.name'),
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { config, mount, createLocalVue } from '@vue/test-utils'
|
||||
import BlockedUsers from './blocked-users.vue'
|
||||
import BlacklistedUsers from './blacklisted-users.vue'
|
||||
import Styleguide from '@human-connection/styleguide'
|
||||
import Filters from '~/plugins/vue-filters'
|
||||
import { Unblock } from '~/graphql/settings/BlockedUsers'
|
||||
import { whitelistUserContent } from '~/graphql/settings/BlacklistedUsers'
|
||||
|
||||
const localVue = createLocalVue()
|
||||
|
||||
@ -11,7 +11,7 @@ localVue.use(Filters)
|
||||
|
||||
config.stubs['nuxt-link'] = '<span><slot /></span>'
|
||||
|
||||
describe('blocked-users.vue', () => {
|
||||
describe('blacklisted-users.vue', () => {
|
||||
let wrapper
|
||||
let mocks
|
||||
|
||||
@ -21,7 +21,7 @@ describe('blocked-users.vue', () => {
|
||||
$apollo: {
|
||||
mutate: jest.fn(),
|
||||
queries: {
|
||||
blockedUsers: {
|
||||
blacklistedUsers: {
|
||||
refetch: jest.fn(),
|
||||
},
|
||||
},
|
||||
@ -35,7 +35,7 @@ describe('blocked-users.vue', () => {
|
||||
|
||||
describe('mount', () => {
|
||||
const Wrapper = () => {
|
||||
return mount(BlockedUsers, { mocks, localVue })
|
||||
return mount(BlacklistedUsers, { mocks, localVue })
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
@ -48,8 +48,8 @@ describe('blocked-users.vue', () => {
|
||||
|
||||
describe('given a list of blocked users', () => {
|
||||
beforeEach(() => {
|
||||
const blockedUsers = [{ id: 'u1', name: 'John Doe', slug: 'john-doe', avatar: '' }]
|
||||
wrapper.setData({ blockedUsers })
|
||||
const blacklistedUsers = [{ id: 'u1', name: 'John Doe', slug: 'john-doe', avatar: '' }]
|
||||
wrapper.setData({ blacklistedUsers })
|
||||
})
|
||||
|
||||
describe('click unblock', () => {
|
||||
@ -59,7 +59,7 @@ describe('blocked-users.vue', () => {
|
||||
|
||||
it('calls unblock mutation with given user', () => {
|
||||
expect(mocks.$apollo.mutate).toHaveBeenCalledWith({
|
||||
mutation: Unblock(),
|
||||
mutation: whitelistUserContent(),
|
||||
variables: { id: 'u1' },
|
||||
})
|
||||
})
|
||||
@ -1,31 +1,31 @@
|
||||
<template>
|
||||
<div>
|
||||
<ds-space>
|
||||
<ds-card :header="$t('settings.blocked-users.name')">
|
||||
<ds-card :header="$t('settings.blacklisted-users.name')">
|
||||
<ds-text>
|
||||
{{ $t('settings.blocked-users.explanation.intro') }}
|
||||
{{ $t('settings.blacklisted-users.explanation.intro') }}
|
||||
</ds-text>
|
||||
<ds-list>
|
||||
<ds-list-item>
|
||||
{{ $t('settings.blocked-users.explanation.your-perspective') }}
|
||||
{{ $t('settings.blacklisted-users.explanation.your-perspective') }}
|
||||
</ds-list-item>
|
||||
<ds-list-item>
|
||||
{{ $t('settings.blocked-users.explanation.their-perspective') }}
|
||||
{{ $t('settings.blacklisted-users.explanation.their-perspective') }}
|
||||
</ds-list-item>
|
||||
<ds-list-item>
|
||||
{{ $t('settings.blocked-users.explanation.search') }}
|
||||
{{ $t('settings.blacklisted-users.explanation.search') }}
|
||||
</ds-list-item>
|
||||
<ds-list-item>
|
||||
{{ $t('settings.blocked-users.explanation.notifications') }}
|
||||
{{ $t('settings.blacklisted-users.explanation.notifications') }}
|
||||
</ds-list-item>
|
||||
</ds-list>
|
||||
<ds-text>
|
||||
{{ $t('settings.blocked-users.explanation.closing') }}
|
||||
{{ $t('settings.blacklisted-users.explanation.closing') }}
|
||||
</ds-text>
|
||||
</ds-card>
|
||||
</ds-space>
|
||||
<ds-card v-if="blockedUsers && blockedUsers.length">
|
||||
<ds-table :data="blockedUsers" :fields="fields" condensed>
|
||||
<ds-card v-if="blacklistedUsers && blacklistedUsers.length">
|
||||
<ds-table :data="blacklistedUsers" :fields="fields" condensed>
|
||||
<template slot="avatar" slot-scope="scope">
|
||||
<nuxt-link
|
||||
:to="{
|
||||
@ -57,20 +57,22 @@
|
||||
</nuxt-link>
|
||||
</template>
|
||||
|
||||
<template slot="unblock" slot-scope="scope">
|
||||
<ds-button size="small" @click="unblock(scope)"><ds-icon name="user-plus" /></ds-button>
|
||||
<template slot="whitelistUserContent" slot-scope="scope">
|
||||
<ds-button size="small" @click="whitelistUserContent(scope)">
|
||||
<ds-icon name="user-plus" />
|
||||
</ds-button>
|
||||
</template>
|
||||
</ds-table>
|
||||
</ds-card>
|
||||
<ds-card v-else>
|
||||
<ds-space>
|
||||
<ds-placeholder>
|
||||
{{ $t('settings.blocked-users.empty') }}
|
||||
{{ $t('settings.blacklisted-users.empty') }}
|
||||
</ds-placeholder>
|
||||
</ds-space>
|
||||
<ds-space>
|
||||
<ds-text align="center">
|
||||
{{ $t('settings.blocked-users.how-to') }}
|
||||
{{ $t('settings.blacklisted-users.how-to') }}
|
||||
</ds-text>
|
||||
</ds-space>
|
||||
</ds-card>
|
||||
@ -78,7 +80,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { BlockedUsers, Unblock } from '~/graphql/settings/BlockedUsers'
|
||||
import { blacklistedUsers, whitelistUserContent } from '~/graphql/settings/BlacklistedUsers'
|
||||
import HcAvatar from '~/components/Avatar/Avatar.vue'
|
||||
|
||||
export default {
|
||||
@ -87,28 +89,31 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
blockedUsers: [],
|
||||
blacklistedUsers: [],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
fields() {
|
||||
return {
|
||||
avatar: '',
|
||||
name: this.$t('settings.blocked-users.columns.name'),
|
||||
slug: this.$t('settings.blocked-users.columns.slug'),
|
||||
unblock: this.$t('settings.blocked-users.columns.unblock'),
|
||||
name: this.$t('settings.blacklisted-users.columns.name'),
|
||||
slug: this.$t('settings.blacklisted-users.columns.slug'),
|
||||
whitelistUserContent: this.$t('settings.blacklisted-users.columns.unblock'),
|
||||
}
|
||||
},
|
||||
},
|
||||
apollo: {
|
||||
blockedUsers: { query: BlockedUsers, fetchPolicy: 'cache-and-network' },
|
||||
blacklistedUsers: { query: blacklistedUsers, fetchPolicy: 'cache-and-network' },
|
||||
},
|
||||
methods: {
|
||||
async unblock(user) {
|
||||
await this.$apollo.mutate({ mutation: Unblock(), variables: { id: user.row.id } })
|
||||
this.$apollo.queries.blockedUsers.refetch()
|
||||
async whitelistUserContent(user) {
|
||||
await this.$apollo.mutate({
|
||||
mutation: whitelistUserContent(),
|
||||
variables: { id: user.row.id },
|
||||
})
|
||||
this.$apollo.queries.blacklistedUsers.refetch()
|
||||
const { name } = user.row
|
||||
this.$toast.success(this.$t('settings.blocked-users.unblocked', { name }))
|
||||
this.$toast.success(this.$t('settings.blacklisted-users.unblocked', { name }))
|
||||
},
|
||||
},
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user