shotvibe / shotvibe-web

ShotVibe REST API webservice
1 stars 0 forks source link

Send push notification to user when he is added to an album #7

Closed benny-shotvibe closed 11 years ago

benny-shotvibe commented 11 years ago

This should be similar to the push that is already sent for new photos:

Two different types of messages for the user who created the album(used only for doing an immediate sync between multiple devices of the same user), and for everyone else

benny-shotvibe commented 11 years ago

We should only need to add a single new function to device_push module: broadcast_new_album

benny-shotvibe commented 11 years ago

Ignore my previous comment. Please use the following definitions for 2 new functions in photos_api.device_push:

def broadcast_added_to_album(album_id, album_name, adder_name, user_ids):
    rq = {
            'user_ids': [str(id) for id in user_ids],
            'gcm': {
                'data': {
                    'type': 'added_to_album',
                    'album_id': str(album_id),
                    'adder': adder_name,
                    'album_name' : album_name,
                    }
                },
            'apns': {
                'aps': {
                    'alert': adder_name + ' added you to the album ' + album_name,
                    'sound': 'default',
                    },
                'album_id': album_id
                }
            }
    send_message_or_log_errors(rq)

def broadcast_album_list_sync(user_ids):
    rq = {
            'user_ids': [str(id) for id in user_ids],
            'gcm': {
                'data': {
                    'type': 'album_list_sync'
                    }
                },
            'apns': {
                'aps': {},
                'type': 'album_list_sync'
                }
            }
    send_message_or_log_errors(rq)
benny-shotvibe commented 11 years ago

For broadcast_album_list_sync it might be best to change the argument from a list of user_ids to just a single user_id, since I can't think of a scenario where it will be needed to broadcast this event to multiple users

benny-shotvibe commented 11 years ago

Implemented in e5c078aa38cb53f81255b3da3fe02c17a6a1c0ba