fix: feed not sending notification

This commit is contained in:
Rotimi Best
2024-08-11 10:26:04 +01:00
parent 4baaef529c
commit 56911d8ac2
2 changed files with 17 additions and 8 deletions
@@ -109,8 +109,12 @@ export async function deleteNewsFeed(feedId: string) {
return response;
}
export async function getFeedForNotification(feedId: string, authorId: string) {
const { data, error } = await supabase
export async function getFeedForNotification(params: {
feedId: string;
authorId: string;
supabase: typeof supabase;
}) {
const { data, error } = await params.supabase
.from('course_newsfeed')
.select(
`
@@ -126,7 +130,7 @@ export async function getFeedForNotification(feedId: string, authorId: string) {
)
`
)
.eq('id', feedId)
.eq('id', params.feedId)
.limit(1)
.returns<
{
@@ -169,7 +173,7 @@ export async function getFeedForNotification(feedId: string, authorId: string) {
if (!feed) return;
return {
id: feedId,
id: params.feedId,
courseId: feed.course.id,
courseTitle: feed.course.title,
teacherName: feed.author?.profile?.fullname,
@@ -177,7 +181,7 @@ export async function getFeedForNotification(feedId: string, authorId: string) {
content: feed.content,
org: feed.course.group?.organization,
courseMembers: feed.course?.group?.members
?.filter((member) => member.id !== authorId)
?.filter((member) => member.id !== params.authorId)
?.map((member) => {
return member.profile;
})