コード例 #1
0
ファイル: commands.py プロジェクト: wonderpl/dolly-web
def _post_facebook_story(user, object_type, object_id, token, action, explicit=False):
    url = ShareLink.get_or_create(user, object_type, object_id)[0].url
    if action.startswith('og'):
        post_args = dict(object=url)
    elif object_type == 'channel':
        post_args = dict(channel=url)
    else:
        post_args = dict(other=url)
    if explicit:
        post_args['fb:explicitly_shared'] = 'true'
    try:
        facebook.GraphAPI(token).request('me/' + action, post_args=post_args)
    except:
        app.logger.exception('Failed to autoshare: %s %s', user, object_id)
    else:
        app.logger.info('Autoshare: %s %s', user, object_id)
コード例 #2
0
ファイル: commands.py プロジェクト: wonderpl/dolly-web
def influencer_starred_email(recipient, sender, influencer_id, video_instance):
    if recipient.id in (sender.id, influencer_id):
        return

    listid = app.config.get('RECOMMENDATION_EMAIL_LISTID', 2)
    if any(f for f in recipient.flags if f.flag in ('bouncing', 'unsub%d' % listid)):
        return

    influencer = User.query.get(influencer_id)
    link = ShareLink.get_or_create(sender.id, 'video_instance', video_instance.id)[0]
    ctx = dict(
        sender=sender,
        link=link,
        object_type='video_instance',
        object_type_name='video',
        object=video_instance,
        senders=[sender, influencer],
        unsubscribe_token=create_unsubscribe_token(listid, recipient.id)
    )
    tracking_params = app.config.get('RECOMMENDATION_EMAIL_TRACKING_PARAMS')
    with url_tracking_context(tracking_params):
        template = email.env.get_template('video_recommendation.html')
        _send_email_or_log(recipient, template, **ctx)