æºå¸¯é»è©±ã«çµµæåå ¥ãã¡ã¼ã«ãRailsããéä¿¡ããã
æ¬æ¥ãjpmobileã使ã£ã¦ãçµµæåå
¥ãã®mailãæºå¸¯ã«å¯¾ãã¦éãããã¨è¨ã話ããã¾ããã
ã¨è¨ãããã§ãRailsで絵文字入りメールを送る方法: ぐうたら技術屋のTipsãåç
§ãã¦
ã¢ã¸ã¥ã¼ã«ãä½ã£ã¦ã¿ãã
ActionMailer::Baseãä¸æ¸ãããã
class ActionMailer::Base def create!(*) super @mobile_filter = nil @docomo_or_au = nil dummy_controller = DummyController.new if @mail.to.to_s.split(/@/).size == 2 if @mail.to.to_s.split(/@/)[1] =~ /docomo.ne.jp/ dummy_controller.request.mobile = Jpmobile::Mobile::Docomo.new({}) @mobile_filter = true @docomo_or_au = true elsif @mail.to.to_s.split(/@/)[1] =~ /ezweb.ne.jp/ dummy_controller.request.mobile = Jpmobile::Mobile::Au.new({}) @mobile_filter = true @docomo_or_au = true elsif @mail.to.to_s.split(/@/)[1] =~ /softbank.ne.jp/ || @mail.to.to_s.split(/@/)[1] =~ /vodafone.ne.jp/ dummy_controller.request.mobile = Jpmobile::Mobile::Softbank.new({}) @mobile_filter = true end end if @mobile_filter mail_title = @docomo_or_au ? NKF.nkf("-xWs", @mail.subject) : @mail.subject mail_title = Jpmobile::Filter::Emoticon::Outer.new.to_external(mail_title, dummy_controller) @mail.subject = @docomo_or_au ? mail_title : Base64.b64encode(mail_title) @mail.body = @docomo_or_au ? NKF.nkf("-xWs", @mail.body) : @mail.body @mail.body = Jpmobile::Filter::Emoticon::Outer.new.to_external(@mail.body, dummy_controller) @mail.body = @docomo_or_au ? @mail.body : Base64.b64encode(@mail.body) @mail.set_content_type "text/plain; charset=#{@docomo_or_au ? 'Shift_JIS' : 'UTF-8'}" @mail.transfer_encoding = "base64" unless @docomo_or_au end @mail end class DummyController attr_accessor :request def initialize self.request = DummyRequest.new end class DummyRequest attr_accessor :mobile end end end
(9/25ä¿®æ£: id:walf443ããã®ã³ã¡ã³ããåãã¦ä¿®æ£)
ä¸ã®PGãlib/mobile_emoji_mail.rbã¨ãã§ä¿åãã¦ã
config/enviroment.rbã®æå¾ã®æ¹ã«
require 'mobile_emoji_mail'
ã¨ãããã°åãã¯ãã
ã¡ãªã¿ã«jpmobileå¿
é ã§ãã
å¾ãå
ãµã¤ãã«æ¸ãã¦ããjpmobileã®ä¿®æ£ã¯å¿
é ã
ä¸ç¹ç®ãlib/jpmobile/filter.rb
case controller.request.mobile.to_s when Jpmobile::Mobile::Docomo.to_s table = Jpmobile::Emoticon::CONVERSION_TABLE_TO_DOCOMO to_sjis = true when Jpmobile::Mobile::Au.to_s table = Jpmobile::Emoticon::CONVERSION_TABLE_TO_AU to_sjis = true when Jpmobile::Mobile::Jphone.to_s table = Jpmobile::Emoticon::CONVERSION_TABLE_TO_SOFTBANK to_sjis = true when Jpmobile::Mobile::Softbank.to_s table = Jpmobile::Emoticon::CONVERSION_TABLE_TO_SOFTBANK end
to_sãã¤ããå½¢ã(9/25追è¨ï¼ã³ã¼ãã®ãã¹ã«ãããããªã£ã¦ãããå¿
è¦ç¡ãã£ãæ§ã§ãã)
svn logã¯
--- vendor/plugins/jpmobile/lib/jpmobile/filter.rb (revision 1830) +++ vendor/plugins/jpmobile/lib/jpmobile/filter.rb (revision 1831) @@ -154,17 +154,17 @@ # 使ç¨ããå¤æãã¼ãã«ã®æ±ºå® table = nil to_sjis = false - case controller.request.mobile - when Jpmobile::Mobile::Docomo + case controller.request.mobile.to_s + when Jpmobile::Mobile::Docomo.to_s table = Jpmobile::Emoticon::CONVERSION_TABLE_TO_DOCOMO to_sjis = true - when Jpmobile::Mobile::Au + when Jpmobile::Mobile::Au.to_s table = Jpmobile::Emoticon::CONVERSION_TABLE_TO_AU to_sjis = true - when Jpmobile::Mobile::Jphone + when Jpmobile::Mobile::Jphone.to_s table = Jpmobile::Emoticon::CONVERSION_TABLE_TO_SOFTBANK to_sjis = true - when Jpmobile::Mobile::Softbank + when Jpmobile::Mobile::Softbank.to_s table = Jpmobile::Emoticon::CONVERSION_TABLE_TO_SOFTBANK end
ã§ãå¾2ç¹ç®lib/jpmobile/emoticon.rb
[converted-0x1000].pack("U")
svn ãã°ã¯
Index: vendor/plugins/jpmobile/lib/jpmobile/emoticon.rb =================================================================== --- vendor/plugins/jpmobile/lib/jpmobile/emoticon.rb (revision 1832) +++ vendor/plugins/jpmobile/lib/jpmobile/emoticon.rb (revision 1833) @@ -87,7 +87,9 @@ if sjis = UNICODE_TO_SJIS[converted] [sjis].pack('n') elsif webcode = SOFTBANK_UNICODE_TO_WEBCODE[converted-0x1000] - "\x1b\x24#{webcode}\x0f" + [converted-0x1000].pack("U") else # ãã£ãªã¢å¤æãã¼ãã«ã«æå®ããã¦ããUnicodeã«å¯¾å¿ãã # æºå¸¯å´ã¨ã³ã³ã¼ãã£ã³ã°ãè¦ã¤ãããªã(å¤æãã¼ãã«ã®ä¸åã®å¯è½æ§ãã)ã
ãããªæãã«ãªãã¾ããã
åç §å ã®ã¨ã³ããªã«æè¬ã