1 parent
ecc201ef50
commit
698e3c4a1b
124 files changed
+4593
-2721
No files matched your search
@@ -11,7 +11,7 @@ pub mod db_calendar {
|
||||
working_hours_end, time_format, zoom_link, teams_link, meet_link, caldav_url, \
|
||||
caldav_username, caldav_enabled, updated_at";
|
||||
|
||||
pub const Q_001: &str = "SELECT CURRENT_TIMESTAMP";
|
||||
pub const Q_001: &str = "SELECT CAST(CURRENT_TIMESTAMP AS CHAR)";
|
||||
pub const Q_002: &str = "INSERT INTO calendar_events
|
||||
(id, title, description, location, start_time, end_time, all_day,
|
||||
recurrence_rule, attendees, organizer, status, source, source_uid,
|
||||
@@ -45,7 +45,7 @@ pub mod db_calendar {
|
||||
pub mod db_contact_groups {
|
||||
pub const Q_001: &str = "INSERT INTO contact_groups (id, name) VALUES (?, ?)";
|
||||
pub const Q_002: &str = "SELECT g.id, g.name, g.created_at, g.updated_at,
|
||||
(SELECT COUNT(*) FROM contact_group_members m WHERE m.group_id = g.id) AS member_count
|
||||
(SELECT CAST(COUNT(*) AS SIGNED) FROM contact_group_members m WHERE m.group_id = g.id) AS member_count
|
||||
FROM contact_groups g
|
||||
ORDER BY g.name ASC";
|
||||
pub const Q_003: &str =
|
||||
@@ -62,7 +62,7 @@ pub mod db_contact_groups {
|
||||
WHERE m.group_id = ?
|
||||
ORDER BY c.name ASC";
|
||||
pub const Q_008: &str = "SELECT g.id, g.name, g.created_at, g.updated_at,
|
||||
(SELECT COUNT(*) FROM contact_group_members m2 WHERE m2.group_id = g.id) AS member_count
|
||||
(SELECT CAST(COUNT(*) AS SIGNED) FROM contact_group_members m2 WHERE m2.group_id = g.id) AS member_count
|
||||
FROM contact_groups g
|
||||
JOIN contact_group_members m ON m.group_id = g.id
|
||||
WHERE m.contact_id = ?
|
||||
@@ -75,29 +75,30 @@ pub mod db_contacts {
|
||||
(id, email, name, company, notes, phone, job_title, address, website, birthday, is_favorite, last_contacted,
|
||||
contact_count, source, created_at, updated_at, emails_json, phones_json, addresses_json)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
ON CONFLICT(id) DO UPDATE SET
|
||||
email=excluded.email, name=excluded.name, company=excluded.company, notes=excluded.notes,
|
||||
phone=excluded.phone, job_title=excluded.job_title, address=excluded.address, website=excluded.website, birthday=excluded.birthday,
|
||||
is_favorite=excluded.is_favorite, last_contacted=excluded.last_contacted, contact_count=excluded.contact_count,
|
||||
source=excluded.source, updated_at=excluded.updated_at, emails_json=excluded.emails_json,
|
||||
phones_json=excluded.phones_json, addresses_json=excluded.addresses_json";
|
||||
ON DUPLICATE KEY UPDATE
|
||||
email=VALUES(email), name=VALUES(name), company=VALUES(company), notes=VALUES(notes),
|
||||
phone=VALUES(phone), job_title=VALUES(job_title), address=VALUES(address), website=VALUES(website), birthday=VALUES(birthday),
|
||||
is_favorite=VALUES(is_favorite), last_contacted=VALUES(last_contacted), contact_count=VALUES(contact_count),
|
||||
source=VALUES(source), updated_at=VALUES(updated_at), emails_json=VALUES(emails_json),
|
||||
phones_json=VALUES(phones_json), addresses_json=VALUES(addresses_json)";
|
||||
pub const Q_002: &str = "DELETE FROM contacts WHERE id = ?";
|
||||
pub const Q_003: &str = r#"
|
||||
SELECT email, name
|
||||
FROM known_addresses
|
||||
WHERE (email LIKE ? ESCAPE '\' OR name LIKE ? ESCAPE '\')
|
||||
WHERE (email LIKE ?1 ESCAPE '!' OR name LIKE ?1 ESCAPE '!')
|
||||
AND email NOT IN (SELECT email FROM contacts)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM contacts c, json_each(c.emails_json) alt
|
||||
SELECT 1 FROM contacts c
|
||||
JOIN JSON_TABLE(COALESCE(NULLIF(c.emails_json, ''), '[]'), '$[*]' COLUMNS(value VARCHAR(320) PATH '$')) alt
|
||||
WHERE lower(alt.value) = lower(known_addresses.email)
|
||||
)
|
||||
ORDER BY email ASC
|
||||
LIMIT ?
|
||||
LIMIT ?2
|
||||
"#;
|
||||
pub const Q_004: &str = "INSERT INTO known_addresses (email, name) VALUES (?, ?)
|
||||
ON CONFLICT(email) DO UPDATE SET name = excluded.name WHERE excluded.name != ''";
|
||||
ON DUPLICATE KEY UPDATE name = IF(VALUES(name) <> '', VALUES(name), name)";
|
||||
pub const Q_005: &str = "INSERT INTO known_addresses (email, name) VALUES (?, ?)
|
||||
ON CONFLICT(email) DO UPDATE SET name = excluded.name WHERE excluded.name != ''";
|
||||
ON DUPLICATE KEY UPDATE name = IF(VALUES(name) <> '', VALUES(name), name)";
|
||||
pub const Q_006: &str = "UPDATE contacts
|
||||
SET contact_count = contact_count + 1,
|
||||
last_contacted = CURRENT_TIMESTAMP,
|
||||
@@ -105,24 +106,24 @@ pub mod db_contacts {
|
||||
WHERE email = ?";
|
||||
pub const Q_007: &str = "INSERT IGNORE INTO contacts (id, email, name, source)
|
||||
VALUES (?, ?, ?, 'auto')";
|
||||
pub const Q_008: &str = "INSERT INTO contact_photos (contact_id, content_type, data, updated_at) VALUES (?, ?, ?, CURRENT_TIMESTAMP) ON CONFLICT(contact_id) DO UPDATE SET content_type=excluded.content_type, data=excluded.data, updated_at=CURRENT_TIMESTAMP";
|
||||
pub const Q_008: &str = "INSERT INTO contact_photos (contact_id, content_type, data, updated_at) VALUES (?, ?, ?, CURRENT_TIMESTAMP) ON DUPLICATE KEY UPDATE content_type=VALUES(content_type), data=VALUES(data), updated_at=CURRENT_TIMESTAMP";
|
||||
pub const Q_009: &str = "SELECT content_type, data FROM contact_photos WHERE contact_id = ?";
|
||||
pub const Q_010: &str = "DELETE FROM contact_photos WHERE contact_id = ?";
|
||||
pub const FORMAT_001: &str = "SELECT {CONTACT_SELECT_COLS} FROM contacts WHERE id = ?";
|
||||
pub const FORMAT_002: &str = "SELECT {CONTACT_SELECT_COLS} FROM contacts \
|
||||
WHERE lower(email) = lower(?) \
|
||||
OR EXISTS (SELECT 1 FROM json_each(contacts.emails_json) WHERE lower(value) = lower(?))";
|
||||
WHERE lower(email) = lower(?1) \
|
||||
OR EXISTS (SELECT 1 FROM JSON_TABLE(COALESCE(NULLIF(contacts.emails_json, ''), '[]'), '$[*]' COLUMNS(value VARCHAR(320) PATH '$')) alt WHERE lower(alt.value) = lower(?1))";
|
||||
pub const FORMAT_003: &str = "SELECT {CONTACT_SELECT_COLS} FROM contacts
|
||||
WHERE name LIKE ? ESCAPE '\\' OR email LIKE ? ESCAPE '\\' OR emails_json LIKE ? ESCAPE '\\'
|
||||
WHERE name LIKE ?1 ESCAPE '!' OR email LIKE ?1 ESCAPE '!' OR emails_json LIKE ?1 ESCAPE '!'
|
||||
ORDER BY name ASC
|
||||
LIMIT ? OFFSET ?";
|
||||
LIMIT ?2 OFFSET ?3";
|
||||
pub const FORMAT_004: &str = "SELECT {CONTACT_SELECT_COLS} FROM contacts
|
||||
ORDER BY name ASC
|
||||
LIMIT ? OFFSET ?";
|
||||
pub const FORMAT_005: &str = "SELECT {CONTACT_SELECT_COLS} FROM contacts
|
||||
WHERE name LIKE ? ESCAPE '\\' OR email LIKE ? ESCAPE '\\' OR emails_json LIKE ? ESCAPE '\\'
|
||||
WHERE name LIKE ?1 ESCAPE '!' OR email LIKE ?1 ESCAPE '!' OR emails_json LIKE ?1 ESCAPE '!'
|
||||
ORDER BY name ASC
|
||||
LIMIT ?";
|
||||
LIMIT ?2";
|
||||
}
|
||||
|
||||
pub mod db_display_preferences {
|
||||
@@ -134,29 +135,28 @@ pub mod db_display_preferences {
|
||||
pub mod db_drafts {
|
||||
pub const Q_001: &str = "INSERT INTO drafts (id, to_addresses, cc_addresses, bcc_addresses, subject, text_body, html_body, in_reply_to, references_header, request_mdn, priority, compose_format, pgp_mode, pgp_inline, pgp_attach_public_key, pgp_attach_recipient_keys, updated_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)
|
||||
ON CONFLICT(id) DO UPDATE SET
|
||||
to_addresses = excluded.to_addresses,
|
||||
cc_addresses = excluded.cc_addresses,
|
||||
bcc_addresses = excluded.bcc_addresses,
|
||||
subject = excluded.subject,
|
||||
text_body = excluded.text_body,
|
||||
html_body = excluded.html_body,
|
||||
in_reply_to = excluded.in_reply_to,
|
||||
references_header = excluded.references_header,
|
||||
request_mdn = excluded.request_mdn,
|
||||
priority = excluded.priority,
|
||||
compose_format = excluded.compose_format,
|
||||
pgp_mode = excluded.pgp_mode,
|
||||
pgp_inline = excluded.pgp_inline,
|
||||
pgp_attach_public_key = excluded.pgp_attach_public_key,
|
||||
pgp_attach_recipient_keys = excluded.pgp_attach_recipient_keys,
|
||||
ON DUPLICATE KEY UPDATE
|
||||
to_addresses = VALUES(to_addresses),
|
||||
cc_addresses = VALUES(cc_addresses),
|
||||
bcc_addresses = VALUES(bcc_addresses),
|
||||
subject = VALUES(subject),
|
||||
text_body = VALUES(text_body),
|
||||
html_body = VALUES(html_body),
|
||||
in_reply_to = VALUES(in_reply_to),
|
||||
references_header = VALUES(references_header),
|
||||
request_mdn = VALUES(request_mdn),
|
||||
priority = VALUES(priority),
|
||||
compose_format = VALUES(compose_format),
|
||||
pgp_mode = VALUES(pgp_mode),
|
||||
pgp_inline = VALUES(pgp_inline),
|
||||
pgp_attach_public_key = VALUES(pgp_attach_public_key),
|
||||
pgp_attach_recipient_keys = VALUES(pgp_attach_recipient_keys),
|
||||
updated_at = CURRENT_TIMESTAMP";
|
||||
pub const Q_002: &str = "SELECT id, to_addresses, cc_addresses, bcc_addresses, subject, text_body, html_body, in_reply_to, references_header, request_mdn, priority, compose_format, pgp_mode, pgp_inline, pgp_attach_public_key, pgp_attach_recipient_keys, remote_folder, remote_uid, remote_uid_validity, created_at, updated_at
|
||||
FROM drafts WHERE id = ?";
|
||||
pub const Q_003: &str = "SELECT id, to_addresses, cc_addresses, bcc_addresses, subject, text_body, html_body, in_reply_to, references_header, request_mdn, priority, compose_format, pgp_mode, pgp_inline, pgp_attach_public_key, pgp_attach_recipient_keys, remote_folder, remote_uid, remote_uid_validity, created_at, updated_at
|
||||
FROM drafts ORDER BY updated_at DESC";
|
||||
pub const Q_004: &str =
|
||||
"UPDATE drafts SET remote_folder = ?, remote_uid = ?, remote_uid_validity = ? WHERE id = ?";
|
||||
pub const Q_004: &str = "UPDATE drafts SET remote_folder = ?2, remote_uid = ?3, remote_uid_validity = ?4 WHERE id = ?1";
|
||||
pub const Q_005: &str = "DELETE FROM drafts WHERE id = ?";
|
||||
pub const Q_006: &str =
|
||||
"INSERT INTO draft_attachments (id, draft_id, filename, content_type, size, file_path)
|
||||
@@ -173,7 +173,7 @@ pub mod db_folder_preferences {
|
||||
pub const Q_003: &str = "SELECT EXISTS(SELECT 1 FROM folders WHERE name = ?)";
|
||||
pub const Q_004: &str = "SELECT flagged_on_top FROM mail_preferences WHERE id = 1";
|
||||
pub const Q_005: &str = "SELECT EXISTS(SELECT 1 FROM folders WHERE name = ?)";
|
||||
pub const Q_006: &str = "INSERT INTO folder_preferences(folder_name, flagged_on_top, updated_at) VALUES(?, ?, CURRENT_TIMESTAMP)\n ON CONFLICT(folder_name) DO UPDATE SET flagged_on_top = excluded.flagged_on_top, updated_at = CURRENT_TIMESTAMP";
|
||||
pub const Q_006: &str = "INSERT INTO folder_preferences(folder_name, flagged_on_top, updated_at) VALUES(?, ?, CURRENT_TIMESTAMP)\n ON DUPLICATE KEY UPDATE flagged_on_top = VALUES(flagged_on_top), updated_at = CURRENT_TIMESTAMP";
|
||||
pub const Q_007: &str = "DELETE FROM folder_preferences WHERE folder_name = ?";
|
||||
}
|
||||
|
||||
@@ -196,17 +196,16 @@ pub mod db_folders {
|
||||
pub const Q_007: &str =
|
||||
"UPDATE folders SET uid_validity = ?, total_count = ?, highest_modseq = ?
|
||||
WHERE name = ?";
|
||||
pub const Q_008: &str =
|
||||
"SELECT COUNT(*) FROM messages WHERE folder = ? AND flags NOT LIKE '%\\Seen%'";
|
||||
pub const Q_008: &str = "SELECT CAST(COUNT(*) AS SIGNED) FROM messages WHERE folder = ? AND LOCATE(CONCAT(CHAR(92), 'Seen'), flags) = 0";
|
||||
pub const Q_009: &str = "UPDATE folders SET unread_count = ? WHERE name = ?";
|
||||
pub const Q_010: &str = "UPDATE folders SET unread_count = GREATEST(0, CAST(unread_count AS SIGNED) + ?) WHERE name = ?";
|
||||
pub const Q_011: &str = "SELECT EXISTS(
|
||||
SELECT 1 FROM folders
|
||||
WHERE updated_at > datetime('now', ?)
|
||||
WHERE updated_at > DATE_FORMAT(DATE_SUB(CURRENT_TIMESTAMP, INTERVAL ? SECOND), '%Y-%m-%d %H:%i:%s')
|
||||
)";
|
||||
pub const Q_012: &str = "SELECT EXISTS(
|
||||
SELECT 1 FROM folders
|
||||
WHERE name = ? AND messages_updated_at > datetime('now', ?)
|
||||
WHERE name = ? AND messages_updated_at > DATE_FORMAT(DATE_SUB(CURRENT_TIMESTAMP, INTERVAL ? SECOND), '%Y-%m-%d %H:%i:%s')
|
||||
)";
|
||||
pub const Q_013: &str = "SELECT messages_updated_at IS NULL FROM folders WHERE name = ?";
|
||||
pub const Q_014: &str = "UPDATE folders SET messages_updated_at = NULL WHERE name = ?";
|
||||
@@ -216,7 +215,7 @@ pub mod db_folders {
|
||||
WHERE name = ?";
|
||||
pub const Q_016: &str = "DELETE FROM messages WHERE folder = ?";
|
||||
pub const Q_017: &str = "DELETE FROM folders WHERE name = ?";
|
||||
pub const Q_018: &str = "PRAGMA defer_foreign_keys = ON;";
|
||||
pub const Q_018: &str = "SELECT 1";
|
||||
pub const Q_019: &str = "INSERT INTO folders (name, delimiter, parent, flags, is_subscribed, total_count, unread_count, uid_validity, highest_modseq, updated_at, messages_updated_at)
|
||||
SELECT ?, delimiter, parent, flags, is_subscribed, total_count, unread_count, uid_validity, highest_modseq, CURRENT_TIMESTAMP, messages_updated_at
|
||||
FROM folders WHERE name = ?";
|
||||
@@ -237,14 +236,14 @@ pub mod db_header_sync {
|
||||
pub const Q_001: &str = "SELECT value FROM user_meta WHERE key = 'header_sync_generation'";
|
||||
pub const Q_002: &str =
|
||||
"INSERT INTO user_meta (key, value) VALUES ('header_sync_generation', '1')
|
||||
ON CONFLICT(key) DO UPDATE SET value = CAST(value AS INTEGER) + 1";
|
||||
ON DUPLICATE KEY UPDATE value = CAST(value AS SIGNED) + 1";
|
||||
}
|
||||
|
||||
pub mod db_identities {
|
||||
pub const IDENTITY_SELECT_COLS: &str = "id, display_name, email, signature_html, is_default, created_at, updated_at, reply_to, bcc, organization, signature_text, signature_new, signature_reply, signature_forward, signature_position, pgp_fingerprint, pgp_sign_default, pgp_encrypt_default, pgp_inline_default";
|
||||
pub const Q_001: &str = "INSERT INTO identities (display_name,email,signature_html,is_default,reply_to,bcc,organization,signature_text,signature_new,signature_reply,signature_forward,signature_position,pgp_fingerprint,pgp_sign_default,pgp_encrypt_default,pgp_inline_default) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
pub const Q_002: &str = "DELETE FROM identities WHERE id = ?";
|
||||
pub const Q_003: &str = "SELECT COUNT(*) FROM identities";
|
||||
pub const Q_003: &str = "SELECT CAST(COUNT(*) AS SIGNED) FROM identities";
|
||||
pub const Q_004: &str =
|
||||
"UPDATE identities SET is_default = 0, updated_at = CURRENT_TIMESTAMP WHERE is_default = 1";
|
||||
pub const FORMAT_001: &str =
|
||||
@@ -273,8 +272,8 @@ pub mod db_messages {
|
||||
pub const Q_004: &str = "SELECT uid, folder, subject, from_address, from_name, to_addresses, \
|
||||
COALESCE(NULLIF(body_text, ''), snippet, ''), date_epoch, has_attachments \
|
||||
FROM messages ORDER BY folder, uid";
|
||||
pub const Q_005: &str = "SELECT COUNT(*) FROM messages WHERE folder = ?";
|
||||
pub const Q_006: &str = "SELECT COUNT(*) FROM messages";
|
||||
pub const Q_005: &str = "SELECT CAST(COUNT(*) AS SIGNED) FROM messages WHERE folder = ?";
|
||||
pub const Q_006: &str = "SELECT CAST(COUNT(*) AS SIGNED) FROM messages";
|
||||
pub const Q_007: &str = "UPDATE messages SET flags = ? WHERE folder = ? AND uid = ?";
|
||||
pub const Q_008: &str = "UPDATE messages
|
||||
SET body_html = ?, body_text = ?, body_cached = 1,
|
||||
@@ -291,7 +290,7 @@ pub mod db_messages {
|
||||
ORDER BY date_epoch DESC
|
||||
LIMIT ?";
|
||||
pub const Q_013: &str = "SELECT uid, flags FROM messages WHERE folder = ?";
|
||||
pub const Q_014: &str = "SELECT SUM(size) FROM messages";
|
||||
pub const Q_014: &str = "SELECT CAST(SUM(size) AS SIGNED) FROM messages";
|
||||
pub const FORMAT_001: &str = "SELECT {MSG_SELECT_COLS}
|
||||
FROM messages
|
||||
WHERE folder = ?
|
||||
@@ -307,9 +306,9 @@ pub mod db_messages {
|
||||
WHERE folder = ? AND uid = ?";
|
||||
pub const FORMAT_004: &str = "SELECT {MSG_SELECT_COLS}
|
||||
FROM messages
|
||||
WHERE message_id = ?
|
||||
OR in_reply_to = ?
|
||||
OR references_header LIKE ? ESCAPE '\\'
|
||||
WHERE message_id = ?1
|
||||
OR in_reply_to = ?1
|
||||
OR references_header LIKE ?2 ESCAPE '!'
|
||||
ORDER BY date_epoch ASC";
|
||||
pub const FORMAT_005: &str = "SELECT {MSG_SELECT_COLS}
|
||||
FROM messages
|
||||
@@ -326,9 +325,9 @@ pub mod db_notification_preferences {
|
||||
|
||||
pub mod db_pgp {
|
||||
pub const KEY_COLS: &str = "fingerprint,key_id,email,user_id,public_key_armor,secret_key_path,has_secret,trust,source,created_at,updated_at";
|
||||
pub const Q_001: &str = "INSERT INTO pgp_keys (fingerprint,key_id,email,user_id,public_key_armor,secret_key_path,has_secret,trust,source) VALUES (?,?,?,?,?,?,?,?,?)\n ON CONFLICT(fingerprint) DO UPDATE SET key_id=excluded.key_id,email=CASE WHEN excluded.email='' THEN pgp_keys.email ELSE excluded.email END,user_id=CASE WHEN excluded.user_id='' THEN pgp_keys.user_id ELSE excluded.user_id END,public_key_armor=excluded.public_key_armor,secret_key_path=COALESCE(excluded.secret_key_path,pgp_keys.secret_key_path),has_secret=MAX(pgp_keys.has_secret,excluded.has_secret),trust=excluded.trust,source=excluded.source,updated_at=CURRENT_TIMESTAMP";
|
||||
pub const Q_001: &str = "INSERT INTO pgp_keys (fingerprint,key_id,email,user_id,public_key_armor,secret_key_path,has_secret,trust,source) VALUES (?,?,?,?,?,?,?,?,?)\n ON DUPLICATE KEY UPDATE key_id=VALUES(key_id),email=CASE WHEN VALUES(email)='' THEN email ELSE VALUES(email) END,user_id=CASE WHEN VALUES(user_id)='' THEN user_id ELSE VALUES(user_id) END,public_key_armor=VALUES(public_key_armor),secret_key_path=COALESCE(VALUES(secret_key_path),secret_key_path),has_secret=GREATEST(has_secret,VALUES(has_secret)),trust=VALUES(trust),source=VALUES(source),updated_at=CURRENT_TIMESTAMP";
|
||||
pub const Q_002: &str = "DELETE FROM pgp_keys WHERE replace(upper(fingerprint),' ','')=?";
|
||||
pub const Q_003: &str = "UPDATE pgp_keys SET trust=?,updated_at=CURRENT_TIMESTAMP WHERE replace(upper(fingerprint),' ','')=?";
|
||||
pub const Q_003: &str = "UPDATE pgp_keys SET trust=?2,updated_at=CURRENT_TIMESTAMP WHERE replace(upper(fingerprint),' ','')=?1";
|
||||
pub const Q_004: &str =
|
||||
"SELECT wkd_enabled,hkp_enabled,require_trusted_encryption FROM pgp_preferences WHERE id=1";
|
||||
pub const Q_005: &str = "UPDATE pgp_preferences SET wkd_enabled=?,hkp_enabled=?,require_trusted_encryption=?,updated_at=CURRENT_TIMESTAMP WHERE id=1";
|
||||
@@ -343,11 +342,12 @@ pub mod db_pgp {
|
||||
|
||||
pub mod db_pool {
|
||||
pub const Q_001: &str = "SELECT 0";
|
||||
pub const Q_002: &str = "SELECT CURRENT_TIMESTAMP";
|
||||
pub const Q_002: &str = "SELECT CAST(CURRENT_TIMESTAMP AS CHAR)";
|
||||
pub const Q_003: &str = "SELECT 1";
|
||||
pub const Q_004: &str = "SELECT 1";
|
||||
pub const Q_005: &str = "SHOW TABLES";
|
||||
pub const Q_006: &str = "SELECT 1";
|
||||
pub const Q_007: &str = "SELECT CAST(COUNT(*) AS SIGNED) FROM information_schema.tables WHERE table_schema = DATABASE()";
|
||||
}
|
||||
|
||||
pub mod db_response_templates {
|
||||
@@ -374,7 +374,7 @@ pub mod db_saved_searches {
|
||||
pub mod db_special_folders {
|
||||
pub const Q_001: &str = "SELECT folder_name FROM special_folders WHERE role = ?";
|
||||
pub const Q_002: &str = "SELECT EXISTS(SELECT 1 FROM folders WHERE name = ?)";
|
||||
pub const Q_003: &str = "INSERT INTO special_folders(role, folder_name, updated_at) VALUES(?, ?, CURRENT_TIMESTAMP)\n ON CONFLICT(role) DO UPDATE SET folder_name = excluded.folder_name, updated_at = CURRENT_TIMESTAMP";
|
||||
pub const Q_003: &str = "INSERT INTO special_folders(role, folder_name, updated_at) VALUES(?, ?, CURRENT_TIMESTAMP)\n ON DUPLICATE KEY UPDATE folder_name = VALUES(folder_name), updated_at = CURRENT_TIMESTAMP";
|
||||
pub const Q_004: &str = "DELETE FROM special_folders WHERE role = ?";
|
||||
pub const Q_005: &str = "UPDATE special_folders SET folder_name = ?, updated_at = CURRENT_TIMESTAMP WHERE folder_name = ?";
|
||||
pub const Q_006: &str = "DELETE FROM special_folders WHERE folder_name = ?";
|
||||
@@ -384,7 +384,7 @@ pub mod db_tags {
|
||||
pub const Q_001: &str = "INSERT INTO tags (id, name, color, imap_keyword) VALUES (?, ?, ?, ?)";
|
||||
pub const Q_002: &str =
|
||||
"SELECT t.id, t.name, t.color, t.imap_keyword, t.created_at, t.updated_at,
|
||||
(SELECT COUNT(*) FROM message_tags mt WHERE mt.tag_id = t.id) AS message_count
|
||||
(SELECT CAST(COUNT(*) AS SIGNED) FROM message_tags mt WHERE mt.tag_id = t.id) AS message_count
|
||||
FROM tags t
|
||||
ORDER BY t.name ASC";
|
||||
pub const Q_003: &str = "SELECT message_uid, message_folder FROM message_tags WHERE tag_id = ?";
|
||||
@@ -409,7 +409,7 @@ pub mod db_tags {
|
||||
WHERE mt.tag_id = ?
|
||||
ORDER BY m.date_epoch DESC
|
||||
LIMIT ? OFFSET ?";
|
||||
pub const Q_010: &str = "SELECT COUNT(*) FROM message_tags WHERE tag_id = ?";
|
||||
pub const Q_010: &str = "SELECT CAST(COUNT(*) AS SIGNED) FROM message_tags WHERE tag_id = ?";
|
||||
pub const Q_011: &str = "INSERT IGNORE INTO folders (name) VALUES (?)";
|
||||
pub const Q_012: &str = "INSERT INTO messages (uid, folder, subject, from_address, from_name, to_addresses, date, flags, size, has_attachments, snippet)
|
||||
VALUES (?, ?, 'Test', 'test@ex.com', 'Test', '[]', '2024-01-01', '', 100, 0, '')";
|
||||
@@ -427,23 +427,23 @@ pub mod db_trusted_senders {
|
||||
}
|
||||
|
||||
pub mod routes_contacts {
|
||||
pub const Q_001: &str = "SELECT CURRENT_TIMESTAMP";
|
||||
pub const Q_002: &str = "SELECT CURRENT_TIMESTAMP";
|
||||
pub const Q_003: &str = "SELECT CURRENT_TIMESTAMP";
|
||||
pub const Q_001: &str = "SELECT CAST(CURRENT_TIMESTAMP AS CHAR)";
|
||||
pub const Q_002: &str = "SELECT CAST(CURRENT_TIMESTAMP AS CHAR)";
|
||||
pub const Q_003: &str = "SELECT CAST(CURRENT_TIMESTAMP AS CHAR)";
|
||||
}
|
||||
|
||||
pub mod routes_diagnostics {
|
||||
pub const Q_001: &str = "SELECT COUNT(*),
|
||||
COALESCE(SUM(CASE WHEN messages_updated_at IS NULL THEN 1 ELSE 0 END), 0),
|
||||
CASE WHEN MAX(updated_at) IS NULL THEN NULL ELSE replace(MAX(updated_at), ' ', 'T') || 'Z' END,
|
||||
CASE WHEN MAX(messages_updated_at) IS NULL THEN NULL ELSE replace(MAX(messages_updated_at), ' ', 'T') || 'Z' END
|
||||
pub const Q_001: &str = "SELECT CAST(COUNT(*) AS SIGNED),
|
||||
CAST(COALESCE(SUM(CASE WHEN messages_updated_at IS NULL THEN 1 ELSE 0 END), 0) AS SIGNED),
|
||||
CASE WHEN MAX(updated_at) IS NULL THEN NULL ELSE CONCAT(replace(MAX(updated_at), ' ', 'T'), 'Z') END,
|
||||
CASE WHEN MAX(messages_updated_at) IS NULL THEN NULL ELSE CONCAT(replace(MAX(messages_updated_at), ' ', 'T'), 'Z') END
|
||||
FROM folders";
|
||||
pub const Q_002: &str = "SELECT COUNT(*) FROM messages";
|
||||
pub const Q_003: &str = "SELECT COUNT(*) FROM messages WHERE body_cached = 1";
|
||||
pub const Q_002: &str = "SELECT CAST(COUNT(*) AS SIGNED) FROM messages";
|
||||
pub const Q_003: &str = "SELECT CAST(COUNT(*) AS SIGNED) FROM messages WHERE body_cached = 1";
|
||||
}
|
||||
|
||||
pub mod routes_folder_mgmt {
|
||||
pub const Q_001: &str = "UPDATE messages SET flags = CASE WHEN flags = '' THEN ? ELSE flags || ',' || ? END WHERE folder = ? AND instr(flags, ?) = 0";
|
||||
pub const Q_001: &str = "UPDATE messages SET flags = CASE WHEN flags = '' THEN ?2 ELSE CONCAT(flags, ',', ?2) END WHERE folder = ?1 AND LOCATE(?2, flags) = 0";
|
||||
pub const Q_002: &str = "UPDATE folders SET unread_count = 0 WHERE name = ?";
|
||||
pub const Q_003: &str = "SELECT uid FROM messages WHERE folder = ?";
|
||||
pub const Q_004: &str = "UPDATE folders SET total_count = 0, unread_count = 0, messages_updated_at = CURRENT_TIMESTAMP WHERE name = ?";
|
||||
@@ -479,7 +479,8 @@ pub mod sessions {
|
||||
"SELECT * FROM sessions WHERE browser_id = ? ORDER BY created_at_unix";
|
||||
pub const BY_USER: &str =
|
||||
"SELECT * FROM sessions WHERE user_hash = ? ORDER BY last_accessed_unix DESC";
|
||||
pub const BROWSER_EXISTS: &str = "SELECT COUNT(*) FROM sessions WHERE browser_id = ?";
|
||||
pub const BROWSER_EXISTS: &str =
|
||||
"SELECT CAST(COUNT(*) AS SIGNED) FROM sessions WHERE browser_id = ?";
|
||||
pub const DELETE_ACCOUNT: &str = "DELETE FROM sessions WHERE account_id = ?";
|
||||
pub const DELETE_BROWSER: &str = "DELETE FROM sessions WHERE browser_id = ?";
|
||||
pub const DELETE_EXPIRED: &str =
|
||||
|
||||
Reference in new issue
Block a user