mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Updated geolocation handling for email alerts
refs https://github.com/TryGhost/Team/issues/1826 - geolocation is a stringified json on member, needs parsing
This commit is contained in:
parent
977aba928c
commit
b16ad52401
2 changed files with 18 additions and 4 deletions
|
@ -150,11 +150,25 @@ class StaffServiceEmails {
|
|||
email: member?.email,
|
||||
adminUrl: this.urlUtils.urlJoin(this.urlUtils.urlFor('admin', true), '#', `/members/${member.id}`),
|
||||
initials: this.extractInitials(name),
|
||||
location: member.geolocation?.country || null,
|
||||
location: this.getGeolocationData(member.geolocation),
|
||||
createdAt: moment(member.created_at).format('D MMM YYYY')
|
||||
};
|
||||
}
|
||||
|
||||
/** @private */
|
||||
getGeolocationData(geolocation) {
|
||||
if (!geolocation) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
const geolocationData = JSON.parse(geolocation);
|
||||
return geolocationData?.country || null;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** @private */
|
||||
getFormattedAmount({amount = 0, currency}) {
|
||||
if (!currency) {
|
||||
|
|
|
@ -153,7 +153,7 @@ describe('StaffService', function () {
|
|||
name: 'Ghost',
|
||||
email: 'member@example.com',
|
||||
id: 'abc',
|
||||
geolocation: {country: 'France'},
|
||||
geolocation: '{"country": "France"}',
|
||||
created_at: '2022-08-01T07:30:39.882Z'
|
||||
};
|
||||
|
||||
|
@ -185,7 +185,7 @@ describe('StaffService', function () {
|
|||
name: 'Ghost',
|
||||
email: 'member@example.com',
|
||||
id: 'abc',
|
||||
geolocation: {country: 'France'},
|
||||
geolocation: '{"country": "France"}',
|
||||
created_at: '2022-08-01T07:30:39.882Z'
|
||||
};
|
||||
offer = {
|
||||
|
@ -316,7 +316,7 @@ describe('StaffService', function () {
|
|||
name: 'Ghost',
|
||||
email: 'member@example.com',
|
||||
id: 'abc',
|
||||
geolocation: {country: 'France'},
|
||||
geolocation: '{"country": "France"}',
|
||||
created_at: '2022-08-01T07:30:39.882Z'
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue