mirror of https://gitgud.io/fatchan/jschan.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
397 B
25 lines
397 B
5 years ago
|
'use strict';
|
||
|
|
||
5 years ago
|
module.exports = (posts) => {
|
||
5 years ago
|
|
||
5 years ago
|
// filter to ones not spoilered
|
||
5 years ago
|
const filteredPosts = posts.filter(post => {
|
||
5 years ago
|
return !post.spoiler && post.files.length > 0;
|
||
5 years ago
|
});
|
||
|
|
||
5 years ago
|
if (filteredPosts.length === 0) {
|
||
|
return {
|
||
5 years ago
|
message:'No post(s) to spoiler'
|
||
5 years ago
|
};
|
||
|
}
|
||
5 years ago
|
|
||
5 years ago
|
return {
|
||
|
message: `Spoilered ${filteredPosts.length} post(s)`,
|
||
|
action: '$set',
|
||
|
query: {
|
||
|
'spoiler': true
|
||
|
}
|
||
|
};
|
||
5 years ago
|
|
||
|
}
|