Skip to content
This repository was archived by the owner on May 25, 2021. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/lib/classes/notification.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import solid from 'solid-auth-client';
import * as N3 from 'n3';
import data from '@solid/query-ldflex';
import { solidResponse, SolidError, shexUtil } from '@utils';
import { solidResponse, SolidError, shexUtil, getBasicPod } from '@utils';
import defaultShape from '../shapes/notification.json';
import AccessControlList from './access-control-list';
import ACLFactory from './access-control-factory';
Expand Down Expand Up @@ -468,8 +468,8 @@ export class Notification {
);

// Loop over resulting notifications
for (const notification of validNotifications) {
const notificationData = {};
for await (const notification of validNotifications) {
let notificationData = {};
// Loop over all predicates in the notification shape and parse out the key and value
for (const field of this.schema[name].shape) {
// Find the quad for this field
Expand All @@ -479,6 +479,13 @@ export class Notification {

notificationData[field.label] = fieldQuad ? fieldQuad.object.value : null;
}

// Take the actor webid and construct an object, fetching name and profile image
// We know that actor exists on the notification object because if it didn't, it would
// not pass ShEx validation
const actor = await getBasicPod(notificationData.actor);
notificationData = { ...notificationData, actor };

// Add the new notification object to the array of validated notifications
notifications = [...notifications, notificationData];
}
Expand Down