Skip to content

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

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
65 changes: 65 additions & 0 deletions config/locales/tr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
tr:
label_redmine_zulip: Zulip
zulip_settings_header: Zulip Eklenti Yapılandırması
zulip_settings_label_url: Zulip URL
zulip_settings_label_email: Zulip Bot E-postası
zulip_settings_label_api_key: Zulip Bot API anahtarı
zulip_settings_label_stream_expression: Kanal adı
zulip_settings_label_issue_updates_subject_expression: >
İş güncellemeleri konusu
zulip_settings_label_version_updates_subject_expression: >
Sürüm güncellemeleri konusu
field_zulip_url: Zulip URL
field_zulip_email: Zulip e-posta
field_zulip_api_key: Zulip Bot API anahtarı
field_zulip_stream_expression: Kanal adı
field_zulip_issue_updates_subject_expression: >
İş güncellemeleri konusu
field_zulip_version_updates_subject_expression: >
Sürüm güncellemeleri konusu
zulip_notify_assignment: >
%{user} [[%{project}#%{id}] %{subject}](%{url}) işini **size** **atadı**:


~~~quote

%{description}

~~~


* **%{status_label}**: %{status}


zulip_notify_unassignment: >
%{user} [[%{project}#%{id}] %{subject}](%{url}) işini **sizden** **kaldırdı**.

zulip_notify_updated: >
%{user} [[%{project}#%{id}] %{subject}](%{url}) işini **güncelledi**.

zulip_notify_destroyed: >
%{user} **%{id}: %{subject}** işini **sildi**.

zulip_init_issue_subject: >
%{user} [[%{project}#%{id}] %{subject}](%{url}) işini **oluşturdu**:


~~~quote

%{description}

~~~

* **%{assigned_to_label}**: %{assigned_to}

* **%{status_label}**: %{status}

zulip_update_version_subject_added: >
%{user} [[%{project}#%{id}] %{subject}](%{url}) işini **%{fixed_version}** sürümüne **ekledi**.

zulip_update_version_subject_removed: >
%{user} [[%{project}#%{id}] %{subject}](%{url}) işini **%{fixed_version}** sürümünden **çıkardı**.

zulip_update_version_subject_status: >
%{user} [[%{project}#%{id}] %{subject}](%{url}) işinin durumunu
*~~%{previous_status}~~* durumundan **%{current_status}** durumuna **değiştirdi**.
2 changes: 1 addition & 1 deletion db/migrate/20130920172651_add_zulip_auth_to_project.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddZulipAuthToProject < ActiveRecord::Migration
class AddZulipAuthToProject < ActiveRecord::Migration[5.2]
def change
add_column :projects, :zulip_email, :string, :default => "", :null => false
add_column :projects, :zulip_api_key, :string, :default => "", :null => false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class UpgradeZulipSettingsToProject < ActiveRecord::Migration
class UpgradeZulipSettingsToProject < ActiveRecord::Migration[5.2]
def change
remove_column :projects, :zulip_email, :string
remove_column :projects, :zulip_api_key, :string
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20191015151700_rename_boolean_settings.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class RenameBooleanSettings < ActiveRecord::Migration
class RenameBooleanSettings < ActiveRecord::Migration[5.2]
def change
rename_column :projects, :zulip_subject_issue, :zulip_issue_updates
rename_column :projects, :zulip_subject_version, :zulip_version_updates
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20191015152900_add_subjects_pattern_settings.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddSubjectsPatternSettings < ActiveRecord::Migration
class AddSubjectsPatternSettings < ActiveRecord::Migration[5.2]
def change
rename_column :projects, :zulip_stream, :zulip_stream_expression
add_column :projects, :zulip_issue_updates_subject_expression, :string
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20191015182300_set_default_patterns.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class SetDefaultPatterns < ActiveRecord::Migration
class SetDefaultPatterns < ActiveRecord::Migration[5.2]
def change
Setting.plugin_redmine_zulip[:zulip_stream_expression] = "${project_name}"
Setting.plugin_redmine_zulip[:zulip_issue_updates_subject_expression] = "${issue_subject}"
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20191018212300_remove_boolean_settings.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class RemoveBooleanSettings < ActiveRecord::Migration
class RemoveBooleanSettings < ActiveRecord::Migration[5.2]
def change
remove_column :projects, :zulip_private_messages, :boolean
remove_column :projects, :zulip_issue_updates, :boolean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddZulipServerSettingsToProjects < ActiveRecord::Migration
class AddZulipServerSettingsToProjects < ActiveRecord::Migration[5.2]
def change
add_column :projects, :zulip_url, :string
add_column :projects, :zulip_email, :string
Expand Down
5 changes: 4 additions & 1 deletion init.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "redmine_zulip"
require File.expand_path('lib/redmine_zulip', __dir__)

Redmine::Plugin.register :redmine_zulip do
name 'Zulip'
Expand All @@ -8,6 +8,8 @@
url 'https://github.com/zulip/zulip-redmine-plugin'
author_url 'https://www.zulip.org/'

requires_redmine version_or_higher: '4.0.0'

settings partial: "settings/redmine_zulip", default: {
"zulip_url" => "",
"zulip_email" => "",
Expand All @@ -17,3 +19,4 @@
"zulip_version_updates_subject_expression" => "Version ${version_name}"
}
end

11 changes: 4 additions & 7 deletions lib/redmine_zulip.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
module RedmineZulip
VERSION = "2.1.2"
end

Rails.configuration.to_prepare do
Issue.send(:include, RedmineZulip::IssuePatch)
Project.send(:include, RedmineZulip::ProjectPatch)
ProjectsController.send(:helper, RedmineZulip::ProjectSettingsTabs)
VERSION = "4.1.0"
end
Issue.send(:include, RedmineZulip::IssuePatch)
Project.send(:include, RedmineZulip::ProjectPatch)
ProjectsController.send(:helper, RedmineZulip::ProjectSettingsTabs)
59 changes: 32 additions & 27 deletions lib/redmine_zulip/issue_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def zulip_api
def notify_assignment
locale = assigned_to.language.present? ?
assigned_to.language : Setting.default_language
message = I18n.t("zulip_notify_assignment", {
message = I18n.t("zulip_notify_assignment", **{
locale: locale,
user: User.current.name,
id: id,
Expand Down Expand Up @@ -141,28 +141,30 @@ 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
locale = assigned_to.language.present? ?
assigned_to.language : Setting.default_language
message = I18n.t("zulip_notify_updated", {
message = I18n.t("zulip_notify_updated", **{
user: User.current.name,
id: id,
url: url,
Expand Down Expand Up @@ -223,7 +225,7 @@ def notify_assigned_to_issue_updated
def notify_assigned_to_issue_destroyed
locale = assigned_to.language.present? ?
assigned_to.language : Setting.default_language
message = I18n.t("zulip_notify_destroyed", {
message = I18n.t("zulip_notify_destroyed", **{
user: User.current.name,
id: id,
project: project.name,
Expand All @@ -239,7 +241,7 @@ def notify_assigned_to_issue_destroyed

def init_issue_subject
locale = Setting.default_language
message = I18n.t("zulip_init_issue_subject", {
message = I18n.t("zulip_init_issue_subject", **{
locale: locale,
user: User.current.name,
id: id,
Expand Down Expand Up @@ -270,7 +272,7 @@ def init_issue_subject

def update_issue_subject
locale = Setting.default_language
message = I18n.t("zulip_notify_updated", {
message = I18n.t("zulip_notify_updated", **{
locale: locale,
user: User.current.name,
id: id,
Expand All @@ -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 Expand Up @@ -341,7 +346,7 @@ def update_issue_subject
end

def update_issue_subject_destroyed
message = I18n.t("zulip_notify_destroyed", {
message = I18n.t("zulip_notify_destroyed", **{
locale: Setting.default_language,
user: User.current.name,
id: id,
Expand All @@ -357,7 +362,7 @@ def update_issue_subject_destroyed
end

def update_version_subject_added
message = I18n.t("zulip_update_version_subject_added", {
message = I18n.t("zulip_update_version_subject_added", **{
locale: Setting.default_language,
user: User.current.name,
id: id,
Expand All @@ -378,7 +383,7 @@ def update_version_subject_removed
previous_fixed_version = Version.find(
previous_changes["fixed_version_id"].first
)
message = I18n.t("zulip_update_version_subject_removed", {
message = I18n.t("zulip_update_version_subject_removed", **{
locale: Setting.default_language,
user: User.current.name,
id: id,
Expand All @@ -397,7 +402,7 @@ def update_version_subject_removed

def update_version_subject_status
previous_status_id = previous_changes["status_id"].first
message = I18n.t("zulip_update_version_subject_status", {
message = I18n.t("zulip_update_version_subject_status", **{
locale: Setting.default_language,
user: User.current.name,
id: id,
Expand All @@ -416,7 +421,7 @@ def update_version_subject_status
end

def update_version_subject_destroyed
message = I18n.t("zulip_notify_destroyed", {
message = I18n.t("zulip_notify_destroyed", **{
locale: Setting.default_language,
user: User.current.name,
id: id,
Expand Down