Esempio n. 1
0
    def set3rdNotifyInfo(self, notify):
        if notify.getTitle() is None or notify.getContent() is None:
            raise Exception("notify title or content cannot be null")

        notifyInfo = gt_req_pb2.NotifyInfo()
        notifyInfo.title = notify.getTitle().decode("utf-8")
        notifyInfo.content = notify.getContent().decode("utf-8")
        if notify.getType() is not None:
            notifyInfo.type = notify.getType()
            setPayloadInfo(notifyInfo, notify)
            if notify.getIntent() is not None:
                if len(notify.getIntent()) > GtConfig.getNotifyIntentLimit():
                    raise Exception('%s%s' % ('intent size overlimit ',
                                              GtConfig.getNotifyIntentLimit()))
                if not re.match(TransmissionTemplate.pattern,
                                notify.getIntent()):
                    raise Exception('%s%s' % (
                        'intent format error,should start with "intent:#Intent;",end with ";end"->',
                        notify.getIntent()))
                notifyInfo.intent = notify.getIntent()
            if notify.getUrl() is not None:
                notifyInfo.url = notify.getUrl()
        else:
            setPayloadInfo(notifyInfo, notify)
        self.getPushInfo().notifyInfo.CopyFrom(notifyInfo)
        self.getPushInfo().validNotify = True