def fetch(): guild_id = request.args.get("guild_id") channel_id = request.args.get('channel_id') after_snowflake = request.args.get('after', 0, type=int) if user_unauthenticated(): key = session['user_keys'][guild_id] else: key = None status = update_user_status(guild_id, session['username'], key) messages = {} if status['banned'] or status['revoked']: status_code = 403 if user_unauthenticated(): session['user_keys'].pop(guild_id, None) session.modified = True else: chan = filter_guild_channel(guild_id, channel_id) if not chan: abort(404) if not chan.get("read") or chan["channel"]["type"] != "text": status_code = 401 else: messages = redisqueue.get_channel_messages(guild_id, channel_id, after_snowflake) status_code = 200 response = jsonify(messages=messages, status=status) response.status_code = status_code return response
def fetch_visitor(): guild_id = request.args.get("guild_id") channel_id = request.args.get('channel_id') after_snowflake = request.args.get('after', 0, type=int) if not guild_accepts_visitors(guild_id): abort(403) messages = {} chan = filter_guild_channel(guild_id, channel_id, True) if not chan: abort(404) if not chan.get("read") or chan["channel"]["type"] != "text": status_code = 401 else: messages = redisqueue.get_channel_messages(guild_id, channel_id, after_snowflake) status_code = 200 response = jsonify(messages=messages) response.status_code = status_code return response