def handle_event(sid, json): # time.sleep(20) # return {} messageID = json["data"]["messageID"] sessionID = json["data"]["sessionID"] from api.signon_response import SignonResponse signonResponse = SignonResponse() user = signonResponse.get_user_from_session_id(sessionID) if not user: return {} broadcastsResponse = BroadcastsResponse(env_config.appType) message, broadcastID = broadcastsResponse.process_broadcast(messageID, user) if message: timestamp = time.time() dt = datetime.datetime.utcnow() formattedTime = dt.strftime("%Y-%m-%d %H:%M:%S UTC") timestamp = dt.timestamp() displayName = user.displayName sio.emit( "messageResponse", { "messageID": message.id, "messageURL": message.url, "broadcastID": broadcastID, "html": bottle.template( "elements-message-panel", message=message, displayName=displayName, formattedTime=formattedTime ), }, )
def handle_signout(): '''Kill User's session. ''' from api.signon_response import SignonResponse signonResponse = SignonResponse() sessionID = signonResponse.signon(bottle.request.POST.get('displayName')) signonResponse.signout(bottle.request.get_cookie('sessionID')) return {'response': 'Signed out.'}
def handle_signon(): from api.signon_response import SignonResponse signonResponse = SignonResponse() user = signonResponse.get_user_from_session() if user: sessionID = user.id else: sessionID = '' return {'sessionID': sessionID}
def handle_signout(): """Kill User's session. """ from api.signon_response import SignonResponse signonResponse = SignonResponse() sessionID = signonResponse.signon(bottle.request.POST.get("displayName")) signonResponse.signout(bottle.request.get_cookie("sessionID")) return {"response": "Signed out."}
def handle_signon(): from api.signon_response import SignonResponse signonResponse = SignonResponse() user = signonResponse.get_user_from_session() if user: sessionID = user.id else: sessionID = "" return {"sessionID": sessionID}
def render_index(): from api.broadcasts_response import BroadcastsResponse broadcastsResponse = BroadcastsResponse(env_config.appType) messages = broadcastsResponse.get_all_messages() messageInputs = bottle.template("elements-message-input", messages=messages) # print(messageInputs) from api.signon_response import SignonResponse signonResponse = SignonResponse() user = signonResponse.get_user_from_session() if user: sessionID = user.id else: sessionID = "" return bottle.template("index", deployTag=deployTag, messageInputs=messageInputs, sessionID=sessionID)
def render_index(): from api.broadcasts_response import BroadcastsResponse broadcastsResponse = BroadcastsResponse(env_config.appType) messages = broadcastsResponse.get_all_messages() messageInputs = bottle.template('elements-message-input', messages=messages) #print(messageInputs) from api.signon_response import SignonResponse signonResponse = SignonResponse() user = signonResponse.get_user_from_session() if user: sessionID = user.id else: sessionID = '' return bottle.template('index', deployTag=deployTag, messageInputs=messageInputs, sessionID=sessionID)
def handle_event(sid, json): #time.sleep(20) #return {} messageID = json['data']['messageID'] sessionID = json['data']['sessionID'] broadcastText = json['data']['broadcastText'] from api.signon_response import SignonResponse signonResponse = SignonResponse() user = signonResponse.get_user_from_session_id(sessionID) if not user: return {} broadcastsResponse = BroadcastsResponse(env_config.appType) message, broadcastID = broadcastsResponse.process_text_broadcast( messageID, broadcastText, user) if broadcastID: timestamp = time.time() dt = datetime.datetime.utcnow() formattedTime = dt.strftime('%Y-%m-%d %H:%M:%S UTC') timestamp = dt.timestamp() displayName = user.displayName sio.emit( 'messageResponse', { #'messageID' : message.id, #'messageText' : message.text, #'messageURL' : message.url, 'broadcastID': broadcastID, 'broadcastText': broadcastText, 'html': bottle.template('elements-broadcast-text', broadcastText=broadcastText, displayName=displayName, formattedTime=formattedTime) })
def handle_signon(): from api.signon_response import SignonResponse signonResponse = SignonResponse() sessionID = signonResponse.signon(bottle.request.POST.get('displayName')) return {'sessionID': sessionID}
def handle_signon(): from api.signon_response import SignonResponse signonResponse = SignonResponse() sessionID = signonResponse.signon(bottle.request.POST.get("displayName")) return {"sessionID": sessionID}