(self, rdb)
This will create a reaction with the supplied information
This will create a reaction with the supplied information
This will create a reaction with the supplied information
def createReaction(self, rdb):
        ''' This will create a reaction with the supplied information '''
        # Encrypt User Input
        if self.config['CRYPTO_ENABLED']:
            crypto = Fernet(self.config['CRYPTO_KEY'])
            try:
                self.data = crypto.encrypt(json.dumps(self.data))
            except:
                return False
            self.encrypted = True

        reactdata = {
            'name': self.name,
            'rtype': self.rtype,
            'uid': self.uid,
            'trigger': self.trigger,
            'frequency': self.frequency,
            'lastrun': 0,
            'data': self.data,
            'encrypted': self.encrypted
        }
        if self.exists(reactdata['name'], reactdata['uid'], rdb):
            return 'exists'
        else:
            results = r.table('reactions').insert(reactdata).run(rdb)
            if results['inserted'] == 1:
                qdata = {}
                qdata['item'] = reactdata
                qdata['action'] = 'create'
                qdata['type'] = 'reaction'
                qdata['item']['rid'] = results['generated_keys'][0]
                q1 = r.table('dc1queue').insert(qdata).run(rdb)
                q2 = r.table('dc2queue').insert(qdata).run(rdb)
                return results['generated_keys'][0]
            else:
                return False
def createReaction ( self , rdb ) : # Encrypt User Input if self . config [ 'CRYPTO_ENABLED' ] : crypto = Fernet ( self . config [ 'CRYPTO_KEY' ] ) try : self . data = crypto . encrypt ( json . dumps ( self . data ) ) except : return False self . encrypted = True reactdata = { 'name' : self . name , 'rtype' : self . rtype , 'uid' : self . uid , 'trigger' : self . trigger , 'frequency' : self . frequency , 'lastrun' : 0 , 'data' : self . data , 'encrypted' : self . encrypted } if self . exists ( reactdata [ 'name' ] , reactdata [ 'uid' ] , rdb ) : return 'exists' else : results = r . table ( 'reactions' ) . insert ( reactdata ) . run ( rdb ) if results [ 'inserted' ] == 1 : qdata = { } qdata [ 'item' ] = reactdata qdata [ 'action' ] = 'create' qdata [ 'type' ] = 'reaction' qdata [ 'item' ] [ 'rid' ] = results [ 'generated_keys' ] [ 0 ] q1 = r . table ( 'dc1queue' ) . insert ( qdata ) . run ( rdb ) q2 = r . table ( 'dc2queue' ) . insert ( qdata ) . run ( rdb ) return results [ 'generated_keys' ] [ 0 ] else : return False