def post_screenshot_notification(post, user_that_screenshotted): if post.user.platform == USER_PLATFORM_iOS and post.user.device_token is not None: jack_apns.send(post.user.device_token, 'The user ' + user_that_screenshotted.nickname + ' just took a screenshot that included your post!', sound='default', extra=dict(post_id=post.id, group_id=post.group.id, pic=user_that_screenshotted.pic, type='screenshot_post'))
def post_auth_removed_request_notification(post): if post.anon == 1: if post.user.platform == USER_PLATFORM_iOS and post.user.device_token is not None: jack_apns.send(post.user.device_token, 'The admins of ' + post.group.title + ' just removed your anonymous post. You can send them an email on More -> Manage Groups.', sound='default', extra=dict(post_id=post.id, group_id=post.group.id, group_title=post.group.title, type='post_auth_removed'))
def post_auth_request_notification(post): if post.anon == 1: if post.user.platform == USER_PLATFORM_iOS: for user in post.group.admins: if user.device_token is not None: jack_apns.send(user.device_token, 'Someone wants to post anonymously to ' + post.group.title, sound='default', extra=dict(post=json.loads(PostSchema().dumps(post).data), user=json.loads(UserSchema().dumps(post.user).data), type='post_auth_request', group_title=post.group.title))
def invited_for_group(invite_object, group_object): if invite_object.invitee.device_token is not None: res = jack_apns.send(invite_object.invitee.device_token, invite_object.inviter.nickname + ' is inviting you to join ' + group_object.title, extra=dict(invite_id=invite_object.id, group_id=group_object.id, type='invite', group_title=group_object.title, inviter_name=invite_object.inviter.nickname, inviter_pic=invite_object.inviter.pic))