pavelk2 / social-feed

JavaScript plugin that shows a user feed from the most popular social networks
http://pavelk2.github.io/social-feed-example/
MIT License
960 stars 303 forks source link

Moderation: more than one word in filter/ #59

Closed andyUA closed 8 years ago

andyUA commented 9 years ago

How to add more than one word in moderation filter?

pavelk2 commented 9 years ago

moderation - is a regular javascript function, which if returns true - the post is visible, if returns false the post is hidden. So you can design this function in whatever fashion you feel comfortable. You might consider using arrays.

moderation: function(content) {
    allow = true;
    if (content.text) {
        var keywords = ["bad word1", "bad word2", "bad word3"];
        for (var i = 0; i < keywords.length && allow; i++) {
            if (content.text.indexOf(keywords[i]) != -1) {
                allow = false;
            }
        }
    }
    return allow;
}