diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 3cf0664e4..993007308 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -118,10 +118,15 @@ class WechatsController < ActionController::Base on :fallback, respond: 'fallback message' on :click, with: 'MY_NEWS' do |request, key| - if user_binded?(request[:FromUserName]) - news = (1..count.to_i).each_with_object([]) { |n, memo| memo << { title: 'News title', content: "No. #{n} news content" } } + uw = user_binded?(request[:FromUserName]) + if uw + ua = UserActivity.where(user_id: uw.user.id).order("id desc").limit(5) + news = ua.map do |ua| + {title: "act_type: #{ua.act_type}, act_id: #{ua.act_id}", content: "container_id: #{ua.container_id}, container_type: #{ua.container_type}"} + end + request.reply.news(news) do |article, n, index| # article is return object - article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: 'http://www.baidu.com/img/bdlogo.gif', url: 'http://www.baidu.com/' + article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: 'https://www.trustie.net/images/trustie_logo1.png', url: 'http://www.baidu.com/' end else openid = request[:FromUserName]