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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{{template "base" .}}
|
| 2 |
+
{{define "content"}}
|
| 3 |
+
<div class="min-h-screen flex flex-col bg-gray-50">
|
| 4 |
+
<!-- Header -->
|
| 5 |
+
<header class="bg-white shadow-sm sticky top-0 z-40">
|
| 6 |
+
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-4">
|
| 7 |
+
<div class="flex items-center justify-between">
|
| 8 |
+
<a href="/inbox/{{.SessionID}}" class="flex items-center gap-3 text-gray-600 hover:text-gray-900 transition-colors">
|
| 9 |
+
<i class="fas fa-arrow-left"></i>
|
| 10 |
+
<span>Back to Inbox</span>
|
| 11 |
+
</a>
|
| 12 |
+
<div class="flex items-center gap-3">
|
| 13 |
+
<button
|
| 14 |
+
onclick="deleteMessage()"
|
| 15 |
+
class="p-2 text-gray-400 hover:text-red-500 transition-colors"
|
| 16 |
+
title="Delete message"
|
| 17 |
+
>
|
| 18 |
+
<i class="fas fa-trash-alt"></i>
|
| 19 |
+
</button>
|
| 20 |
+
</div>
|
| 21 |
+
</div>
|
| 22 |
+
</div>
|
| 23 |
+
</header>
|
| 24 |
+
|
| 25 |
+
<!-- Main Content -->
|
| 26 |
+
<main class="flex-1 max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-8 w-full">
|
| 27 |
+
<div class="bg-white rounded-2xl shadow-lg overflow-hidden animate-fade-in">
|
| 28 |
+
<!-- Message Header -->
|
| 29 |
+
<div class="px-6 py-6 border-b border-gray-100">
|
| 30 |
+
<h1 class="text-2xl font-bold text-gray-900 mb-4">
|
| 31 |
+
{{.Message.Subject}}
|
| 32 |
+
</h1>
|
| 33 |
+
|
| 34 |
+
<div class="flex items-start gap-4">
|
| 35 |
+
<div class="w-12 h-12 bg-gradient-to-br from-indigo-400 to-purple-500 rounded-full flex items-center justify-center text-white font-bold text-lg flex-shrink-0">
|
| 36 |
+
{{if .Message.From.Name}}
|
| 37 |
+
{{slice .Message.From.Name 0 1}}
|
| 38 |
+
{{else}}
|
| 39 |
+
{{slice .Message.From.Address 0 1}}
|
| 40 |
+
{{end}}
|
| 41 |
+
</div>
|
| 42 |
+
<div class="flex-1">
|
| 43 |
+
<div class="flex flex-wrap items-center gap-2 mb-1">
|
| 44 |
+
<span class="font-semibold text-gray-900">
|
| 45 |
+
{{if .Message.From.Name}}{{.Message.From.Name}}{{else}}{{.Message.From.Address}}{{end}}
|
| 46 |
+
</span>
|
| 47 |
+
<span class="text-gray-400"><{{.Message.From.Address}}></span>
|
| 48 |
+
</div>
|
| 49 |
+
<div class="text-sm text-gray-500">
|
| 50 |
+
<span>To: {{.Email}}</span>
|
| 51 |
+
<span class="mx-2">•</span>
|
| 52 |
+
<span>{{.Message.CreatedAt.Format "Jan 02, 2006 at 15:04"}}</span>
|
| 53 |
+
</div>
|
| 54 |
+
</div>
|
| 55 |
+
</div>
|
| 56 |
+
|
| 57 |
+
{{if .Message.HasAttachments}}
|
| 58 |
+
<div class="mt-4 p-4 bg-gray-50 rounded-lg">
|
| 59 |
+
<h4 class="text-sm font-semibold text-gray-700 mb-3">
|
| 60 |
+
<i class="fas fa-paperclip mr-2"></i>
|
| 61 |
+
Attachments ({{len .Message.Attachments}})
|
| 62 |
+
</h4>
|
| 63 |
+
<div class="flex flex-wrap gap-2">
|
| 64 |
+
{{range .Message.Attachments}}
|
| 65 |
+
<a
|
| 66 |
+
href="https://api.mail.tm{{.DownloadURL}}"
|
| 67 |
+
target="_blank"
|
| 68 |
+
class="flex items-center gap-2 px-3 py-2 bg-white border border-gray-200 rounded-lg hover:border-indigo-500 hover:text-indigo-600 transition-colors text-sm"
|
| 69 |
+
>
|
| 70 |
+
<i class="fas fa-file"></i>
|
| 71 |
+
<span>{{.Filename}}</span>
|
| 72 |
+
<span class="text-gray-400">({{.Size}} bytes)</span>
|
| 73 |
+
</a>
|
| 74 |
+
{{end}}
|
| 75 |
+
</div>
|
| 76 |
+
</div>
|
| 77 |
+
{{end}}
|
| 78 |
+
</div>
|
| 79 |
+
|
| 80 |
+
<!-- Message Body -->
|
| 81 |
+
<div class="px-6 py-6">
|
| 82 |
+
{{if .HTMLContent}}
|
| 83 |
+
<div class="prose max-w-none" id="htmlContent">
|
| 84 |
+
{{.HTMLContent}}
|
| 85 |
+
</div>
|
| 86 |
+
{{else if .Message.Text}}
|
| 87 |
+
<div class="whitespace-pre-wrap text-gray-700 leading-relaxed">
|
| 88 |
+
{{.Message.Text}}
|
| 89 |
+
</div>
|
| 90 |
+
{{else}}
|
| 91 |
+
<div class="text-center py-12 text-gray-500">
|
| 92 |
+
<i class="fas fa-file-alt text-4xl mb-4"></i>
|
| 93 |
+
<p>No content available</p>
|
| 94 |
+
</div>
|
| 95 |
+
{{end}}
|
| 96 |
+
</div>
|
| 97 |
+
</div>
|
| 98 |
+
|
| 99 |
+
<!-- Actions -->
|
| 100 |
+
<div class="mt-6 flex justify-center gap-4">
|
| 101 |
+
<a
|
| 102 |
+
href="/inbox/{{.SessionID}}"
|
| 103 |
+
class="px-6 py-3 bg-white border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 transition-colors flex items-center gap-2"
|
| 104 |
+
>
|
| 105 |
+
<i class="fas fa-arrow-left"></i>
|
| 106 |
+
Back to Inbox
|
| 107 |
+
</a>
|
| 108 |
+
<button
|
| 109 |
+
onclick="deleteMessage()"
|
| 110 |
+
class="px-6 py-3 bg-red-500 text-white rounded-lg hover:bg-red-600 transition-colors flex items-center gap-2"
|
| 111 |
+
>
|
| 112 |
+
<i class="fas fa-trash-alt"></i>
|
| 113 |
+
Delete Message
|
| 114 |
+
</button>
|
| 115 |
+
</div>
|
| 116 |
+
</main>
|
| 117 |
+
|
| 118 |
+
<!-- Footer -->
|
| 119 |
+
<footer class="bg-white border-t border-gray-100 py-6 mt-auto">
|
| 120 |
+
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 text-center text-gray-500 text-sm">
|
| 121 |
+
<p>© 2024 TempMail. All rights reserved.</p>
|
| 122 |
+
</div>
|
| 123 |
+
</footer>
|
| 124 |
+
</div>
|
| 125 |
+
|
| 126 |
+
<script>
|
| 127 |
+
const sessionId = '{{.SessionID}}';
|
| 128 |
+
const messageId = '{{.Message.ID}}';
|
| 129 |
+
|
| 130 |
+
// Delete message
|
| 131 |
+
async function deleteMessage() {
|
| 132 |
+
if (!confirm('Are you sure you want to delete this message?')) {
|
| 133 |
+
return;
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
try {
|
| 137 |
+
const response = await fetch(`/api/message/${sessionId}/${messageId}`, {
|
| 138 |
+
method: 'DELETE'
|
| 139 |
+
});
|
| 140 |
+
|
| 141 |
+
if (response.ok) {
|
| 142 |
+
showToast('Message deleted', 'success');
|
| 143 |
+
setTimeout(() => {
|
| 144 |
+
window.location.href = `/inbox/${sessionId}`;
|
| 145 |
+
}, 500);
|
| 146 |
+
} else {
|
| 147 |
+
const data = await response.json();
|
| 148 |
+
showToast(data.error || 'Failed to delete message', 'error');
|
| 149 |
+
}
|
| 150 |
+
} catch (error) {
|
| 151 |
+
showToast('Network error', 'error');
|
| 152 |
+
}
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
// Sanitize HTML content (basic XSS prevention)
|
| 156 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 157 |
+
const htmlContent = document.getElementById('htmlContent');
|
| 158 |
+
if (htmlContent) {
|
| 159 |
+
// Remove potentially dangerous elements
|
| 160 |
+
const scripts = htmlContent.querySelectorAll('script');
|
| 161 |
+
scripts.forEach(s => s.remove());
|
| 162 |
+
|
| 163 |
+
// Handle external links
|
| 164 |
+
const links = htmlContent.querySelectorAll('a');
|
| 165 |
+
links.forEach(link => {
|
| 166 |
+
link.setAttribute('target', '_blank');
|
| 167 |
+
link.setAttribute('rel', 'noopener noreferrer');
|
| 168 |
+
});
|
| 169 |
+
}
|
| 170 |
+
});
|
| 171 |
+
</script>
|
| 172 |
+
{{end}}
|