-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from flamingchickens1540/zach/fix
Manager Stuff
- Loading branch information
Showing
16 changed files
with
146 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import config from '~lib/config' | ||
import logger from '~lib/logger' | ||
import prisma from '~lib/prisma' | ||
import { EventMiddleware } from '~slack/lib/types' | ||
|
||
export const handleAppMentioned: EventMiddleware<'app_mention'> = async ({ event, client }) => { | ||
if (event.channel == config.slack.channels.checkin) { | ||
await client.reactions.add({ | ||
channel: event.channel, | ||
timestamp: event.ts, | ||
name: 'stopwatch' | ||
}) | ||
const user = await client.auth.test() | ||
const managers = await prisma.member.findMany({ where: { MemberCerts: { some: { Cert: { isManager: true } } } } }) | ||
const copres_string = config.slack.users.copres.join(',') | ||
for (const manager of managers) { | ||
if (!manager.slack_id) { | ||
logger.warn('No slack id for manager ' + manager.email) | ||
continue | ||
} | ||
const dm = await client.conversations.open({ | ||
users: copres_string + ',' + manager.slack_id | ||
}) | ||
if (dm.channel?.id == null) { | ||
logger.warn('No group dm for manager ' + manager.email) | ||
continue | ||
} | ||
await client.chat.postMessage({ | ||
channel: dm.channel!.id!, | ||
text: event.text.replace(user.user_id!, manager.slack_id) | ||
}) | ||
} | ||
await client.reactions.remove({ | ||
channel: event.channel, | ||
timestamp: event.ts, | ||
name: 'stopwatch' | ||
}) | ||
await client.reactions.add({ | ||
channel: event.channel, | ||
timestamp: event.ts, | ||
name: 'white_check_mark' | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Prisma } from '@prisma/client' | ||
import config from '~lib/config' | ||
import logger from '~lib/logger' | ||
import prisma from '~lib/prisma' | ||
import { emitCluckChange } from '~lib/sockets' | ||
import { slack_client } from '~slack' | ||
import responses from '~slack/blocks/responses' | ||
|
||
export async function promptCheckinMessage() { | ||
await slack_client.chat.postMessage({ | ||
channel: config.slack.channels.checkin, | ||
text: "<!channel> it's that time again! Make a checkin post" | ||
}) | ||
} | ||
|
||
export async function logoutAll() { | ||
const loggedIn = await prisma.hourLog.findMany({ | ||
where: { | ||
state: 'pending', | ||
type: 'lab' | ||
}, | ||
select: { time_in: true, Member: { select: { slack_id: true, email: true } } } | ||
}) | ||
for (const log of loggedIn) { | ||
try { | ||
const slack_id = log.Member.slack_id | ||
emitCluckChange({ email: log.Member.email, logging_in: false }) | ||
if (slack_id) { | ||
await slack_client.chat.postMessage({ | ||
...responses.autoSignoutDM({ slack_id, time_in: log.time_in }), | ||
channel: slack_id | ||
}) | ||
} | ||
} catch (e) { | ||
logger.warn(e) | ||
} | ||
} | ||
await prisma.hourLog.updateMany({ | ||
where: { | ||
state: 'pending', | ||
type: 'lab' | ||
}, | ||
data: { | ||
state: 'cancelled', | ||
time_out: new Date(), | ||
duration: new Prisma.Decimal(0) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters