Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22399576
mailcatcher.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
1004 B
Referenced Files
None
Subscribers
None
mailcatcher.ts
View Options
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import
axios
from
"axios"
;
import
App
from
"../app/app"
;
import
asyncForEach
from
"../utils/async-foreach"
;
export
type
MailcatcherMessage
=
{
recipients
:
string
[];
subject
:
string
;
id
:
number
;
sender
:
string
;
};
export
default
(
smtp_api_url
:
string
,
app
:
App
)
=>
{
const
ret
=
{
getMessages
:
async
()
=>
{
const
app_address
=
app
.
ConfigManager
.
get
(
"email"
).
from_address
;
const
all_messages
=
(
await
axios
.
get
(
`
${
smtp_api_url
}
/messages`
))
.
data
as
MailcatcherMessage
[];
return
all_messages
.
filter
(
(
message
)
=>
message
.
sender
==
`<
${
app_address
}
>`
);
},
getMessageById
:
async
(
id
:
number
)
=>
(
await
axios
.
get
(
`
${
smtp_api_url
}
/messages/
${
id
}
.html`
))
.
data
as
string
,
deleteAllInstanceEmails
:
async
()
=>
{
const
messages
=
await
ret
.
getMessages
();
await
asyncForEach
(
messages
,
async
(
m
)
=>
{
await
axios
.
delete
(
`
${
smtp_api_url
}
/messages/
${
m
.
id
}
`
);
});
},
};
return
ret
;
};
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Fri, Nov 27, 17:36 (1 d, 13 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1216696
Default Alt Text
mailcatcher.ts (1004 B)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline