From 213aa0b475c8d336b60a474c40a3d99ae7108392 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sun, 28 Mar 2021 23:24:56 -0400 Subject: [PATCH 1/3] 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 Date: Mon, 29 Mar 2021 01:53:48 -0400 Subject: [PATCH 2/3] send notifications to mailing list for documentation approval --- src/api/board.ins/routes/root.ts | 40 ++++++++++++++++++++++++++++++++ src/events/messageReactionAdd.ts | 29 +++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/src/api/board.ins/routes/root.ts b/src/api/board.ins/routes/root.ts index 3d8219f..9b5c970 100644 --- a/src/api/board.ins/routes/root.ts +++ b/src/api/board.ins/routes/root.ts @@ -62,6 +62,26 @@ export default class Root extends Route { case 'eo': title = 'Executive Order'; color = 0xff00a7; + this.server.client.util.transporter.sendMail({ + to: 'all-staff@lists.libraryofcode.org', + from: 'Board Register System ', + text: ` + EXECUTIVE ORDER ${id} + + ISSUED BY: + ${director.member.username}, ${director.user.pn.join(', ')} + + SUBJECT: + ${payload.subject} + + BODY: + ${payload.body} + + _____________________________________________________________________ + LIBRARY OF CODE SP-US | BOARD OF DIRECTORS + BOARD REGISTER SYSTEM https://board.ins/ + `, + }); break; case 'motion': @@ -77,6 +97,26 @@ export default class Root extends Route { case 'res': title = 'Resolution'; color = 0x27b17a; + this.server.client.util.transporter.sendMail({ + to: 'all-staff@lists.libraryofcode.org', + from: 'Board Register System ', + text: ` + RESOLUTION ${id} + + SPONSOR: + ${director.member.username}, ${director.user.pn.join(', ')} + + SUBJECT: + ${payload.subject} + + BODY: + ${payload.body} + + _____________________________________________________________________ + LIBRARY OF CODE SP-US | BOARD OF DIRECTORS + BOARD REGISTER SYSTEM https://board.ins/ + `, + }); break; case 'confirmMotion': diff --git a/src/events/messageReactionAdd.ts b/src/events/messageReactionAdd.ts index 5beeb44..8542d5a 100644 --- a/src/events/messageReactionAdd.ts +++ b/src/events/messageReactionAdd.ts @@ -1,3 +1,4 @@ +/* eslint-disable newline-per-chained-call */ import { Emoji, GuildTextableChannel, Member, Message } from 'eris'; import { Client, Event, RichEmbed } from '../class'; @@ -101,6 +102,34 @@ export default class MessageReactionAdd extends Event { embed.setFooter('Library of Code sp-us | Board Register System', 'https://static.libraryofcode.org/library_of_code.png'); embed.setTimestamp(); + this.client.util.transporter.sendMail({ + to: 'all-staff@lists.libraryofcode.org', + from: 'Board Register System ', + subject: `Proclamation ${proc.oID}`, + text: ` + PROCLAMATION ${proc.oID} + + SPONSOR: + ${message.embeds[0].author.name.split('#').slice(0, 1)}, ${message.embeds[0].author.name.split('#').slice(1).join(' ').split(', ').slice(1).join(', ')} + + VOTING RESULTS: + YEA: ${proc.results.yea} + NAY: ${proc.results.nay} + PRESENT ${proc.results.present} + + SUBJECT: + ${proc.subject} + + BODY: + ${proc.body} + + + _____________________________________________________________________ + LIBRARY OF CODE SP-US | BOARD OF DIRECTORS + BOARD REGISTER SYSTEM https://board.ins/ + `, + }); + await message.channel.createMessage({ embed }); } } From f68fff2a8b583b20a4e90fbfcbb03d3cdeee8f1e Mon Sep 17 00:00:00 2001 From: Matthew R Date: Mon, 29 Mar 2021 02:04:12 -0400 Subject: [PATCH 3/3] updates --- src/api/board.ins/routes/root.ts | 2 ++ src/events/messageReactionAdd.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/api/board.ins/routes/root.ts b/src/api/board.ins/routes/root.ts index 9b5c970..675cd71 100644 --- a/src/api/board.ins/routes/root.ts +++ b/src/api/board.ins/routes/root.ts @@ -65,6 +65,7 @@ export default class Root extends Route { this.server.client.util.transporter.sendMail({ to: 'all-staff@lists.libraryofcode.org', from: 'Board Register System ', + subject: `EXECUTIVE ORDER ${id}`, text: ` EXECUTIVE ORDER ${id} @@ -100,6 +101,7 @@ export default class Root extends Route { this.server.client.util.transporter.sendMail({ to: 'all-staff@lists.libraryofcode.org', from: 'Board Register System ', + subject: `RESOLUTION ${id}`, text: ` RESOLUTION ${id} diff --git a/src/events/messageReactionAdd.ts b/src/events/messageReactionAdd.ts index 8542d5a..e8e9837 100644 --- a/src/events/messageReactionAdd.ts +++ b/src/events/messageReactionAdd.ts @@ -105,7 +105,7 @@ export default class MessageReactionAdd extends Event { this.client.util.transporter.sendMail({ to: 'all-staff@lists.libraryofcode.org', from: 'Board Register System ', - subject: `Proclamation ${proc.oID}`, + subject: `PROCLAMATION ${proc.oID}`, text: ` PROCLAMATION ${proc.oID}