Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F7112840
mailcatcher.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
mailcatcher.ts
View Options
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import
axios
from
"axios"
;
import
type
{
App
}
from
"../app/app"
;
import
asyncForEach
from
"../utils/async-foreach"
;
export
type
MailcatcherMessage
=
{
recipients
:
string
[];
subject
:
string
;
id
:
number
;
sender
:
string
;
};
export
default
class
MailcatcherAPI
{
constructor
(
public
smtp_api_url
:
string
,
private
app
:
App
)
{}
async
getMessages
()
{
const
app_address
=
this
.
app
.
ConfigManager
.
get
(
"email"
).
from_address
;
const
all_messages
=
(
await
axios
.
get
(
`
${
this
.
smtp_api_url
}
/messages`
))
.
data
as
MailcatcherMessage
[];
return
all_messages
.
filter
(
(
message
)
=>
message
.
sender
==
`<
${
app_address
}
>`
);
}
async
getMessageById
(
id
:
number
)
{
return
(
await
axios
.
get
(
`
${
this
.
smtp_api_url
}
/messages/
${
id
}
.html`
))
.
data
as
string
;
}
async
deleteAllInstanceEmails
()
{
const
messages
=
await
this
.
getMessages
();
await
asyncForEach
(
messages
,
async
(
m
)
=>
{
await
axios
.
delete
(
`
${
this
.
smtp_api_url
}
/messages/
${
m
.
id
}
`
);
});
}
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Fri, Jul 4, 06:43 (21 h, 46 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
774707
Default Alt Text
mailcatcher.ts (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment