mirror of https://github.com/calzoneman/sync.git
Continue fixing things
This commit is contained in:
parent
22c4e8f9ff
commit
a4260bd25b
|
@ -1,6 +1,7 @@
|
|||
var util = require("./utilities");
|
||||
var db = require("./database");
|
||||
var Playlist = require("./playlist");
|
||||
var Poll = require("./poll").Poll;
|
||||
var Filter = require("./filter").Filter;
|
||||
var Logger = require("./logger");
|
||||
var AsyncQueue = require("./asyncqueue");
|
||||
|
@ -873,30 +874,6 @@ Channel.prototype.sendChatFilters = function (users) {
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Sends the current poll
|
||||
*/
|
||||
Channel.prototype.sendPoll = function (users, sendNew) {
|
||||
var self = this;
|
||||
if (!self.poll) {
|
||||
return;
|
||||
}
|
||||
|
||||
sendNew = sendNew || false;
|
||||
var msg = sendNew ? "newPoll" : "updatePoll";
|
||||
|
||||
var obscured = self.poll.packupdate(true);
|
||||
var unobscured = self.poll.packupdate(false);
|
||||
|
||||
users.forEach(function (u) {
|
||||
if (self.hasPermission(u, "viewpollresults")) {
|
||||
u.socket.emit(msg, unobscured);
|
||||
} else {
|
||||
u.socket.emit(msg, obscured);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Sends the channel permissions
|
||||
*/
|
||||
|
@ -1153,6 +1130,27 @@ Channel.prototype.sendUserLeave = function (users, user) {
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Sends the current poll
|
||||
*/
|
||||
Channel.prototype.sendPoll = function (users) {
|
||||
var self = this;
|
||||
if (!self.poll) {
|
||||
return;
|
||||
}
|
||||
|
||||
var obscured = self.poll.packUpdate(false);
|
||||
var unobscured = self.poll.packUpdate(true);
|
||||
|
||||
users.forEach(function (u) {
|
||||
if (self.hasPermission(u, "viewpollresults")) {
|
||||
u.socket.emit("newPoll", unobscured);
|
||||
} else {
|
||||
u.socket.emit("newPoll", obscured);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Sends a poll notification
|
||||
*/
|
||||
|
@ -1163,9 +1161,9 @@ Channel.prototype.sendPollUpdate = function (users) {
|
|||
|
||||
users.forEach(function (u) {
|
||||
if (self.hasPermission(u, "viewhiddenpoll")) {
|
||||
u.socket.emit("newPoll", unhidden);
|
||||
u.socket.emit("updatePoll", unhidden);
|
||||
} else {
|
||||
u.socket.emit("newPoll", hidden);
|
||||
u.socket.emit("updatePoll", hidden);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -1712,7 +1710,7 @@ Channel.prototype.move = function (from, after, callback) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (self.playlist.move(data.from, data.after)) {
|
||||
if (self.playlist.move(from, after)) {
|
||||
self.sendAll("moveVideo", {
|
||||
from: from,
|
||||
after: after
|
||||
|
@ -1918,7 +1916,7 @@ Channel.prototype.handleOpenPoll = function (user, data) {
|
|||
var obscured = (data.obscured === true);
|
||||
var poll = new Poll(user.name, title, opts, obscured);
|
||||
this.poll = poll;
|
||||
this.sendPoll(this.users);
|
||||
this.sendPoll(this.users, true);
|
||||
this.logger.log("*** " + user.name + " Opened Poll: '" + poll.title + "'");
|
||||
};
|
||||
|
||||
|
@ -1933,7 +1931,7 @@ Channel.prototype.handleClosePoll = function (user) {
|
|||
if (this.poll) {
|
||||
if (this.poll.obscured) {
|
||||
this.poll.obscured = false;
|
||||
this.sendPoll(this.users);
|
||||
this.sendPollUpdate(this.users);
|
||||
}
|
||||
|
||||
this.logger.log("*** " + user.name + " closed the active poll");
|
||||
|
@ -1956,7 +1954,7 @@ Channel.prototype.handlePollVote = function (user, data) {
|
|||
|
||||
if (this.poll) {
|
||||
this.poll.vote(user.ip, data.option);
|
||||
this.sendPoll(this.users);
|
||||
this.sendPollUpdate(this.users);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1995,7 +1993,7 @@ Channel.prototype.checkVoteskipPass = function () {
|
|||
}
|
||||
|
||||
var max = this.calcVoteskipMax();
|
||||
var need = Math.ceil(count * this.opts.voteskip_ratio);
|
||||
var need = Math.ceil(max * this.opts.voteskip_ratio);
|
||||
if (this.voteskip.counts[0] >= need) {
|
||||
this.logger.log("### Voteskip passed, skipping to next video");
|
||||
this.playNext();
|
||||
|
|
|
@ -241,11 +241,11 @@ User.prototype.initChannelCallbacks = function () {
|
|||
});
|
||||
|
||||
wrapTypecheck("newPoll", function (data) {
|
||||
self.channel.handlePoll(self, data);
|
||||
self.channel.handleOpenPoll(self, data);
|
||||
});
|
||||
|
||||
wrapTypecheck("vote", function (data) {
|
||||
self.channel.handleVote(self, data);
|
||||
self.channel.handlePollVote(self, data);
|
||||
});
|
||||
|
||||
wrap("closePoll", function () {
|
||||
|
|
Loading…
Reference in New Issue