further optimize raw email feature
This commit is contained in:
parent
3854c0a29e
commit
72873b8368
|
@ -14,10 +14,10 @@ import ObjectController from 'discourse/controllers/object';
|
|||
export default ObjectController.extend(ModalFunctionality, {
|
||||
raw_email: "",
|
||||
|
||||
loadEmail: function(postId) {
|
||||
loadRawEmail: function(postId) {
|
||||
var self = this;
|
||||
Discourse.Post.load(postId).then(function (result) {
|
||||
self.set("raw_email", result.get('raw_email'));
|
||||
Discourse.Post.loadRawEmail(postId).then(function (raw_email) {
|
||||
self.set("raw_email", raw_email);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -490,6 +490,12 @@ Discourse.Post.reopenClass({
|
|||
});
|
||||
},
|
||||
|
||||
loadRawEmail: function(postId) {
|
||||
return Discourse.ajax("/posts/" + postId + "/raw-email").then(function (result) {
|
||||
return result.raw_email;
|
||||
});
|
||||
},
|
||||
|
||||
load: function(postId) {
|
||||
return Discourse.ajax("/posts/" + postId + ".json").then(function (result) {
|
||||
return Discourse.Post.create(result);
|
||||
|
|
|
@ -75,7 +75,7 @@ Discourse.TopicRoute = Discourse.Route.extend({
|
|||
|
||||
showRawEmail: function(post) {
|
||||
Discourse.Route.showModal(this, 'raw-email', post);
|
||||
this.controllerFor('raw_email').loadEmail(post.get("id"));
|
||||
this.controllerFor('raw_email').loadRawEmail(post.get("id"));
|
||||
},
|
||||
|
||||
mergeTopic: function() {
|
||||
|
|
|
@ -30,6 +30,12 @@ class PostsController < ApplicationController
|
|||
render json: {cooked: post.cooked}
|
||||
end
|
||||
|
||||
def raw_email
|
||||
guardian.ensure_can_view_raw_email!
|
||||
post = Post.find(params[:id].to_i)
|
||||
render json: {raw_email: post.raw_email}
|
||||
end
|
||||
|
||||
def short_link
|
||||
post = Post.find(params[:post_id].to_i)
|
||||
# Stuff the user in the request object, because that's what IncomingLink wants
|
||||
|
|
|
@ -51,8 +51,7 @@ class PostSerializer < BasicPostSerializer
|
|||
:wiki,
|
||||
:user_custom_fields,
|
||||
:static_doc,
|
||||
:via_email,
|
||||
:raw_email
|
||||
:via_email
|
||||
|
||||
def topic_slug
|
||||
object.try(:topic).try(:slug)
|
||||
|
|
|
@ -1384,7 +1384,6 @@ en:
|
|||
history: "History"
|
||||
changed_by: "by {{author}}"
|
||||
|
||||
|
||||
raw_email:
|
||||
title: "Raw Email"
|
||||
not_available: "Not available!"
|
||||
|
|
|
@ -416,6 +416,7 @@ Discourse::Application.routes.draw do
|
|||
get "/posts/:id/cooked" => "posts#cooked"
|
||||
get "/posts/:id/expand-embed" => "posts#expand_embed"
|
||||
get "/posts/:id/raw" => "posts#markdown_id"
|
||||
get "/posts/:id/raw-email" => "posts#raw_email"
|
||||
get "raw/:topic_id(/:post_number)" => "posts#markdown_num"
|
||||
|
||||
resources :invites do
|
||||
|
|
|
@ -193,6 +193,10 @@ module PostGuardian
|
|||
is_staff?
|
||||
end
|
||||
|
||||
def can_view_raw_email?
|
||||
is_staff?
|
||||
end
|
||||
|
||||
def can_unhide?(post)
|
||||
post.try(:hidden) && is_staff?
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue