项目缺陷消息点对点发送

回复逻辑优化(未完成)
This commit is contained in:
huang 2015-09-21 17:51:00 +08:00
parent b49d19cdb2
commit 48b93f2113
4 changed files with 32 additions and 11 deletions

View File

@ -223,7 +223,6 @@ class IssuesController < ApplicationController
end
if saved
#修改界面增加跟踪者
watcherlist = @issue.watcher_users
select_users = []
@ -253,9 +252,7 @@ class IssuesController < ApplicationController
JournalReply.add_reply(@issue.current_journal.id, reply_id, User.current.id)
end
flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record?
respond_to do |format|
format.html { redirect_to issue_url(@issue.id) }
format.api { render_api_ok }
end

View File

@ -171,11 +171,16 @@ class Journal < ActiveRecord::Base
# 缺陷状态更改,消息提醒
def act_as_forge_message
receivers = []
# 直接回复
if self.user_id != self.issue.author_id
self.forge_messages << ForgeMessage.new(:user_id => self.issue.author_id, :project_id => self.issue.project_id, :viewed => false)
receivers << self.issue.author_id
end
if self.user_id != self.issue.assigned_to_id && self.issue.assigned_to_id != self.issue.author_id # 指派人不是自己的话,则给指派人发送
self.forge_messages << ForgeMessage.new(:user_id => self.issue.assigned_to_id, :project_id => self.issue.project_id, :viewed => false)
receivers << self.issue.assigned_to_id
end
receivers.each do |r|
self.forge_messages << ForgeMessage.new(:user_id => r, :project_id => self.issue.project_id, :viewed => false)
end
end

View File

@ -5,8 +5,33 @@ class JournalReply < ActiveRecord::Base
belongs_to :user
belongs_to :journal
after_create :send_journal_messages
def self.add_reply(journal_id, reply_id, user_id)
self.create(:journal_id => journal_id, :reply_id => reply_id, :user_id => user_id)
end
def send_journal_messages
journal = self.journal
replier = User.find(self.reply_id)
receivers = []
# 被回复的人发送消息
if journal.user_id != self.reply_id
receivers << self.replier
end
if journal.user_id != journal.issue.author_id && self.reply_id != journal.issue.author_id
receivers << self.journal.issue.author
end
receivers.each do |r|
journal.forge_messages << ForgeMessage.new(:user_id =>r, :project_id => journal.issue.project, :viewed => false)
end
# if self.user_id != self.journal_reply.user_id
# receivers << self.journal_reply.user_id
# end
# # 给缺陷发布者发送
# if self.user_id != self.issue.author_id && self.journal_reply.user_id != self.issue.author_id
# receivers << self.issue.author_id
# end
end
end

View File

@ -6,15 +6,9 @@
<div id="all_attributes" style="display:none;">
<%= render :partial => 'form', :locals => {:f => f} %>
<div class="ping_C mb10 ml10"></div>
<!--<a remote="true" href="javascript:void(0)" class="blue_btn fl" style="margin-left: 80px;margin-bottom: 10px;margin-top: -10px;" onclick="$('#issue-form').submit();">-->
<!--<%#= l(:button_submit) %>-->
<!--</a>-->
</div>
<% end %><!--end-->
<!--<fieldset><legend><%#= l(:field_notes) %></legend>-->
<!--回复框-->
<% if @journals.present? %>
<div id="history">
<%= render :partial => 'history', :locals => {:issue => @issue, :journals => @journals} %>