Exemplo n.º 1
0
def get(user, fields = None):
    duser   = frappe.get_doc('User', user)
    dprof   = frappe.get_doc('Chat Profile', user)

    # If you're adding something here, make sure the client recieves it.
    profile = dict(
        # User
        name       = duser.name,
        email      = duser.email,
        first_name = duser.first_name,
        last_name  = duser.last_name,
        username   = duser.username,
        avatar     = duser.user_image,
        bio        = duser.bio,
        # Chat Profile
        status             = dprof.status,
        chat_background    = dprof.chat_background,
        message_preview    = bool(dprof.message_preview),
        notification_tones = bool(dprof.notification_tones),
        conversation_tones = bool(dprof.conversation_tones),
        enable_chat        = bool(dprof.enable_chat)
    )
    profile = filter_dict(profile, fields)

    return dictify(profile)
Exemplo n.º 2
0
def get(user, fields=None):
    duser = frappe.get_doc('User', user)

    if frappe.db.exists('Chat Profile', user):
        dprof = frappe.get_doc('Chat Profile', user)

        # If you're adding something here, make sure the client recieves it.
        profile = dict(
            # User
            name=duser.name,
            email=duser.email,
            first_name=duser.first_name,
            last_name=duser.last_name,
            username=duser.username,
            avatar=duser.user_image,
            bio=duser.bio,
            # Chat Profile
            status=dprof.status,
            chat_background=dprof.chat_background,
            message_preview=bool(dprof.message_preview),
            notification_tones=bool(dprof.notification_tones),
            conversation_tones=bool(dprof.conversation_tones),
            enable_chat=bool(dprof.enable_chat))
        profile = filter_dict(profile, fields)

        return dictify(profile)
Exemplo n.º 3
0
def settings(fields=None):
    fields = safe_json_loads(fields)

    dsettings = frappe.get_single('Website Settings')
    response = dict(
        socketio=dict(port=frappe.conf.socketio_port),
        enable=bool(dsettings.chat_enable),
        enable_from=dsettings.chat_enable_from,
        enable_to=dsettings.chat_enable_to,
        room_name=dsettings.chat_room_name,
        welcome_message=dsettings.chat_welcome_message,
        operators=[duser.user for duser in dsettings.chat_operators])

    if fields:
        response = filter_dict(response, fields)

    return response
Exemplo n.º 4
0
def settings(fields = None):
    fields    = safe_json_loads(fields)

    dsettings = frappe.get_single('Website Settings')
    response  = dict(
        socketio         = dict(
            port         = frappe.conf.socketio_port
        ),
        enable           = bool(dsettings.chat_enable),
        enable_from      = dsettings.chat_enable_from,
        enable_to        = dsettings.chat_enable_to,
        room_name        = dsettings.chat_room_name,
        welcome_message  = dsettings.chat_welcome_message,
        operators        = [
            duser.user for duser in dsettings.chat_operators
        ]
    )

    if fields:
        response = filter_dict(response, fields)

    return response