feat: enhance notification system and role-based access across schemas
- Updated MessageSchema to include context-aware filtering for notifications, allowing retrieval based on recipientId for NOTIFICATION and SYSTEM contexts. - Enhanced RefundTicketSchema to notify moderators upon refund requests, improving communication and response times. - Modified ResumeSchema to send notifications to mentors and center owners when a new resume is submitted, ensuring timely updates. - Improved ServiceSchema to notify center owners and mentors about service approvals, enhancing user engagement and awareness. - Implemented role-based access control checks across schemas to ensure only authorized users can perform specific actions, enhancing security and user experience.
This commit is contained in:
@@ -81,9 +81,14 @@ export class MessageSchema extends PothosSchema {
|
||||
if (ctx.isSubscription) {
|
||||
throw new Error('Not allowed')
|
||||
}
|
||||
// if message.context is NOTIFICATION, filter by recipientId
|
||||
if (args.filter?.context === MessageContextType.NOTIFICATION) {
|
||||
args.filter.recipientId = ctx.http.me?.id
|
||||
if (args.filter?.context && typeof args.filter.context === 'object') {
|
||||
// if args.context is NOTIFICATION or SYSTEM, filter by recipientId
|
||||
if (
|
||||
args.filter.context.in?.toString().includes(MessageContextType.NOTIFICATION) ||
|
||||
args.filter.context.in?.toString().includes(MessageContextType.SYSTEM)
|
||||
) {
|
||||
args.filter.recipientId = ctx.http.me?.id
|
||||
}
|
||||
}
|
||||
return await this.prisma.message.findMany({
|
||||
...query,
|
||||
|
||||
Reference in New Issue
Block a user