2 * coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
3 * Understanding is not required. Only obedience.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3 of the License ONLY.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 // this rebuilds FTS5 tables in SQLite supplementary mail database.
18 module zsq_rebuild_support
is aliced
;
30 // ////////////////////////////////////////////////////////////////////////// //
31 void main (string
[] args
) {
32 ChiroTimerEnabled
= true;
33 chiroParseCommonCLIArgs(args
);
35 // here, i don't have any threads at all
36 if (sqlite3_config(SQLITE_CONFIG_SINGLETHREAD
) != SQLITE_OK
) throw new Exception("cannot switch SQLite to multi-threaded mode");
38 writeln("opening message support db...");
41 if (args
.length
< 2) {
44 foreach (auto row
; dbView
.statement(`SELECT MAX(uid) AS uid FROM info;`).range
) uid
= row
.uid
!uint;
45 args
~= uid
.to
!string
;
47 //import std.conv : to;
48 //uid = argv[1].to!uint;
51 auto stSelEmailInfo
= dbView
.persistentStatement(`
54 , from_name AS fromName
55 , from_mail AS fromMail
59 , datetime(threads.time, 'unixepoch') AS time
60 , ChiroUnpack(content_text.content) AS text
61 , ChiroUnpack(content_html.content) AS html
63 INNER JOIN threads USING(uid)
64 INNER JOIN content_text USING(uid)
65 INNER JOIN content_html USING(uid)
70 auto stSelEmailTags
= dbView
.persistentStatement(`
72 DISTINCT(threads.tagid) AS tagid
73 , tagnames.tag AS tagname
77 WHERE threads.uid=:uid
80 foreach (string uidstr
; args
[1..$]) {
86 writeln("INVALID UID: ", uidstr
);
89 foreach (auto mrow
; stSelEmailInfo
.bind(":uid", uid
).range
) {
90 writeln("================ UID: ", uid
, " ================");
91 writeln("From: ", mrow
.fromName
!SQ3Text
.recodeToKOI8
, " <", mrow
.fromMail
!SQ3Text
.recodeToKOI8
, ">");
92 writeln(" To: ", mrow
.toName
!SQ3Text
.recodeToKOI8
, " <", mrow
.toMail
!SQ3Text
.recodeToKOI8
, ">");
93 writeln("Subj: ", mrow
.subj
!SQ3Text
.recodeToKOI8
);
94 writeln("Date: ", mrow
.time
!SQ3Text
);
98 foreach (auto trow
; stSelEmailTags
.bind(":uid", uid
).range
) {
99 if (wasTag
) write(","); else wasTag
= true;
100 write(" ", trow
.tagname
!SQ3Text
);
104 if (mrow
.text
!SQ3Text
.length
) {
105 writeln("----------------------------------------------- (text)");
106 writeln(mrow
.text
!SQ3Text
.recodeToKOI8
);
109 if (mrow
.html
!SQ3Text
.length
) {
110 writeln("----------------------------------------------- (html)");
111 writeln(mrow
.html
!SQ3Text
.recodeToKOI8
);