Merge branch 'master' of github.com:ian-kent/Go-MailHog

This commit is contained in:
Ian Kent 2014-12-17 19:54:48 +00:00
commit ba6490cc86
3 changed files with 18 additions and 11 deletions

View file

@ -3,39 +3,39 @@ Go-MailHog API v1
The v1 API is a RESTful HTTP JSON API. The v1 API is a RESTful HTTP JSON API.
### GET /v1/api/events ### GET /api/v1/events
Streams new messages using EventSource and chunked encoding Streams new messages using EventSource and chunked encoding
### GET /v1/api/messages ### GET /api/v1/messages
Lists all messages excluding message content Lists all messages excluding message content
### DELETE /v1/api/messages ### DELETE /api/v1/messages
Deletes all messages Deletes all messages
Returns a ```200``` response code if message deletion was successful. Returns a ```200``` response code if message deletion was successful.
### GET /v1/api/messages/{ message_id } ### GET /api/v1/messages/{ message_id }
Returns an individual message including message content Returns an individual message including message content
### DELETE /v1/api/messages/{ message_id } ### DELETE /api/v1/messages/{ message_id }
Delete an individual message Delete an individual message
Returns a ```200``` response code if message deletion was successful. Returns a ```200``` response code if message deletion was successful.
### GET /v1/api/messages/{ message_id }/download ### GET /api/v1/messages/{ message_id }/download
Download the complete message Download the complete message
### GET /v1/api/messages/{ message_id }/mime/part/{ part_index }/download ### GET /api/v1/messages/{ message_id }/mime/part/{ part_index }/download
Download a MIME part Download a MIME part
### POST /v1/api/messages/{ message_id }/release ### POST /api/v1/messages/{ message_id }/release
Release the message to an SMTP server Release the message to an SMTP server

View file

@ -181,7 +181,7 @@ mailhogApp.controller('MailCtrl', function ($scope, $http, $sce, $timeout) {
$scope.getMessagePlain = function(message) { $scope.getMessagePlain = function(message) {
var l = $scope.findMatchingMIME(message, "text/plain"); var l = $scope.findMatchingMIME(message, "text/plain");
if(l != null && l !== "undefined") { if(l != null && l !== "undefined") {
return l.Body; return $scope.tryDecode(l);
} }
return message.Content.Body; return message.Content.Body;
} }
@ -217,11 +217,18 @@ mailhogApp.controller('MailCtrl', function ($scope, $http, $sce, $timeout) {
$scope.getMessageHTML = function(message) { $scope.getMessageHTML = function(message) {
var l = $scope.findMatchingMIME(message, "text/html"); var l = $scope.findMatchingMIME(message, "text/html");
if(l != null && l !== "undefined") { if(l != null && l !== "undefined") {
return l.Body; return $scope.tryDecode(l);
} }
return "<HTML not found>"; return "<HTML not found>";
} }
$scope.tryDecode = function(l){
if(l.Headers && l.Headers["Content-Type"] && l.Headers["Content-Transfer-Encoding"]){
return $scope.tryDecodeContent({Content:l},l.Body.replace(/=[\r\n]+/gm,""));
}else{
return l.Body;
}
};
$scope.date = function(timestamp) { $scope.date = function(timestamp) {
return (new Date(timestamp)).toString(); return (new Date(timestamp)).toString();
}; };

View file

@ -228,7 +228,7 @@
</ul> </ul>
<div class="tab-content"> <div class="tab-content">
<div ng-if="hasHTML(preview)" ng-class="{ active: hasHTML(preview) }" class="tab-pane" id="preview-html" ng-bind-html="preview.previewHTML"></div> <div ng-if="hasHTML(preview)" ng-class="{ active: hasHTML(preview) }" class="tab-pane" id="preview-html" ng-bind-html="preview.previewHTML"></div>
<div class="tab-pane" ng-class="{ active: !hasHTML(preview) }" id="preview-plain">{{ tryDecodeContent(preview, getMessagePlain(preview)) }}</div> <div class="tab-pane" ng-class="{ active: !hasHTML(preview) }" id="preview-plain">{{ getMessagePlain(preview) }}</div>
<div class="tab-pane" id="preview-source">{{ getSource(preview) }}</div> <div class="tab-pane" id="preview-source">{{ getSource(preview) }}</div>
<div class="tab-pane" id="preview-mime"> <div class="tab-pane" id="preview-mime">
<div ng-repeat="part in preview.MIME.Parts" class="mime-part"> <div ng-repeat="part in preview.MIME.Parts" class="mime-part">