22 |
22 |
include Redmine::I18n
|
23 |
23 |
|
24 |
24 |
class UnauthorizedAction < StandardError; end
|
|
25 |
class NotAllowedInProject < UnauthorizedAction; end
|
|
26 |
class InsufficientPermissions < UnauthorizedAction; end
|
25 |
27 |
class MissingInformation < StandardError; end
|
26 |
28 |
|
27 |
29 |
attr_reader :email, :user, :handler_options
|
... | ... | |
182 |
184 |
# Creates a new issue
|
183 |
185 |
def receive_issue
|
184 |
186 |
project = target_project
|
|
187 |
|
|
188 |
# Never receive emails to projects where adding issues is not possible
|
|
189 |
raise NotAllowedInProject, "not possible to add issues to project [#{project.name}]" unless project.allows_to?(:add_issues)
|
|
190 |
|
185 |
191 |
# check permission
|
186 |
192 |
unless handler_options[:no_permission_check]
|
187 |
|
raise UnauthorizedAction, "not allowed to add issues to project [#{project.name}]" unless user.allowed_to?(:add_issues, project)
|
|
193 |
raise InsufficientPermissions, "not allowed to add issues to project [#{project.name}]" unless user.allowed_to?(:add_issues, project)
|
188 |
194 |
end
|
189 |
195 |
|
190 |
196 |
issue = Issue.new(:author => user, :project => project)
|
... | ... | |
223 |
229 |
return nil
|
224 |
230 |
end
|
225 |
231 |
|
|
232 |
# Never receive emails to projects where adding issue notes is not possible
|
|
233 |
project = issue.project
|
|
234 |
raise NotAllowedInProject, "not possible to add notes to project [#{project.name}]" unless project.allows_to?(:add_issue_notes)
|
|
235 |
|
226 |
236 |
# check permission
|
227 |
237 |
unless handler_options[:no_permission_check]
|
228 |
238 |
unless issue.notes_addable?
|
229 |
|
raise UnauthorizedAction, "not allowed to add notes on issues to project [#{issue.project.name}]"
|
|
239 |
raise InsufficientPermissions, "not allowed to add notes on issues to project [#{issue.project.name}]"
|
230 |
240 |
end
|
231 |
241 |
end
|
232 |
242 |
|
... | ... | |
274 |
284 |
return nil
|
275 |
285 |
end
|
276 |
286 |
|
|
287 |
# Never receive emails to projects where adding messages is not possible
|
|
288 |
project = message.project
|
|
289 |
raise NotAllowedInProject, "not possible to add messages to project [#{project.name}]" unless project.allows_to?(:add_messages)
|
|
290 |
|
277 |
291 |
unless handler_options[:no_permission_check]
|
278 |
|
raise UnauthorizedAction, "not allowed to add messages to project [#{message.project.name}]" unless user.allowed_to?(:add_messages, message.project)
|
|
292 |
raise InsufficientPermissions, "not allowed to add messages to project [#{message.project.name}]" unless user.allowed_to?(:add_messages, message.project)
|
279 |
293 |
end
|
280 |
294 |
|
281 |
295 |
if !message.locked?
|