diff --git a/data/web/admin.php b/data/web/admin.php
index a6f07620..a68ec033 100644
--- a/data/web/admin.php
+++ b/data/web/admin.php
@@ -111,8 +111,7 @@ $template_data = [
'password_complexity' => password_complexity('get'),
'show_rspamd_global_filters' => @$_SESSION['show_rspamd_global_filters'],
'lang_admin' => json_encode($lang['admin']),
- 'lang_datatables' => json_encode($lang['datatables']),
- 'last_login' => last_login('get', $_SESSION['mailcow_cc_username'], 7, 0)['ui']['time']
+ 'lang_datatables' => json_encode($lang['datatables'])
];
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php';
diff --git a/data/web/inc/header.inc.php b/data/web/inc/header.inc.php
index a158d82a..f62819a2 100644
--- a/data/web/inc/header.inc.php
+++ b/data/web/inc/header.inc.php
@@ -48,6 +48,7 @@ $globalVariables = [
'app_links' => customize('get', 'app_links'),
'is_root_uri' => (parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) == '/'),
'uri' => $_SERVER['REQUEST_URI'],
+ 'last_login' => last_login('get', $_SESSION['mailcow_cc_username'], 7, 0)['ui']['time']
];
foreach ($globalVariables as $globalVariableName => $globalVariableValue) {
diff --git a/data/web/js/build/014-mailcow.js b/data/web/js/build/014-mailcow.js
index 5148a1f0..27bc54ce 100644
--- a/data/web/js/build/014-mailcow.js
+++ b/data/web/js/build/014-mailcow.js
@@ -343,6 +343,65 @@ $(document).ready(function() {
localStorage.setItem('darkmode', 'true');
}
}
+
+ // show whats new modal
+ if (mailcow_cc_role === "admin" || mailcow_cc_role === "domainadmin"){
+ if (mailcow_info.updatedAt > last_login){
+ var parsedSeenTimestamp = parseInt(localStorage.getItem("seenChangelog"));
+ if (!isNaN(parsedSeenTimestamp) && mailcow_info.updatedAt < parsedSeenTimestamp) {
+ console.log("changelog seen");
+ return;
+ }
+ $.ajax({
+ type: 'GET',
+ url: 'https://api.github.com/repos/' + mailcow_info.project_owner + '/' + mailcow_info.project_repo + '/releases/tags/' + mailcow_info.version_tag,
+ dataType: 'json',
+ success: function (data) {
+ var md = window.markdownit();
+ var result = md.render(data.body);
+ result = parseGithubMarkdownLinks(result);
+
+ $('#showWhatsNewModal').find(".modal-body").html(`
+
` + data.name + `
+ ` + result + `
+ `);
+
+ localStorage.setItem("seenChangelog", Math.floor(Date.now() / 1000).toString());
+ }
+ });
+
+ new bootstrap.Modal(document.getElementById("showWhatsNewModal"), {
+ backdrop: 'static',
+ keyboard: false
+ }).show();
+ }
+ }
+
+ function parseGithubMarkdownLinks(inputText) {
+ var replacedText, replacePattern1;
+
+ replacePattern1 = /(\b(https?):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim;
+ replacedText = inputText.replace(replacePattern1, (matched, index, original, input_string) => {
+ if (matched.includes('github.com')){
+ // return short link if it's github link
+ last_uri_path = matched.split('/');
+ last_uri_path = last_uri_path[last_uri_path.length - 1];
+
+ // adjust Full Changelog link to match last git version and new git version, if link is a compare link
+ if (matched.includes('/compare/') && mailcow_info.last_version_tag !== ''){
+ matched = matched.replace(last_uri_path, mailcow_info.last_version_tag + '...' + mailcow_info.version_tag);
+ last_uri_path = mailcow_info.last_version_tag + '...' + mailcow_info.version_tag;
+ }
+
+ return '' + last_uri_path + '
';
+ };
+
+ // if it's not a github link, return complete link
+ return '' + matched + '';
+ });
+
+ return replacedText;
+ }
});
diff --git a/data/web/js/site/admin.js b/data/web/js/site/admin.js
index 6402d4c6..61268b02 100644
--- a/data/web/js/site/admin.js
+++ b/data/web/js/site/admin.js
@@ -794,61 +794,4 @@ jQuery(function($){
$('#add_f2b_regex_row').click(function() {
add_table_row($('#f2b_regex_table'), "f2b_regex");
});
-
- // show whats new modal
- if (mailcow_info.updatedAt > last_login){
- var parsedSeenTimestamp = parseInt(localStorage.getItem("seenChangelog"));
- if (!isNaN(parsedSeenTimestamp) && mailcow_info.updatedAt < parsedSeenTimestamp) {
- console.log("changelog seen");
- return;
- }
- $.ajax({
- type: 'GET',
- url: 'https://api.github.com/repos/' + mailcow_info.project_owner + '/' + mailcow_info.project_repo + '/releases/tags/' + mailcow_info.version_tag,
- dataType: 'json',
- success: function (data) {
- var md = window.markdownit();
- var result = md.render(data.body);
- result = parseLinks(result);
-
- $('#showWhatsNew').find(".modal-body").html(`
- ` + data.name + `
- ` + result + `
- `);
-
- localStorage.setItem("seenChangelog", Math.floor(Date.now() / 1000).toString());
- }
- });
-
- new bootstrap.Modal(document.getElementById("showWhatsNew"), {
- backdrop: 'static',
- keyboard: false
- }).show();
- }
-
- function parseLinks(inputText) {
- var replacedText, replacePattern1;
-
- replacePattern1 = /(\b(https?):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim;
- replacedText = inputText.replace(replacePattern1, (matched, index, original, input_string) => {
- if (matched.includes('github.com')){
- // return short link if it's github link
- last_uri_path = matched.split('/');
- last_uri_path = last_uri_path[last_uri_path.length - 1];
-
- // adjust Full Changelog link to match last git version and new git version, if link is a compare link
- if (matched.includes('/compare/') && mailcow_info.last_version_tag !== ''){
- matched = matched.replace(last_uri_path, mailcow_info.last_version_tag + '...' + mailcow_info.version_tag);
- last_uri_path = mailcow_info.last_version_tag + '...' + mailcow_info.version_tag;
- }
-
- return '' + last_uri_path + '
';
- };
-
- // if it's not a github link, return complete link
- return '' + matched + '';
- });
-
- return replacedText;
- }
});
diff --git a/data/web/templates/admin.twig b/data/web/templates/admin.twig
index 33f430f4..0a70252e 100644
--- a/data/web/templates/admin.twig
+++ b/data/web/templates/admin.twig
@@ -70,6 +70,5 @@ var admin_username = '{{ mailcow_cc_username }}';
var csrf_token = '{{ csrf_token }}';
var pagination_size = '{{ pagination_size }}';
var log_pagination_size = '{{ log_pagination_size }}';
-var last_login = '{{ last_login }}';
{% endblock %}
diff --git a/data/web/templates/base.twig b/data/web/templates/base.twig
index 88245aa1..c39ceda4 100644
--- a/data/web/templates/base.twig
+++ b/data/web/templates/base.twig
@@ -135,6 +135,8 @@
var lang_tfa = {{ lang_tfa|raw }};
var lang_fido2 = {{ lang_fido2|raw }};
var docker_timeout = {{ docker_timeout|raw }} * 1000;
+ var mailcow_cc_role = '{{ mailcow_cc_role }}';
+ var last_login = '{{ last_login }}';
var mailcow_info = {
version_tag: '{{ mailcow_info.version_tag }}',
last_version_tag: '{{ mailcow_info.last_version_tag }}',
diff --git a/data/web/templates/modals/admin.twig b/data/web/templates/modals/admin.twig
index 56b19d96..a67e4848 100644
--- a/data/web/templates/modals/admin.twig
+++ b/data/web/templates/modals/admin.twig
@@ -261,19 +261,3 @@
-
-
\ No newline at end of file
diff --git a/data/web/templates/modals/footer.twig b/data/web/templates/modals/footer.twig
index 352c97cb..8bb0889e 100644
--- a/data/web/templates/modals/footer.twig
+++ b/data/web/templates/modals/footer.twig
@@ -238,3 +238,19 @@
+
+