Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

[WIP] Remove blacklist #188

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 0 additions & 43 deletions features/api/usersettings/blacklist.feature

This file was deleted.

38 changes: 0 additions & 38 deletions features/step_definitions/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ let currentUserPassword;
let httpResponse;
let currentUserAccessToken;
let lastPost;
let blacklistedUser;

function authenticate(email, plainTextPassword) {
const formData = {
Expand Down Expand Up @@ -131,34 +130,6 @@ When('you create your user settings via POST request to {string} with:', functio
postRequest(route, JSON.stringify(jsonBody), callback);
});

Then('you will stop seeing posts of the user with id {string}', function (blacklistedUserId) {
return this.app.service('usersettings').find({userId: currentUser._id.toString()}).then((settings) => {
expect(settings.total).to.eq(1);
expect(settings.data[0].blacklist).to.be.an('array').that.does.include(blacklistedUserId);
});
});

Given('you blacklisted the user {string} before', async function (blacklistedUserName) {
const res = await this.app.service('users').find({query: {name: blacklistedUserName}});
blacklistedUser = res.data[0];
const params = {
userId: currentUser._id,
blacklist: [blacklistedUser._id]
};
return this.app.service('usersettings').create(params);
});

When('this user publishes a post', function () {
const params = {
title: 'Awful title',
content: 'disgusting content',
language: 'en',
type: 'post',
userId: blacklistedUser._id
};
return this.app.service('contributions').create(params);
});

When('you read your current news feed', function (callback) {
getRequest('/contributions', callback);
});
Expand All @@ -181,15 +152,6 @@ Given('there is a post {string} by user {string}', async function (postTitle, us
return lastPost;
});

Given('the blacklisted user wrote a comment on that post:', function (comment) {
const commentParams = {
userId: blacklistedUser._id,
content: comment,
contributionId: lastPost._id
};
return this.app.service('comments').create(commentParams);
});

When('you read through the comments of that post', function (callback) {
getRequest('/comments', callback);
});
Expand Down
40 changes: 0 additions & 40 deletions server/hooks/conceal-blacklisted-data.js

This file was deleted.

27 changes: 0 additions & 27 deletions server/hooks/exclude-blacklisted.js

This file was deleted.

1 change: 0 additions & 1 deletion server/models/usersettings.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module.exports = function (app) {
const mongooseClient = app.get('mongooseClient');
const usersettings = new mongooseClient.Schema({
userId: {type: String, required: true, unique: true},
blacklist: {type: Array, default: []},
uiLanguage: {type: String, required: true},
contentLanguages: {type: Array, default: []},
filter: {
Expand Down
19 changes: 2 additions & 17 deletions server/services/comments/comments.hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const {
const { isVerified } = require('feathers-authentication-management').hooks;
const createExcerpt = require('../../hooks/create-excerpt');
const patchDeletedData = require('../../hooks/patch-deleted-data');
const concealBlacklistedData = require('../../hooks/conceal-blacklisted-data');
const keepDeletedDataFields = require('../../hooks/keep-deleted-data-fields');
const createNotifications = require('./hooks/create-notifications');
const createMentionNotifications = require('./hooks/create-mention-notifications');
Expand Down Expand Up @@ -119,24 +118,10 @@ module.exports = {
],
find: [
populate({ schema: userSchema }),
protect('content', 'badgeIds'),
concealBlacklistedData({
data: {
content: 'Comments of this blacklisted user are not visible.',
contentExcerpt: 'Comments of this blacklisted user are not visible.',
hasMore: false
}
})
protect('content', 'badgeIds')
],
get: [
populate({ schema: userSchema }),
concealBlacklistedData({
data: {
content: 'Comments of this blacklisted user are not visible.',
contentExcerpt: 'Comments of this blacklisted user are not visible.',
hasMore: false
}
})
populate({ schema: userSchema })
],
create: [
populate({ schema: userSchema }),
Expand Down
2 changes: 0 additions & 2 deletions server/services/contributions/contributions.hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const search = require('feathers-mongodb-fuzzy-search');
const thumbnails = require('../../hooks/thumbnails');
const isModerator = require('../../hooks/is-moderator-boolean');
const excludeDisabled = require('../../hooks/exclude-disabled');
const excludeBlacklisted = require('../../hooks/exclude-blacklisted');
const getAssociatedCanDos = require('./hooks/get-associated-can-dos');
const createMentionNotifications = require('./hooks/create-mention-notifications');
const notifyFollowers = require('./hooks/notify-followers');
Expand Down Expand Up @@ -114,7 +113,6 @@ module.exports = {
unless(isModerator(),
excludeDisabled()
),
excludeBlacklisted(),
when(isProvider('server'),
includeAll()
),
Expand Down
24 changes: 0 additions & 24 deletions server/services/usersettings/hooks/validate-blacklist.js

This file was deleted.

5 changes: 0 additions & 5 deletions server/services/usersettings/usersettings.hooks.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { restrictToOwner } = require('feathers-authentication-hooks');
const mapCreateToUpsert = require('../../hooks/map-create-to-upsert');
const validateBlacklist = require('./hooks/validate-blacklist');
const { authenticate } = require('@feathersjs/authentication').hooks;

module.exports = {
Expand All @@ -10,25 +9,21 @@ module.exports = {
get: [],
create: [
authenticate('jwt'),
validateBlacklist(),
mapCreateToUpsert(context => {
const { data } = context;
return { userId: data.userId };
})
],
update: [
authenticate('jwt'),
validateBlacklist(),
restrictToOwner()
],
patch: [
authenticate('jwt'),
validateBlacklist(),
restrictToOwner()
],
remove: [
authenticate('jwt'),
validateBlacklist(),
restrictToOwner()
]
},
Expand Down
66 changes: 0 additions & 66 deletions test/hooks/exclude-blacklisted.test.js

This file was deleted.

Loading