mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
FEATURE: new 'raw email' modal when listing rejected emails
This commit is contained in:
parent
de58e58272
commit
cf4c256b17
9 changed files with 42 additions and 17 deletions
|
@ -23,6 +23,10 @@ IncomingEmail.reopenClass({
|
||||||
|
|
||||||
return Discourse.ajax(`/admin/email/${status}.json?offset=${offset}`, { data: filter })
|
return Discourse.ajax(`/admin/email/${status}.json?offset=${offset}`, { data: filter })
|
||||||
.then(incomings => _.map(incomings, incoming => IncomingEmail.create(incoming)));
|
.then(incomings => _.map(incomings, incoming => IncomingEmail.create(incoming)));
|
||||||
|
},
|
||||||
|
|
||||||
|
loadRawEmail(id) {
|
||||||
|
return Discourse.ajax(`/admin/email/incoming/${id}/raw.json`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,14 @@
|
||||||
|
import showModal from 'discourse/lib/show-modal';
|
||||||
import AdminEmailIncomings from 'admin/routes/admin-email-incomings';
|
import AdminEmailIncomings from 'admin/routes/admin-email-incomings';
|
||||||
export default AdminEmailIncomings.extend({ status: "rejected" });
|
|
||||||
|
export default AdminEmailIncomings.extend({
|
||||||
|
status: "rejected",
|
||||||
|
|
||||||
|
actions: {
|
||||||
|
showRawEmail(incomingEmailId) {
|
||||||
|
showModal('raw-email');
|
||||||
|
this.controllerFor('raw_email').loadIncomingRawEmail(incomingEmailId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
|
@ -41,7 +41,9 @@
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</td>
|
</td>
|
||||||
<td>{{email.subject}}</td>
|
<td>{{email.subject}}</td>
|
||||||
<td class="error">{{email.error}}</td>
|
<td class="error">
|
||||||
|
<a {{action "showRawEmail" email.id}}>{{email.error}}</a>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{else}}
|
{{else}}
|
||||||
<tr><td colspan="5">{{i18n 'admin.email.incoming_emails.none'}}</td></tr>
|
<tr><td colspan="5">{{i18n 'admin.email.incoming_emails.none'}}</td></tr>
|
||||||
|
|
|
@ -1,14 +1,19 @@
|
||||||
import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
||||||
|
import Post from 'discourse/models/post';
|
||||||
|
import IncomingEmail from 'admin/models/incoming-email';
|
||||||
|
|
||||||
// This controller handles displaying of raw email
|
// This controller handles displaying of raw email
|
||||||
export default Ember.Controller.extend(ModalFunctionality, {
|
export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
rawEmail: "",
|
rawEmail: "",
|
||||||
|
|
||||||
loadRawEmail: function(postId) {
|
loadRawEmail(postId) {
|
||||||
var self = this;
|
return Post.loadRawEmail(postId)
|
||||||
Discourse.Post.loadRawEmail(postId).then(function (result) {
|
.then(result => this.set("rawEmail", result.raw_email));
|
||||||
self.set("rawEmail", result);
|
},
|
||||||
});
|
|
||||||
|
loadIncomingRawEmail(incomingEmailId) {
|
||||||
|
return IncomingEmail.loadRawEmail(incomingEmailId)
|
||||||
|
.then(result => this.set("rawEmail", result.raw_email));
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -427,8 +427,7 @@ Post.reopenClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
loadRawEmail(postId) {
|
loadRawEmail(postId) {
|
||||||
return Discourse.ajax("/posts/" + postId + "/raw-email")
|
return Discourse.ajax(`/posts/${postId}/raw-email.json`);
|
||||||
.then(result => result.raw_email);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -51,6 +51,12 @@ class Admin::EmailController < Admin::AdminController
|
||||||
render text: "email was processed"
|
render text: "email was processed"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def raw_email
|
||||||
|
params.require(:id)
|
||||||
|
incoming_email = IncomingEmail.find(params[:id].to_i)
|
||||||
|
render json: { raw_email: incoming_email.raw }
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def filter_email_logs(email_logs, params)
|
def filter_email_logs(email_logs, params)
|
||||||
|
|
|
@ -79,7 +79,7 @@ class PostsController < ApplicationController
|
||||||
def raw_email
|
def raw_email
|
||||||
post = Post.find(params[:id].to_i)
|
post = Post.find(params[:id].to_i)
|
||||||
guardian.ensure_can_view_raw_email!(post)
|
guardian.ensure_can_view_raw_email!(post)
|
||||||
render json: {raw_email: post.raw_email}
|
render json: { raw_email: post.raw_email }
|
||||||
end
|
end
|
||||||
|
|
||||||
def short_link
|
def short_link
|
||||||
|
|
|
@ -123,6 +123,7 @@ Discourse::Application.routes.draw do
|
||||||
get "skipped"
|
get "skipped"
|
||||||
get "received"
|
get "received"
|
||||||
get "rejected"
|
get "rejected"
|
||||||
|
get "/incoming/:id/raw" => "email#raw_email"
|
||||||
get "preview-digest" => "email#preview_digest"
|
get "preview-digest" => "email#preview_digest"
|
||||||
post "handle_mail"
|
post "handle_mail"
|
||||||
end
|
end
|
||||||
|
|
|
@ -48,16 +48,12 @@ module Email
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_internal
|
def process_internal
|
||||||
raise AutoGeneratedEmailError if is_auto_generated?
|
user = find_or_create_user(from)
|
||||||
|
@incoming_email.update_columns(user_id: user.id)
|
||||||
body = select_body || ""
|
body = select_body || ""
|
||||||
|
|
||||||
|
raise AutoGeneratedEmailError if is_auto_generated?
|
||||||
raise NoBodyDetectedError if body.blank? && !@mail.has_attachments?
|
raise NoBodyDetectedError if body.blank? && !@mail.has_attachments?
|
||||||
|
|
||||||
user = find_or_create_user(from)
|
|
||||||
|
|
||||||
@incoming_email.update_columns(user_id: user.id)
|
|
||||||
|
|
||||||
raise InactiveUserError if !user.active && !user.staged
|
raise InactiveUserError if !user.active && !user.staged
|
||||||
|
|
||||||
if action = subscription_action_for(body, subject)
|
if action = subscription_action_for(body, subject)
|
||||||
|
|
Loading…
Reference in a new issue