diff --git a/discordbot/titanembeds/socketio/socketiointerface.py b/discordbot/titanembeds/socketio/socketiointerface.py
index 1dc3ab4..6c5249f 100644
--- a/discordbot/titanembeds/socketio/socketiointerface.py
+++ b/discordbot/titanembeds/socketio/socketiointerface.py
@@ -149,7 +149,7 @@ class SocketIOInterface:
await self.io.emit('CHANNEL_CREATE', data=chan, room=str("GUILD_"+channel.server.id), namespace='/gateway')
async def on_channel_update(self, channel):
- if str(channel.type) != "text":
+ if str(channel.type) not in ["text", "category"]:
return
chan = self.get_formatted_channel(channel)
await self.io.emit('CHANNEL_UPDATE', data=chan, room=str("GUILD_"+channel.server.id), namespace='/gateway')
diff --git a/discordbot/titanembeds/utils.py b/discordbot/titanembeds/utils.py
index cee65f2..235673d 100644
--- a/discordbot/titanembeds/utils.py
+++ b/discordbot/titanembeds/utils.py
@@ -64,7 +64,7 @@ def get_roles_list(guildroles):
def get_channels_list(guildchannels):
channels = []
for channel in guildchannels:
- if str(channel.type) == "text":
+ if str(channel.type) in ["text", "category"]:
overwrites = []
for target, overwrite in channel.overwrites:
if isinstance(target, discord.Role):
@@ -80,14 +80,17 @@ def get_channels_list(guildchannels):
"allow": allow,
"deny": deny,
})
-
+ parent = channel.parent
+ if parent:
+ parent = parent.id
channels.append({
"id": channel.id,
"name": channel.name,
"topic": channel.topic,
"position": channel.position,
"type": str(channel.type),
- "permission_overwrites": overwrites
+ "permission_overwrites": overwrites,
+ "parent_id": parent,
})
return channels
diff --git a/webapp/titanembeds/blueprints/api/api.py b/webapp/titanembeds/blueprints/api/api.py
index ffcf773..6392ab3 100644
--- a/webapp/titanembeds/blueprints/api/api.py
+++ b/webapp/titanembeds/blueprints/api/api.py
@@ -179,7 +179,7 @@ def fetch():
chan = filter_guild_channel(guild_id, channel_id)
if not chan:
abort(404)
- if not chan.get("read"):
+ if not chan.get("read") or chan["channel"]["type"] != "text":
status_code = 401
else:
messages = get_channel_messages(guild_id, channel_id, after_snowflake)
@@ -200,7 +200,7 @@ def fetch_visitor():
chan = filter_guild_channel(guild_id, channel_id, True)
if not chan:
abort(404)
- if not chan.get("read"):
+ if not chan.get("read") or chan["channel"]["type"] != "text":
status_code = 401
else:
messages = get_channel_messages(guild_id, channel_id, after_snowflake)
@@ -233,7 +233,7 @@ def post():
status_code = 401
else:
chan = filter_guild_channel(guild_id, channel_id)
- if not chan.get("write"):
+ if not chan.get("write") or chan["channel"]["type"] != "text":
status_code = 401
elif not illegal_post:
userid = session["user_id"]
diff --git a/webapp/titanembeds/static/css/embedstyle.css b/webapp/titanembeds/static/css/embedstyle.css
index 7e0034c..1126213 100644
--- a/webapp/titanembeds/static/css/embedstyle.css
+++ b/webapp/titanembeds/static/css/embedstyle.css
@@ -82,6 +82,10 @@ nav .brand-logo {
color: #eceff1;
}
+.side-nav li>a[id^=channel] {
+ margin-left: 7px;
+}
+
.side-nav .subheader {
color: #cfd8dc;
font-variant: small-caps;
@@ -213,6 +217,10 @@ nav .brand-logo {
-webkit-filter: brightness(150%);
}
+.subheader .channel-category {
+ text-transform: uppercase;
+}
+
.chatusername {
font-weight: bold;
color: #eceff1;
diff --git a/webapp/titanembeds/static/js/embed.js b/webapp/titanembeds/static/js/embed.js
index 44d5a31..38bd5e8 100644
--- a/webapp/titanembeds/static/js/embed.js
+++ b/webapp/titanembeds/static/js/embed.js
@@ -371,20 +371,74 @@
guild_channels_list = channels;
var template = $('#mustache_channellistings').html();
Mustache.parse(template);
+ var template_category = $('#mustache_channelcategory').html();
+ Mustache.parse(template_category);
$("#channels-list").empty();
var curr_default_channel = selected_channel;
+ var categories = [{
+ "channel": {id: null, name: "Uncategorized"},
+ "children": [],
+ "read": true,
+ }];
for (var i = 0; i < channels.length; i++) {
var chan = channels[i];
guild_channels[chan.channel.id] = chan;
- if (chan.read) {
- var rendered = Mustache.render(template, {"channelid": chan.channel.id, "channelname": chan.channel.name});
- $("#channels-list").append(rendered);
- $("#channel-" + chan.channel.id.toString()).click({"channel_id": chan.channel.id.toString()}, function(event) {
- select_channel(event.data.channel_id);
- });
- if (!selected_channel && (!curr_default_channel || chan.channel.position < curr_default_channel.channel.position)) {
- curr_default_channel = chan;
- }
+ if (chan.channel.type == "category") {
+ chan.children = [];
+ categories.push(chan);
+ }
+ }
+ categories.sort(function(a, b) {
+ return parseInt(a.channel.position) - parseInt(b.channel.position);
+ });
+ for (var i = 0; i < channels.length; i++) {
+ var chan = channels[i];
+ if (chan.channel.type == "text") {
+ var cate = chan.channel.parent_id;
+ for (var j = 0; j < categories.length; j++) {
+ var thiscategory = categories[j];
+ if (thiscategory.channel.id == cate) {
+ thiscategory.children.push(chan);
+ break;
+ }
+ }
+ }
+ }
+ for (var i = 0; i < categories.length; i++) {
+ var cate = categories[i];
+ cate.read = false;
+ for (var j = 0; j < cate.children.length; j++) {
+ var chan = cate.children[j];
+ if (chan.channel.type == "text" && chan.read) {
+ cate.read = true;
+ break;
+ }
+ }
+ }
+ for (var i = 0; i < categories.length; i++) {
+ var cate = categories[i];
+ var children = cate.children;
+ children.sort(function(a, b) {
+ return parseInt(a.channel.position) - parseInt(b.channel.position);
+ });
+ if (i != 0) {
+ if (cate.read) {
+ var rendered_category = Mustache.render(template_category, {"name": cate.channel.name});
+ $("#channels-list").append(rendered_category);
+ }
+ }
+ for (var j = 0; j < children.length; j++) {
+ var chan = children[j];
+ if (chan.read) {
+ var rendered_channel = Mustache.render(template, {"channelid": chan.channel.id, "channelname": chan.channel.name});
+ $("#channels-list").append(rendered_channel);
+ $("#channel-" + chan.channel.id.toString()).click({"channel_id": chan.channel.id.toString()}, function(event) {
+ select_channel(event.data.channel_id);
+ });
+ if (!selected_channel && (!curr_default_channel || chan.channel.position < curr_default_channel.channel.position)) {
+ curr_default_channel = chan;
+ }
+ }
}
}
if (typeof curr_default_channel == "object") {
diff --git a/webapp/titanembeds/templates/embed.html.j2 b/webapp/titanembeds/templates/embed.html.j2
index cb64439..ef08585 100644
--- a/webapp/titanembeds/templates/embed.html.j2
+++ b/webapp/titanembeds/templates/embed.html.j2
@@ -211,6 +211,10 @@
+
+