-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set Up Coffee Chat API #635
Conversation
…into set-up-coffee-chat-api
[diff-counting] Significant lines: 243. |
/** | ||
* Deletes all coffee chats for all users | ||
*/ | ||
static async clearAllCoffeeChats(): Promise<void> { |
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.
You should be able to use deleteCollection
here.
idol/backend/src/utils/firebase-utils.ts
Lines 57 to 68 in 95ee0b8
export async function deleteCollection( | |
db: FirebaseFirestore.Firestore, | |
collectionPath: string, | |
batchSize: number | |
): Promise<void> { | |
const collectionRef = db.collection(collectionPath); | |
const query = collectionRef.orderBy('__name__').limit(batchSize); | |
return new Promise((resolve, reject) => { | |
deleteQueryBatch(db, query, resolve).catch(reject); | |
}); | |
} |
backend/src/API/coffeeChatAPI.ts
Outdated
|
||
if ( | ||
!isLeadOrAdmin && | ||
(coffeeChat.members[0].email !== user.email || coffeeChat.members[1].email !== user.email) |
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.
Hm, I'm thinking about this more and I think it probably only makes sense for a lead to delete a coffee chat for now. i.e. say that a person submits a coffee chat and it gets approved for both members. And then one member for some reason deletes the coffee chat, since we don't have two "copies" of it, the other members gets affected too.
Right now since we just use the google form and the lead already has control over the coffee chat, I think it makes sense to make this not allowed for any non-lead. Seems much easier to manage permissions-wise this way, since coffee chats concern two people.
Summary
This PR sets up the Coffee Chat API (and DAO). Members are not allowed to submit a coffee chat with themselves, or with someone they have coffee chatted in a previous semester.
Notion/Figma Link
Coffee Chat DAO Design Doc
Coffee Chat API Design Doc
Test Plan
The endpoints were tested using Jest (PR #363).