forge
Explore
Log in

Don't you dare go Hollow

A second web crate wearing the new coat

Browse files at this commit

4deb90c3ca73309afbec541574937fad667680d3Ahmet Kaan GümüşParent: 95bcb6d
  • feat
    • a second web crate wearing the new coat
Show full message
✨ feat(topcoat): a second web crate wearing the new coat
.gitignoremodified+1 -0
@@ -7,3 +7,4 @@
7 izlek.key7 izlek.key
8 /config/izlek.toml8 /config/izlek.toml
9 CLAUDE.md9 CLAUDE.md
10+/crates/izlek-topcoat/assets
Cargo.lockmodified+713 -1
@@ -53,6 +53,18 @@ dependencies = [
53 "subtle",53 "subtle",
54 ]54 ]
55 55
56+[[package]]
57+name = "ahash"
58+version = "0.8.12"
59+source = "registry+https://github.com/rust-lang/crates.io-index"
60+checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75"
61+dependencies = [
62+ "cfg-if",
63+ "once_cell",
64+ "version_check",
65+ "zerocopy",
66+]
67+
56 [[package]]68 [[package]]
57 name = "aho-corasick"69 name = "aho-corasick"
58 version = "1.1.5"70 version = "1.1.5"
@@ -62,6 +74,21 @@ dependencies = [
62 "memchr",74 "memchr",
63 ]75 ]
64 76
77+[[package]]
78+name = "alloc-no-stdlib"
79+version = "2.0.4"
80+source = "registry+https://github.com/rust-lang/crates.io-index"
81+checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3"
82+
83+[[package]]
84+name = "alloc-stdlib"
85+version = "0.2.4"
86+source = "registry+https://github.com/rust-lang/crates.io-index"
87+checksum = "0e76a019e91224d279006ff972f1e984179a6e9feb050adba6ce8274aef23195"
88+dependencies = [
89+ "alloc-no-stdlib",
90+]
91+
65 [[package]]92 [[package]]
66 name = "allocator-api2"93 name = "allocator-api2"
67 version = "0.2.21"94 version = "0.2.21"
@@ -83,6 +110,56 @@ dependencies = [
83 "libc",110 "libc",
84 ]111 ]
85 112
113+[[package]]
114+name = "anstream"
115+version = "1.0.0"
116+source = "registry+https://github.com/rust-lang/crates.io-index"
117+checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d"
118+dependencies = [
119+ "anstyle",
120+ "anstyle-parse",
121+ "anstyle-query",
122+ "anstyle-wincon",
123+ "colorchoice",
124+ "is_terminal_polyfill",
125+ "utf8parse",
126+]
127+
128+[[package]]
129+name = "anstyle"
130+version = "1.0.14"
131+source = "registry+https://github.com/rust-lang/crates.io-index"
132+checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000"
133+
134+[[package]]
135+name = "anstyle-parse"
136+version = "1.0.0"
137+source = "registry+https://github.com/rust-lang/crates.io-index"
138+checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e"
139+dependencies = [
140+ "utf8parse",
141+]
142+
143+[[package]]
144+name = "anstyle-query"
145+version = "1.1.5"
146+source = "registry+https://github.com/rust-lang/crates.io-index"
147+checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
148+dependencies = [
149+ "windows-sys 0.61.2",
150+]
151+
152+[[package]]
153+name = "anstyle-wincon"
154+version = "3.0.11"
155+source = "registry+https://github.com/rust-lang/crates.io-index"
156+checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
157+dependencies = [
158+ "anstyle",
159+ "once_cell_polyfill",
160+ "windows-sys 0.61.2",
161+]
162+
86 [[package]]163 [[package]]
87 name = "antithesis_sdk"164 name = "antithesis_sdk"
88 version = "0.2.9"165 version = "0.2.9"
@@ -117,6 +194,12 @@ version = "1.0.104"
117 source = "registry+https://github.com/rust-lang/crates.io-index"194 source = "registry+https://github.com/rust-lang/crates.io-index"
118 checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"195 checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"
119 196
197+[[package]]
198+name = "anymap3"
199+version = "1.1.0"
200+source = "registry+https://github.com/rust-lang/crates.io-index"
201+checksum = "fb5dfbc6d8d2675589ccbe4d0fd61df2419075625f8c1a62325e718e2b0049f9"
202+
120 [[package]]203 [[package]]
121 name = "arc-swap"204 name = "arc-swap"
122 version = "1.9.2"205 version = "1.9.2"
@@ -263,7 +346,7 @@ dependencies = [
263 "hyper",346 "hyper",
264 "hyper-util",347 "hyper-util",
265 "itoa",348 "itoa",
266- "matchit",349+ "matchit 0.8.4",
267 "memchr",350 "memchr",
268 "mime",351 "mime",
269 "multer",352 "multer",
@@ -448,6 +531,27 @@ dependencies = [
448 "rustc_version",531 "rustc_version",
449 ]532 ]
450 533
534+[[package]]
535+name = "brotli"
536+version = "8.0.4"
537+source = "registry+https://github.com/rust-lang/crates.io-index"
538+checksum = "5cc91aac060a7a1e25823bdccbfb6af1875b88f17c6daac97894eed8207166b3"
539+dependencies = [
540+ "alloc-no-stdlib",
541+ "alloc-stdlib",
542+ "brotli-decompressor",
543+]
544+
545+[[package]]
546+name = "brotli-decompressor"
547+version = "5.0.3"
548+source = "registry+https://github.com/rust-lang/crates.io-index"
549+checksum = "3a32acac15fe1967bc3986b2a6347dffc965602354ea6f450ad07e8bfd253583"
550+dependencies = [
551+ "alloc-no-stdlib",
552+ "alloc-stdlib",
553+]
554+
451 [[package]]555 [[package]]
452 name = "bumpalo"556 name = "bumpalo"
453 version = "3.20.3"557 version = "3.20.3"
@@ -607,6 +711,33 @@ dependencies = [
607 "libloading",711 "libloading",
608 ]712 ]
609 713
714+[[package]]
715+name = "clap"
716+version = "4.6.6"
717+source = "registry+https://github.com/rust-lang/crates.io-index"
718+checksum = "473c7e07f409a8d772161724aa8db6a765a2532a70f9667eeb7b49d3d02fbdca"
719+dependencies = [
720+ "clap_builder",
721+]
722+
723+[[package]]
724+name = "clap_builder"
725+version = "4.6.6"
726+source = "registry+https://github.com/rust-lang/crates.io-index"
727+checksum = "7b48fea5a88e9ae728a2dcbedbfc0e730f7d60da42e1cb049a83c9fb8b789889"
728+dependencies = [
729+ "anstream",
730+ "anstyle",
731+ "clap_lex",
732+ "strsim",
733+]
734+
735+[[package]]
736+name = "clap_lex"
737+version = "1.1.0"
738+source = "registry+https://github.com/rust-lang/crates.io-index"
739+checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9"
740+
610 [[package]]741 [[package]]
611 name = "cmov"742 name = "cmov"
612 version = "0.5.4"743 version = "0.5.4"
@@ -624,18 +755,31 @@ dependencies = [
624 "thiserror",755 "thiserror",
625 ]756 ]
626 757
758+[[package]]
759+name = "codemap"
760+version = "0.1.3"
761+source = "registry+https://github.com/rust-lang/crates.io-index"
762+checksum = "b9e769b5c8c8283982a987c6e948e540254f1058d5a74b8794914d4ef5fc2a24"
763+
627 [[package]]764 [[package]]
628 name = "collection_literals"765 name = "collection_literals"
629 version = "1.0.3"766 version = "1.0.3"
630 source = "registry+https://github.com/rust-lang/crates.io-index"767 source = "registry+https://github.com/rust-lang/crates.io-index"
631 checksum = "2550f75b8cfac212855f6b1885455df8eaee8fe8e246b647d69146142e016084"768 checksum = "2550f75b8cfac212855f6b1885455df8eaee8fe8e246b647d69146142e016084"
632 769
770+[[package]]
771+name = "colorchoice"
772+version = "1.0.5"
773+source = "registry+https://github.com/rust-lang/crates.io-index"
774+checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
775+
633 [[package]]776 [[package]]
634 name = "compression-codecs"777 name = "compression-codecs"
635 version = "0.4.38"778 version = "0.4.38"
636 source = "registry+https://github.com/rust-lang/crates.io-index"779 source = "registry+https://github.com/rust-lang/crates.io-index"
637 checksum = "ce2548391e9c1929c21bf6aa2680af86fe4c1b33e6cea9ac1cfeec0bd11218cf"780 checksum = "ce2548391e9c1929c21bf6aa2680af86fe4c1b33e6cea9ac1cfeec0bd11218cf"
638 dependencies = [781 dependencies = [
782+ "brotli",
639 "compression-core",783 "compression-core",
640 "flate2",784 "flate2",
641 "memchr",785 "memchr",
@@ -745,6 +889,24 @@ dependencies = [
745 "convert_case 0.11.0",889 "convert_case 0.11.0",
746 ]890 ]
747 891
892+[[package]]
893+name = "cookie"
894+version = "0.18.2"
895+source = "registry+https://github.com/rust-lang/crates.io-index"
896+checksum = "1a373e3602691c3cdea496d2f0ee5935151e6168fe87739483c463db1b2f2f87"
897+dependencies = [
898+ "aes-gcm",
899+ "base64 0.22.1",
900+ "hkdf",
901+ "hmac",
902+ "percent-encoding",
903+ "rand 0.8.8",
904+ "sha2 0.10.9",
905+ "subtle",
906+ "time",
907+ "version_check",
908+]
909+
748 [[package]]910 [[package]]
749 name = "core-foundation-sys"911 name = "core-foundation-sys"
750 version = "0.8.7"912 version = "0.8.7"
@@ -939,6 +1101,7 @@ checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
939 dependencies = [1101 dependencies = [
940 "block-buffer 0.10.4",1102 "block-buffer 0.10.4",
941 "crypto-common 0.1.7",1103 "crypto-common 0.1.7",
1104+ "subtle",
942 ]1105 ]
943 1106
944 [[package]]1107 [[package]]
@@ -992,6 +1155,15 @@ dependencies = [
992 "pin-project-lite",1155 "pin-project-lite",
993 ]1156 ]
994 1157
1158+[[package]]
1159+name = "elsa"
1160+version = "1.11.2"
1161+source = "registry+https://github.com/rust-lang/crates.io-index"
1162+checksum = "9abf33c656a7256451ebb7d0082c5a471820c31269e49d807c538c252352186e"
1163+dependencies = [
1164+ "stable_deref_trait",
1165+]
1166+
995 [[package]]1167 [[package]]
996 name = "email-encoding"1168 name = "email-encoding"
997 version = "0.4.2"1169 version = "0.4.2"
@@ -1391,12 +1563,66 @@ dependencies = [
1391 "web-sys",1563 "web-sys",
1392 ]1564 ]
1393 1565
1566+[[package]]
1567+name = "grass"
1568+version = "0.13.4"
1569+source = "registry+https://github.com/rust-lang/crates.io-index"
1570+checksum = "f7a68216437ef68f0738e48d6c7bb9e6e6a92237e001b03d838314b068f33c94"
1571+dependencies = [
1572+ "clap",
1573+ "getrandom 0.2.17",
1574+ "grass_compiler",
1575+]
1576+
1577+[[package]]
1578+name = "grass_compiler"
1579+version = "0.13.4"
1580+source = "registry+https://github.com/rust-lang/crates.io-index"
1581+checksum = "2d9e3df7f0222ce5184154973d247c591d9aadc28ce7a73c6cd31100c9facff6"
1582+dependencies = [
1583+ "codemap",
1584+ "indexmap",
1585+ "lasso",
1586+ "once_cell",
1587+ "phf",
1588+ "rand 0.8.8",
1589+]
1590+
1394 [[package]]1591 [[package]]
1395 name = "guardian"1592 name = "guardian"
1396 version = "1.3.0"1593 version = "1.3.0"
1397 source = "registry+https://github.com/rust-lang/crates.io-index"1594 source = "registry+https://github.com/rust-lang/crates.io-index"
1398 checksum = "17e2ac29387b1aa07a1e448f7bb4f35b500787971e965b02842b900afa5c8f6f"1595 checksum = "17e2ac29387b1aa07a1e448f7bb4f35b500787971e965b02842b900afa5c8f6f"
1399 1596
1597+[[package]]
1598+name = "h2"
1599+version = "0.4.19"
1600+source = "registry+https://github.com/rust-lang/crates.io-index"
1601+checksum = "ef8e5e5a340588f4452631496976cf8636d4a7ecf600239fdc27615d2530bc16"
1602+dependencies = [
1603+ "atomic-waker",
1604+ "bytes",
1605+ "fnv",
1606+ "futures-core",
1607+ "futures-sink",
1608+ "http",
1609+ "indexmap",
1610+ "slab",
1611+ "tokio",
1612+ "tokio-util",
1613+ "tracing",
1614+]
1615+
1616+[[package]]
1617+name = "hashbrown"
1618+version = "0.14.5"
1619+source = "registry+https://github.com/rust-lang/crates.io-index"
1620+checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
1621+dependencies = [
1622+ "ahash",
1623+ "allocator-api2 0.2.21",
1624+]
1625+
1400 [[package]]1626 [[package]]
1401 name = "hashbrown"1627 name = "hashbrown"
1402 version = "0.16.1"1628 version = "0.16.1"
@@ -1432,6 +1658,24 @@ version = "0.4.3"
1432 source = "registry+https://github.com/rust-lang/crates.io-index"1658 source = "registry+https://github.com/rust-lang/crates.io-index"
1433 checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"1659 checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
1434 1660
1661+[[package]]
1662+name = "hkdf"
1663+version = "0.12.4"
1664+source = "registry+https://github.com/rust-lang/crates.io-index"
1665+checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7"
1666+dependencies = [
1667+ "hmac",
1668+]
1669+
1670+[[package]]
1671+name = "hmac"
1672+version = "0.12.1"
1673+source = "registry+https://github.com/rust-lang/crates.io-index"
1674+checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e"
1675+dependencies = [
1676+ "digest 0.10.7",
1677+]
1678+
1435 [[package]]1679 [[package]]
1436 name = "home"1680 name = "home"
1437 version = "0.5.12"1681 version = "0.5.12"
@@ -1441,6 +1685,17 @@ dependencies = [
1441 "windows-sys 0.61.2",1685 "windows-sys 0.61.2",
1442 ]1686 ]
1443 1687
1688+[[package]]
1689+name = "hostname"
1690+version = "0.4.2"
1691+source = "registry+https://github.com/rust-lang/crates.io-index"
1692+checksum = "617aaa3557aef3810a6369d0a99fac8a080891b68bd9f9812a1eeda0c0730cbd"
1693+dependencies = [
1694+ "cfg-if",
1695+ "libc",
1696+ "windows-link",
1697+]
1698+
1444 [[package]]1699 [[package]]
1445 name = "html-escape"1700 name = "html-escape"
1446 version = "0.2.15"1701 version = "0.2.15"
@@ -1538,6 +1793,7 @@ dependencies = [
1538 "bytes",1793 "bytes",
1539 "futures-channel",1794 "futures-channel",
1540 "futures-core",1795 "futures-core",
1796+ "h2",
1541 "http",1797 "http",
1542 "http-body",1798 "http-body",
1543 "httparse",1799 "httparse",
@@ -1823,6 +2079,12 @@ dependencies = [
1823 "libc",2079 "libc",
1824 ]2080 ]
1825 2081
2082+[[package]]
2083+name = "is_terminal_polyfill"
2084+version = "1.70.2"
2085+source = "registry+https://github.com/rust-lang/crates.io-index"
2086+checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
2087+
1826 [[package]]2088 [[package]]
1827 name = "itertools"2089 name = "itertools"
1828 version = "0.12.1"2090 version = "0.12.1"
@@ -1868,6 +2130,21 @@ dependencies = [
1868 "uuid",2130 "uuid",
1869 ]2131 ]
1870 2132
2133+[[package]]
2134+name = "izlek-topcoat"
2135+version = "0.1.0"
2136+dependencies = [
2137+ "async-trait",
2138+ "grass",
2139+ "izlek-core",
2140+ "lettre",
2141+ "serde",
2142+ "thiserror",
2143+ "time",
2144+ "tokio",
2145+ "topcoat",
2146+]
2147+
1871 [[package]]2148 [[package]]
1872 name = "izlek-web"2149 name = "izlek-web"
1873 version = "0.1.0"2150 version = "0.1.0"
@@ -1930,6 +2207,15 @@ version = "0.2.19"
1930 source = "registry+https://github.com/rust-lang/crates.io-index"2207 source = "registry+https://github.com/rust-lang/crates.io-index"
1931 checksum = "a4933f3f57a8e9d9da04db23fb153356ecaf00cbd14aee46279c33dc80925c37"2208 checksum = "a4933f3f57a8e9d9da04db23fb153356ecaf00cbd14aee46279c33dc80925c37"
1932 2209
2210+[[package]]
2211+name = "lasso"
2212+version = "0.7.3"
2213+source = "registry+https://github.com/rust-lang/crates.io-index"
2214+checksum = "6e14eda50a3494b3bf7b9ce51c52434a761e383d7238ce1dd5dcec2fbc13e9fb"
2215+dependencies = [
2216+ "hashbrown 0.14.5",
2217+]
2218+
1933 [[package]]2219 [[package]]
1934 name = "lazy_static"2220 name = "lazy_static"
1935 version = "1.5.0"2221 version = "1.5.0"
@@ -2179,6 +2465,7 @@ dependencies = [
2179 "fastrand",2465 "fastrand",
2180 "futures-io",2466 "futures-io",
2181 "futures-util",2467 "futures-util",
2468+ "hostname",
2182 "httpdate",2469 "httpdate",
2183 "idna",2470 "idna",
2184 "mime",2471 "mime",
@@ -2355,6 +2642,12 @@ version = "0.8.4"
2355 source = "registry+https://github.com/rust-lang/crates.io-index"2642 source = "registry+https://github.com/rust-lang/crates.io-index"
2356 checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3"2643 checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3"
2357 2644
2645+[[package]]
2646+name = "matchit"
2647+version = "0.9.2"
2648+source = "registry+https://github.com/rust-lang/crates.io-index"
2649+checksum = "8863b587001c1b9a8a4e36008cebc6b3612cb1226fe2de94858e06092687b608"
2650+
2358 [[package]]2651 [[package]]
2359 name = "measure_time"2652 name = "measure_time"
2360 version = "0.9.0"2653 version = "0.9.0"
@@ -2569,6 +2862,12 @@ version = "1.21.4"
2569 source = "registry+https://github.com/rust-lang/crates.io-index"2862 source = "registry+https://github.com/rust-lang/crates.io-index"
2570 checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"2863 checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
2571 2864
2865+[[package]]
2866+name = "once_cell_polyfill"
2867+version = "1.70.2"
2868+source = "registry+https://github.com/rust-lang/crates.io-index"
2869+checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
2870+
2572 [[package]]2871 [[package]]
2573 name = "oneshot"2872 name = "oneshot"
2574 version = "0.1.13"2873 version = "0.1.13"
@@ -2694,6 +2993,48 @@ dependencies = [
2694 "getrandom 0.4.3",2993 "getrandom 0.4.3",
2695 ]2994 ]
2696 2995
2996+[[package]]
2997+name = "phf"
2998+version = "0.11.3"
2999+source = "registry+https://github.com/rust-lang/crates.io-index"
3000+checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078"
3001+dependencies = [
3002+ "phf_macros",
3003+ "phf_shared",
3004+]
3005+
3006+[[package]]
3007+name = "phf_generator"
3008+version = "0.11.3"
3009+source = "registry+https://github.com/rust-lang/crates.io-index"
3010+checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d"
3011+dependencies = [
3012+ "phf_shared",
3013+ "rand 0.8.8",
3014+]
3015+
3016+[[package]]
3017+name = "phf_macros"
3018+version = "0.11.3"
3019+source = "registry+https://github.com/rust-lang/crates.io-index"
3020+checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216"
3021+dependencies = [
3022+ "phf_generator",
3023+ "phf_shared",
3024+ "proc-macro2",
3025+ "quote",
3026+ "syn 2.0.119",
3027+]
3028+
3029+[[package]]
3030+name = "phf_shared"
3031+version = "0.11.3"
3032+source = "registry+https://github.com/rust-lang/crates.io-index"
3033+checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5"
3034+dependencies = [
3035+ "siphasher",
3036+]
3037+
2697 [[package]]3038 [[package]]
2698 name = "pin-project"3039 name = "pin-project"
2699 version = "1.1.13"3040 version = "1.1.13"
@@ -2809,6 +3150,15 @@ dependencies = [
2809 "syn 3.0.4",3150 "syn 3.0.4",
2810 ]3151 ]
2811 3152
3153+[[package]]
3154+name = "proc-macro-crate"
3155+version = "3.5.0"
3156+source = "registry+https://github.com/rust-lang/crates.io-index"
3157+checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f"
3158+dependencies = [
3159+ "toml_edit",
3160+]
3161+
2812 [[package]]3162 [[package]]
2813 name = "proc-macro-error-attr2"3163 name = "proc-macro-error-attr2"
2814 version = "2.0.0"3164 version = "2.0.0"
@@ -3119,6 +3469,26 @@ dependencies = [
3119 "bitflags",3469 "bitflags",
3120 ]3470 ]
3121 3471
3472+[[package]]
3473+name = "ref-cast"
3474+version = "1.0.27"
3475+source = "registry+https://github.com/rust-lang/crates.io-index"
3476+checksum = "7e440fb4e4b4147295338efb76001ab9e4efc0e5839df2c47fc5ac2381d365c3"
3477+dependencies = [
3478+ "ref-cast-impl",
3479+]
3480+
3481+[[package]]
3482+name = "ref-cast-impl"
3483+version = "1.0.27"
3484+source = "registry+https://github.com/rust-lang/crates.io-index"
3485+checksum = "92ecd8964f8453721699a1ed72037b0db49ce2f5a5138486ee89bed6f67cdf3a"
3486+dependencies = [
3487+ "proc-macro2",
3488+ "quote",
3489+ "syn 3.0.4",
3490+]
3491+
3122 [[package]]3492 [[package]]
3123 name = "regex"3493 name = "regex"
3124 version = "1.13.1"3494 version = "1.13.1"
@@ -4093,6 +4463,7 @@ dependencies = [
4093 "bytes",4463 "bytes",
4094 "futures-core",4464 "futures-core",
4095 "futures-sink",4465 "futures-sink",
4466+ "libc",
4096 "pin-project-lite",4467 "pin-project-lite",
4097 "tokio",4468 "tokio",
4098 ]4469 ]
@@ -4121,6 +4492,18 @@ dependencies = [
4121 "serde_core",4492 "serde_core",
4122 ]4493 ]
4123 4494
4495+[[package]]
4496+name = "toml_edit"
4497+version = "0.25.13+spec-1.1.0"
4498+source = "registry+https://github.com/rust-lang/crates.io-index"
4499+checksum = "6975367e4d2ef766d86af01ffad14b622fecc8d4357a998fbc4deb6e9bacaf9b"
4500+dependencies = [
4501+ "indexmap",
4502+ "toml_datetime",
4503+ "toml_parser",
4504+ "winnow",
4505+]
4506+
4124 [[package]]4507 [[package]]
4125 name = "toml_parser"4508 name = "toml_parser"
4126 version = "1.1.3+spec-1.1.0"4509 version = "1.1.3+spec-1.1.0"
@@ -4136,6 +4519,319 @@ version = "1.1.2+spec-1.1.0"
4136 source = "registry+https://github.com/rust-lang/crates.io-index"4519 source = "registry+https://github.com/rust-lang/crates.io-index"
4137 checksum = "7d56353a2a665ad0f41a421187180aab746c8c325620617ad883a99a1cbe66d2"4520 checksum = "7d56353a2a665ad0f41a421187180aab746c8c325620617ad883a99a1cbe66d2"
4138 4521
4522+[[package]]
4523+name = "topcoat"
4524+version = "0.6.2"
4525+source = "registry+https://github.com/rust-lang/crates.io-index"
4526+checksum = "050c11e7b0e146a2b1eb15855abd5fa03e2754eb880922f8b6cab5ec71cac5aa"
4527+dependencies = [
4528+ "futures-util",
4529+ "inventory",
4530+ "serde",
4531+ "serde_urlencoded",
4532+ "tokio",
4533+ "tokio-tungstenite",
4534+ "topcoat-asset",
4535+ "topcoat-cookie",
4536+ "topcoat-core",
4537+ "topcoat-core-macro",
4538+ "topcoat-font",
4539+ "topcoat-font-macro",
4540+ "topcoat-mail",
4541+ "topcoat-router",
4542+ "topcoat-router-macro",
4543+ "topcoat-runtime",
4544+ "topcoat-runtime-macro",
4545+ "topcoat-session",
4546+ "topcoat-view",
4547+ "topcoat-view-macro",
4548+]
4549+
4550+[[package]]
4551+name = "topcoat-asset"
4552+version = "0.6.2"
4553+source = "registry+https://github.com/rust-lang/crates.io-index"
4554+checksum = "a72e4ba8cb6a9d29613a25c2151e72d887b4a79b3f179b497734eed0e65ea702"
4555+dependencies = [
4556+ "http",
4557+ "memchr",
4558+ "serde",
4559+ "sha2 0.11.0",
4560+ "thiserror",
4561+ "tokio",
4562+ "toml",
4563+ "topcoat-core",
4564+ "topcoat-router",
4565+ "topcoat-view",
4566+]
4567+
4568+[[package]]
4569+name = "topcoat-cookie"
4570+version = "0.6.2"
4571+source = "registry+https://github.com/rust-lang/crates.io-index"
4572+checksum = "f68c83654c4bf075f667d39463cd38ef0be9fee057054454b06612efe16e7a37"
4573+dependencies = [
4574+ "cookie",
4575+ "getrandom 0.2.17",
4576+ "http",
4577+ "serde",
4578+ "serde_json",
4579+ "topcoat-core",
4580+ "topcoat-router",
4581+]
4582+
4583+[[package]]
4584+name = "topcoat-core"
4585+version = "0.6.2"
4586+source = "registry+https://github.com/rust-lang/crates.io-index"
4587+checksum = "42f94adaa301d7a4b949d650fa803323c00cc8ffa8bf1984511c1ec5d390b6c6"
4588+dependencies = [
4589+ "anyhow",
4590+ "anymap3",
4591+ "elsa",
4592+ "http",
4593+ "pin-project-lite",
4594+ "siphasher",
4595+ "thiserror",
4596+ "tokio",
4597+]
4598+
4599+[[package]]
4600+name = "topcoat-core-grammar"
4601+version = "0.6.2"
4602+source = "registry+https://github.com/rust-lang/crates.io-index"
4603+checksum = "0756aa9285794c155624494bc563d56859e35205313db883a89d7dabfa6d0393"
4604+dependencies = [
4605+ "proc-macro-crate",
4606+ "proc-macro2",
4607+ "quote",
4608+ "syn 2.0.119",
4609+]
4610+
4611+[[package]]
4612+name = "topcoat-core-macro"
4613+version = "0.6.2"
4614+source = "registry+https://github.com/rust-lang/crates.io-index"
4615+checksum = "e4908dba6268c8592be73e9059cdefa053066e1b1bc879c1c9a5d8d3b6e97aad"
4616+dependencies = [
4617+ "quote",
4618+ "syn 2.0.119",
4619+ "topcoat-core-grammar",
4620+]
4621+
4622+[[package]]
4623+name = "topcoat-font"
4624+version = "0.6.2"
4625+source = "registry+https://github.com/rust-lang/crates.io-index"
4626+checksum = "e7b8308aff65f46bbe2f58371fc9823db596236bd0ea3c9d87de6534fd977e60"
4627+dependencies = [
4628+ "heck",
4629+ "inventory",
4630+ "serde",
4631+ "serde_json",
4632+ "topcoat-asset",
4633+ "topcoat-core",
4634+ "topcoat-router",
4635+ "topcoat-view",
4636+ "topcoat-view-macro",
4637+]
4638+
4639+[[package]]
4640+name = "topcoat-font-grammar"
4641+version = "0.6.2"
4642+source = "registry+https://github.com/rust-lang/crates.io-index"
4643+checksum = "5b7d68e226827fb7531d0dba69cb74fa7b82515f8428fd1a75f556f5a2bf87c1"
4644+dependencies = [
4645+ "proc-macro2",
4646+ "quote",
4647+ "syn 2.0.119",
4648+ "topcoat-core-grammar",
4649+ "topcoat-font",
4650+]
4651+
4652+[[package]]
4653+name = "topcoat-font-macro"
4654+version = "0.6.2"
4655+source = "registry+https://github.com/rust-lang/crates.io-index"
4656+checksum = "e655c430bcb380f879603ea750c6222ade2ff3ade33869d9eaa32e3fc49f5469"
4657+dependencies = [
4658+ "quote",
4659+ "syn 2.0.119",
4660+ "topcoat-font-grammar",
4661+]
4662+
4663+[[package]]
4664+name = "topcoat-mail"
4665+version = "0.6.2"
4666+source = "registry+https://github.com/rust-lang/crates.io-index"
4667+checksum = "959c9c32172ad3840f94c589a29bd143c072661c9abf2215a68fd76440ed2300"
4668+dependencies = [
4669+ "lettre",
4670+ "thiserror",
4671+ "time",
4672+ "topcoat-core",
4673+ "topcoat-router",
4674+ "topcoat-view",
4675+]
4676+
4677+[[package]]
4678+name = "topcoat-router"
4679+version = "0.6.2"
4680+source = "registry+https://github.com/rust-lang/crates.io-index"
4681+checksum = "e062bd348df5647f6904f4f4045b3c92c08c4a8826196e8e91a51aade00b5764"
4682+dependencies = [
4683+ "bytes",
4684+ "form_urlencoded",
4685+ "futures-core",
4686+ "futures-util",
4687+ "heck",
4688+ "http",
4689+ "http-body",
4690+ "http-body-util",
4691+ "hyper",
4692+ "hyper-util",
4693+ "inventory",
4694+ "matchit 0.9.2",
4695+ "multer",
4696+ "percent-encoding",
4697+ "ref-cast",
4698+ "serde",
4699+ "serde_json",
4700+ "serde_path_to_error",
4701+ "serde_urlencoded",
4702+ "tokio",
4703+ "topcoat-core",
4704+ "topcoat-view",
4705+ "tower",
4706+ "tower-http 0.7.0",
4707+]
4708+
4709+[[package]]
4710+name = "topcoat-router-grammar"
4711+version = "0.6.2"
4712+source = "registry+https://github.com/rust-lang/crates.io-index"
4713+checksum = "c052423d2aa4039036f1ac5567d1e2dac48897602d34561b3024a87830e5bdce"
4714+dependencies = [
4715+ "heck",
4716+ "proc-macro2",
4717+ "quote",
4718+ "syn 2.0.119",
4719+ "topcoat-core-grammar",
4720+]
4721+
4722+[[package]]
4723+name = "topcoat-router-macro"
4724+version = "0.6.2"
4725+source = "registry+https://github.com/rust-lang/crates.io-index"
4726+checksum = "cea98692b786bab3adda35a60d71981f60b2a98c6e7105ac92e582b7c9ce9cab"
4727+dependencies = [
4728+ "quote",
4729+ "syn 2.0.119",
4730+ "topcoat-router-grammar",
4731+]
4732+
4733+[[package]]
4734+name = "topcoat-runtime"
4735+version = "0.6.2"
4736+source = "registry+https://github.com/rust-lang/crates.io-index"
4737+checksum = "5dea200c86ca554bab7410f09cae8790a8adcbfd8f306eb78db7092ca71f8aae"
4738+dependencies = [
4739+ "inventory",
4740+ "ref-cast",
4741+ "serde",
4742+ "serde_json",
4743+ "topcoat-asset",
4744+ "topcoat-core",
4745+ "topcoat-router",
4746+ "topcoat-view",
4747+ "uuid",
4748+]
4749+
4750+[[package]]
4751+name = "topcoat-runtime-grammar"
4752+version = "0.6.2"
4753+source = "registry+https://github.com/rust-lang/crates.io-index"
4754+checksum = "87b73f7e4e10f49e006a71dd43e8ee629c76c08451acbc51faa7ec5b6952c53c"
4755+dependencies = [
4756+ "proc-macro2",
4757+ "quote",
4758+ "serde",
4759+ "serde_json",
4760+ "syn 2.0.119",
4761+ "topcoat-core-grammar",
4762+ "topcoat-runtime",
4763+ "uuid",
4764+]
4765+
4766+[[package]]
4767+name = "topcoat-runtime-macro"
4768+version = "0.6.2"
4769+source = "registry+https://github.com/rust-lang/crates.io-index"
4770+checksum = "5dc3e4e245abcaea6af780437cae072e8f2157c9852ec5b3058a658c61b9e0bf"
4771+dependencies = [
4772+ "quote",
4773+ "syn 2.0.119",
4774+ "topcoat-runtime-grammar",
4775+]
4776+
4777+[[package]]
4778+name = "topcoat-session"
4779+version = "0.6.2"
4780+source = "registry+https://github.com/rust-lang/crates.io-index"
4781+checksum = "e079e8c5a63987d7f929ab05a75922feab1fe390a9cfa2c101eb35829e67eac2"
4782+dependencies = [
4783+ "base64 0.22.1",
4784+ "getrandom 0.4.3",
4785+ "sha2 0.11.0",
4786+ "thiserror",
4787+ "tokio",
4788+ "topcoat-cookie",
4789+ "topcoat-core",
4790+ "topcoat-router",
4791+ "web-time",
4792+]
4793+
4794+[[package]]
4795+name = "topcoat-view"
4796+version = "0.6.2"
4797+source = "registry+https://github.com/rust-lang/crates.io-index"
4798+checksum = "5904449bd6f633759d187fa621ded68178b551428c297959fd53d8fb91f3e6f6"
4799+dependencies = [
4800+ "futures-core",
4801+ "futures-util",
4802+ "http",
4803+ "itoa",
4804+ "memchr",
4805+ "pin-project-lite",
4806+ "smallvec",
4807+ "topcoat-core",
4808+]
4809+
4810+[[package]]
4811+name = "topcoat-view-grammar"
4812+version = "0.6.2"
4813+source = "registry+https://github.com/rust-lang/crates.io-index"
4814+checksum = "1bf4293156d7c5fa7960edc573b686eb27426dcd888bfbe9e532304178cdda24"
4815+dependencies = [
4816+ "heck",
4817+ "proc-macro2",
4818+ "quote",
4819+ "syn 2.0.119",
4820+ "topcoat-core-grammar",
4821+ "topcoat-view",
4822+]
4823+
4824+[[package]]
4825+name = "topcoat-view-macro"
4826+version = "0.6.2"
4827+source = "registry+https://github.com/rust-lang/crates.io-index"
4828+checksum = "58ab2b200eda4516abdb543f307006d83fedd3681b871d2042c17106c688f716"
4829+dependencies = [
4830+ "quote",
4831+ "syn 2.0.119",
4832+ "topcoat-view-grammar",
4833+]
4834+
4139 [[package]]4835 [[package]]
4140 name = "tower"4836 name = "tower"
4141 version = "0.5.3"4837 version = "0.5.3"
@@ -4652,6 +5348,12 @@ version = "1.0.4"
4652 source = "registry+https://github.com/rust-lang/crates.io-index"5348 source = "registry+https://github.com/rust-lang/crates.io-index"
4653 checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"5349 checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
4654 5350
5351+[[package]]
5352+name = "utf8parse"
5353+version = "0.2.2"
5354+source = "registry+https://github.com/rust-lang/crates.io-index"
5355+checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
5356+
4655 [[package]]5357 [[package]]
4656 name = "uuid"5358 name = "uuid"
4657 version = "1.25.0"5359 version = "1.25.0"
@@ -4802,6 +5504,16 @@ dependencies = [
4802 "wasm-bindgen",5504 "wasm-bindgen",
4803 ]5505 ]
4804 5506
5507+[[package]]
5508+name = "web-time"
5509+version = "1.1.0"
5510+source = "registry+https://github.com/rust-lang/crates.io-index"
5511+checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb"
5512+dependencies = [
5513+ "js-sys",
5514+ "wasm-bindgen",
5515+]
5516+
4805 [[package]]5517 [[package]]
4806 name = "webpki-roots"5518 name = "webpki-roots"
4807 version = "1.0.9"5519 version = "1.0.9"
Cargo.tomlmodified+1 -1
@@ -1,6 +1,6 @@
1 [workspace]1 [workspace]
2 resolver = "3"2 resolver = "3"
3-members = ["crates/izlek-core", "crates/izlek-web"]3+members = ["crates/izlek-core", "crates/izlek-web", "crates/izlek-topcoat"]
4 4
5 [workspace.package]5 [workspace.package]
6 version = "0.1.0"6 version = "0.1.0"
crates/izlek-topcoat/Cargo.tomladded+39 -0
@@ -0,0 +1,39 @@
1+[package]
2+name = "izlek-topcoat"
3+version.workspace = true
4+edition.workspace = true
5+license.workspace = true
6+repository.workspace = true
7+description = "Izlek web app: topcoat UI, routes and the server"
8+
9+[dependencies]
10+topcoat = { version = "0.6.2", default-features = false, features = [
11+ "router",
12+ "view",
13+ "runtime",
14+ "asset",
15+ "cookie",
16+ "discover",
17+ "serve",
18+ "compression",
19+ "multipart",
20+] }
21+izlek-core = { workspace = true, features = ["server"] }
22+serde.workspace = true
23+time.workspace = true
24+thiserror.workspace = true
25+tokio = { workspace = true }
26+async-trait = "0.1.92"
27+# TLS through rustls with the ring provider: no OpenSSL on the deployment box,
28+# and no system certificate store to be missing inside a container.
29+lettre = { version = "0.11.23", default-features = false, features = [
30+ "smtp-transport",
31+ "builder",
32+ "tokio1-rustls",
33+ "ring",
34+ "webpki-roots",
35+ "pool",
36+] }
37+
38+[build-dependencies]
39+grass = "0.13"
crates/izlek-topcoat/build.rsadded+18 -0
@@ -0,0 +1,18 @@
1+//! Compiles `style/main.scss` to `assets/main.css` under this crate's
2+//! manifest directory, where `asset!("assets/main.css")` in `layout.rs`
3+//! expects to find it. Crate-relative rather than `OUT_DIR`-relative so the
4+//! asset's id does not churn with every profile/build-hash (see the topcoat
5+//! contract sheet, (a)).
6+
7+fn main() {
8+ let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
9+ let scss = format!("{manifest_dir}/../../style/main.scss");
10+ println!("cargo:rerun-if-changed={scss}");
11+
12+ let css = grass::from_path(&scss, &grass::Options::default())
13+ .unwrap_or_else(|err| panic!("failed to compile {scss}: {err}"));
14+
15+ let out_dir = format!("{manifest_dir}/assets");
16+ std::fs::create_dir_all(&out_dir).expect("failed to create assets/");
17+ std::fs::write(format!("{out_dir}/main.css"), css).expect("failed to write assets/main.css");
18+}
crates/izlek-topcoat/src/layout.rsadded+65 -0
@@ -0,0 +1,65 @@
1+//! The document shell every page renders inside, ported from
2+//! `izlek-web/src/app.rs`'s `shell`/`App`/`NotFound`.
3+
4+use topcoat::{
5+ Result,
6+ asset::{Asset, asset},
7+ router::{
8+ StatusCode, layout, page,
9+ error::{NotFoundError, not_found},
10+ },
11+ view::view,
12+};
13+
14+/// Placeholder landing page — the real board view lands in a later slice.
15+#[page("/")]
16+async fn landing() -> Result {
17+ view! { <main class="scaffold-note"><p>"Izlek"</p></main> }
18+}
19+
20+/// Every path that matches no page raises a `NotFoundError`, so it renders
21+/// through `root_layout`'s catch below rather than the router's bare default.
22+/// `/` itself is served by `landing` above and never reaches this route.
23+#[page("/{*path}")]
24+async fn missing() -> Result {
25+ Err(not_found().into())
26+}
27+
28+/// `style/main.scss`, compiled by `build.rs` into `assets/main.css`.
29+const STYLE: Asset = asset!("assets/main.css");
30+
31+#[layout("/")]
32+async fn root_layout(slot: Result) -> Result {
33+ let content = match slot {
34+ Err(error) if error.downcast_ref::<NotFoundError>().is_some() => view! {
35+ (StatusCode::NOT_FOUND)
36+ <main class="scaffold-note">
37+ <p>"Nothing at this address."</p>
38+ </main>
39+ },
40+ content => content,
41+ }?;
42+
43+ view! {
44+ <!DOCTYPE html>
45+ <html lang="en">
46+ <head>
47+ <meta charset="utf-8">
48+ <meta name="viewport" content="width=device-width, initial-scale=1">
49+ <link rel="preconnect" href="https://fonts.googleapis.com">
50+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin="">
51+ <link
52+ rel="stylesheet"
53+ href="https://fonts.googleapis.com/css2?family=Schibsted+Grotesk:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap"
54+ >
55+ <title>"Izlek"</title>
56+ <link rel="stylesheet" href=(STYLE)>
57+ topcoat::runtime::script()
58+ topcoat::dev::script()
59+ </head>
60+ <body>
61+ (content)
62+ </body>
63+ </html>
64+ }
65+}
crates/izlek-topcoat/src/lib.rsadded+7 -0
@@ -0,0 +1,7 @@
1+// topcoat's `view!` nests as deeply as leptos's did for the same pages, so
2+// the raised limit carries over from day one rather than waiting for the
3+// first overflow.
4+#![recursion_limit = "256"]
5+
6+pub mod layout;
7+pub mod smtp;
crates/izlek-topcoat/src/main.rsadded+93 -0
@@ -0,0 +1,93 @@
1+use izlek_core::accounts::Accounts;
2+use izlek_core::store::TursoStore;
3+use std::sync::Arc;
4+use topcoat::Result;
5+use topcoat::asset::{AssetBundle, RouterBuilderAssetExt};
6+use topcoat::cookie::RouterBuilderCookieExt;
7+use topcoat::router::{Router, RouterBuilderDiscoverExt, route};
8+
9+#[route(GET "/healthz")]
10+async fn healthz() -> Result<&'static str> {
11+ Ok("ok")
12+}
13+
14+#[tokio::main]
15+async fn main() {
16+ // config/izlek.toml is read here, before anything is opened, and written with
17+ // development defaults if it is not there yet. A broken key stops the
18+ // boot with its name in the message: the failure this prevents is not an
19+ // empty database, it is a second Izlek writing a different file while
20+ // everyone believes they share a board.
21+ let config = match izlek_core::Config::load() {
22+ Ok(config) => config,
23+ Err(problem) => {
24+ eprintln!("izlek: {problem}");
25+ std::process::exit(2);
26+ }
27+ };
28+ // Said once, so the answer to "which file are we on" lives in the log.
29+ for line in config.report() {
30+ println!("izlek {line}");
31+ }
32+
33+ // One process per database file: Turso is a single-writer engine and a
34+ // second process on the same file loses writes rather than queueing.
35+ //
36+ // `open` applies any unapplied migration before it returns.
37+ let store = TursoStore::open(&config.database.to_string_lossy())
38+ .await
39+ .expect("failed to open the database");
40+ let store: Arc<dyn izlek_core::store::Store> = Arc::new(store);
41+ let accounts = Accounts::new(store.clone(), config.base_url.clone());
42+
43+ // The engine is always built, because a sender can appear at any moment:
44+ // an admin fills the panel in and the next sweep sends what was held. It
45+ // holds one connection pool, rebuilt only when the settings behind it
46+ // change, and two things use it — every committed crossing, and the sweep.
47+ let engine = Arc::new(izlek_core::MailEngine::new(
48+ store.clone(),
49+ Arc::new(izlek_topcoat::smtp::WorkspaceSmtp::new(store.clone())),
50+ config.base_url.clone(),
51+ ));
52+ tokio::spawn(sweep(engine.clone()));
53+
54+ let router = Router::builder()
55+ .discover()
56+ .cookies()
57+ .assets(AssetBundle::load().expect("failed to load the asset bundle"))
58+ .app_context(accounts)
59+ .app_context(engine)
60+ .build();
61+
62+ topcoat::start(router).await.expect("server error");
63+}
64+
65+/// Retries what a mail server refused earlier and picks up anything a crash
66+/// left claimed but unsent.
67+///
68+/// A minute is short enough that the first retry of a host that blinked lands
69+/// while somebody is still looking at the board, and long enough that a host
70+/// which is properly down is not hammered — the wait per send widens on its
71+/// own, and a send that has used its attempts is written off rather than
72+/// carried forever.
73+async fn sweep(engine: std::sync::Arc<izlek_core::MailEngine>) {
74+ /// Enough that a morning's backlog clears in a few passes, few enough that
75+ /// one pass cannot sit on the mail server for minutes.
76+ const PER_PASS: u32 = 50;
77+
78+ let mut every_minute = tokio::time::interval(std::time::Duration::from_secs(60));
79+ loop {
80+ every_minute.tick().await;
81+ match engine
82+ .deliver_owed(time::OffsetDateTime::now_utc(), PER_PASS)
83+ .await
84+ {
85+ Ok(report) if report.sent + report.failed + report.abandoned > 0 => println!(
86+ "izlek mail sweep: {} sent, {} to retry, {} given up on",
87+ report.sent, report.failed, report.abandoned
88+ ),
89+ Ok(_) => {}
90+ Err(problem) => eprintln!("izlek mail sweep could not read the ledger: {problem}"),
91+ }
92+ }
93+}
crates/izlek-topcoat/src/smtp.rsadded+203 -0
@@ -0,0 +1,203 @@
1+//! The `Mailer` the engine talks to when the mail is real.
2+//!
3+//! Everything about SMTP stops here. The engine knows a send was accepted or
4+//! refused, and whether the refusal is worth trying again; it does not know
5+//! what a 550 is. Keeping the protocol in one file is also what makes the
6+//! engine testable — the tests hand it a mailer that remembers instead of
7+//! connecting.
8+//!
9+//! The credentials come from the workspace's own settings, written by an admin
10+//! on the Settings screen. They are never in a literal in here, and the
11+//! password is not in anything this module logs or puts in an error message: a
12+//! refusal that quoted the password would put it in the ledger, where an admin
13+//! screen would later print it.
14+//!
15+//! Because the sender is editable while the process runs, the transport cannot
16+//! be built once at boot. [`WorkspaceSmtp`] holds the last one it built and the
17+//! settings it was built from; a send whose settings still match reuses the
18+//! connection pool, and a send after an edit builds a new one and drops the old.
19+
20+use std::sync::Arc;
21+
22+use izlek_core::store::Store;
23+use izlek_core::mail::{MailError, Mailer, Outgoing};
24+use lettre::message::header::ContentType;
25+use lettre::transport::smtp::authentication::Credentials;
26+use lettre::{AsyncSmtpTransport, AsyncTransport, Message, Tokio1Executor};
27+
28+/// The sender as the mailer needs it: what the admin typed, password included.
29+/// It exists only inside this module and inside the store; nothing that can
30+/// reach a response body holds one.
31+#[derive(Clone, PartialEq, Eq)]
32+pub struct Sending {
33+ pub host: String,
34+ pub port: u16,
35+ pub username: String,
36+ pub password: String,
37+ /// `Name <address>` if a name was given, the bare address otherwise.
38+ pub from: String,
39+}
40+
41+/// A sender holding one connection pool.
42+pub struct Smtp {
43+ transport: AsyncSmtpTransport<Tokio1Executor>,
44+ from: String,
45+}
46+
47+impl Smtp {
48+ /// Builds the transport. Fails only on a host name TLS cannot be set up
49+ /// against — a server that is merely unreachable is discovered per send,
50+ /// as a retryable refusal, which is the honest place for it.
51+ pub fn new(mail: &Sending) -> Result<Self, String> {
52+ // 465 is submissions, where TLS is up before the greeting. Everything
53+ // else — 587 above all — is submission, where the session starts in
54+ // the clear and is upgraded. Both are encrypted before the password
55+ // moves; a plaintext session is not among the options.
56+ let builder = if mail.port == 465 {
57+ AsyncSmtpTransport::<Tokio1Executor>::relay(&mail.host)
58+ } else {
59+ AsyncSmtpTransport::<Tokio1Executor>::starttls_relay(&mail.host)
60+ }
61+ .map_err(|problem| format!("{} cannot be reached over TLS: {problem}", mail.host))?;
62+
63+ Ok(Self {
64+ transport: builder
65+ .port(mail.port)
66+ .credentials(Credentials::new(
67+ mail.username.clone(),
68+ mail.password.clone(),
69+ ))
70+ .build(),
71+ from: mail.from.clone(),
72+ })
73+ }
74+}
75+
76+#[async_trait::async_trait]
77+impl Mailer for Smtp {
78+ async fn send(&self, mail: &Outgoing) -> Result<(), MailError> {
79+ let built =
80+ Message::builder()
81+ .from(self.from.parse().map_err(|_| {
82+ MailError::permanent(format!("{} is not an address", self.from))
83+ })?)
84+ .to(mail
85+ .to
86+ .parse()
87+ .map_err(|_| MailError::permanent(format!("{} is not an address", mail.to)))?)
88+ .subject(&mail.subject)
89+ .header(ContentType::TEXT_PLAIN)
90+ .body(mail.body.clone())
91+ .map_err(|problem| MailError::permanent(problem.to_string()))?;
92+
93+ self.transport
94+ .send(built)
95+ .await
96+ .map(|_| ())
97+ .map_err(|problem| {
98+ let said = problem.to_string();
99+ // A permanent SMTP code is the server saying the address will not
100+ // work today or tomorrow — a mailbox that does not exist, a domain
101+ // that does not accept us. Everything else, a timeout above all,
102+ // is worth another attempt: the alternative is losing a mail
103+ // because a host restarted at the wrong moment.
104+ if problem.is_permanent() {
105+ MailError::permanent(said)
106+ } else {
107+ MailError::retryable(said)
108+ }
109+ })
110+ }
111+}
112+
113+/// The mailer the engine actually holds: it reads the workspace's sender at
114+/// send time, so an admin who fixes a typo in the host does not have to restart
115+/// anything for the next mail to go out.
116+pub struct WorkspaceSmtp {
117+ store: Arc<dyn Store>,
118+ /// The live transport and the settings it was built from. Rebuilt only when
119+ /// those settings change — building one per send would throw away the
120+ /// connection pool that makes a backlog drain quickly.
121+ current: tokio::sync::Mutex<Option<(Sending, Arc<Smtp>)>>,
122+}
123+
124+impl WorkspaceSmtp {
125+ pub fn new(store: Arc<dyn Store>) -> Self {
126+ Self {
127+ store,
128+ current: tokio::sync::Mutex::new(None),
129+ }
130+ }
131+
132+ /// The sender as it stands right now, or `None` while the panel is empty.
133+ ///
134+ /// A half-filled sender counts as none. The screen will not save one, but
135+ /// the check is here too, because this is the side that would otherwise
136+ /// hand lettre an empty host and turn a missing setting into a stack of
137+ /// refusals in the ledger.
138+ async fn sending(&self) -> Result<Option<Sending>, MailError> {
139+ let store = &self.store;
140+ let workspace = store
141+ .workspace()
142+ .await
143+ .map_err(|e| MailError::retryable(e.to_string()))?;
144+ let Some(ws) = workspace else {
145+ return Ok(None);
146+ };
147+ let (Some(host), Some(port), Some(username), Some(address)) = (
148+ ws.smtp_host.clone(),
149+ ws.smtp_port,
150+ ws.smtp_username.clone(),
151+ ws.smtp_from_address.clone(),
152+ ) else {
153+ return Ok(None);
154+ };
155+ let password = store
156+ .smtp_password(&ws.id)
157+ .await
158+ .map_err(|e| MailError::retryable(e.to_string()))?;
159+ let (Some(password), Ok(port)) = (password, u16::try_from(port)) else {
160+ return Ok(None);
161+ };
162+ if host.trim().is_empty() || username.trim().is_empty() || password.is_empty() {
163+ return Ok(None);
164+ }
165+ let from = match ws.smtp_from_name.as_deref().map(str::trim) {
166+ Some(name) if !name.is_empty() => format!("{name} <{address}>"),
167+ _ => address,
168+ };
169+ Ok(Some(Sending {
170+ host,
171+ port,
172+ username,
173+ password,
174+ from,
175+ }))
176+ }
177+
178+ /// The transport for the current settings, building a new one only when
179+ /// they have changed since the last send.
180+ async fn transport(&self, want: &Sending) -> Result<Arc<Smtp>, MailError> {
181+ let mut current = self.current.lock().await;
182+ if let Some((held, smtp)) = current.as_ref()
183+ && held == want
184+ {
185+ return Ok(smtp.clone());
186+ }
187+ let built = Arc::new(Smtp::new(want).map_err(MailError::retryable)?);
188+ *current = Some((want.clone(), built.clone()));
189+ Ok(built)
190+ }
191+}
192+
193+#[async_trait::async_trait]
194+impl Mailer for WorkspaceSmtp {
195+ async fn send(&self, mail: &Outgoing) -> Result<(), MailError> {
196+ let Some(want) = self.sending().await? else {
197+ // Not a failure, and pointedly not an attempt: the mail is owed
198+ // until somebody fills the sender in.
199+ return Err(MailError::unsent("no sender configured"));
200+ };
201+ self.transport(&want).await?.send(mail).await
202+ }
203+}