Esempio n. 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
                ),
            },
        )
Esempio n. 2
0
def get_broadcasts():
    from api.broadcasts_response import BroadcastsResponse
    broadcastsResponse = BroadcastsResponse(env_config.appType)
    response = broadcastsResponse.get_last_broadcasts_response(100)
    output = []
    for x in range(len(response)):
        output.append(response[len(response) - x - 1])
    return json.dumps(output)
Esempio n. 3
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)
Esempio n. 4
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)
Esempio n. 5
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)
            })
Esempio n. 6
0
def get_broadcasts():
    from api.broadcasts_response import BroadcastsResponse
    broadcastsResponse = BroadcastsResponse(env_config.appType)
    response = broadcastsResponse.get_last_broadcasts_response(100)
    return json.dumps(response)
Esempio n. 7
0
def get_broadcasts():
    from api.broadcasts_response import BroadcastsResponse
    broadcastsResponse = BroadcastsResponse(env_config.appType)
    messages = broadcastsResponse.get_all_messages_response()
    return messages
Esempio n. 8
0
def get_broadcasts():
    from api.broadcasts_response import BroadcastsResponse

    broadcastsResponse = BroadcastsResponse(env_config.appType)
    response = broadcastsResponse.get_last_broadcasts_response(10)
    return json.dumps(response)
Esempio n. 9
0
def get_broadcasts():
    from api.broadcasts_response import BroadcastsResponse

    broadcastsResponse = BroadcastsResponse(env_config.appType)
    messages = broadcastsResponse.get_all_messages_response()
    return messages