Ejemplo n.º 1
0
def test(request):
    from mainapp.utils.notification_helper import NotificationHelper
    device_token = "2F79378100B67B4CABB83F03AE52493120D73B6F0BE848FE3899BFCCE49A4352"
    message = "hello!"
    button_title = "Confirm"
    NotificationHelper(device_token).send_notification_with_custome_button(message, button_title)
    return HttpResponse(json.dumps(dict(result="OK")), content_type="application/json")
Ejemplo n.º 2
0
def invite_members_to_activity(request):
    user_id = request.user.username
    post_data = json.loads(request.body)
    event_id = post_data['event_id']
    members = post_data['members']
    ActivityOperation(user_id, event_id).invite_members_to_activity(members)
    device_token_list = UserInfoHelper().get_device_token_list_by_users(
        members)
    message = "activity"
    payload = dict(event_type=EVENT_TYPE, )
    NotificationHelper(device_token_list).send_notification_with_payload(
        message, payload)
    return Response(data=dict(result="success"), status=status.HTTP_200_OK)
Ejemplo n.º 3
0
def create_topic(request):
    user_id = request.user.username
    post_data = json.loads(request.body)
    topic_name = post_data['topic_name']
    topic_description = post_data['topic_description']
    members = post_data['members']
    event_id = CreateEventHelper(user_id, EVENT_TYPE).create_topic(
        topic_name, topic_description, members)
    device_token_list = UserInfoHelper().get_device_token_list_by_users(
        members)
    message = topic_name
    payload = dict(event_type=EVENT_TYPE, )
    NotificationHelper(device_token_list).send_notification_with_payload(
        message, payload)
    return Response(data=dict(result="success", event_id=event_id),
                    status=status.HTTP_200_OK)
Ejemplo n.º 4
0
def complete_reminder_by_receiver(request):
    user_id = request.user.username
    post_data = json.loads(request.body)
    event_id = post_data['event_id']
    if 'message' in post_data:
        message = post_data['message']
    else:
        message = None
    creator_id = ReminderOperation(
        user_id, event_id).complete_reminder_by_receiver(message)
    device_token_list = UserInfoHelper().get_device_token_list_by_users(
        [creator_id])
    message = "complete"
    payload = dict(event_type=EVENT_TYPE, )
    NotificationHelper(device_token_list).send_notification_with_payload(
        message, payload)
    return Response(data=dict(result="success"), status=status.HTTP_200_OK)
Ejemplo n.º 5
0
def create_reminder(request):
    user_id = request.user.username
    post_data = json.loads(request.body)
    reminder_content = post_data['reminder_content']
    receivers = post_data['receivers']
    time_dict = post_data['time']
    location_dict = post_data['location']
    event_id = CreateEventHelper(user_id, EVENT_TYPE).create_reminder(
        reminder_content, receivers, time_dict, location_dict)
    device_token_list = UserInfoHelper().get_device_token_list_by_users(
        receivers)
    message = reminder_content
    payload = dict(event_type=EVENT_TYPE, )
    NotificationHelper(device_token_list).send_notification_with_payload(
        message, payload)
    return Response(data=dict(result="success", event_id=event_id),
                    status=status.HTTP_200_OK)