2020-09-01 20:56:37 +00:00
|
|
|
/* global storage, _ */
|
2018-07-07 00:48:14 +00:00
|
|
|
|
|
|
|
// eslint-disable-next-line func-names
|
2018-04-27 21:25:04 +00:00
|
|
|
(function() {
|
|
|
|
'use strict';
|
2018-07-07 00:48:14 +00:00
|
|
|
|
2018-09-13 19:57:07 +00:00
|
|
|
const BLOCKED_NUMBERS_ID = 'blocked';
|
2020-03-05 21:14:58 +00:00
|
|
|
const BLOCKED_UUIDS_ID = 'blocked-uuids';
|
2018-09-13 19:57:07 +00:00
|
|
|
const BLOCKED_GROUPS_ID = 'blocked-groups';
|
|
|
|
|
2018-07-07 00:48:14 +00:00
|
|
|
storage.isBlocked = number => {
|
2018-09-13 19:57:07 +00:00
|
|
|
const numbers = storage.get(BLOCKED_NUMBERS_ID, []);
|
2018-01-30 02:14:39 +00:00
|
|
|
|
2018-04-27 21:25:04 +00:00
|
|
|
return _.include(numbers, number);
|
|
|
|
};
|
2018-07-07 00:48:14 +00:00
|
|
|
storage.addBlockedNumber = number => {
|
2018-09-13 19:57:07 +00:00
|
|
|
const numbers = storage.get(BLOCKED_NUMBERS_ID, []);
|
2018-04-27 21:25:04 +00:00
|
|
|
if (_.include(numbers, number)) {
|
|
|
|
return;
|
|
|
|
}
|
2018-01-30 02:14:39 +00:00
|
|
|
|
2018-07-21 19:00:08 +00:00
|
|
|
window.log.info('adding', number, 'to blocked list');
|
2018-09-13 19:57:07 +00:00
|
|
|
storage.put(BLOCKED_NUMBERS_ID, numbers.concat(number));
|
2018-04-27 21:25:04 +00:00
|
|
|
};
|
2018-07-07 00:48:14 +00:00
|
|
|
storage.removeBlockedNumber = number => {
|
2018-09-13 19:57:07 +00:00
|
|
|
const numbers = storage.get(BLOCKED_NUMBERS_ID, []);
|
2018-04-27 21:25:04 +00:00
|
|
|
if (!_.include(numbers, number)) {
|
|
|
|
return;
|
|
|
|
}
|
2018-01-30 02:14:39 +00:00
|
|
|
|
2018-07-21 19:00:08 +00:00
|
|
|
window.log.info('removing', number, 'from blocked list');
|
2018-09-13 19:57:07 +00:00
|
|
|
storage.put(BLOCKED_NUMBERS_ID, _.without(numbers, number));
|
|
|
|
};
|
|
|
|
|
2020-03-05 21:14:58 +00:00
|
|
|
storage.isUuidBlocked = uuid => {
|
|
|
|
const uuids = storage.get(BLOCKED_UUIDS_ID, []);
|
|
|
|
|
|
|
|
return _.include(uuids, uuid);
|
|
|
|
};
|
|
|
|
storage.addBlockedUuid = uuid => {
|
|
|
|
const uuids = storage.get(BLOCKED_UUIDS_ID, []);
|
|
|
|
if (_.include(uuids, uuid)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
window.log.info('adding', uuid, 'to blocked list');
|
|
|
|
storage.put(BLOCKED_UUIDS_ID, uuids.concat(uuid));
|
|
|
|
};
|
|
|
|
storage.removeBlockedUuid = uuid => {
|
|
|
|
const numbers = storage.get(BLOCKED_UUIDS_ID, []);
|
|
|
|
if (!_.include(numbers, uuid)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
window.log.info('removing', uuid, 'from blocked list');
|
2020-09-01 20:56:37 +00:00
|
|
|
storage.put(BLOCKED_UUIDS_ID, _.without(numbers, uuid));
|
2020-03-05 21:14:58 +00:00
|
|
|
};
|
|
|
|
|
2018-09-13 19:57:07 +00:00
|
|
|
storage.isGroupBlocked = groupId => {
|
|
|
|
const groupIds = storage.get(BLOCKED_GROUPS_ID, []);
|
|
|
|
|
|
|
|
return _.include(groupIds, groupId);
|
|
|
|
};
|
|
|
|
storage.addBlockedGroup = groupId => {
|
|
|
|
const groupIds = storage.get(BLOCKED_GROUPS_ID, []);
|
|
|
|
if (_.include(groupIds, groupId)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
window.log.info(`adding groupId(${groupId}) to blocked list`);
|
|
|
|
storage.put(BLOCKED_GROUPS_ID, groupIds.concat(groupId));
|
|
|
|
};
|
|
|
|
storage.removeBlockedGroup = groupId => {
|
|
|
|
const groupIds = storage.get(BLOCKED_GROUPS_ID, []);
|
|
|
|
if (!_.include(groupIds, groupId)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
window.log.info(`removing group(${groupId} from blocked list`);
|
|
|
|
storage.put(BLOCKED_GROUPS_ID, _.without(groupIds, groupId));
|
2018-04-27 21:25:04 +00:00
|
|
|
};
|
2016-09-07 00:12:45 +00:00
|
|
|
})();
|