-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(fix) Force names to send synchronously
Closes #60
- Loading branch information
Showing
2 changed files
with
18 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { VercelRequest, VercelResponse } from '@vercel/node'; | ||
import { connectToDatabase } from './_connectToDatabase'; | ||
import { sendMsg, StandupGroup, Member, About } from './_helpers'; | ||
import { sendMsg, StandupGroup, Member } from './_helpers'; | ||
|
||
module.exports = async (req: VercelRequest, res: VercelResponse) => { | ||
if ( | ||
|
@@ -23,37 +23,18 @@ module.exports = async (req: VercelRequest, res: VercelResponse) => { | |
.find({ submitted: true }) | ||
.toArray(); | ||
|
||
const sentStandup = []; | ||
const sendPromises = []; | ||
users | ||
.filter((g) => !!g.groups.length) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
.forEach((user: Member) => { | ||
This comment has been minimized.
Sorry, something went wrong.
RusseII
Member
|
||
user.groups.forEach((group: StandupGroup) => { | ||
user.groups.forEach(async (group: StandupGroup) => { | ||
const theUpdate = user.updateArchive.slice(-1)[0]; | ||
const type = theUpdate?.type; | ||
const hasEntities = | ||
theUpdate?.body?.message?.entities || | ||
theUpdate?.body?.message?.caption_entities; | ||
|
||
if (!hasEntities && type === 'text') { | ||
sentStandup.push( | ||
sendMsg( | ||
`${user.about.first_name}:`, | ||
group.chatId, | ||
null, | ||
true, | ||
theUpdate | ||
) | ||
); | ||
} else { | ||
sentStandup.push( | ||
sendMsg(`${user.about.first_name}:`, group.chatId, null, true), | ||
sendMsg(``, group.chatId, null, true, theUpdate) | ||
); | ||
} | ||
|
||
await sendMsg(`${user.about.first_name}:`, group.chatId, null, true); | ||
await sendMsg(``, group.chatId, null, true, theUpdate); | ||
}); | ||
}); | ||
|
||
await Promise.all(sentStandup); | ||
if (process.env.NODE_ENV === 'production') { | ||
await markAllSent(); | ||
} | ||
|
1 comment
on commit 1ac8731
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
if you are going to have a useless variable you should just destructure