1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
class AdminIncomingMessageController < AdminController
def edit
@incoming_message = IncomingMessage.find(params[:id])
end
def update
@incoming_message = IncomingMessage.find(params[:id])
old_prominence = @incoming_message.prominence
old_prominence_reason = @incoming_message.prominence_reason
@incoming_message.prominence = params[:incoming_message][:prominence]
@incoming_message.prominence_reason = params[:incoming_message][:prominence_reason]
if @incoming_message.save
@incoming_message.info_request.log_event('edit_incoming',
:incoming_message_id => @incoming_message.id,
:editor => admin_current_user(),
:old_prominence => old_prominence,
:prominence => @incoming_message.prominence,
:old_prominence_reason => old_prominence_reason,
:prominence_reason => @incoming_message.prominence_reason)
expire_for_request(@incoming_message.info_request)
flash[:notice] = 'Incoming message successfully updated.'
redirect_to admin_request_url(@incoming_message.info_request)
else
render :action => 'edit'
end
end
def destroy
@incoming_message = IncomingMessage.find(params[:id])
@info_request = @incoming_message.info_request
incoming_message_id = @incoming_message.id
@incoming_message.fully_destroy
@incoming_message.info_request.log_event("destroy_incoming",
{ :editor => admin_current_user(), :deleted_incoming_message_id => incoming_message_id })
# expire cached files
expire_for_request(@info_request)
flash[:notice] = 'Incoming message successfully destroyed.'
redirect_to admin_request_url(@info_request)
end
def redeliver
incoming_message = IncomingMessage.find(params[:id])
message_ids = params[:url_title].split(",").each {|x| x.strip}
previous_request = incoming_message.info_request
destination_request = nil
ActiveRecord::Base.transaction do
for m in message_ids
if m.match(/^[0-9]+$/)
destination_request = InfoRequest.find_by_id(m.to_i)
else
destination_request = InfoRequest.find_by_url_title!(m)
end
if destination_request.nil?
flash[:error] = "Failed to find destination request '" + m + "'"
return redirect_to admin_request_url(previous_request)
end
raw_email_data = incoming_message.raw_email.data
mail = MailHandler.mail_from_raw_email(raw_email_data)
destination_request.receive(mail, raw_email_data, true)
incoming_message_id = incoming_message.id
incoming_message.info_request.log_event("redeliver_incoming", {
:editor => admin_current_user(),
:destination_request => destination_request.id,
:deleted_incoming_message_id => incoming_message_id
})
flash[:notice] = "Message has been moved to request(s). Showing the last one:"
end
# expire cached files
expire_for_request(previous_request)
incoming_message.fully_destroy
end
redirect_to admin_request_url(destination_request)
end
end
|