Skip to content

Commit

Permalink
Add a sidebar warning when channel credentials are missing
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosuav committed Nov 11, 2024
1 parent 04926f9 commit e7c2f34
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion modules/http/chan_.pike
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,17 @@ __async__ mapping(string:mixed) find_channel(Protocols.HTTP.Server.Request req,
"backlink": "<a href=\"./\">StilleBot - " + channel->display_name + "</a>",
"menubutton": "<span id=togglesidebarbox><button type=button id=togglesidebar title=\"Show/hide sidebar\">Show/hide sidebar</button></span>",
]);
string navbar_warning = "";
if (mapping user = req->misc->session->?user) {
if (channel->user_badges[(int)user->id]->?_mod || is_localhost_mod(user->login, req->get_ip()))
req->misc->is_mod = 1;
else req->misc->chaninfo->save_or_login = "<i>You're logged in, but not a recognized mod. Before you can make changes, go to the channel and say something, so I can see your mod sword. Thanks!</i>";
req->misc->chaninfo->logout = "| <a href=\"/logout\" class=twitchlogout>Log out</a>";
if ((int)user->id == channel->userid) {
mapping tok = G->G->user_credentials[channel->userid] || ([]);
//The channel may be in a reduced functionality state due to missing permissions.
if (tok->missing) navbar_warning = "<li style='margin-top: 0.5em'><button class=twitchlogin scopes=\"" + tok->missing * " " + "\">Fix login</button></li>";
}
}
else req->misc->chaninfo->save_or_login = "[Mods, login to make changes](:.twitchlogin)";
mapping profile = channel->userid ? await(get_user_info(channel->userid))
Expand All @@ -141,9 +147,10 @@ __async__ mapping(string:mixed) find_channel(Protocols.HTTP.Server.Request req,
"link_override": "https://mustardmine.com/activate",
]);
req->misc->chaninfo->menunav = sprintf(
"<nav id=sidebar><ul>%{<li><a href=%q>%s</a></li>%}</ul>"
"<nav id=sidebar><ul>%{<li><a href=%q>%s</a></li>%}%s</ul>"
"<a href=%q target=_blank><img src=%q alt=\"Channel avatar\" title=%q></a></nav>",
req->misc->is_mod ? sidebar_modmenu : sidebar_nonmodmenu,
navbar_warning,
profile->link_override || "https://twitch.tv/" + profile->login,
profile->profile_image_url || "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVR42mNgAAIAAAUAAen63NgAAAAASUVORK5CYII=",
"Go to channel " + (profile->display_name || ""));
Expand Down

0 comments on commit e7c2f34

Please sign in to comment.