Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #30 catch record not found exception for group users #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 22 additions & 17 deletions lib/redmine_zulip/issue_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,22 +141,24 @@ def notify_assignment
def notify_unassignment
previous_assigned_to = User.find(
previous_changes["assigned_to_id"].first
)
locale = previous_assigned_to.language.present? ?
previous_assigned_to.language : Setting.default_language
message = I18n.t("zulip_notify_unassignment", {
user: User.current.name,
id: id,
url: url,
project: project.name,
subject: subject_without_punctuation,
locale: locale
})
zulip_api.messages.send(
type: "private",
content: message,
to: previous_assigned_to.mail
)
) rescue nil
if previous_changes.nil?
locale = previous_assigned_to.language.present? ?
previous_assigned_to.language : Setting.default_language
message = I18n.t("zulip_notify_unassignment", {
user: User.current.name,
id: id,
url: url,
project: project.name,
subject: subject_without_punctuation,
locale: locale
})
zulip_api.messages.send(
type: "private",
content: message,
to: previous_assigned_to.mail
)
end
end

def notify_assigned_to_issue_updated
Expand Down Expand Up @@ -293,7 +295,10 @@ def update_issue_subject
message += "\n* **#{Issue.human_attribute_name(:assigned_to, locale: locale)}**: "
previous_assigned_to_id = previous_changes["assigned_to_id"].first
if previous_assigned_to_id.present?
previous_assigned_to = User.find(previous_assigned_to_id)
previous_assigned_to = User.find(previous_assigned_to_id) rescue nil
if previous_assigned_to.nil?
previous_assigned_to = Group.find(previous_assigned_to_id) rescue nil
end
message += "*~~#{previous_assigned_to.name}~~* " if previous_assigned_to.present?
end
if assigned_to.present?
Expand Down