Merge branch 'weixin_guange' of https://git.trustie.net/jacknudt/trustieforge into weixin_guange
This commit is contained in:
commit
799722ef45
|
@ -77,7 +77,6 @@ class BlogComment < ActiveRecord::Base
|
||||||
|
|
||||||
#博客回复微信模板消息
|
#博客回复微信模板消息
|
||||||
def blog_wechat_message
|
def blog_wechat_message
|
||||||
unless self.parent_id == nil
|
|
||||||
uw = UserWechat.where(user_id: self.parent.author_id).first
|
uw = UserWechat.where(user_id: self.parent.author_id).first
|
||||||
#unless uw.nil? && self.parent.author_id != User.current.id
|
#unless uw.nil? && self.parent.author_id != User.current.id
|
||||||
unless uw.nil?
|
unless uw.nil?
|
||||||
|
@ -96,11 +95,11 @@ class BlogComment < ActiveRecord::Base
|
||||||
color:"#173177"
|
color:"#173177"
|
||||||
},
|
},
|
||||||
keyword2:{
|
keyword2:{
|
||||||
value:self.created_at,
|
value:format_time(self.created_at),
|
||||||
color:"#173177"
|
color:"#173177"
|
||||||
},
|
},
|
||||||
keyword3:{
|
keyword3:{
|
||||||
value:h(truncate(" - #{self.content.html_safe}", length:50, omission: '...')),
|
value:h(truncate(key3, :length=>50, :omission=> '...')),
|
||||||
color:"#173177"
|
color:"#173177"
|
||||||
},
|
},
|
||||||
remark:{
|
remark:{
|
||||||
|
@ -109,15 +108,9 @@ class BlogComment < ActiveRecord::Base
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uri = URI("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=1234567")
|
logger.info "start send template message: #{data}"
|
||||||
body = data.to_json
|
req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data)
|
||||||
res = Net::HTTP.new(uri.host, uri.port).start do |client|
|
logger.info "send over. #{req}"
|
||||||
request = Net::HTTP::Post.new(uri.path)
|
|
||||||
request.body = body
|
|
||||||
request["Content-Type"] = "application/json"
|
|
||||||
client.request(request)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -133,14 +133,9 @@ class HomeworkCommon < ActiveRecord::Base
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uri = URI("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=1234567")
|
logger.info "start send template message: #{data}"
|
||||||
body = data.to_json
|
req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data)
|
||||||
res = Net::HTTP.new(uri.host, uri.port).start do |client|
|
logger.info "send over. #{req}"
|
||||||
request = Net::HTTP::Post.new(uri.path)
|
|
||||||
request.body = body
|
|
||||||
request["Content-Type"] = "application/json"
|
|
||||||
client.request(request)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -256,11 +256,11 @@ class Journal < ActiveRecord::Base
|
||||||
color:"#173177"
|
color:"#173177"
|
||||||
},
|
},
|
||||||
keyword2:{
|
keyword2:{
|
||||||
value:self.created_on,
|
value:format_time(self.created_on),
|
||||||
color:"#173177"
|
color:"#173177"
|
||||||
},
|
},
|
||||||
keyword3:{
|
keyword3:{
|
||||||
value:h(truncate(" - #{self.description.html_safe}", length:50, omission: '...')),
|
value:h(truncate(key3, :length=>50, :omission=> '...')),
|
||||||
color:"#173177"
|
color:"#173177"
|
||||||
},
|
},
|
||||||
remark:{
|
remark:{
|
||||||
|
@ -269,14 +269,9 @@ class Journal < ActiveRecord::Base
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uri = URI("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=1234567")
|
logger.info "start send template message: #{data}"
|
||||||
body = data.to_json
|
req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data)
|
||||||
res = Net::HTTP.new(uri.host, uri.port).start do |client|
|
logger.info "send over. #{req}"
|
||||||
request = Net::HTTP::Post.new(uri.path)
|
|
||||||
request.body = body
|
|
||||||
request["Content-Type"] = "application/json"
|
|
||||||
client.request(request)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -326,11 +326,11 @@ class JournalsForMessage < ActiveRecord::Base
|
||||||
color:"#173177"
|
color:"#173177"
|
||||||
},
|
},
|
||||||
keyword2:{
|
keyword2:{
|
||||||
value:self.created_on,
|
value:format_time(self.created_on),
|
||||||
color:"#173177"
|
color:"#173177"
|
||||||
},
|
},
|
||||||
keyword3:{
|
keyword3:{
|
||||||
value:h(truncate(" - #{self.notes.html_safe}", length:50, omission: '...')),
|
value:h(truncate(key3, :length=>50, :omission=> '...')),
|
||||||
color:"#173177"
|
color:"#173177"
|
||||||
},
|
},
|
||||||
remark:{
|
remark:{
|
||||||
|
@ -339,14 +339,9 @@ class JournalsForMessage < ActiveRecord::Base
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uri = URI("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=1234567")
|
logger.info "start send template message: #{data}"
|
||||||
body = data.to_json
|
req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data)
|
||||||
res = Net::HTTP.new(uri.host, uri.port).start do |client|
|
logger.info "send over. #{req}"
|
||||||
request = Net::HTTP::Post.new(uri.path)
|
|
||||||
request.body = body
|
|
||||||
request["Content-Type"] = "application/json"
|
|
||||||
client.request(request)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -710,7 +710,7 @@ class Mailer < ActionMailer::Base
|
||||||
:subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}",
|
:subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}",
|
||||||
:filter => true
|
:filter => true
|
||||||
|
|
||||||
mail_wechat_message news.author_id, "3e5Dj2GIx8MOcMyRKpTUEQnM7Tg0ASSCNc01NS9HCGI", "您的课程通知有新回复了", @author.try(:realname), comment.created_on, comment.comments.html_safe
|
mail_wechat_message news.author_id, "A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", "您的课程通知有新回复了", @author.try(:realname), format_time(comment.created_on), comment.comments.html_safe
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -737,10 +737,10 @@ class Mailer < ActionMailer::Base
|
||||||
:filter => true
|
:filter => true
|
||||||
if message.parent_id == nil
|
if message.parent_id == nil
|
||||||
message.project.members.each do |member|
|
message.project.members.each do |member|
|
||||||
mail_wechat_message member.user_id, "oKzFCdk7bsIHnGbscA__N8LPQrBkUShvpjV3-kuwWDQ", "项目讨论区有新帖子发布了", message.subject, @author.try(:realname), message.created_on
|
mail_wechat_message member.user_id, "oKzFCdk7bsIHnGbscA__N8LPQrBkUShvpjV3-kuwWDQ", "项目讨论区有新帖子发布了", message.subject, @author.try(:realname), format_time(message.created_on)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
mail_wechat_message member.parent.author_id, "A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", "您的帖子有新回复了", @author.try(:realname), message.created_on, message.content.html_safe
|
mail_wechat_message member.parent.author_id, "A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", "您的帖子有新回复了", @author.try(:realname), format_time(message.created_on), message.content.html_safe
|
||||||
end
|
end
|
||||||
elsif message.course
|
elsif message.course
|
||||||
redmine_headers 'Course' => message.course.id,
|
redmine_headers 'Course' => message.course.id,
|
||||||
|
@ -759,10 +759,10 @@ class Mailer < ActionMailer::Base
|
||||||
:filter => true
|
:filter => true
|
||||||
if message.parent_id == nil
|
if message.parent_id == nil
|
||||||
message.course.members.each do |member|
|
message.course.members.each do |member|
|
||||||
mail_wechat_message member.user_id, "oKzFCdk7bsIHnGbscA__N8LPQrBkUShvpjV3-kuwWDQ", "课程问答区有新帖子发布了", message.subject, @author.try(:realname), message.created_on
|
mail_wechat_message member.user_id, "oKzFCdk7bsIHnGbscA__N8LPQrBkUShvpjV3-kuwWDQ", "课程问答区有新帖子发布了", message.subject, @author.try(:realname), format_time(message.created_on)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
mail_wechat_message member.parent.author_id, "A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", "您的帖子有新回复了", @author.try(:realname), message.created_on, message.content.html_safe
|
mail_wechat_message member.parent.author_id, "A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", "您的帖子有新回复了", @author.try(:realname), format_time(message.created_on), message.content.html_safe
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue