Implement support for mailbox filtering + start http server
This commit is contained in:
@@ -10,6 +10,7 @@ const maybeConfig: any = {
|
||||
user: process.env.CHORUS_IMAP_USER,
|
||||
pass: process.env.CHORUS_IMAP_PASS,
|
||||
},
|
||||
mailbox: process.env.CHORUS_MAILBOX,
|
||||
},
|
||||
threads: {
|
||||
type: 'alias',
|
||||
@@ -21,6 +22,11 @@ const maybeConfig: any = {
|
||||
dirs: {
|
||||
data: process.env.CHORUS_DATA_DIR || 'chorus-data',
|
||||
},
|
||||
http: {
|
||||
enabled: process.env.CHORUS_HTTP_ENABLE === 'true',
|
||||
address: process.env.CHORUS_HTTP_ADDRESS || '0.0.0.0',
|
||||
port: process.env.CHORUS_HTTP_PORT || 8101,
|
||||
},
|
||||
}
|
||||
|
||||
export const config: CommentsConfig = castCommentsConfig(maybeConfig)
|
||||
|
||||
11
src/http/server.ts
Normal file
11
src/http/server.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import {config} from "../config.ts";
|
||||
|
||||
export async function runHttpServer() {
|
||||
Bun.serve({
|
||||
hostname: config.http.address,
|
||||
port: config.http.port,
|
||||
fetch: async request => {
|
||||
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -13,6 +13,12 @@ import {htmlReplyPipeline} from "./sanitize.ts";
|
||||
import {blake2bHex, blake2sHex} from "blakejs";
|
||||
|
||||
export async function getMailboxesToSearch(thread?: string, client?: ImapFlow): Promise<Collection<string>> {
|
||||
// If the config indicates a specific mailbox to search, use that:
|
||||
if ( config.mail.imap.mailbox ) {
|
||||
return collect([config.mail.imap.mailbox])
|
||||
}
|
||||
|
||||
// Otherwise, search all plausible mailboxes automatically.
|
||||
// There are 2 possibilities for where mail might end up.
|
||||
// Either the mail-server is configured to forward the + extensions
|
||||
// to their own folders automatically (e.g. the "c.1234" folder), or
|
||||
|
||||
@@ -9,6 +9,7 @@ const commentsConfigSchema = z.object({
|
||||
user: z.string(),
|
||||
pass: z.string(),
|
||||
}),
|
||||
mailbox: z.string().optional(),
|
||||
}),
|
||||
threads: z.object({
|
||||
type: z.string(), // fixme : in validation
|
||||
@@ -20,6 +21,11 @@ const commentsConfigSchema = z.object({
|
||||
dirs: z.object({
|
||||
data: z.string(),
|
||||
}),
|
||||
http: z.object({
|
||||
enabled: z.boolean().optional(),
|
||||
address: z.string(),
|
||||
port: z.number(),
|
||||
}),
|
||||
})
|
||||
|
||||
export type CommentsConfig = z.infer<typeof commentsConfigSchema>
|
||||
|
||||
Reference in New Issue
Block a user