145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
# File 'app/models/subscription_client_notice.rb', line 145
def self.notify_connection_error(notice_subject_type_key, notice_subject_id)
notice_subject_type = notice_subject_types[notice_subject_type_key.to_sym]
return false unless notice_subject_type
notices = list(
notice_type: types[:connection_error],
notice_subject_type: notice_subject_type,
notice_subject_id: notice_subject_id
)
if notices.any?
notice = notices.first
notice.updated_at = DateTime.now.iso8601(3)
notice.save
else
opts = {}
if notice_subject_type === notice_subject_types[:supplier]
supplier = SubscriptionClientSupplier.find(notice_subject_id)
opts[:supplier] = supplier.name
end
create!(
title: I18n.t("subscription_client.notices.#{notice_subject_type_key}.connection_error.title", **opts),
message: I18n.t("subscription_client.notices.#{notice_subject_type_key}.connection_error.message", **opts),
notice_subject_type: notice_subject_type,
notice_subject_id: notice_subject_id,
notice_type: types[:connection_error],
created_at: DateTime.now.iso8601(3),
updated_at: DateTime.now.iso8601(3)
)
end
end
|