1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-08-10 08:10:52 +00:00

3.5.270. Fix a BTTV template. Change the get_editor_of function to use DOMParser for better security. Fix websocket callbacks not getting called. Remove a client-side permissions check from the /ffz following command.

This commit is contained in:
SirStendec 2016-08-12 14:25:19 -04:00
parent 0ee788b998
commit 9592dc1c2c
7 changed files with 69 additions and 19 deletions

View file

@ -1,3 +1,14 @@
<div class="list-header">3.5.270</div>
<ul class="chat-menu-content menu-side-padding">
<li>Changed: Remove client-side permissions check from <code>/ffz following</code>.</li>
<li>Fixed: Socket command callbacks were not being called if an error occured.</li>
</ul>
<div class="list-header">3.5.269</div>
<ul class="chat-menu-content menu-side-padding">
<li>Fixed: Update one of BetterTTV's chat templates so sub notifications have backgrounds as they should with BTTV.</li>
</ul>
<div class="list-header">3.5.268</div> <div class="list-header">3.5.268</div>
<ul class="chat-menu-content menu-side-padding"> <ul class="chat-menu-content menu-side-padding">
<li>As was pointed out on Twitter, I'm silly and the strings for username colors should be <code>Deprecated</code> and not <code>Depreciated</code>.</li> <li>As was pointed out on Twitter, I'm silly and the strings for username colors should be <code>Deprecated</code> and not <code>Depreciated</code>.</li>

View file

@ -45,6 +45,32 @@ FFZ.prototype.setup_channel = function() {
return; return;
Channel.reopen({ Channel.reopen({
/*isEditable: function() {
var channel_id = this.get('content.id'),
user = this.get('login.userData');
if ( ! user || ! user.login )
return false;
else if ( user.login === channel_id || user.is_admin || user.is_staff)
return true;
// Okay, have we loaded this user's editor status? Try that.
if ( f._editor_of )
return f._editor_of.indexOf(channel_id) !== -1;
var t = this;
f.get_user_editor_of().then(function(result) {
// Once editor status is loaded, if the user does have editor
// status for this channel, update this property.
if ( result.indexOf(channel_id) !== -1 )
Ember.propertyDidChange(t, 'isEditable');
});
return false;
}.property('content.id', 'login.userData', 'login.userData.login'),*/
ffzUpdateUptime: function() { ffzUpdateUptime: function() {
if ( f._cindex ) if ( f._cindex )
f._cindex.ffzUpdateUptime(); f._cindex.ffzUpdateUptime();
@ -142,6 +168,7 @@ FFZ.prototype.setup_channel = function() {
}.observes("content.hostModeTarget") }.observes("content.hostModeTarget")
}); });
Ember.propertyDidChange(Channel, 'isEditable');
Channel.ffzUpdateInfo(); Channel.ffzUpdateInfo();
} }

View file

@ -155,7 +155,7 @@ FFZ.prototype.setup_bttv = function(delay) {
f.bttv_badges(data); f.bttv_badges(data);
// Now, do everything else manually because things are hard-coded. // Now, do everything else manually because things are hard-coded.
return '<div class="chat-line'+(opts.highlight?' highlight':'')+(opts.action?' action':'')+(opts.server?' admin':'')+'" data-sender="'+(data.sender||"").toLowerCase()+'" data-room="'+received_room+'">'+ return '<div class="chat-line'+(opts.highlight?' highlight':'')+(opts.action?' action':'')+(opts.server?' admin':'')+(opts.notice?' notice':'')+'" data-sender="'+(data.sender||"").toLowerCase()+'" data-room="'+received_room+'">'+
BC.templates.timestamp(data.time)+' '+ BC.templates.timestamp(data.time)+' '+
(opts.isMod ? BC.templates.modicons():'')+' '+ (opts.isMod ? BC.templates.modicons():'')+' '+
BC.templates.badges(data.badges)+ BC.templates.badges(data.badges)+
@ -201,9 +201,11 @@ FFZ.prototype.setup_bttv = function(delay) {
received_sender; received_sender;
BC.templates.message = function(sender, message, data) { BC.templates.message = function(sender, message, data) {
try { try {
data = data || {};
var colored = data.colored || false, var colored = data.colored || false,
force = data.force || false, force = data.force || false,
emotes = data.emotes, emotes = data.emotes,
bits = data.bits,
rawMessage = encodeURIComponent(message); rawMessage = encodeURIComponent(message);
if(sender !== 'jtv') { if(sender !== 'jtv') {
@ -214,7 +216,7 @@ FFZ.prototype.setup_bttv = function(delay) {
for(var i=0; i<tokenizedMessage.length; i++) { for(var i=0; i<tokenizedMessage.length; i++) {
if(typeof tokenizedMessage[i] === 'string') { if(typeof tokenizedMessage[i] === 'string') {
tokenizedMessage[i] = BC.templates.bttvMessageTokenize(sender, tokenizedMessage[i], data.bits); tokenizedMessage[i] = BC.templates.bttvMessageTokenize(sender, tokenizedMessage[i], bits);
} else { } else {
tokenizedMessage[i] = tokenizedMessage[i][0]; tokenizedMessage[i] = tokenizedMessage[i][0];
} }
@ -229,7 +231,7 @@ FFZ.prototype.setup_bttv = function(delay) {
spam = true; spam = true;
} }
return '<span class="message ' + (spam ? 'spam' : '') + '" ' + (colored ? 'style="color: ' + colored + '" ' : '') + 'data-raw="' + rawMessage + '" data-emotes="' + (emotes ? encodeURIComponent(JSON.stringify(emotes)) : 'false') + '">' + message + '</span>'; return '<span class="message ' + (spam ? 'spam' : '') + '" ' + (colored ? 'style="color: ' + colored + '" ' : '') + 'data-raw="' + rawMessage + '" data-bits="' + (bits ? encodeURIComponent(JSON.stringify(bits)) : 'false') + '" data-emotes="' + (emotes ? encodeURIComponent(JSON.stringify(emotes)) : 'false') + '">' + message + '</span>';
} catch(err) { } catch(err) {
f.log("Error: ", err); f.log("Error: ", err);

View file

@ -34,7 +34,7 @@ FFZ.msg_commands = {};
// Version // Version
var VER = FFZ.version_info = { var VER = FFZ.version_info = {
major: 3, minor: 5, revision: 268, major: 3, minor: 5, revision: 270,
toString: function() { toString: function() {
return [VER.major, VER.minor, VER.revision].join(".") + (VER.extra || ""); return [VER.major, VER.minor, VER.revision].join(".") + (VER.extra || "");
} }
@ -125,24 +125,35 @@ FFZ.prototype.get_user = function(force_reload) {
return user; return user;
} }
FFZ.prototype._editor_of = null;
FFZ.prototype.get_user_editor_of = function() { FFZ.prototype.get_user_editor_of = function() {
var f = this; var f = this;
return new Promise(function(succeed,fail) { return new Promise(function(succeed,fail) {
var user = f.get_user(); var user = f.get_user();
if ( ! user || ! user.login ) if ( ! user || ! user.login )
return fail('not logged in'); return fail();
jQuery.get("/" + user.login + "/dashboard/permissions").done(function(data) { jQuery.get("/" + user.login + "/dashboard/permissions").done(function(data) {
var el = document.createElement('div'); try {
el.innerHTML = data; var dom = new DOMParser().parseFromString(data, 'text/html'),
links = dom.querySelectorAll('#editable .label');
var links = _.pluck(el.querySelectorAll('#editable .label'), 'href'); f._editor_of = _.map(links, function(e) {
succeed(_.map(links, function(e) { return e.substr(e.lastIndexOf('/') + 1) })); var href = e.getAttribute('href');
return href && href.substr(href.lastIndexOf('/') + 1);
});
succeed(f._editor_of);
} catch(err) {
f.error("Failed to parse User Editor State", err);
fail();
}
}).fail(function(e) { }).fail(function(e) {
f.error("Failed to load User Editor State", e); f.error("Failed to load User Editor State", e);
fail('failed to load dashboard'); fail();
}); });
}); });
} }

View file

@ -298,12 +298,12 @@ FFZ.prototype.ws_create = function() {
else else
f.log("Invalid command: " + cmd, data, false, true); f.log("Invalid command: " + cmd, data, false, true);
} else if ( cmd === "error" ) { } /*else if ( cmd === "error" ) {
f.log("Socket server reported error: " + data); f.log("Socket server reported error: " + data);
if (f._ws_callbacks[request] ) if (f._ws_callbacks[request] )
delete f._ws_callbacks[request]; delete f._ws_callbacks[request];
} else { }*/ else {
var success = cmd === 'ok', var success = cmd === 'ok',
has_callback = typeof f._ws_callbacks[request] === "function"; has_callback = typeof f._ws_callbacks[request] === "function";

View file

@ -41,7 +41,9 @@ FFZ.settings_info.follow_buttons = {
FFZ.ffz_commands.following = function(room, args) { FFZ.ffz_commands.following = function(room, args) {
args = args.join(" ").trim().toLowerCase().split(/[ ,]+/); args = args.join(" ").trim().toLowerCase().split(/[ ,]+/);
var out = []; var f = this,
out = [];
for(var i=0,l=args.length; i<l; i++) { for(var i=0,l=args.length; i<l; i++) {
var arg = args[i], var arg = args[i],
match = arg.match(TWITCH_URL); match = arg.match(TWITCH_URL);
@ -52,13 +54,10 @@ FFZ.ffz_commands.following = function(room, args) {
out.push(arg); out.push(arg);
} }
var user = this.get_user(), f = this;
if ( ! user || (user.login !== room.id && user.login !== "sirstendec" && user.login !== "dansalvato") )
return "You must be logged in as the broadcaster to use this command.";
if ( ! this.ws_send("update_follow_buttons", [room.id, out], function(success, data) { if ( ! this.ws_send("update_follow_buttons", [room.id, out], function(success, data) {
if ( ! success ) { if ( ! success ) {
f.room_message(room, "There was an error updating the following buttons."); f.log("Not a Success: " + JSON.stringify(data));
f.room_message(room, data);
return; return;
} }

View file

@ -130,7 +130,7 @@ body.ffz-bttv-dark .ffz-ui-toggle.blue.live:hover svg.svg-emoticons path { fill:
50% { opacity: 0.75; } 50% { opacity: 0.75; }
} }
.drawer__item--brick .warp__logo:hover { .warp__logo:hover {
animation: ffzflipwobble 4s infinite; animation: ffzflipwobble 4s infinite;
} }