Fixed external media inliner logs

refs https://github.com/TryGhost/Toolbox/issues/524

- The "tableName" property is not present on the bookshelf model instance - it was a mistake assumption using it for logs. In case the logs are too ambiguous we could figure pass around model names separately into the "inlineSimpleFields" method
This commit is contained in:
Naz 2023-03-08 15:24:21 +08:00
parent 6fa00faaa2
commit 46508b7299
No known key found for this signature in database
2 changed files with 3 additions and 7 deletions

View File

@ -187,7 +187,7 @@ class ExternalMediaInliner {
* @param {string[]} domains - domains to inline media from
*/
async #inlineSimpleFields(resources, model, fields, domains) {
logging.info(`Starting inlining external media for ${resources?.length} ${model.tableName}`);
logging.info(`Starting inlining external media for ${resources?.length} resources and with ${fields.join(', ')} fields`);
for (const resource of resources) {
try {
@ -202,7 +202,7 @@ class ExternalMediaInliner {
});
}
} catch (err) {
logging.error(`Error inlining media for ${model.tableName}: ${resource.id}`);
logging.error(`Error inlining media for: ${resource.id}`);
logging.error(new errors.DataImportError({
err
}));

View File

@ -23,28 +23,24 @@ describe('ExternalMediaInliner', function () {
};
postModelStub = {
tableName: 'posts',
findPage: sinon.stub().resolves({
data: []
}),
edit: sinon.stub().resolves()
};
postMetaModelStub = {
tableName: 'posts_meta',
findPage: sinon.stub().resolves({
data: []
}),
edit: sinon.stub().resolves()
};
tagModelStub = {
tableName: 'tags',
findPage: sinon.stub().resolves({
data: []
}),
edit: sinon.stub().resolves()
};
userModelStub = {
tableName: 'users',
findPage: sinon.stub().resolves({
data: []
}),
@ -335,7 +331,7 @@ describe('ExternalMediaInliner', function () {
assert.ok(requestMock.isDone());
assert.ok(tagModelStub.edit.calledOnce);
assert.equal(logging.error.args[0][0], 'Error inlining media for tags: errored-tag-id');
assert.equal(logging.error.args[0][0], 'Error inlining media for: errored-tag-id');
});
it('inlines image in the post\'s feature_image field', async function () {