mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Prepare sending mail
This commit is contained in:
@ -8,6 +8,7 @@ import emil.{MailAddress, SSLType}
|
||||
import docspell.common._
|
||||
import docspell.store._
|
||||
import docspell.store.records.RUserEmail
|
||||
import OMail.{ItemMail, SmtpSettings}
|
||||
|
||||
trait OMail[F[_]] {
|
||||
|
||||
@ -15,15 +16,31 @@ trait OMail[F[_]] {
|
||||
|
||||
def findSettings(accId: AccountId, name: Ident): OptionT[F, RUserEmail]
|
||||
|
||||
def createSettings(accId: AccountId, data: OMail.SmtpSettings): F[AddResult]
|
||||
def createSettings(accId: AccountId, data: SmtpSettings): F[AddResult]
|
||||
|
||||
def updateSettings(accId: AccountId, name: Ident, data: OMail.SmtpSettings): F[Int]
|
||||
|
||||
def deleteSettings(accId: AccountId, name: Ident): F[Int]
|
||||
|
||||
def sendMail(accId: AccountId, name: Ident, m: ItemMail): F[SendResult]
|
||||
}
|
||||
|
||||
object OMail {
|
||||
|
||||
case class ItemMail(
|
||||
item: Ident,
|
||||
subject: String,
|
||||
recipients: List[MailAddress],
|
||||
body: String,
|
||||
attach: AttachSelection
|
||||
)
|
||||
|
||||
sealed trait AttachSelection
|
||||
object AttachSelection {
|
||||
case object All extends AttachSelection
|
||||
case class Selected(ids: List[Ident]) extends AttachSelection
|
||||
}
|
||||
|
||||
case class SmtpSettings(
|
||||
name: Ident,
|
||||
smtpHost: String,
|
||||
@ -79,5 +96,8 @@ object OMail {
|
||||
|
||||
def deleteSettings(accId: AccountId, name: Ident): F[Int] =
|
||||
store.transact(RUserEmail.delete(accId, name))
|
||||
|
||||
def sendMail(accId: AccountId, name: Ident, m: ItemMail): F[SendResult] =
|
||||
Effect[F].pure(SendResult.Failure(new Exception("not implemented")))
|
||||
})
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
package docspell.backend.ops
|
||||
|
||||
import docspell.common._
|
||||
|
||||
sealed trait SendResult
|
||||
|
||||
object SendResult {
|
||||
|
||||
case class Success(id: Ident) extends SendResult
|
||||
|
||||
case class Failure(ex: Throwable) extends SendResult
|
||||
}
|
Reference in New Issue
Block a user