点击模板消息跳到微信详情页面
This commit is contained in:
parent
ef987d6bf7
commit
aed3818273
2
1234567
2
1234567
|
@ -1 +1 @@
|
|||
{"access_token":"GbIQJdIaX2c0IyQSOJcNNT2TxUH5aSQCNL7N92BV9oggGePRoj886HDohtqRokwPS6OVcIYF8WZTnSn717CP-czrWupY_gIHehK4UqjqXYqGkVqODXaXEB_LV0grMIwEXQDhAAAFYL","expires_in":7200,"got_token_at":1461117548}
|
||||
{"access_token":"x7GUTe-MLoVPMzId82-3VSdCsO6sq5cOJZCmIN-yUjDcohfI00t2lzPkNKdRhETLUBptZRQ--v-IBQTG-o5iRZZv-EelOBX7K96DcPMFt9rdzwNu7XerNnZw_ncGYncSLHXeACAQMC","expires_in":7200,"got_token_at":1461133885}
|
|
@ -82,11 +82,11 @@ class BlogComment < ActiveRecord::Base
|
|||
if self.parent_id.nil?
|
||||
self.author.watcher_users.each do |watcher|
|
||||
content = strip_html self.author.try(:realname) + " 发表了博客:" + self.title.html_safe, 200
|
||||
ws.message_update_template watcher.id, "#{l(:label_new_blog_template)}", content, format_time(self.created_at)
|
||||
ws.message_update_template watcher.id, "blog_comment", self.id, "#{l(:label_new_blog_template)}", content, format_time(self.created_at)
|
||||
end
|
||||
else
|
||||
content = strip_html self.content.html_safe, 200
|
||||
ws.comment_template self.parent.author_id, "#{l(:label_blog_comment_template)}", self.author.try(:realname), format_time(self.created_at), content
|
||||
ws.comment_template self.parent.author_id, "blog_comment", self.parent_id, "#{l(:label_blog_comment_template)}", self.author.try(:realname), format_time(self.created_at), content
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -46,13 +46,13 @@ class Comment < ActiveRecord::Base
|
|||
if self.author_id != self.commented.author_id
|
||||
self.course_messages << CourseMessage.new(:user_id => self.commented.author_id, :course_id => self.commented.course.id, :viewed => false)
|
||||
content = strip_html self.comments.html_safe, 200
|
||||
ws.comment_template self.commented.author_id, "#{l(:label_notice_comment_template)}", self.author.try(:realname), format_time(self.created_on), content
|
||||
ws.comment_template self.commented.author_id, "course_notice", self.id, "#{l(:label_notice_comment_template)}", self.author.try(:realname), format_time(self.created_on), content
|
||||
end
|
||||
else # 项目相关
|
||||
if self.author_id != self.commented.author_id
|
||||
self.forge_messages << ForgeMessage.new(:user_id => self.commented.author_id, :project_id => self.commented.project.id, :viewed => false)
|
||||
content = strip_html self.comments.html_safe, 200
|
||||
ws.comment_template self.commented.author_id, "#{l(:label_news_comment_template)}", self.author.try(:realname), format_time(self.created_on), content
|
||||
#content = strip_html self.comments.html_safe, 200
|
||||
#ws.comment_template self.commented.author_id, "blog_comment", self.id, "#{l(:label_news_comment_template)}", self.author.try(:realname), format_time(self.created_on), content
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -60,7 +60,7 @@ class HomeworkCommon < ActiveRecord::Base
|
|||
# if m.user_id != self.user_id
|
||||
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false)
|
||||
ws = WechatService.new
|
||||
ws.homework_template(m.user_id, "#{l(:label_new_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59")
|
||||
ws.homework_template(m.user_id, "homework", self.id, "#{l(:label_new_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59")
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
@ -107,7 +107,7 @@ class HomeworkCommon < ActiveRecord::Base
|
|||
def wechat_message
|
||||
self.course.members.each do |member|
|
||||
ws = WechatService.new
|
||||
ws.homework_template(member.user_id, "#{l(:label_update_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59")
|
||||
ws.homework_template(member.user_id, "homework", self.id, "#{l(:label_update_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ class Issue < ActiveRecord::Base
|
|||
self.forge_messages << ForgeMessage.new(:user_id => self.assigned_to_id, :project_id => self.project_id, :viewed => false)
|
||||
ws = WechatService.new
|
||||
content = strip_html self.author.try(:realname) + " 给您指派了缺陷:" + self.subject.html_safe, 200
|
||||
ws.message_update_template self.assigned_to_id, "#{l(:label_new_issue_template)}", content, format_time(self.created_on)
|
||||
ws.message_update_template self.assigned_to_id, "issues", self.id, "#{l(:label_new_issue_template)}", content, format_time(self.created_on)
|
||||
end
|
||||
if self.tracker_id == 5
|
||||
self.project.members.each do |m|
|
||||
|
|
|
@ -241,6 +241,6 @@ class Journal < ActiveRecord::Base
|
|||
def issue_wechat_message
|
||||
ws = WechatService.new
|
||||
content = strip_html self.notes.html_safe, 200
|
||||
ws.comment_template self.issue.author_id, "#{l(:label_issue_comment_template)}", self.user.try(:realname), format_time(self.created_on), content
|
||||
ws.comment_template self.issue.author_id, "issues", self.journalized_id, "#{l(:label_issue_comment_template)}", self.user.try(:realname), format_time(self.created_on), content
|
||||
end
|
||||
end
|
||||
|
|
|
@ -259,7 +259,7 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
ws = WechatService.new
|
||||
#content = truncate(strip_tags(self.notes.to_s), length: 200)
|
||||
content = strip_html self.notes.html_safe, 200
|
||||
ws.comment_template self.jour.user_id, "#{l(:label_homework_comment_template)}", self.user.try(:realname), format_time(self.created_on), content
|
||||
ws.comment_template self.jour.user_id, "homework", self.jour_id, "#{l(:label_homework_comment_template)}", self.user.try(:realname), format_time(self.created_on), content
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -274,7 +274,7 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
if self.user_id != self.jour_id # 过滤自己给自己的留言消息
|
||||
receivers << self.jour
|
||||
content = strip_html self.notes, 200
|
||||
ws.message_update_template self.jour_id, "#{l(:label_new_journals_template)}", content, format_time(self.created_on)
|
||||
ws.message_update_template self.jour_id, "journal_for_message", self.id, "#{l(:label_new_journals_template)}", content, format_time(self.created_on)
|
||||
end
|
||||
else # 留言回复
|
||||
reply_to = User.find(self.reply_id)
|
||||
|
@ -285,7 +285,7 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
receivers << self.parent.jour
|
||||
end
|
||||
content = strip_html self.notes, 200
|
||||
ws.comment_template self.reply_id, "#{l(:label_journals_comment_template)}", self.user.try(:realname), format_time(self.created_on), content
|
||||
ws.comment_template self.reply_id, "journal_for_message", self.parent.id, "#{l(:label_journals_comment_template)}", self.user.try(:realname), format_time(self.created_on), content
|
||||
end
|
||||
receivers.each do |r|
|
||||
self.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => self.id, :journals_for_message_type => "Principal", :viewed => false)
|
||||
|
|
|
@ -267,7 +267,7 @@ class Message < ActiveRecord::Base
|
|||
if self.author.allowed_to?(:as_teacher, self.course) && m.user_id != self.author_id # 老师 自己的帖子不给自己发送消息
|
||||
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false)
|
||||
content = strip_html self.subject, 200
|
||||
ws.topic_publish_template m.user_id, "#{l(:label_course_topic_template)}", content, self.author.try(:realname), format_time(self.created_on)
|
||||
ws.topic_publish_template m.user_id, "course_discussion", self.id, "#{l(:label_course_topic_template)}", content, self.author.try(:realname), format_time(self.created_on)
|
||||
end
|
||||
end
|
||||
else # 回帖
|
||||
|
@ -275,7 +275,7 @@ class Message < ActiveRecord::Base
|
|||
if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息
|
||||
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false)
|
||||
content = strip_html self.content.html_safe, 200
|
||||
ws.comment_template m.user_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content
|
||||
ws.comment_template m.user_id, "course_discussion", self.parent_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -285,7 +285,7 @@ class Message < ActiveRecord::Base
|
|||
if m.user_id != self.author_id
|
||||
self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false)
|
||||
content = strip_html self.subject, 200
|
||||
ws.topic_publish_template m.user_id, "#{l(:label_project_topic_template)}", content, self.author.try(:realname), format_time(self.created_on)
|
||||
ws.topic_publish_template m.user_id, "project_discussion", self.id, "#{l(:label_project_topic_template)}", content, self.author.try(:realname), format_time(self.created_on)
|
||||
end
|
||||
end
|
||||
else # 回帖
|
||||
|
@ -293,7 +293,7 @@ class Message < ActiveRecord::Base
|
|||
if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息
|
||||
self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false)
|
||||
content = strip_html self.content.html_safe, 200
|
||||
ws.comment_template m.user_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content
|
||||
ws.comment_template m.user_id, "project_discussion", self.parent_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -172,7 +172,7 @@ class News < ActiveRecord::Base
|
|||
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false)
|
||||
ws = WechatService.new
|
||||
content = strip_html self.author.try(:realname) + " 发布了通知:" + self.title.html_safe, 200
|
||||
ws.message_update_template m.user_id, "#{l(:label_new_notice_template)}", self.author.try(:realname) + " 发布了通知:" + content, format_time(self.created_on)
|
||||
ws.message_update_template m.user_id, "course_notice", self.id, "#{l(:label_new_notice_template)}", self.author.try(:realname) + " 发布了通知:" + content, format_time(self.created_on)
|
||||
end
|
||||
end
|
||||
else
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#encoding: utf-8
|
||||
class WechatService
|
||||
|
||||
def template_data(openid, template_id, first, key1, key2, key3, remark="具体内容请点击详情查看网站")
|
||||
def template_data(openid, template_id, type, id, first, key1, key2, key3, remark="具体内容请点击详情查看网站")
|
||||
data = {
|
||||
touser:openid,
|
||||
template_id:template_id,
|
||||
url:"https://www.trustie.net/",
|
||||
url:"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect",
|
||||
topcolor:"#FF0000",
|
||||
data:{
|
||||
first: {
|
||||
|
@ -33,10 +33,10 @@ class WechatService
|
|||
data
|
||||
end
|
||||
|
||||
def homework_template(user_id, first, key1, key2, key3, remark="具体内容请点击详情查看网站")
|
||||
def homework_template(user_id, type, id, first, key1, key2, key3, remark="具体内容请点击详情查看网站")
|
||||
uw = UserWechat.where(user_id: user_id).first
|
||||
unless uw.nil?
|
||||
data = template_data uw.openid,"3e5Dj2GIx8MOcMyRKpTUEQnM7Tg0ASSCNc01NS9HCGI",first, key1, key2, key3, remark
|
||||
data = template_data uw.openid,"3e5Dj2GIx8MOcMyRKpTUEQnM7Tg0ASSCNc01NS9HCGI", type, id, first, key1, key2, key3, remark
|
||||
begin
|
||||
req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data)
|
||||
rescue Exception => e
|
||||
|
@ -44,12 +44,13 @@ class WechatService
|
|||
end
|
||||
Rails.logger.info "send over. #{req}"
|
||||
end
|
||||
Rails.logger.info "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect"
|
||||
end
|
||||
|
||||
def topic_publish_template(user_id, first, key1, key2, key3, remark="具体内容请点击详情查看网站")
|
||||
def topic_publish_template(user_id, type, id, first, key1, key2, key3, remark="具体内容请点击详情查看网站")
|
||||
uw = UserWechat.where(user_id: user_id).first
|
||||
unless uw.nil?
|
||||
data = template_data uw.openid,"oKzFCdk7bsIHnGbscA__N8LPQrBkUShvpjV3-kuwWDQ",first, key1, key2, key3, remark
|
||||
data = template_data uw.openid,"oKzFCdk7bsIHnGbscA__N8LPQrBkUShvpjV3-kuwWDQ", type, id,first, key1, key2, key3, remark
|
||||
Rails.logger.info "start send template message: #{data}"
|
||||
begin
|
||||
req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data)
|
||||
|
@ -58,12 +59,13 @@ class WechatService
|
|||
end
|
||||
Rails.logger.info "send over. #{req}"
|
||||
end
|
||||
Rails.logger.info "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect"
|
||||
end
|
||||
|
||||
def comment_template(user_id, first, key1, key2, key3, remark="具体内容请点击详情查看网站")
|
||||
def comment_template(user_id,type, id, first, key1, key2, key3, remark="具体内容请点击详情查看网站")
|
||||
uw = UserWechat.where(user_id: user_id).first
|
||||
unless uw.nil?
|
||||
data = template_data uw.openid,"A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c",first, key1, key2, key3, remark
|
||||
data = template_data uw.openid,"A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c",type, id,first, key1, key2, key3, remark
|
||||
Rails.logger.info "start send template message: #{data}"
|
||||
begin
|
||||
req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data)
|
||||
|
@ -72,15 +74,16 @@ class WechatService
|
|||
end
|
||||
Rails.logger.info "send over. #{req}"
|
||||
end
|
||||
Rails.logger.info "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect"
|
||||
end
|
||||
|
||||
def message_update_template(user_id, first, key1, key2, remark="具体内容请点击详情查看网站")
|
||||
def message_update_template(user_id, type, id, first, key1, key2, remark="具体内容请点击详情查看网站")
|
||||
uw = UserWechat.where(user_id: user_id).first
|
||||
unless uw.nil?
|
||||
data = {
|
||||
touser:uw.openid,
|
||||
template_id:"YTyNPZnQD8uZFBFq-Q6cCOWaq5LA9vL6RFlF2JuD5Cg",
|
||||
url:"https://www.trustie.net/",
|
||||
url:"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect",
|
||||
topcolor:"#FF0000",
|
||||
data:{
|
||||
first: {
|
||||
|
@ -101,7 +104,6 @@ class WechatService
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rails.logger.info "start send template message: #{data}"
|
||||
begin
|
||||
req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data)
|
||||
|
@ -110,5 +112,6 @@ class WechatService
|
|||
end
|
||||
Rails.logger.info "send over. #{req}"
|
||||
end
|
||||
Rails.logger.info "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect"
|
||||
end
|
||||
end
|
|
@ -2138,15 +2138,9 @@ zh:
|
|||
label_new_journals_template: 您有新留言了
|
||||
label_journals_comment_template: 您的留言有新回复了
|
||||
label_blog_comment_template: 您的博客有新回复了
|
||||
label_new_blog_template: 您的课程有新作业了
|
||||
label_new_blog_template: 有新博客了
|
||||
label_new_issue_template: 您有新缺陷了
|
||||
label_new_notice_template: 您的课程有新通知了
|
||||
label_resource_name: 您的课程有新作业了
|
||||
label_resource_name: 您的课程有新作业了
|
||||
label_resource_name: 您的课程有新作业了
|
||||
label_resource_name: 您的课程有新作业了
|
||||
label_resource_name: 您的课程有新作业了
|
||||
label_resource_name: 您的课程有新作业了
|
||||
#edit yk
|
||||
label_code_work_tests: 代码测试列表
|
||||
|
||||
|
|
Loading…
Reference in New Issue