Skip to content
Snippets Groups Projects
Verified Commit f7c7cd62 authored by Gabriel Zachmann's avatar Gabriel Zachmann
Browse files

fix ics_invite

parent 8060c02e
No related branches found
No related tags found
No related merge requests found
Pipeline #349709 passed
...@@ -28,6 +28,7 @@ func HandleEmailRequest(req pkg.EmailNotificationRequest) error { ...@@ -28,6 +28,7 @@ func HandleEmailRequest(req pkg.EmailNotificationRequest) error {
log.WithError(err).Error("error while sending ics mail invite") log.WithError(err).Error("error while sending ics mail invite")
return err return err
} }
return nil
} }
sender := mailing.PlainTextMailSender sender := mailing.PlainTextMailSender
if req.PreferHTML { if req.PreferHTML {
......
...@@ -180,4 +180,194 @@ function copyTokenTr($tr, force, tokens) { ...@@ -180,4 +180,194 @@ function copyTokenTr($tr, force, tokens) {
copyTokenTr($child, true, tokens); copyTokenTr($child, true, tokens);
}) })
} }
\ No newline at end of file
const $notificationTypeSelector = $('#notification-type-selector');
function notificationModal(doesExpire) {
let id = this.id.replace("notify-", "");
$notificationMOMID.val(id);
$('.notification-type-option').attr("disabled", false);
if (!doesExpire) {
$('#notification-type-option-calendar').attr("disabled", true);
$('#notification-type-option-entry').attr("disabled", true);
$notificationTypeSelector.val("email");
}
$notificationTypeSelector.trigger('change');
$notificationsModal.modal();
}
const $notificationTypeEmailContent = $('.notify-email-content');
const $notificationTypeEntryContent = $('.notify-entry-content');
const $notificationTypeCalendarContent = $('.notify-calendar-content');
const $calendarSelector = $('#notify-calendar-selector');
const $calendarURL = $('#notify-calendar-url');
let calendarURLs = {};
let cachedNotificationsTypeData = {};
$notificationTypeSelector.on('change', function () {
let t = $(this).val();
switch (t) {
case 'email':
$notificationTypeEntryContent.hideB();
$notificationTypeCalendarContent.hideB();
$notificationTypeEmailContent.showB();
break;
case 'entry':
$notificationTypeCalendarContent.hideB();
$notificationTypeEmailContent.hideB();
$notificationTypeEntryContent.showB();
let email_ok = cachedNotificationsTypeData["email_ok"];
if (email_ok !== undefined && email_ok !== null && email_ok) {
break;
}
$('.notify-entry-content-element').hideB();
$.ajax({
type: "GET",
url: storageGet('usersettings_endpoint') + "/email",
success: function (res) {
let email = res["email_address"];
let email_verified = res["email_verified"];
if (email === undefined || email === null || email === "") {
$('#email-not-verified-hint').showB();
cachedNotificationsTypeData["email_ok"] = false;
return;
}
if (email_verified === undefined || !email_verified) {
$('#email-not-set-hint').showB();
cachedNotificationsTypeData["email_ok"] = false;
return;
}
$('#notify-entry-content-normal').showB();
cachedNotificationsTypeData["email_ok"] = true;
},
error: function (errRes) {
$errorModalMsg.text(getErrorMessage(errRes));
$errorModal.modal();
},
});
break;
case 'calendar':
$notificationTypeEntryContent.hideB();
$notificationTypeEmailContent.hideB();
$notificationTypeCalendarContent.showB();
function fillCals(cals) {
let options = "";
if (cals !== undefined && cals !== null) {
cals.forEach(function (cal) {
let name = cal["name"];
calendarURLs[name] = cal["ics_path"];
options += `<option value=${name}>${name}</option>`;
});
cachedNotificationsTypeData["calendars"] = cals;
}
$calendarSelector.html(options);
$calendarSelector.trigger('change');
}
let cals = cachedNotificationsTypeData["calendars"];
if (cals !== undefined && cals !== null && cals.length > 0) {
fillCals(cals);
break;
}
$.ajax({
type: "GET",
url: storageGet('notifications_endpoint') + "/calendars",
success: function (res) {
let cals = res["calendars"];
fillCals(cals);
},
error: function (errRes) {
$settingsErrorModalMsg.text(getErrorMessage(errRes));
$settingsErrorModal.modal();
},
});
break;
}
})
$('#sent-entry').on('click', function () {
let data = {
"mom_id": $notificationMOMID.val(),
"notification_type": "ics_invite"
};
let comment = $('#notify-entry-comment').val();
if (comment !== undefined && comment !== null && comment !== "") {
data["comment"] = comment;
}
data = JSON.stringify(data);
$.ajax({
type: "POST",
data: data,
dataType: "json",
contentType: "application/json",
url: storageGet('notifications_endpoint'),
success: function () {
$notificationsModal.modal("hide");
},
error: function (errRes) {
$errorModalMsg.text(getErrorMessage(errRes));
$errorModal.modal();
},
});
})
$calendarSelector.on('change', function () {
let url = calendarURLs[$(this).val()];
$calendarURL.text(url);
$calendarURL.attr("href", url);
})
$('#sent-calendar-add').on('click', function () {
let data = {"mom_id": $notificationMOMID.val()};
let comment = $('#notify-calendar-comment').val();
if (comment !== undefined && comment !== null && comment !== "") {
data["comment"] = comment;
}
let calendar = $calendarSelector.val();
data = JSON.stringify(data);
$.ajax({
type: "POST",
data: data,
dataType: "json",
contentType: "application/json",
url: storageGet('notifications_endpoint') + "/calendars/" + calendar,
success: function () {
$notificationsModal.modal("hide");
},
error: function (errRes) {
$errorModalMsg.text(getErrorMessage(errRes));
$errorModal.modal();
},
});
})
$('#sent-create-mail-notification').on('click', function () {
let data = {
"mom_id": $notificationMOMID.val(),
"notification_type": "mail",
"notification_classes": getCheckedCapabilities("notifications-"),
"include_children": $('#notification-req-include-children').prop("checked")
};
data = JSON.stringify(data);
$.ajax({
type: "POST",
data: data,
dataType: "json",
contentType: "application/json",
url: storageGet('notifications_endpoint'),
success: function () {
$notificationsModal.modal("hide");
},
error: function (errRes) {
$errorModalMsg.text(getErrorMessage(errRes));
$errorModal.modal();
},
});
})
...@@ -323,189 +323,3 @@ $('#revoke-tokeninfo').on('click', function () { ...@@ -323,189 +323,3 @@ $('#revoke-tokeninfo').on('click', function () {
$revocationFormID.addClass(revocationClassFromTokeninfo); $revocationFormID.addClass(revocationClassFromTokeninfo);
$revocationModal.modal(); $revocationModal.modal();
}) })
const $notificationTypeSelector = $('#notification-type-selector');
function notificationModal(doesExpire) {
let id = this.id.replace("notify-", "");
$notificationMOMID.val(id);
$('.notification-type-option').attr("disabled", false);
if (!doesExpire) {
$('#notification-type-option-calendar').attr("disabled", true);
$('#notification-type-option-entry').attr("disabled", true);
$notificationTypeSelector.val("email");
}
$notificationTypeSelector.trigger('change');
$notificationsModal.modal();
}
const $notificationTypeEmailContent = $('.notify-email-content');
const $notificationTypeEntryContent = $('.notify-entry-content');
const $notificationTypeCalendarContent = $('.notify-calendar-content');
const $calendarSelector = $('#notify-calendar-selector');
const $calendarURL = $('#notify-calendar-url');
let calendarURLs = {};
let cachedNotificationsTypeData = {};
$notificationTypeSelector.on('change', function () {
let t = $(this).val();
switch (t) {
case 'email':
$notificationTypeEntryContent.hideB();
$notificationTypeCalendarContent.hideB();
$notificationTypeEmailContent.showB();
break;
case 'entry':
$notificationTypeCalendarContent.hideB();
$notificationTypeEmailContent.hideB();
$notificationTypeEntryContent.showB();
let email_ok = cachedNotificationsTypeData["email_ok"];
if (email_ok !== undefined && email_ok !== null && email_ok) {
break;
}
$('.notify-entry-content-element').hideB();
$.ajax({
type: "GET",
url: storageGet('usersettings_endpoint') + "/email",
success: function (res) {
let email = res["email_address"];
let email_verified = res["email_verified"];
if (email === undefined || email === null || email === "") {
$('#email-not-verified-hint').showB();
cachedNotificationsTypeData["email_ok"] = false;
return;
}
if (email_verified === undefined || !email_verified) {
$('#email-not-set-hint').showB();
cachedNotificationsTypeData["email_ok"] = false;
return;
}
$('#notify-entry-content-normal').showB();
cachedNotificationsTypeData["email_ok"] = true;
},
error: function (errRes) {
$errorModalMsg.text(getErrorMessage(errRes));
$errorModal.modal();
},
});
break;
case 'calendar':
$notificationTypeEntryContent.hideB();
$notificationTypeEmailContent.hideB();
$notificationTypeCalendarContent.showB();
function fillCals(cals) {
let options = "";
if (cals !== undefined && cals !== null) {
cals.forEach(function (cal) {
let name = cal["name"];
calendarURLs[name] = cal["ics_path"];
options += `<option value=${name}>${name}</option>`;
});
cachedNotificationsTypeData["calendars"] = cals;
}
$calendarSelector.html(options);
$calendarSelector.trigger('change');
}
let cals = cachedNotificationsTypeData["calendars"];
if (cals !== undefined && cals !== null && cals.length > 0) {
fillCals(cals);
break;
}
$.ajax({
type: "GET",
url: storageGet('notifications_endpoint') + "/calendars",
success: function (res) {
let cals = res["calendars"];
fillCals(cals);
},
error: function (errRes) {
$settingsErrorModalMsg.text(getErrorMessage(errRes));
$settingsErrorModal.modal();
},
});
break;
}
})
$('#sent-entry').on('click', function () {
let data = {"mom_id": $notificationMOMID.val()};
let comment = $('#notify-entry-comment').val();
if (comment !== undefined && comment !== null && comment !== "") {
data["comment"] = comment;
}
data = JSON.stringify(data);
$.ajax({
type: "POST",
data: data,
dataType: "json",
contentType: "application/json",
url: storageGet('notifications_endpoint'),
success: function () {
$notificationsModal.modal("hide");
},
error: function (errRes) {
$errorModalMsg.text(getErrorMessage(errRes));
$errorModal.modal();
},
});
})
$calendarSelector.on('change', function () {
let url = calendarURLs[$(this).val()];
$calendarURL.text(url);
$calendarURL.attr("href", url);
})
$('#sent-calendar-add').on('click', function () {
let data = {"mom_id": $notificationMOMID.val()};
let comment = $('#notify-calendar-comment').val();
if (comment !== undefined && comment !== null && comment !== "") {
data["comment"] = comment;
}
let calendar = $calendarSelector.val();
data = JSON.stringify(data);
$.ajax({
type: "POST",
data: data,
dataType: "json",
contentType: "application/json",
url: storageGet('notifications_endpoint') + "/calendars/" + calendar,
success: function () {
$notificationsModal.modal("hide");
},
error: function (errRes) {
$errorModalMsg.text(getErrorMessage(errRes));
$errorModal.modal();
},
});
})
$('#sent-create-mail-notification').on('click', function () {
let data = {
"mom_id": $notificationMOMID.val(),
"notification_type": "mail",
"notification_classes": getCheckedCapabilities("notifications-"),
"include_children": $('#notification-req-include-children').prop("checked")
};
data = JSON.stringify(data);
$.ajax({
type: "POST",
data: data,
dataType: "json",
contentType: "application/json",
url: storageGet('notifications_endpoint'),
success: function () {
$notificationsModal.modal("hide");
},
error: function (errRes) {
$errorModalMsg.text(getErrorMessage(errRes));
$errorModal.modal();
},
});
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment