Last active
October 30, 2017 11:51
-
-
Save Loschcode/523b75cffa180c277933c17369b98989 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WechatBot | |
class Exchange < Base | |
class Qrcode < Base | |
def request | |
'二维码' | |
end | |
# this is not the best way at a performance level because it accepts #request and then cancel it via a false if the user is not referrer | |
# best is to control this from the #request itself and return nil. The result is the same tho. | |
# WE KEPT THIS AS A GOOD EXAMPLE | |
def response | |
if user&.referrer | |
# wechat forces us to use '.jpg' extension otherwise it considers the file as invalid format | |
# NOTE : yes, they don't check MIME Type, no clue why. | |
messenger.image! url: "#{guest_referrer_qrcode_url(user.referrer)}.jpg" | |
return true | |
end | |
false | |
end | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment