mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Ignore unsupported notifications features in subscriptions
This commit is contained in:
parent
65860f77da
commit
67d1ff4ac0
@ -223,6 +223,8 @@ export abstract class BaseChannelType implements NotificationChannelType {
|
||||
|
||||
// Apply the values for all present features that are enabled
|
||||
for (const feature of DEFAULT_NOTIFICATION_FEATURES) {
|
||||
const featNode = this.features.find((node): boolean => node.value === feature);
|
||||
if (featNode) {
|
||||
const objects = data.getObjects(subject, feature, null);
|
||||
if (objects.length === 1) {
|
||||
// Will always succeed since we are iterating over a list which was built using `featureDefinitions`
|
||||
@ -237,6 +239,7 @@ export abstract class BaseChannelType implements NotificationChannelType {
|
||||
(channel as Record<typeof key, string | number>)[key] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return channel;
|
||||
}
|
||||
|
@ -142,6 +142,26 @@ describe('A BaseChannelType', (): void => {
|
||||
}));
|
||||
});
|
||||
|
||||
it('removes features from the input that are not supported.', async(): Promise<void> => {
|
||||
const date = '1988-03-09T14:48:00.000Z';
|
||||
|
||||
data.addQuad(quad(subject, NOTIFY.terms.startAt, literal(date, XSD.terms.dateTime)));
|
||||
data.addQuad(quad(subject, NOTIFY.terms.endAt, literal(date, XSD.terms.dateTime)));
|
||||
data.addQuad(quad(subject, NOTIFY.terms.rate, literal('PT10S', XSD.terms.duration)));
|
||||
data.addQuad(quad(subject, NOTIFY.terms.accept, literal('text/turtle')));
|
||||
data.addQuad(quad(subject, NOTIFY.terms.state, literal('123456')));
|
||||
|
||||
const featChannelType = new DummyChannelType([ 'notify:endAt', 'notify:accept', NOTIFY.state ]);
|
||||
await expect(featChannelType.initChannel(data, credentials)).resolves.toEqual({
|
||||
id,
|
||||
type: dummyType.value,
|
||||
topic: 'https://storage.example/resource',
|
||||
endAt: Date.parse(date),
|
||||
accept: 'text/turtle',
|
||||
state: '123456',
|
||||
});
|
||||
});
|
||||
|
||||
it('requires correct datatypes on the features.', async(): Promise<void> => {
|
||||
for (const feature of DEFAULT_NOTIFICATION_FEATURES) {
|
||||
const badData = new Store(data.getQuads(null, null, null, null));
|
||||
|
Loading…
x
Reference in New Issue
Block a user