0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Added default email to send import reports to (#16485)

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

- When a Self-Serve integration does content/members import it failed
because there was no "user" to get the email from - needed to send the
import report
- The fix defaults to the instance's owner email when an integration
does the request

Co-authored-by: Naz <hi@nazavo.com>
This commit is contained in:
Paul Davis 2023-03-24 13:33:24 +00:00 committed by GitHub
parent 64c9e66b56
commit 751f7d5278
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 3 deletions

View file

@ -82,12 +82,20 @@ module.exports = {
cacheInvalidate: true cacheInvalidate: true
}, },
permissions: true, permissions: true,
query(frame) { async query(frame) {
const siteTimezone = settingsCache.get('timezone'); const siteTimezone = settingsCache.get('timezone');
const importTag = `#Import ${moment().tz(siteTimezone).format('YYYY-MM-DD HH:mm')}`; const importTag = `#Import ${moment().tz(siteTimezone).format('YYYY-MM-DD HH:mm')}`;
let email;
if (frame.user) {
email = frame.user.get('email');
} else {
email = await models.User.getOwnerUser().get('email');
}
return importer.importFromFile(frame.file, { return importer.importFromFile(frame.file, {
user: { user: {
email: frame.user.get('email') email: email
}, },
importTag importTag
}); });

View file

@ -367,6 +367,13 @@ module.exports = {
const pathToCSV = frame.file.path; const pathToCSV = frame.file.path;
const headerMapping = frame.data.mapping; const headerMapping = frame.data.mapping;
let email;
if (frame.user) {
email = frame.user.get('email');
} else {
email = await models.User.getOwnerUser().get('email');
}
return membersService.processImport({ return membersService.processImport({
pathToCSV, pathToCSV,
headerMapping, headerMapping,
@ -374,7 +381,7 @@ module.exports = {
importLabel, importLabel,
LabelModel: models.Label, LabelModel: models.Label,
user: { user: {
email: frame.user.get('email') email: email
} }
}); });
} }