Commit graph

222 commits

Author SHA1 Message Date
lcd1232
d055cc5311
Add support for selecting SMTP per campaign (#2290)
This patch adds a new optional `name` field to SMTP server config on the UI.
When a name is given to an SMTP server, it's initialized as a standalone messenger
which shows up as a sub-group item under the main "email" messenger
on the campaign page.

Co-authored-by: Kailash Nadh <kailash@nadh.in>
2025-02-11 22:41:45 +05:30
Kailash Nadh
61c6b7e15a Add explicit Unschedule button on campaign UI. 2025-01-19 16:27:39 +05:30
Kailash Nadh
fd31ac6f58 Remove redundant send_later param in campaign POST/PUT. 2025-01-19 16:06:39 +05:30
Shaun Warman
a5e56c3446
fix: forwardemail bounce processing invalid signature issue (#2250) 2025-01-10 10:40:21 +05:30
ANU MADHAV
2abc0a8651
Apply minor Go code fixes (#2219)
- replace deprecated 'strings.Title' with 'cases.Title'
- remove unreachable return and fix syntax issue
2024-12-25 19:57:14 +05:30
Kailash Nadh
97fde64461 Make CSV (import) header fields agnostic of surrounding spaces. Closes #2189. 2024-12-04 23:11:51 +05:30
Kailash Nadh
63712285aa Fix schema and add migration for incorrect subscriber count (null) in materialized view. 2024-12-04 23:06:49 +05:30
Kailash Nadh
5c0de6ef0b Fix broken sorting lists by subscriber_count. Closes #2151. 2024-12-04 22:40:13 +05:30
Kailash Nadh
894d284309 Fix GET subscribers not filtering by list permissions. Closes #2129. 2024-11-12 22:59:33 +05:30
Kailash Nadh
18edc653a8 Add v4.1.0 migrations. 2024-11-11 16:11:56 +05:30
Shaun Warman
cb8b54fd00
Add ForwardEmail (provider) bounce integration (#2016)
* Add ForwardEmail one-click SMTP form option.
* Add bounce webhook integration.

---------

Co-authored-by: Kailash Nadh <kailash@nadh.in>
2024-11-10 21:45:07 +05:30
Kailash Nadh
b8ae4f6f9e Change v4.0.0 migration script to not auto-generate credentials. 2024-10-27 17:18:28 +05:30
Kailash Nadh
1e4b3a26f2 Separate get individual user and get all users queries. 2024-10-26 17:03:02 +05:30
Kailash Nadh
25cdb7b18e Pull e-mail from userinfo endpoint if OIDC token endpoint doesn't return it. 2024-10-23 15:09:05 +05:30
Kailash Nadh
8c07a2a1c4 Fix broken status in subscriber export query. 2024-10-20 23:50:06 +05:30
Kailash Nadh
cea65c009d Fix and refactor subscriber batch fetching in campaign processing.
This has been a hair-pulling rabbit hole of an issue. #1931 and others.
When the `next-campaign-subscribers` query that fetches $n subscribers
per batch for a campaign returns no results, the manager assumes
that the campaign is done and marks as finished.

Marathon debugging revealed fundamental flaws in qyery's logic that
would incorrectly return 0 rows under certain conditions.
- Based on the "layout" of subscribers for eg: a series of blocklisted
  subscribers between confirmed subscribers.
  A series of unconfirmed subscribers in a batch belonging to a double
  opt-in list.
- Bulk import blocklisting users, but not marking their subscriptions
  as 'unsubscribed'.
- Conditions spread across multiple CTEs resulted in returning an
  arbitrary number of rows and $N per batch as the selected $N rows
  would get filtered out elsewhere, possibly even becoming 0.

After fixing this and testing it on our prod instance that has
15 million subscribers and ~70 million subscriptions in the
`subscriber_lists` table, ended up discovered significant inefficiences
in Postgres query planning. When `subscriber_lists` and campaign list IDs
are joined dynamically (CTE or ANY() or any kind of JOIN that involves)
a query, the Postgres query planner is unable to use the right indexes.

After testing dozens of approaches, discovered that statically passing
the values to join on (hardcoding or passing via parametrized $1 vars),
the query uses the right indexes. The difference is staggering.
For the particular scenario on our large prod DB to pull a batch,
~15 seconds vs. ~50ms, a whopping 300x improvement!

This patch splits `next-campaign-subscribers` into two separate queries,
one which fetches campaign metadata and list_ids, whose values are then
passed statically to the next query to fetch subscribers by batch.

In addition, it fixes and refactors broken filtering and counting logic
in `create-campaign` and `next-campaign` queries.

Closes #1931, #1993, #1986.
2024-10-13 17:03:59 +05:30
Kailash Nadh
d9b4bae0a8 Rename migration to v4.0.0 2024-10-13 17:03:59 +05:30
Kailash Nadh
eb47e80c35 Fix list auth by adding an explicit 'getAll' flag to query. 2024-10-13 17:03:59 +05:30
Kailash Nadh
ae2a386193 Add support for "list roles".
This commit splits roles into two, user roles and list roles, both of which
are attached separately to a user.

List roles are collection of lists each with read|write permissions, while
user roles now have all permissions except for per-list ones.

This allows for easier management of roles, eliminating the need to clone and
create new roles just to adjust specific list permissions.
2024-10-13 17:03:58 +05:30
Kailash Nadh
12a6451ed0 Add list permission check to subscriber calls. 2024-10-13 17:03:55 +05:30
Kailash Nadh
d74e067961 Add per-list permission to list management.
- Filter lists by permitted list IDs in DB get calls.
- Split getLists() handlers into two (one, all) for clarity.
- Introduce new `subscribers:get_by_list` permission.
- Tweak UI rendering to work with new per-list permssions.
2024-10-13 16:59:52 +05:30
Kailash Nadh
2da920d634 Add legacy TOML user+password to API auth on init with warning. 2024-10-13 16:59:52 +05:30
Kailash Nadh
5024ded763 Add API user authentication to auth module with caching of creds on user CRUD. 2024-10-13 16:59:52 +05:30
Kailash Nadh
e6ec1cb9b3 User legacy (TOML) admin credentials as API creds for backwards compatibility. 2024-10-13 16:59:52 +05:30
Kailash Nadh
1e875afa67 Add OIDC auth hooks (init, callback, session) and finish OIDC support. 2024-10-13 16:59:52 +05:30
Kailash Nadh
72c7676ce5 Add cookie check hack to auth for v3 -> 4 browser BasicAuth session issue. 2024-10-13 16:59:52 +05:30
Kailash Nadh
d52eac0948 Update user APIs and queries to embed role + list permissions. 2024-10-13 16:59:52 +05:30
Kailash Nadh
612c1d6eac Add per-list permission management to roles. 2024-10-13 16:59:52 +05:30
Kailash Nadh
dd9612b1ed Add user profile based permission check in auth middleware. 2024-10-13 16:59:52 +05:30
Kailash Nadh
32d5823dfe Refactor 'super' user type to a pre-defined super admin role. 2024-10-13 16:59:52 +05:30
Kailash Nadh
d4e4c5fa99 Add granular permissions and role management to backend and admin UI. 2024-10-13 16:59:51 +05:30
Kailash Nadh
7bb14de42e Upgrade simplesessions to v3. 2024-10-13 16:59:51 +05:30
Kailash Nadh
4997c10b97 Add user profile APIs and update UI. 2024-10-13 16:59:51 +05:30
Kailash Nadh
a6e06d92f8 Refactor migration for the latest version. 2024-10-13 16:59:51 +05:30
Kailash Nadh
906e0f57b6 Refactor handler groups and add mising auth features like logout. 2024-10-13 16:59:51 +05:30
Kailash Nadh
57ac9dca4b Add public login page and auth middleware and handlers. 2024-10-13 16:59:51 +05:30
Kailash Nadh
1516bf216f Add api type user. 2024-10-13 16:59:51 +05:30
Kailash Nadh
bf0b500bb0 Add API token authentication. 2024-10-13 16:59:51 +05:30
Kailash Nadh
0968e58766 Add user/password login handler. 2024-10-13 16:59:51 +05:30
Kailash Nadh
435d6d5169 Add create/add/delete user management UI and database schema. 2024-10-13 16:59:51 +05:30
Kailash Nadh
4648f9122d Fix bug in OIDC cookie check. 2024-10-13 16:59:51 +05:30
Kailash Nadh
83e4f5def4 Add migrations for OIDC db fields. 2024-10-13 16:59:51 +05:30
Kailash Nadh
f8b3ddb5ee Refactor the oidc package and separate out handlers. 2024-10-13 16:59:51 +05:30
Marc Bärtschi
1b7128abf2 Implement OIDC
This is a simple OIDC implementation. It's very basic and just logs the user in. Access control needs to be done on the IDP side.
2024-10-13 16:59:50 +05:30
Bowrna
16f4dfd3e9
Fix incorrect bulk blocklisting behaviour (#2041). Fixes #1841 2024-09-19 10:56:56 +05:30
Vinoth Kumar
d7fe13c4b9
Fix typo and formatting (#2028) 2024-08-30 13:24:45 +05:30
Vaibhav Dixit
c812caad1a
Fix syntax error in GetBounce method (#2007) 2024-08-27 13:14:29 +05:30
Abhinav Raut
679457cb12
Ensure unique upload filenames by adding a suffix (#1963)
Fixes #1957.

Co-authored-by: Abhinav Raut <abhinav.raut@zerodha.com>
2024-08-08 15:42:29 +05:30
Keshav Gupta
c334d2e6e1
fix #1950:Export of unsubscribed users exports all users (#1965)
Co-authored-by: keshav <keshav.gupta@jarvis.consulting>
2024-08-02 00:05:33 +05:30
Sergey Minkov
3babd9020e
parse cc and bcc from custom headers to add them on email envelope (#1865) 2024-05-18 17:49:24 +05:30