コード例 #1
0
ファイル: rtip.py プロジェクト: globaleaks/GLBackend-outdated
def postpone_expiration_date(store, user_id, tip_id):
    rtip = access_tip(store, user_id, tip_id)

    node = store.find(Node).one()

    if not (node.postpone_superpower or
            rtip.internaltip.context.postpone_superpower or
            rtip.receiver.postpone_superpower):

        raise errors.ExtendTipLifeNotEnabled()
    else:
        log.debug("Postpone check: Node %s, Context %s, Receiver %s" %(
            "True" if node.postpone_superpower else "False",
            "True" if rtip.internaltip.context.postpone_superpower else "False",
            "True" if rtip.receiver.postpone_superpower else "False"
        ))

    rtip.internaltip.expiration_date = \
        utc_future_date(seconds=rtip.internaltip.context.tip_timetolive)

    log.debug(" [%s] in %s has extended expiration time to %s" % (
        rtip.receiver.name,
        datetime_to_pretty_str(datetime_now()),
        datetime_to_pretty_str(rtip.internaltip.expiration_date)))

    comment = Comment()
    comment.system_content = dict({
           'type': "1", # the first kind of structured system_comments
           'receiver_name': rtip.receiver.name,
           'expire_on' : datetime_to_ISO8601(rtip.internaltip.expiration_date)
    })

    # remind: this is put just for debug, it's never used in the flow
    # and a system comment may have nothing to say except the struct
    comment.content = "%s %s %s (UTC)" % (
                   rtip.receiver.name,
                   datetime_to_pretty_str(datetime_now()),
                   datetime_to_pretty_str(rtip.internaltip.expiration_date))

    comment.internaltip_id = rtip.internaltip.id
    comment.author = u'System' # The printed line
    comment.type = Comment._types[2] # System
    comment.mark = Comment._marker[4] # skipped

    rtip.internaltip.comments.add(comment)
コード例 #2
0
ファイル: rtip.py プロジェクト: keichacon/GlobaLeaks
def postpone_expiration_date(store, user_id, tip_id):
    rtip = access_tip(store, user_id, tip_id)

    node = store.find(Node).one()

    if not (node.postpone_superpower
            or rtip.internaltip.context.postpone_superpower
            or rtip.receiver.postpone_superpower):

        raise errors.ExtendTipLifeNotEnabled()
    else:
        log.debug("Postpone check: Node %s, Context %s, Receiver %s" %
                  ("True" if node.postpone_superpower else "False", "True" if
                   rtip.internaltip.context.postpone_superpower else "False",
                   "True" if rtip.receiver.postpone_superpower else "False"))

    rtip.internaltip.expiration_date = \
        utc_future_date(seconds=rtip.internaltip.context.tip_timetolive)

    log.debug(" [%s] in %s has extended expiration time to %s" %
              (rtip.receiver.name, datetime_to_pretty_str(datetime_now()),
               datetime_to_pretty_str(rtip.internaltip.expiration_date)))

    comment = Comment()
    comment.system_content = dict({
        'type':
        "1",  # the first kind of structured system_comments
        'receiver_name':
        rtip.receiver.name,
        'expire_on':
        datetime_to_ISO8601(rtip.internaltip.expiration_date)
    })

    # remind: this is put just for debug, it's never used in the flow
    # and a system comment may have nothing to say except the struct
    comment.content = "%s %s %s (UTC)" % (
        rtip.receiver.name, datetime_to_pretty_str(datetime_now()),
        datetime_to_pretty_str(rtip.internaltip.expiration_date))

    comment.internaltip_id = rtip.internaltip.id
    comment.author = u'System'
    comment.type = u'system'
    comment.mark = u'skipped'

    rtip.internaltip.comments.add(comment)
コード例 #3
0
ファイル: rtip.py プロジェクト: globaleaks/GLBackend-outdated
def delete_receiver_tip(store, user_id, tip_id):
    """
    This operation is permitted to every receiver, and trigger
    a System comment on the Tip history.
    """
    rtip = access_tip(store, user_id, tip_id)

    comment = Comment()
    comment.content = "%s personally remove from this Tip" % rtip.receiver.name
    comment.system_content = dict({ "type" : 2,
                                    "receiver_name" : rtip.receiver.name})

    comment.internaltip_id = rtip.internaltip.id
    comment.author = u'System' # The printed line
    comment.type = u'system' # Comment._types[2]
    comment.mark = u'not notified' # Comment._marker[0]

    rtip.internaltip.comments.add(comment)

    store.remove(rtip)
コード例 #4
0
ファイル: rtip.py プロジェクト: keichacon/GlobaLeaks
def delete_receiver_tip(store, user_id, tip_id):
    """
    This operation is permitted to every receiver, and trigger
    a System comment on the Tip history.
    """
    rtip = access_tip(store, user_id, tip_id)

    comment = Comment()
    comment.content = "%s personally remove from this Tip" % rtip.receiver.name
    comment.system_content = dict({
        "type": 2,
        "receiver_name": rtip.receiver.name
    })

    comment.internaltip_id = rtip.internaltip.id
    comment.author = u'system'  # The printed line
    comment.type = u'system'
    comment.mark = u'not notified'

    rtip.internaltip.comments.add(comment)

    store.remove(rtip)