nodebb-plugin-poll 4.0.1 → 4.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/sockets.js +2 -2
- package/library.js +7 -0
- package/package.json +1 -1
- package/templates/poll/view.tpl +4 -4
package/lib/sockets.js
CHANGED
|
@@ -23,8 +23,8 @@ Sockets.get = async function (socket, data) {
|
|
|
23
23
|
if (!Array.isArray(data.pollIds) || !data.pollIds.length) {
|
|
24
24
|
throw new Error('Invalid request, pollId is required');
|
|
25
25
|
}
|
|
26
|
-
if (
|
|
27
|
-
|
|
26
|
+
if (!socket.uid && !allowAnon) {
|
|
27
|
+
return [];
|
|
28
28
|
}
|
|
29
29
|
return await Promise.all(data.pollIds.map(async (pollId) => {
|
|
30
30
|
const pollData = await Poll.get(pollId, socket.uid, !!socket.uid);
|
package/library.js
CHANGED
|
@@ -90,6 +90,13 @@ Plugin.defineWidgets = async function (widgets) {
|
|
|
90
90
|
Plugin.renderPollWidget = async function (widget) {
|
|
91
91
|
const { pollId } = widget.data;
|
|
92
92
|
const Poll = require('./lib/poll');
|
|
93
|
+
|
|
94
|
+
const settings = await Config.getSettings();
|
|
95
|
+
const allowAnon = parseInt(settings.allowGuestsToViewResults, 10) === 1;
|
|
96
|
+
|
|
97
|
+
if (!widget.uid && !allowAnon) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
93
100
|
const pollData = await Poll.get(pollId, widget.uid, widget.req.loggedIn);
|
|
94
101
|
if (!pollData) {
|
|
95
102
|
return null;
|
package/package.json
CHANGED
package/templates/poll/view.tpl
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<div class="poll-view mb-3" data-poll-id="{poll.info.pollId}">
|
|
2
2
|
<div class="card shadow-sm border-0">
|
|
3
|
-
<div class="card-header border-0 d-flex justify-content-between align-items-center">
|
|
4
|
-
<h5 class="card-title mb-0">
|
|
3
|
+
<div class="card-header border-0 d-flex justify-content-between align-items-center flex-wrap">
|
|
4
|
+
<h5 class="card-title mb-0 {{{ if poll.isWidget }}}fs-6{{{ end }}}">
|
|
5
5
|
{{{ if poll.isWidget }}}
|
|
6
|
-
<a class="text-reset" href="{config.relative_path}/post/{poll.info.pid}">{poll.info.title}</a>
|
|
6
|
+
<a class="text-reset text-break" href="{config.relative_path}/post/{poll.info.pid}">{poll.info.title}</a>
|
|
7
7
|
{{{ else }}}
|
|
8
8
|
{poll.info.title}
|
|
9
9
|
{{{ end }}}
|
|
10
10
|
</h5>
|
|
11
|
-
{{{ if isAdmin }}}
|
|
11
|
+
{{{ if (isAdmin && !poll.isWidget) }}}
|
|
12
12
|
<span class="text-sm text-secondary">[[poll:poll-id-x, {poll.info.pollId}]]</span>
|
|
13
13
|
{{{ end }}}
|
|
14
14
|
</div>
|