Updated fallback for storing source site title

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

Previously, we didn't have any backup for storing source site title and it could have stored as empty if missing. This change ensures the source site title is stored as site host instead as fallback if not present.
This commit is contained in:
Rishabh 2023-03-21 00:09:33 +05:30 committed by Rishabh Garg
parent 61a206c9eb
commit 0b7e09c986
2 changed files with 7 additions and 3 deletions

View File

@ -12,7 +12,7 @@ Object {
"source_excerpt": null,
"source_favicon": null,
"source_featured_image": null,
"source_site_title": null,
"source_site_title": "source.com",
"source_title": Any<String>,
"target": Any<String>,
"timestamp": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
@ -27,7 +27,7 @@ Object {
"source_excerpt": null,
"source_favicon": null,
"source_featured_image": null,
"source_site_title": null,
"source_site_title": "anothersource.com",
"source_title": Any<String>,
"target": Any<String>,
"timestamp": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,

View File

@ -112,7 +112,11 @@ module.exports = class Mention {
/** @type {string | null} */
const sourceExcerpt = validateString(metadata.sourceExcerpt, 2000, 'sourceExcerpt');
/** @type {string | null} */
const sourceSiteTitle = validateString(metadata.sourceSiteTitle, 2000, 'sourceSiteTitle');
let sourceSiteTitle = validateString(metadata.sourceSiteTitle, 2000, 'sourceSiteTitle');
if (sourceSiteTitle === null) {
sourceSiteTitle = this.#source.host;
}
/** @type {string | null} */
const sourceAuthor = validateString(metadata.sourceAuthor, 2000, 'sourceAuthor');