mirror of
https://github.com/knadh/listmonk.git
synced 2025-09-17 11:55:46 +08:00
Add all
to subscriber deletion by query which broke with query
validation. Ref: #2122.
This commit is contained in:
parent
a1291114d9
commit
7bfbd6a856
3 changed files with 12 additions and 5 deletions
|
@ -30,6 +30,7 @@ type subQueryReq struct {
|
|||
Action string `json:"action"`
|
||||
Status string `json:"status"`
|
||||
SubscriptionStatus string `json:"subscription_status"`
|
||||
All bool `json:"all"`
|
||||
}
|
||||
|
||||
// subProfileData represents a subscriber's collated data in JSON
|
||||
|
@ -439,7 +440,9 @@ func handleDeleteSubscribersByQuery(c echo.Context) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if req.Query == "" {
|
||||
if req.All {
|
||||
req.Query = ""
|
||||
} else if req.Query == "" {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, app.i18n.Ts("globals.messages.invalidFields", "name", "query"))
|
||||
}
|
||||
|
||||
|
|
|
@ -604,10 +604,11 @@ Delete subscribers based on SQL expression.
|
|||
|
||||
##### Parameters
|
||||
|
||||
| Name | Type | Required | Description |
|
||||
|:---------|:---------|:---------|:--------------------------------------------|
|
||||
| query | string | Yes | SQL expression to filter subscribers with. |
|
||||
| list_ids | []number | No | Optional list IDs to limit the filtering to.|
|
||||
| Name | Type | Required | Description |
|
||||
|:---------|:---------|:---------|:-------------------------------------------------------------------|
|
||||
| query | string | No | SQL expression to filter subscribers with. |
|
||||
| list_ids | []number | No | Optional list IDs to limit the filtering to. |
|
||||
| all | bool | No | When set to `true`, ignores any query and deletes all subscribers. |
|
||||
|
||||
|
||||
##### Example Request
|
||||
|
|
|
@ -423,6 +423,9 @@ export default Vue.extend({
|
|||
// 'All' is selected, delete by query.
|
||||
fn = () => {
|
||||
this.$api.deleteSubscribersByQuery({
|
||||
// If the query expression is empty, explicitly pass `all=true`
|
||||
// so that the backend deletes all records in the DB with an empty query string.
|
||||
all: this.queryParams.queryExp.trim() === '',
|
||||
query: this.queryParams.queryExp,
|
||||
list_ids: this.queryParams.listID ? [this.queryParams.listID] : null,
|
||||
subscription_status: this.queryParams.subStatus,
|
||||
|
|
Loading…
Add table
Reference in a new issue