feat: wip, better digest handling (+ eventual digest resend logic) (#7995)
* feat: wip, better digest handling (+ eventual digest resend logic) - await emailer.send call in digest.send method - save send success to a new sorted set digest:{interval}:byUid * feat: continuing work on digest tools - Added ACP page to view digest settings and delivery times per user * feat: added paginator and stub buttons for resending digest * feat: wrapping up digest revamp - New language strings in ACP digest page - Client-side ACP script for digest ACP page - Websocket call for ACP page to execute digests - Broke out logic to retrieve user digest settings to getUsersInterval * fix: minor cleanup * fix: #8010 and some style suggestions from baris * fix: resolve confusing commentv1.18.x
parent
e3c9dafa08
commit
645d647248
@ -0,0 +1,21 @@
|
||||
{
|
||||
"lead": "A listing of digest delivery stats and times is displayed below.",
|
||||
"disclaimer": "Please be advised that email delivery is not guaranteed, due to the nature of email technology. Many variables factor into whether an email sent to the recipient server is ultimately delivered into the user's inbox, including server reputation, blacklisted IP addresses, and whether DKIM/SPF/DMARC is configured.",
|
||||
"disclaimer-continued": "A successful delivery means the message was sent successfully by NodeBB and acknowledged by the recipient server. It does not mean the email landed in the inbox. For best results, we recommend using a third-party email delivery service such as <a href=\"https://sendgrid.com/why-sendgrid/\">SendGrid</a>.",
|
||||
|
||||
"user": "User",
|
||||
"subscription": "Subscription Type",
|
||||
"last-delivery": "Last successful delivery",
|
||||
"default": "System default",
|
||||
"default-help": "<em>System default</em> means the user has not explicitly overridden the global forum setting for digests, which is currently: "<strong>%1</strong>"",
|
||||
"resend": "Resend Digest",
|
||||
"resend-all-confirm": "Are you sure you wish to mnually execute this digest run?",
|
||||
"resent-single": "Manual digest resend completed",
|
||||
"resent-day": "Daily digest resent",
|
||||
"resent-week": "Weekly digest resent",
|
||||
"resent-month": "Monthly digest resent",
|
||||
"null": "<em>Never</em>",
|
||||
"manual-run": "Manual digest run:",
|
||||
|
||||
"no-delivery-data": "No delivery data found"
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
define('admin/manage/digest', function () {
|
||||
var Digest = {};
|
||||
|
||||
Digest.init = function () {
|
||||
$('table').on('click', '[data-action]', function () {
|
||||
var action = this.getAttribute('data-action');
|
||||
var uid = this.getAttribute('data-uid');
|
||||
|
||||
if (action.startsWith('resend-')) {
|
||||
var interval = action.slice(7);
|
||||
bootbox.confirm('[[admin/manage/digest:resend-all-confirm]]', function (ok) {
|
||||
if (ok) {
|
||||
Digest.send(action, undefined, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err);
|
||||
}
|
||||
|
||||
app.alertSuccess('[[admin/manage/digest:resent-' + interval + ']]');
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Digest.send(action, uid, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err);
|
||||
}
|
||||
|
||||
app.alertSuccess('[[admin/manage/digest:resent-single]]');
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Digest.send = function (action, uid, callback) {
|
||||
socket.emit('admin.digest.resend', {
|
||||
action: action,
|
||||
uid: uid,
|
||||
}, callback);
|
||||
};
|
||||
|
||||
return Digest;
|
||||
});
|
@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
const meta = require('../../meta');
|
||||
const digest = require('../../user/digest');
|
||||
const pagination = require('../../pagination');
|
||||
|
||||
const digestController = module.exports;
|
||||
|
||||
digestController.get = async function (req, res) {
|
||||
const page = parseInt(req.query.page, 10) || 1;
|
||||
const resultsPerPage = 50;
|
||||
const start = Math.max(0, page - 1) * resultsPerPage;
|
||||
const stop = start + resultsPerPage - 1;
|
||||
const delivery = await digest.getDeliveryTimes(start, stop);
|
||||
|
||||
const pageCount = Math.ceil(delivery.count / resultsPerPage);
|
||||
res.render('admin/manage/digest', {
|
||||
title: '[[admin/menu:manage/digest]]',
|
||||
delivery: delivery.users,
|
||||
default: meta.config.dailyDigestFreq,
|
||||
pagination: pagination.create(page, pageCount),
|
||||
});
|
||||
};
|
@ -0,0 +1,51 @@
|
||||
<p class="lead">[[admin/manage/digest:lead]]</p>
|
||||
<p>[[admin/manage/digest:disclaimer]]</p>
|
||||
<p>[[admin/manage/digest:disclaimer-continued]]</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<th>[[admin/manage/digest:user]]</th>
|
||||
<th>[[admin/manage/digest:subscription]]</th>
|
||||
<th>[[admin/manage/digest:last-delivery]]</th>
|
||||
<th></th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- BEGIN delivery -->
|
||||
<tr>
|
||||
<td><a href="{config.relative_path}/uid/{../uid}">{buildAvatar(delivery, "sm", true)} {../username}</a></td>
|
||||
<td>{{{if ../setting}}}{../setting}{{{else}}}<em>[[admin/manage/digest:default]]</em>{{{end}}}</td>
|
||||
<td>{../lastDelivery}</td>
|
||||
<td><button class="btn btn-xs btn-default" data-action="resend" data-uid="{../uid}">[[admin/manage/digest:resend]]</button></td>
|
||||
</tr>
|
||||
<!-- END delivery -->
|
||||
<!-- IF !delivery.length -->
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<div class="alert alert-success">
|
||||
[[admin/manage/digest:no-delivery-data]]
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- ENDIF !delivery.length -->
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="4"><!-- IMPORT partials/paginator.tpl --></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<em>[[admin/manage/digest:default-help, {default}]]</em>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
[[admin/manage/digest:manual-run]]
|
||||
<button class="btn btn-xs btn-default" data-action="resend-day">[[admin/settings/user:digest-freq.daily]]</button>
|
||||
<button class="btn btn-xs btn-default" data-action="resend-week">[[admin/settings/user:digest-freq.weekly]]</button>
|
||||
<button class="btn btn-xs btn-default" data-action="resend-month">[[admin/settings/user:digest-freq.monthly]]</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
Loading…
Reference in New Issue