#328128 Add the user's datetime offset to their profile. Use it to format the date in event-related emails.
This commit is contained in:
Родитель
34123b5030
Коммит
72fcc8521e
|
@ -37,7 +37,9 @@ export class UsersService {
|
||||||
}
|
}
|
||||||
|
|
||||||
register(username: string, password: string, displayName: string) {
|
register(username: string, password: string, displayName: string) {
|
||||||
return this._users.register(username, password, { Email: username, DisplayName: displayName });
|
let attrs: any = { Email: username, DisplayName: displayName };
|
||||||
|
attrs.TimezoneOffset = (new Date()).getTimezoneOffset();
|
||||||
|
return this._users.register(username, password, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
resetUserPassword(identifier: string) {
|
resetUserPassword(identifier: string) {
|
||||||
|
|
|
@ -111,8 +111,22 @@ function getDataForUserRegisteredForEvent (context) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _offsetDate (dateIsoString, offset) {
|
||||||
|
var oneHour = 3600000;
|
||||||
|
var msInMinute = 60000;
|
||||||
|
var d = new Date(dateIsoString);
|
||||||
|
var offsetDateInMs = d.getTime() + (d.getTimezoneOffset() * msInMinute);
|
||||||
|
return new Date(offsetDateInMs + (oneHour * offset));
|
||||||
|
}
|
||||||
|
|
||||||
|
function _formatDate (dateIsoString, offset) {
|
||||||
|
var dateStr = _offsetDate(dateIsoString, offset).toString();
|
||||||
|
var ind = dateStr.indexOf(' GMT');
|
||||||
|
return dateStr.substring(0, ind);
|
||||||
|
}
|
||||||
|
|
||||||
function getDataForEventRelated (templateName, context) {
|
function getDataForEventRelated (templateName, context) {
|
||||||
var event, group, members;
|
var event, group, members, organizer;
|
||||||
return Promise.all([getEvent(context.eventId), getGroup(context.groupId), getGroupMembers(context.groupId)])
|
return Promise.all([getEvent(context.eventId), getGroup(context.groupId), getGroupMembers(context.groupId)])
|
||||||
.then(function(results) {
|
.then(function(results) {
|
||||||
event = results[0].result;
|
event = results[0].result;
|
||||||
|
@ -122,6 +136,15 @@ function getDataForEventRelated (templateName, context) {
|
||||||
})
|
})
|
||||||
.then(function(organizerRes) {
|
.then(function(organizerRes) {
|
||||||
var organizer = organizerRes.result;
|
var organizer = organizerRes.result;
|
||||||
|
var offset = organizer.TimezoneOffset;
|
||||||
|
if (event.EventDate) {
|
||||||
|
event.EventDate = _formatDate(event.EventDate, offset);
|
||||||
|
} else {
|
||||||
|
event.EventDateChoices = event.EventDateChoices.map(function(dateOption) {
|
||||||
|
return _formatDate(dateOption, offset);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var userData = filterForNotification(members);
|
var userData = filterForNotification(members);
|
||||||
var emailContext = {
|
var emailContext = {
|
||||||
Event: event,
|
Event: event,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче