Skip to content

Poll plugin refinement and bug fix (4.14 and 4.15)#160

Open
jasonwch wants to merge 3 commits into
NodeBB:masterfrom
jasonwch:master
Open

Poll plugin refinement and bug fix (4.14 and 4.15)#160
jasonwch wants to merge 3 commits into
NodeBB:masterfrom
jasonwch:master

Conversation

@jasonwch

Copy link
Copy Markdown

Poll plugin refinement and bug fix targeted 4.14 and 4.15

Poll plugin refinement and bug fix targeted 4.14 and 4.15
Comment thread lib/config.js Outdated
'use strict';

const meta = nodebb.require('./src/meta');
const meta = require.main.require('./src/meta');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nodebb.require is the future proof way, so that should be used

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, will update the PR

Comment thread public/js/poll/view.js
{
// Option details
register: function (view) {
if (!app.user.uid) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this gonna break guests from viewing results if allowed in the admin page?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The guest switch is working

  1. Sockets.get (sockets.js:26-28): Returns poll data to guests if allowAnon is true.

  2. View.prototype.load (view.js:191): if (!app.user.uid || self.pollData.hasVoted) → calls showResultsPanel() — guests see results.

  3. results.tpl (lines 9-12): For guests ({{{ if config.loggedIn }}} → false), renders votecount as a non-clickable — guests see the vote count numbers.

  4. The early return at view.js:132: Only skips registering the option details click handler (the "who voted" popup). Guests never see clickable votecount links, so there's nothing to click anyway.

  5. Server-side guard: Sockets.getOptionDetails (sockets.js:148) checks if (!socket.uid || ...) and throws — so even if the handler were registered, the server would reject it.

Comment thread public/js/poll/view.js
const translator = await app.require('translator');
await Promise.all(details.votes.map(async (voter) => {
if (voter.displayname && voter.displayname.includes('[[')) {
voter.displayname = await translator.translate(voter.displayname);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want to translate usernames

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, will update the PR

jasonwch added 2 commits July 11, 2026 22:11
1. Use nodebb.require
2. Do not translate usernames
Fix for guest translate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants