0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

🐛 Fixed missing incoming recommendations (#21317)

ref https://linear.app/tryghost/issue/ONC-433

- due to a regression introduced in commit 871d21a, incoming
recommendations were not rendering in Admin Settings anymore, as they
were marked as deleted
- this commit updates the refresh logic of incoming recommendations on
boot: previously deleted incoming recommendations are refetched, and if
now available, restored
- when a recommendation is restored, we don't send a staff email
notification
This commit is contained in:
Sag 2024-10-16 11:00:47 +02:00 committed by GitHub
parent a3b84e8cd1
commit 6ee3d05da5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 9 additions and 4 deletions

View file

@ -6,7 +6,7 @@ const Mention = ghostBookshelf.Model.extend({
deleted: false,
verified: false
},
enforcedFilters() {
defaultFilters() {
return 'deleted:false';
}
}, {

View file

@ -95,8 +95,10 @@ export class IncomingRecommendationService {
}
async #updateIncomingRecommendations() {
// Note: we also recheck recommendations that were not verified (verification could have failed)
const filter = this.#getMentionFilter();
// We refresh all incoming recommendations, including:
// - recommendations that were not verified, as the verification could have failed
// - recommendations that were deleted previously. Implementation note: given that we have `deleted:false` as default filter in the Mention model, we need to override it here
const filter = this.#getMentionFilter() + '+deleted:[true,false]';
await this.#mentionsApi.refreshMentions({filter, limit: 100});
}

View file

@ -52,6 +52,10 @@ describe('IncomingRecommendationService', function () {
await service.init();
clock.tick(1000 * 60 * 60 * 24);
assert(refreshMentions.calledOnce);
assert(refreshMentions.calledWith({
filter: `source:~$'/.well-known/recommendations.json'+deleted:[true,false]`,
limit: 100
}));
} finally {
process.env.NODE_ENV = saved;
}

View file

@ -33,7 +33,6 @@ module.exports = class Mention {
// When an earlier mention is deleted, but then it gets verified again, we need to undelete it
if (this.#deleted) {
this.#deleted = false;
this.events.push(MentionCreatedEvent.create({mention: this}));
}
}