#NEWLINE# def set_rule_attr( self , user_id , spec , val ) : #NEWLINE# #INDENT# if ( spec [ 'attr' ] == 'enabled' ) : #NEWLINE# #INDENT# if ( isinstance ( val , dict ) and ( 'enabled' in val ) ) : #NEWLINE# #INDENT# val = val [ 'enabled' ] #NEWLINE# #UNINDENT# if ( not isinstance ( val , bool ) ) : #NEWLINE# #INDENT# raise SynapseError ( 400 , "Value for 'enabled' must be boolean" ) #NEWLINE# #UNINDENT# namespaced_rule_id = _namespaced_rule_id_from_spec ( spec ) #NEWLINE# return self . store . set_push_rule_enabled ( user_id , namespaced_rule_id , val ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( spec [ 'attr' ] == 'actions' ) : #NEWLINE# #INDENT# actions = val . get ( 'actions' ) #NEWLINE# _check_actions ( actions ) #NEWLINE# namespaced_rule_id = _namespaced_rule_id_from_spec ( spec ) #NEWLINE# rule_id = spec [ 'rule_id' ] #NEWLINE# is_default_rule = rule_id . startswith ( '.' ) #NEWLINE# if is_default_rule : #NEWLINE# #INDENT# if ( namespaced_rule_id not in BASE_RULE_IDS ) : #NEWLINE# #INDENT# raise SynapseError ( 404 , ( 'Unknown rule %r' % ( namespaced_rule_id , ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# return self . store . set_push_rule_actions ( user_id , namespaced_rule_id , actions , is_default_rule ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise UnrecognizedRequestError ( )