DEV: s/\$redis/Discourse\.redis (#8431)

This commit also adds a rubocop rule to prevent global variables.
This commit is contained in:
Joffrey JAFFEUX
2019-12-03 10:05:53 +01:00
committed by GitHub
parent 9eccfb7b52
commit 0d3d2c43a0
118 changed files with 378 additions and 362 deletions

View File

@ -119,8 +119,8 @@ class WebhooksController < ActionController::Base
# prevent replay attacks
key = "mailgun_token_#{token}"
return false unless $redis.setnx(key, 1)
$redis.expire(key, 10.minutes)
return false unless Discourse.redis.setnx(key, 1)
Discourse.redis.expire(key, 10.minutes)
# ensure timestamp isn't too far from current time
return false if (Time.at(timestamp.to_i) - Time.now).abs > 12.hours.to_i