Example #1
0
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
                ),
            },
        )
Example #2
0
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.'}
Example #3
0
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}
Example #4
0
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."}
Example #5
0
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}
Example #6
0
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)
Example #7
0
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)
Example #8
0
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)
            })
Example #9
0
def handle_signon():
    from api.signon_response import SignonResponse
    signonResponse = SignonResponse()
    sessionID = signonResponse.signon(bottle.request.POST.get('displayName'))
    return {'sessionID': sessionID}
Example #10
0
def handle_signon():
    from api.signon_response import SignonResponse

    signonResponse = SignonResponse()
    sessionID = signonResponse.signon(bottle.request.POST.get("displayName"))
    return {"sessionID": sessionID}