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():
return guild_id in session['user_keys']
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):
if (session['unauthenticated']):

View File

@ -204,12 +204,14 @@ function _wait_for_discord_login(index) {
}
function select_channel(channel_id) {
if (selected_channel != channel_id) {
selected_channel = channel_id;
last_message_id = null;
$("#channels-list > li.active").removeClass("active");
$("#channel-"+selected_channel).parent().addClass("active");
clearTimeout(fetchtimeout);
run_fetch_routine();
}
}
function replace_message_mentions(message) {
@ -332,8 +334,11 @@ $("#custom_username_field").keyup(function(event){
});
$("#messagebox").keyup(function(event){
if ($(this).val().length == 1) {
$(this).val($.trim($(this).val()));
}
if(event.keyCode == 13 && $(this).val().length >= 1 && $(this).val().length <= 350) {
$(this).val($.trim($(this).val()));
$(this).blur();
var funct = post(selected_channel, $(this).val());
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()
if not dbGuild:
return False
guilds = discord_api.get_all_guilds()
for guild in guilds:
if guild_id == guild['id']:
return True
return False
guild = discord_api.get_guild(guild_id)
return guild['code'] == 200
def guild_query_unauth_users_bool(guild_id):
dbGuild = db.session.query(Guilds).filter(Guilds.guild_id==guild_id).first()