Commit Graph

233 Commits

Author SHA1 Message Date
Girish Ramakrishnan
36aa641cb9 migrate to "export default"
also, set no-use-before-define in linter
2026-02-14 15:43:24 +01:00
Girish Ramakrishnan
96dc79cfe6 Migrate codebase from CommonJS to ES Modules
- Convert all require()/module.exports to import/export across 260+ files
- Add "type": "module" to package.json to enable ESM by default
- Add migrations/package.json with "type": "commonjs" to keep db-migrate compatible
- Convert eslint.config.js to ESM with sourceType: "module"
- Replace __dirname/__filename with import.meta.dirname/import.meta.filename
- Replace require.main === module with process.argv[1] === import.meta.filename
- Remove 'use strict' directives (implicit in ESM)
- Convert dynamic require() in switch statements to static import lookup maps
  (dns.js, domains.js, backupformats.js, backupsites.js, network.js)
- Extract self-referencing exports.CONSTANT patterns into standalone const
  declarations (apps.js, services.js, locks.js, users.js, mail.js, etc.)
- Lazify SERVICES object in services.js to avoid circular dependency TDZ issues
- Add clearMailQueue() to mailer.js for ESM-safe queue clearing in tests
- Add _setMockApp() to ldapserver.js for ESM-safe test mocking
- Add _setMockResolve() wrapper to dig.js for ESM-safe DNS mocking in tests
- Convert backupupload.js to use dynamic imports so --check exits before
  loading the module graph (which requires BOX_ENV)
- Update check-install to use ESM import for infra_version.js
- Convert scripts/ (hotfix, release, remote_hotfix.js, find-unused-translations)
- All 1315 tests passing

Migration stats (AI-assisted using Cursor with Claude):
- Wall clock time: ~3-4 hours
- Assistant completions: ~80-100
- Estimated token usage: ~1-2M tokens

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-14 15:11:45 +01:00
Girish Ramakrishnan
12e073e8cf use node: prefix for requires
mostly because code is being autogenerated by all the AI stuff using
this prefix. it's also used in the stack trace.
2025-08-14 12:55:35 +05:30
Girish Ramakrishnan
c184f1e42e mailer: handle error at the caller instead
the send test email logic breaks if we disable throwing error in send
2025-08-06 10:18:09 +02:00
Girish Ramakrishnan
5c7d19ce13 mailer: set timeouts 2025-08-06 10:00:56 +02:00
Girish Ramakrishnan
3d4b3edc3a mailer: log error and do not throw
this suppresses eventlog exceptions when mail is down or the
mail is rejected because outbound is disabled.

in apphealthmonitor, we hit a case where eventlog entries are
continuously added since mailer was not sending emails. the health
state of the app is never switched because mail sending failed.
2025-08-06 09:59:40 +02:00
Girish Ramakrishnan
a7ffc8a172 mailer: node-mailer supports async natively 2025-08-06 08:26:57 +02:00
Girish Ramakrishnan
0cf0c7a27c notifications: add low disk space notification 2025-05-07 13:19:20 +02:00
Girish Ramakrishnan
ac0426d97d notification: update failure mail 2025-01-24 18:44:44 +01:00
Girish Ramakrishnan
0280059c13 notifications: server reboot email 2025-01-19 11:18:49 +01:00
Girish Ramakrishnan
be340580d4 various notification fixes 2024-12-11 23:58:17 +01:00
Girish Ramakrishnan
701c25d07a notifications: add back app down and app oom mails 2024-12-11 20:56:15 +01:00
Girish Ramakrishnan
6004cd17bf notifications: per user email prefs 2024-12-11 19:12:20 +01:00
Girish Ramakrishnan
bcf497b460 translation.js -> translations.js
kept confusing my why i can't find this file! this is in line
with the rest of our code
2024-07-05 12:45:27 +02:00
Girish Ramakrishnan
bf51a60986 change args of translation.translate 2024-07-05 12:42:33 +02:00
Girish Ramakrishnan
41809d1ca8 mailer: format is not used 2024-07-05 12:20:30 +02:00
Girish Ramakrishnan
86530df37e mailer: add html version of test mail 2024-07-05 11:07:51 +02:00
Girish Ramakrishnan
470417fcbe more test fixing 2023-12-03 21:18:16 +01:00
Girish Ramakrishnan
ceb908bee7 Use constants.TEST 2023-10-01 13:52:19 +05:30
Girish Ramakrishnan
eee49a8291 move dashboard setting into dashboard.js 2023-08-11 21:04:10 +05:30
Girish Ramakrishnan
67ee82abb9 remove settings.dashboardOrigin 2023-08-04 22:10:14 +05:30
Girish Ramakrishnan
946e5caacb split mail and mailserver
mail = all the per-domain code
mailserver = all the mail server level code
2023-08-04 20:54:39 +05:30
Girish Ramakrishnan
fccc2d04a9 settings: move support config to support 2023-08-02 23:02:40 +05:30
Girish Ramakrishnan
e0d07c3c19 settings: move branding settings into branding.js 2023-08-02 23:02:40 +05:30
Girish Ramakrishnan
9cef08aa6a mail relay: do not accept TLS servers
haraka can only relay via STARTTLS
2022-09-14 17:42:21 +02:00
Girish Ramakrishnan
7f45e1db06 send new login location to user email 2021-11-17 11:53:03 -08:00
Johannes Zellner
4356d673bc Fix wrong assert and minor typos 2021-10-27 22:31:54 +02:00
Johannes Zellner
475795a107 Invite is now also separate 2021-10-27 19:58:06 +02:00
Johannes Zellner
9a80049d36 Add two distinct password reset routes 2021-10-27 19:12:18 +02:00
Girish Ramakrishnan
971b73f853 move the bind inside 2021-10-26 11:03:54 -07:00
Johannes Zellner
074ce574dd Return password reset link on reset request route 2021-09-16 14:34:56 +02:00
Girish Ramakrishnan
95af5ef138 mailer: fix crash 2021-08-22 09:52:01 -07:00
Girish Ramakrishnan
4cd5137292 mailer: fix error handling
previous mailer code has no callback and thus no way to pass back errors.
now with asyncification it passes back the error
2021-08-19 12:40:53 -07:00
Girish Ramakrishnan
ada7166bf8 translation: asyncify 2021-08-19 11:54:28 -07:00
Girish Ramakrishnan
03e22170da appstore and support: async'ify 2021-08-18 23:38:18 -07:00
Johannes Zellner
eda3cd83ae Make new login email translatable
Fixes #798
2021-07-29 10:54:38 +02:00
Girish Ramakrishnan
a1c61facdc merge userdb.js into users.js 2021-07-16 22:33:22 -07:00
Girish Ramakrishnan
9c0f983ce1 backups: fix failure notitification 2021-06-24 01:44:46 -07:00
Girish Ramakrishnan
b24cf78bc0 certs: fix renewal notification 2021-06-24 01:12:33 -07:00
Girish Ramakrishnan
73917e95c9 rework notifications
notifications are now system level instead of user level.

To clarify the use events/notifications/email:
* eventlog - everything that is happenning on server
* notifications - specific important events (alerts)
* email - these are really urgent things that require immediate attention. this is for
  the case where an admin does not visit the dashboard often. can also be alerts like
  bad backup config or reboot required which are not events per-se.

Notes on notifications
* oom - notification only
* appUpdated - notification only
* cert renewal failure - only raise when < 10 days to go. also send email thereafter (todo).
* Backup failure - only if last 5 backups failed (todo).
* Box update - notification only. we anyway send newsletter.
* box update available - we raise a notification. no email.
* app update available - we already have update indicator on dashboard. so, no notification or email.

Alerts:
* backup config
* disk space
* mail status
* reboot
* box updated
* ubuntu update required
2021-05-28 15:29:53 -07:00
Girish Ramakrishnan
44ac406e57 admin -> dashboard 2021-05-05 12:29:04 -07:00
Johannes Zellner
fed8ba95f0 Fallback to unkown useragent and don't stash such login attempts 2021-05-04 20:07:28 +02:00
Girish Ramakrishnan
64414eb932 new login mail: minor adjustments to text 2021-04-30 12:01:57 -07:00
Johannes Zellner
549b2f2a6b Improve new login location email 2021-04-30 16:20:50 +02:00
Johannes Zellner
fb5c2a5e52 Properly detect new user agents and location 2021-04-30 15:22:10 +02:00
Johannes Zellner
61e51c7875 Send new login location notification mail 2021-04-21 16:14:49 +02:00
Girish Ramakrishnan
355de5b0a4 notifications: fix update notification
the notification wasn't working because this was in apptask and the apptask died
before it could send out the email. we now move the notification to box process
and also remove the email notification.
2021-04-19 15:14:04 -07:00
Girish Ramakrishnan
ef476f74bf notifications: no email for app up/down/oom events
emails will not be used for self monitoring events. these are best done
from the outside. we just log everything in eventlog and raise notifications
as well.
2021-04-15 15:29:25 -07:00
Girish Ramakrishnan
66ff2a9eb7 Revert "make box code send emails with STARTTLS"
This reverts commit ca496df535.

2525 has no TLS anymore
2021-03-22 14:34:07 -07:00
Girish Ramakrishnan
ca496df535 make box code send emails with STARTTLS 2021-03-14 12:19:37 -07:00