0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Used current time for created_at for missing events

refs https://github.com/TryGhost/Team/issues/873

This is an unexpected state, but possible if the alpha version of tier
has been enabled previous to the events being added.
This commit is contained in:
Fabien O'Carroll 2021-08-26 11:50:16 +02:00
parent 40699893ba
commit 3a91687b08

View file

@ -39,10 +39,12 @@ module.exports = class MemberBREADService {
for (const product of member.products) {
if (!subscriptionProducts.includes(product.id)) {
const productAddEvent = member.productEvents.find(event => event.product_id === product.id);
let startDate;
if (!productAddEvent || productAddEvent.action !== 'added') {
// There's something very wrong here. They have been comped this product - why is there no event????
startDate = moment();
} else {
startDate = moment(productAddEvent.created_at);
}
const startDate = moment(productAddEvent.created_at);
member.subscriptions.push({
id: '',
customer: {