summaryrefslogtreecommitdiff
path: root/src/jwebmail/model
diff options
context:
space:
mode:
authorJannis M. Hoffmann <jannis@fehcom.de>2024-12-08 16:15:37 +0100
committerJannis M. Hoffmann <jannis@fehcom.de>2024-12-08 16:15:37 +0100
commit57423db1e342b48c970b972a6f18e84e7a7b1a22 (patch)
tree778ecf925dfd7e04eb68edf3ebca4491ae128fcb /src/jwebmail/model
parentbdb14d5b5fff9c53ea2684a8180f7a9e55dcc8f3 (diff)
update for mail-storage version 1.1.0
Now a keyset based pagination is used instead of an offset based one. This removes the dependency flask-paginate. URL arguments are taken from the request object in the displayheaders templates instead of passing them in manually. Not needed arguments for about render_template are removed.
Diffstat (limited to 'src/jwebmail/model')
-rw-r--r--src/jwebmail/model/de.jmhoffmann.jwebmail.mail-storage.varlink35
-rw-r--r--src/jwebmail/model/read_mails.py43
2 files changed, 60 insertions, 18 deletions
diff --git a/src/jwebmail/model/de.jmhoffmann.jwebmail.mail-storage.varlink b/src/jwebmail/model/de.jmhoffmann.jwebmail.mail-storage.varlink
index 3be999b..850ff19 100644
--- a/src/jwebmail/model/de.jmhoffmann.jwebmail.mail-storage.varlink
+++ b/src/jwebmail/model/de.jmhoffmann.jwebmail.mail-storage.varlink
@@ -58,23 +58,54 @@ type MIMEPart (
body: MailBody
)
+# sorting by subject is deprecated
type Sort (
direction: (asc, desc),
- parameter: (date, size, sender)
+ parameter: (date, size, sender, subject)
+)
+
+type Bound (
+ param: string,
+ id: string
)
method Init(unix_user: string, mailbox_path: string) -> ()
+
+# deprecated: use ListSearch instead
method List(folder: string, start: int, end: int, sort: Sort) -> (mail_heads: []ListMailHeader)
+
method Stats(folder: string) -> (mail_count: int, unread_count: int, byte_size: int)
+
method Show(folder: string, mid: string) -> (mail: Mail)
-method Raw(folder: string, mid: string, path: ?string) -> (header: MIMEHeader, body: string) # body is base64 encoded
+
+# body is base64 encoded
+method Raw(folder: string, mid: string, path: ?string) -> (header: MIMEHeader, body: string)
+
+# deprecated: use ListSearch instead
method Search(folder: string, pattern: string) -> (found: []ListMailHeader)
+
method Folders() -> (folders: []string)
+
method Move(mid: string, from_folder: string, to_folder: string) -> ()
+
method Remove(folder: string, mid: string) -> ()
+
method AddFolder(name: string) -> (status: (created, skiped))
+method ListSearch(
+ folder: string,
+ bound: ?Bound,
+ direction: (after, before),
+ limit: int,
+ sort: Sort,
+ search: ?string
+) -> (
+ mail_heads: []ListMailHeader,
+ first: bool,
+ last: bool
+)
+
error NotInitialized()
error InvalidFolder(folder: string)
diff --git a/src/jwebmail/model/read_mails.py b/src/jwebmail/model/read_mails.py
index 8a19224..b2e1191 100644
--- a/src/jwebmail/model/read_mails.py
+++ b/src/jwebmail/model/read_mails.py
@@ -27,7 +27,7 @@ class QMailAuthuser:
self._client = None
self._connection = None
- def read_headers_for(self, folder, start, end, sort):
+ def list_search(self, folder, bound, after, limit, sort, search):
sort_val = dict()
if sort[0] == "!":
sort = sort[1:]
@@ -41,17 +41,32 @@ class QMailAuthuser:
case _:
raise ValueError(f"invalid sort parameter {sort!r}")
- req = self._connection.List(folder=folder, start=start, end=end, sort=sort_val)
- return [
- {
- "message_handle": lmh["mid"],
- "byte_size": lmh["byte_size"],
- "unread": lmh["unread"],
- "date_received": lmh["rec_date"],
- "head": self._mail_header(lmh["header"]),
- }
- for lmh in req["mail_heads"]
- ]
+ if bound is not None:
+ param, mid = bound.split("_", 1)
+ bound = {"param": param, "id": mid}
+
+ req = self._connection.ListSearch(
+ folder=folder,
+ bound=bound,
+ direction="after" if after else "before",
+ limit=limit,
+ sort=sort_val,
+ search=search,
+ )
+ return (
+ [
+ {
+ "message_handle": lmh["mid"],
+ "byte_size": lmh["byte_size"],
+ "unread": lmh["unread"],
+ "date_received": lmh["rec_date"],
+ "head": self._mail_header(lmh["header"]),
+ }
+ for lmh in req["mail_heads"]
+ ],
+ req["first"],
+ req["last"],
+ )
def count(self, folder):
resp = self._connection.Stats(folder=folder)
@@ -75,10 +90,6 @@ class QMailAuthuser:
"body": b64decode(resp["body"]),
}
- def search(self, pattern, folder):
- resp = self._connection.Search(folder=folder, pattern=pattern)
- return resp
-
def folders(self):
resp = self._connection.Folders()
return list(resp["folders"]) + [""]