mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 11:55:03 +03:00
Moved the DomainEvents service as a dependency of members-events-service
refs https://github.com/TryGhost/Ghost/pull/14197 - Using the package directly was creating a second instance and was never triggering the subscriber - Passing DomainEvents as a dependency solves this issue
This commit is contained in:
parent
88fb84027c
commit
88f8b622f1
@ -1,4 +1,3 @@
|
||||
const DomainEvents = require('@tryghost/domain-events');
|
||||
const {MemberPageViewEvent} = require('@tryghost/member-events');
|
||||
const moment = require('moment-timezone');
|
||||
|
||||
@ -12,6 +11,7 @@ class LastSeenAtUpdater {
|
||||
* @param {Object} deps.models The list of model dependencies
|
||||
* @param {any} deps.models.Member The Member model
|
||||
* @param {Object} deps.services The list of service dependencies
|
||||
* @param {any} deps.services.domainEvent The DomainEvent service
|
||||
* @param {any} deps.services.settingsCache The settings service
|
||||
*/
|
||||
constructor({
|
||||
@ -19,12 +19,15 @@ class LastSeenAtUpdater {
|
||||
Member
|
||||
},
|
||||
services: {
|
||||
domainEvent,
|
||||
settingsCache
|
||||
}
|
||||
}) {
|
||||
this._memberModel = Member;
|
||||
this._domainEventsService = domainEvent;
|
||||
this._settingsCacheService = settingsCache;
|
||||
DomainEvents.subscribe(MemberPageViewEvent, async (event) => {
|
||||
|
||||
this._domainEventsService.subscribe(MemberPageViewEvent, async (event) => {
|
||||
await this.updateLastSeenAt(event.data.memberId, event.data.memberLastSeenAt, event.timestamp);
|
||||
});
|
||||
}
|
||||
|
@ -24,7 +24,8 @@ describe('LastSeenAtUpdater', function () {
|
||||
services: {
|
||||
settingsCache: {
|
||||
get: settingsCache
|
||||
}
|
||||
},
|
||||
domainEvent: DomainEvents
|
||||
}
|
||||
});
|
||||
DomainEvents.dispatch(MemberPageViewEvent.create({memberId: '1', memberLastSeenAt: previousLastSeen, url: '/'}, now.toDate()));
|
||||
@ -49,7 +50,8 @@ describe('LastSeenAtUpdater', function () {
|
||||
services: {
|
||||
settingsCache: {
|
||||
get: settingsCache
|
||||
}
|
||||
},
|
||||
domainEvent: DomainEvents
|
||||
}
|
||||
});
|
||||
DomainEvents.dispatch(MemberPageViewEvent.create({memberId: '1', memberLastSeenAt: previousLastSeen, url: '/'}, now.toDate()));
|
||||
@ -70,7 +72,8 @@ describe('LastSeenAtUpdater', function () {
|
||||
services: {
|
||||
settingsCache: {
|
||||
get: settingsCache
|
||||
}
|
||||
},
|
||||
domainEvent: DomainEvents
|
||||
}
|
||||
});
|
||||
DomainEvents.dispatch(MemberPageViewEvent.create({memberId: '1', memberLastSeenAt: previousLastSeen, url: '/'}, now.toDate()));
|
||||
@ -95,7 +98,8 @@ describe('LastSeenAtUpdater', function () {
|
||||
services: {
|
||||
settingsCache: {
|
||||
get: settingsCache
|
||||
}
|
||||
},
|
||||
domainEvent: DomainEvents
|
||||
}
|
||||
});
|
||||
DomainEvents.dispatch(MemberPageViewEvent.create({memberId: '1', memberLastSeenAt: previousLastSeen, url: '/'}, now.toDate()));
|
||||
@ -115,7 +119,8 @@ describe('LastSeenAtUpdater', function () {
|
||||
services: {
|
||||
settingsCache: {
|
||||
get: settingsCache
|
||||
}
|
||||
},
|
||||
domainEvent: DomainEvents
|
||||
}
|
||||
});
|
||||
DomainEvents.dispatch(MemberSubscribeEvent.create({memberId: '1', source: 'api'}, now.toDate()));
|
||||
|
Loading…
Reference in New Issue
Block a user