From 213aa0b475c8d336b60a474c40a3d99ae7108392 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 28 Mar 2021 23:24:56 -0400 Subject: [PATCH] auto-conf for adding/removal of members to ALL-STAFF maling list --- src/class/Util.ts | 27 +++++++++++++++++++++++++++ src/intervals/departmentPager.ts | 12 ++++++++++++ src/intervals/score.ts | 15 --------------- 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/src/class/Util.ts b/src/class/Util.ts index 2b1b82e..2b41975 100644 --- a/src/class/Util.ts +++ b/src/class/Util.ts @@ -1,4 +1,5 @@ /* eslint-disable no-bitwise */ +import axios from 'axios'; import nodemailer from 'nodemailer'; import childProcess from 'child_process'; import { promisify } from 'util'; @@ -46,6 +47,32 @@ export default class Util { }; } + public async addUserToMailingList(email: string, list: string) { + try { + const { data } = await axios({ + method: 'POST', + url: `localhost:2161/list/${list}/`, + params: { auth: this.client.config.internalKey, email }, + }); + return true; + } catch { + return false; + } + } + + public async removeUserFromMailingList(email: string, list: string) { + try { + const { data } = await axios({ + method: 'DELETE', + url: `localhost:2161/list/${list}/`, + params: { auth: this.client.config.internalKey, email }, + }); + return true; + } catch { + return false; + } + } + public hrn(number: any, fixed: number, formatter: any | any[]) { const builtInFormatters = { en: ['KMGTPEZY'.split(''), 1e3], diff --git a/src/intervals/departmentPager.ts b/src/intervals/departmentPager.ts index 003ed4b..0f7a1e8 100644 --- a/src/intervals/departmentPager.ts +++ b/src/intervals/departmentPager.ts @@ -91,31 +91,43 @@ export default async function departmentPager(client: Client): Promise