发布博客500问题

chenlw_dev
huang 9 years ago
parent cd9ad535f5
commit f951d22d56

@ -78,40 +78,44 @@ class BlogComment < ActiveRecord::Base
#博客回复微信模板消息
def blog_wechat_message
uw = UserWechat.where(user_id: self.parent.author_id).first
#unless uw.nil? && self.parent.author_id != User.current.id
unless uw.nil?
data = {
touser:uw.openid,
template_id:"A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c",
url:"http://weixin.qq.com/download",
topcolor:"#FF0000",
data:{
first: {
value:"您的博客有新回复了",
color:"#173177"
},
keyword1:{
value:self.author.try(:realname),
color:"#173177"
},
keyword2:{
value:format_time(self.created_at),
color:"#173177"
},
keyword3:{
value:self.content.html_safe,
color:"#173177"
},
remark:{
value:"具体内容请点击详情查看网站",
color:"#173177"
}
}
}
logger.info "start send template message: #{data}"
req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data)
logger.info "send over. #{req}"
# 发布博客
unless self.parent_id.nil?
uw = UserWechat.where(user_id: self.parent.author_id).first
#unless uw.nil? && self.parent.author_id != User.current.id
unless uw.nil?
data = {
touser:uw.openid,
template_id:"A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c",
url:"http://weixin.qq.com/download",
topcolor:"#FF0000",
data:{
first: {
value:"您的博客有新回复了",
color:"#173177"
},
keyword1:{
value:self.author.try(:realname),
color:"#173177"
},
keyword2:{
value:format_time(self.created_at),
color:"#173177"
},
keyword3:{
value:self.content.html_safe,
color:"#173177"
},
remark:{
value:"具体内容请点击详情查看网站",
color:"#173177"
}
}
}
logger.info "start send template message: #{data}"
req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data)
logger.info "send over. #{req}"
end
end
end
end

Loading…
Cancel
Save