@@ -127,7 +127,7 @@ def ensure_chatops_authenticated
127127 signature_valid? ( Chatops . alt_public_key , @chatops_signature , signature_string )
128128 return true
129129 end
130- return render :status => :forbidden , :plain => "Not authorized"
130+ return jsonrpc_error ( - 32800 , 403 , "Not authorized" )
131131 end
132132
133133 def ensure_valid_chatops_url
@@ -142,7 +142,7 @@ def ensure_valid_chatops_url
142142
143143 def ensure_valid_chatops_nonce
144144 @chatops_nonce = request . headers [ "Chatops-Nonce" ]
145- return render :status => :forbidden , :plain => "A Chatops-Nonce header is required" unless @chatops_nonce . present?
145+ return jsonrpc_error ( - 32801 , 403 , "A Chatops-Nonce header is required" ) unless @chatops_nonce . present?
146146 end
147147
148148 def ensure_valid_chatops_signature
@@ -158,19 +158,19 @@ def ensure_valid_chatops_signature
158158 end
159159
160160 unless @chatops_signature . present?
161- return render :status => :forbidden , :plain => "Failed to parse signature header"
161+ return jsonrpc_error ( - 32802 , 403 , "Failed to parse signature header" )
162162 end
163163 end
164164
165165 def ensure_valid_chatops_timestamp
166166 @chatops_timestamp = request . headers [ "Chatops-Timestamp" ]
167167 time = Time . iso8601 ( @chatops_timestamp )
168168 if !( time > 1 . minute . ago && time < 1 . minute . from_now )
169- return render :status => :forbidden , :plain => "Chatops timestamp not within 1 minute of server time: #{ @chatops_timestamp } vs #{ Time . now . utc . iso8601 } "
169+ return jsonrpc_error ( - 32803 , 403 , "Chatops timestamp not within 1 minute of server time: #{ @chatops_timestamp } vs #{ Time . now . utc . iso8601 } " )
170170 end
171171 rescue ArgumentError , TypeError
172- # time parsing or missing can raise these
173- return render :status => :forbidden , :plain => "Invalid Chatops-Timestamp: #{ @chatops_timestamp } "
172+ # time parsing or missing can raise these
173+ return jsonrpc_error ( - 32804 , 403 , "Invalid Chatops-Timestamp: #{ @chatops_timestamp } " )
174174 end
175175
176176 def request_is_chatop?
0 commit comments