Update user chip if a user has been updated

This commit is contained in:
Jeremy Zhang 2017-08-25 23:19:13 +00:00
parent ac956106e9
commit 8b6645306a
2 changed files with 20 additions and 2 deletions

View File

@ -1,6 +1,6 @@
from titanembeds.utils import socketio, guild_accepts_visitors, get_client_ipaddr from titanembeds.utils import socketio, guild_accepts_visitors, get_client_ipaddr
from titanembeds.userbookkeeping import check_user_in_guild, get_guild_channels, update_user_status from titanembeds.userbookkeeping import check_user_in_guild, get_guild_channels, update_user_status
from titanembeds.database import db, GuildMembers from titanembeds.database import db, GuildMembers, get_guild_member
from flask_socketio import Namespace, emit, disconnect, join_room, leave_room from flask_socketio import Namespace, emit, disconnect, join_room, leave_room
import functools import functools
from flask import request, session from flask import request, session
@ -79,3 +79,16 @@ class Gateway(Namespace):
else: else:
leave_room("CHANNEL_"+chan["channel"]["id"]) leave_room("CHANNEL_"+chan["channel"]["id"])
emit("channel_list", channels) emit("channel_list", channels)
def on_current_user_info(self, data):
guild_id = data["guild_id"]
if "user_keys" in session and not session["unauthenticated"]:
dbMember = get_guild_member(guild_id, session["user_id"])
usr = {
'avatar': session["avatar"],
'username': dbMember.username,
'nickname': dbMember.nickname,
'discriminator': dbMember.discriminator,
'user_id': session['user_id'],
}
emit("current_user_info", usr)

View File

@ -1052,6 +1052,7 @@
socket.on("GUILD_MEMBER_UPDATE", function (usr) { socket.on("GUILD_MEMBER_UPDATE", function (usr) {
update_socket_channels(); update_socket_channels();
socket.emit("current_user_info", {"guild_id": guild_id});
for (var i = 0; i < discord_users_list.length; i++) { for (var i = 0; i < discord_users_list.length; i++) {
if (usr.id == discord_users_list[i].id) { if (usr.id == discord_users_list[i].id) {
discord_users_list.splice(i, 1); discord_users_list.splice(i, 1);
@ -1116,6 +1117,10 @@
} }
} }
}); });
socket.on("current_user_info", function (usr) {
update_embed_userchip(true, usr.avatar, usr.username, usr.nickname, usr.userid, usr.discriminator);
});
} }
function update_socket_channels() { function update_socket_channels() {