3 const assert = require('assert');
4 const mongoUtils = require('gitter-web-persistence-utils/lib/mongo-utils');
6 // Super basic Ethereum spam detection
7 // - `0x31999626cDc00c877530b64c209707Ad0ED556fE`
8 // - `0x519040d1Daa5Ab78b9C87F825A38b5464Cd3828d`
9 const ETH_SPAM_RE = /^0x[0-9a-f]{40}$/i;
11 function detectDirtyGroup(targetGroupId, dirtyGroupList = []) {
16 return dirtyGroupList.some(groupId => {
17 return mongoUtils.objectIDsEqual(groupId, targetGroupId);
21 async function detect({
23 // List of groups that we should clean Ethereum spam in
31 if (!dirtyGroupList || dirtyGroupList.length === 0) {
35 const isDirtyGroup = await detectDirtyGroup(groupId, dirtyGroupList);
41 return ETH_SPAM_RE.test(text);
44 module.exports = detect;