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:
parent
cab655289f
commit
00f70a445b
4 changed files with 9 additions and 4 deletions
|
@ -6,7 +6,7 @@ const Mention = ghostBookshelf.Model.extend({
|
|||
deleted: false,
|
||||
verified: false
|
||||
},
|
||||
enforcedFilters() {
|
||||
defaultFilters() {
|
||||
return 'deleted:false';
|
||||
}
|
||||
}, {
|
||||
|
|
|
@ -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});
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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}));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue