Updates
This commit is contained in:
parent
d67c39251a
commit
e7532e5e67
@ -1,13 +1,13 @@
|
||||
{
|
||||
"files": {
|
||||
"main.css": "/static/css/main.06c3544e.css",
|
||||
"main.js": "/static/js/main.47736d7c.js",
|
||||
"main.js": "/static/js/main.51967182.js",
|
||||
"index.html": "/index.html",
|
||||
"main.06c3544e.css.map": "/static/css/main.06c3544e.css.map",
|
||||
"main.47736d7c.js.map": "/static/js/main.47736d7c.js.map"
|
||||
"main.51967182.js.map": "/static/js/main.51967182.js.map"
|
||||
},
|
||||
"entrypoints": [
|
||||
"static/css/main.06c3544e.css",
|
||||
"static/js/main.47736d7c.js"
|
||||
"static/js/main.51967182.js"
|
||||
]
|
||||
}
|
||||
@ -1 +1 @@
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="2 Week Mail - Temporary Email Service"/><title>2 Week Mail</title><script defer="defer" src="/static/js/main.47736d7c.js"></script><link href="/static/css/main.06c3544e.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="2 Week Mail - Temporary Email Service"/><title>2 Week Mail</title><script defer="defer" src="/static/js/main.51967182.js"></script><link href="/static/css/main.06c3544e.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
client/build/static/js/main.51967182.js.map
Normal file
1
client/build/static/js/main.51967182.js.map
Normal file
File diff suppressed because one or more lines are too long
@ -162,40 +162,74 @@ const App = () => {
|
||||
</Card>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<Card
|
||||
className="hover:shadow-lg transition-shadow cursor-pointer"
|
||||
onClick={() => window.location.href = '/docs'}
|
||||
>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center space-x-2">
|
||||
<span>API Documentation</span>
|
||||
<ArrowRight className="h-4 w-4" />
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<p className="text-gray-600">
|
||||
Comprehensive API documentation with examples and integration guides.
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Card
|
||||
className="hover:shadow-lg transition-shadow cursor-pointer"
|
||||
onClick={() => window.location.href = '/docs'}
|
||||
>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center space-x-2">
|
||||
<span>API Documentation</span>
|
||||
<ArrowRight className="h-4 w-4" />
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<p className="text-gray-600">
|
||||
Comprehensive API documentation with examples and integration guides.
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card
|
||||
className="hover:shadow-lg transition-shadow cursor-pointer"
|
||||
onClick={() => setCurrentPage('stats')}
|
||||
>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center space-x-2">
|
||||
<span>Usage Statistics</span>
|
||||
<BarChart2 className="h-4 w-4" />
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<p className="text-gray-600">
|
||||
View real-time statistics about email creation and message reception.
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
<Card
|
||||
className="hover:shadow-lg transition-shadow cursor-pointer"
|
||||
onClick={() => setCurrentPage('stats')}
|
||||
>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center space-x-2">
|
||||
<span>Usage Statistics</span>
|
||||
<BarChart2 className="h-4 w-4" />
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<p className="text-gray-600">
|
||||
View real-time statistics about email creation and message reception.
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card
|
||||
className="hover:shadow-lg transition-shadow cursor-pointer"
|
||||
onClick={() => window.location.href = 'https://status.2weekmail.fyi/status/main'}
|
||||
>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center space-x-2">
|
||||
<span>API Status</span>
|
||||
<ArrowRight className="h-4 w-4" />
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<p className="text-gray-600">
|
||||
Check the current status and uptime of our API services.
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card
|
||||
className="hover:shadow-lg transition-shadow cursor-pointer"
|
||||
onClick={() => window.location.href = 'https://ploi.app/status-pages/2weekmail-status'}
|
||||
>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center space-x-2">
|
||||
<span>Infrastructure Status</span>
|
||||
<ArrowRight className="h-4 w-4" />
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<p className="text-gray-600">
|
||||
Monitor our infrastructure and server status.
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Footer />
|
||||
|
||||
@ -2,26 +2,22 @@ const Message = require("../../db/models/Message");
|
||||
const Domain = require("../../db/models/Domain");
|
||||
const TempEmail = require("../../db/models/TempEmail");
|
||||
const config = require("../../config/haraka");
|
||||
const { Model } = require('objection');
|
||||
const Knex = require('knex');
|
||||
const knexConfig = require('../../config/database');
|
||||
const { Model } = require("objection");
|
||||
const Knex = require("knex");
|
||||
const knexConfig = require("../../config/database");
|
||||
const knex = Knex(knexConfig.development);
|
||||
Model.knex(knex);
|
||||
|
||||
class MessageService {
|
||||
static async isValidDomain(email) {
|
||||
const domain = email.split("@")[1];
|
||||
const tempDomain = await Domain.query()
|
||||
.where("name", domain)
|
||||
.first();
|
||||
const tempDomain = await Domain.query().where("name", domain).first();
|
||||
|
||||
return !tempDomain;
|
||||
}
|
||||
|
||||
static async isValidEmail(email) {
|
||||
const tempEmail = await TempEmail.query()
|
||||
.where("email", email)
|
||||
.first();
|
||||
const tempEmail = await TempEmail.query().where("email", email).first();
|
||||
|
||||
return !tempEmail;
|
||||
}
|
||||
@ -47,12 +43,37 @@ class MessageService {
|
||||
}
|
||||
|
||||
static async cleanup() {
|
||||
const now = new Date().toISOString();
|
||||
const cutoffDate = new Date();
|
||||
cutoffDate.setDate(cutoffDate.getDate() - config.storage.retention);
|
||||
|
||||
const deletedMessages = await Message.query().where("created_at", "<", cutoffDate).delete();
|
||||
const deletedTempEmails = await TempEmail.query().where("created_at", "<", cutoffDate).delete();
|
||||
return { deletedMessages, deletedTempEmails };
|
||||
const expiredEmails = await TempEmail.query()
|
||||
.where("expires_at", "<", now)
|
||||
.select("id");
|
||||
|
||||
const expiredEmailIds = expiredEmails.map((email) => email.id);
|
||||
|
||||
if (expiredEmailIds.length > 0) {
|
||||
console.log("Deleting messages for expired emails");
|
||||
const deletedMessages = await Message.query()
|
||||
.whereIn("temp_email_id", expiredEmailIds)
|
||||
.delete();
|
||||
|
||||
console.log("Deleting expired temp emails");
|
||||
const deletedTempEmails = await TempEmail.query()
|
||||
.whereIn("id", expiredEmailIds)
|
||||
.delete();
|
||||
|
||||
const expiredMessages = await Message.query()
|
||||
.where("created_at", "<", cutoffDate)
|
||||
.delete();
|
||||
|
||||
console.log("Deleted messages:", deletedMessages + expiredMessages);
|
||||
console.log("Deleted emails:", deletedTempEmails);
|
||||
return { deletedMessages, deletedTempEmails };
|
||||
}
|
||||
|
||||
return { deletedMessages: 0, deletedTempEmails: 0 };
|
||||
}
|
||||
|
||||
static async search(params) {
|
||||
|
||||
11
test.js
11
test.js
@ -4,16 +4,9 @@ const Knex = require('knex');
|
||||
const knexConfig = require('./src/config/database');
|
||||
const knex = Knex(knexConfig.development);
|
||||
Model.knex(knex);
|
||||
const { getRandomDomain, mysqlSafeTimestamp } = require('./src/utils/functions');
|
||||
const DailyStats = require('./src/db/models/DailyStats');
|
||||
|
||||
const MessageService = require('./src/email_server/services/MessageService');
|
||||
async function main() {
|
||||
// const domain = await getRandomDomain(true);
|
||||
// console.log(domain);
|
||||
// console.log(mysqlSafeTimestamp(true, 14));
|
||||
const stats = await DailyStats.getTotalStats();
|
||||
console.log(stats);
|
||||
process.exit(0);
|
||||
await MessageService.cleanup();
|
||||
}
|
||||
|
||||
main();
|
||||
Loading…
x
Reference in New Issue
Block a user