Fixes for authenticated discord user check and other small fixes

This commit is contained in:
Jeremy Zhang 2017-04-05 18:43:59 +00:00
parent f5d53dd89a
commit 13e9649c10
3 changed files with 16 additions and 13 deletions

View File

@ -93,7 +93,8 @@ def check_user_in_guild(guild_id):
if user_unauthenticated(): if user_unauthenticated():
return guild_id in session['user_keys'] return guild_id in session['user_keys']
else: else:
return 200 == discord_api.get_guild_member_nocache(guild_id, session['user_id'])['code'] dbUser = db.session.query(AuthenticatedUsers).filter(and_(AuthenticatedUsers.guild_id == guild_id, AuthenticatedUsers.client_id == session['user_id'])).first()
return 200 == discord_api.get_guild_member_nocache(guild_id, session['user_id'])['code'] and dbUser is not None
def format_post_content(message): def format_post_content(message):
if (session['unauthenticated']): if (session['unauthenticated']):

View File

@ -204,6 +204,7 @@ function _wait_for_discord_login(index) {
} }
function select_channel(channel_id) { function select_channel(channel_id) {
if (selected_channel != channel_id) {
selected_channel = channel_id; selected_channel = channel_id;
last_message_id = null; last_message_id = null;
$("#channels-list > li.active").removeClass("active"); $("#channels-list > li.active").removeClass("active");
@ -211,6 +212,7 @@ function select_channel(channel_id) {
clearTimeout(fetchtimeout); clearTimeout(fetchtimeout);
run_fetch_routine(); run_fetch_routine();
} }
}
function replace_message_mentions(message) { function replace_message_mentions(message) {
var mentions = message.mentions; var mentions = message.mentions;
@ -332,8 +334,11 @@ $("#custom_username_field").keyup(function(event){
}); });
$("#messagebox").keyup(function(event){ $("#messagebox").keyup(function(event){
if ($(this).val().length == 1) {
$(this).val($.trim($(this).val())); $(this).val($.trim($(this).val()));
}
if(event.keyCode == 13 && $(this).val().length >= 1 && $(this).val().length <= 350) { if(event.keyCode == 13 && $(this).val().length >= 1 && $(this).val().length <= 350) {
$(this).val($.trim($(this).val()));
$(this).blur(); $(this).blur();
var funct = post(selected_channel, $(this).val()); var funct = post(selected_channel, $(this).val());
funct.done(function(data) { funct.done(function(data) {

View File

@ -56,11 +56,8 @@ def check_guild_existance(guild_id):
dbGuild = Guilds.query.filter_by(guild_id=guild_id).first() dbGuild = Guilds.query.filter_by(guild_id=guild_id).first()
if not dbGuild: if not dbGuild:
return False return False
guilds = discord_api.get_all_guilds() guild = discord_api.get_guild(guild_id)
for guild in guilds: return guild['code'] == 200
if guild_id == guild['id']:
return True
return False
def guild_query_unauth_users_bool(guild_id): def guild_query_unauth_users_bool(guild_id):
dbGuild = db.session.query(Guilds).filter(Guilds.guild_id==guild_id).first() dbGuild = db.session.query(Guilds).filter(Guilds.guild_id==guild_id).first()