diff --git a/client/src/account/API.js b/client/src/account/API.js index 4f0a889f..42636879 100644 --- a/client/src/account/API.js +++ b/client/src/account/API.js @@ -86,18 +86,44 @@ export default class API extends Component { -
-
- POST /api/subscribe/:listId – {t('addSubscription')} -
-
-

- {t('thisApiCallEitherInsertsANewSubscription')} -

-
-
-

POST /api/subscribe/:listId – {t('addSubscription')}

+
+
+
+ +
+
+
+

+ {t('Get subscribers')} +

+

+ {t('Query params')} +

+
    +
  • access_token – {t('yourPersonalAccessToken')} +
      +
    • start – {t('startPosition')} ({t('optionalDefault0')})
    • +
    • limit – {t('limitEmailsCountInResponse')} ({t('optionalDefault10000')})
    • +
    +
  • +
+ +

+ {t('example')} +

+ +
curl -XGET '{getUrl(`api/subscriptions/P5wKkz-e7?access_token=${accessToken}&limit=10&start=10&search=gmail`)}' 
+ +
+
+
+
+
+

+
+
+

{t('thisApiCallEitherInsertsANewSubscription')}

@@ -141,8 +167,20 @@ export default class API extends Component {
curl -XPOST '{getUrl(`api/subscribe/B16uVTdW?access_token=${accessToken}`)}' \
--data 'EMAIL=test@example.com&MERGE_CHECKBOX=yes&REQUIRE_CONFIRMATION=yes'
-

POST /api/unsubscribe/:listId – {t('removeSubscription')}

+

+ {t('Response example')}: +

+
"data": ("id":"TTrw41znK")
+
+
+
+
+
+ +
+
+

{t('thisApiCallMarksASubscriptionAs')}

@@ -168,8 +206,20 @@ export default class API extends Component {
curl -XPOST '{getUrl(`api/unsubscribe/B16uVTdW?access_token=${accessToken}`)}' \
--data 'EMAIL=test@example.com'
-

POST /api/delete/:listId – {t('deleteSubscription')}

+

+ {t('Response example')}: +

+
"data": ("id":"TTrw41znK", "unsubscribed":true)
+
+
+
+
+
+ +
+
+

{t('thisApiCallDeletesASubscription')}

@@ -194,9 +244,20 @@ export default class API extends Component {
curl -XPOST '{getUrl(`api/delete/B16uVTdW?access_token=${accessToken}`)}' \
--data 'EMAIL=test@example.com'
+

+ {t('Response example')}: +

+
"data": ("id":"TTrw41znK", "deleted":true)
-

POST /api/field/:listId – {t('addNewCustomField')}

- +
+
+
+
+
+ +
+
+

{t('thisApiCallCreatesANewCustomFieldForA')}

@@ -241,11 +302,21 @@ export default class API extends Component {

curl -XPOST '{getUrl(`api/field/B16uVTdW?access_token=${accessToken}`)}' \
---data 'NAME=Birthday&TYPE=birthday-us&VISIBLE=yes'
- -

GET /api/blacklist/get – {t('getListOfBlacklistedEmails')}

- +--data 'NAME=Comment&TYPE=text'

+ {t('Response example')}: +

+
"data": ("id":22, "tag":"MERGE_COMMENT")
+
+
+
+
+
+ +
+
+
+

{t('thisApiCallGetListOfBlacklistedEmails')}

@@ -268,8 +339,15 @@ export default class API extends Component {
curl -XGET '{getUrl(`api/blacklist/get?access_token=${accessToken}&limit=10&start=10&search=gmail`)}' 
-

POST /api/blacklist/add – {t('addEmailToBlacklist')}

- +
+
+
+
+
+ +
+
+

{t('thisApiCallEitherAddEmailsToBlacklist')}

@@ -294,9 +372,15 @@ export default class API extends Component {
curl -XPOST '{getUrl(`api/blacklist/add?access_token=${accessToken}`)}' \
--data 'EMAIL=test@example.com'
- -

POST /api/blacklist/delete – {t('deleteEmailFromBlacklist')}

- +
+
+
+
+
+ +
+
+

{t('thisApiCallEitherDeleteEmailsFrom')}

@@ -321,9 +405,15 @@ export default class API extends Component {
curl -XPOST '{getUrl(`api/blacklist/delete?access_token=${accessToken}`)}' \
--data 'EMAIL=test@example.com'
- -

GET /api/lists/:email – {t('getTheListsAUserHasSubscribedTo')}

- +
+
+
+
+
+ +
+
+

{t('retrieveTheListsThatTheUserWithEmailHas')}

@@ -340,10 +430,15 @@ export default class API extends Component {

curl -XGET '{getUrl(`api/lists/test@example.com?access_token=${accessToken}`)}'
- - -

GET /api/lists-by-namespace/:namespaceId – {t('getListsInNamespace')}

- +
+
+
+
+
+ +
+
+

{t('retrieveTheListsThatTheNamespaceHas')}

@@ -360,10 +455,15 @@ export default class API extends Component {

curl -XGET '{getUrl(`api/lists-by-namespace/1?access_token=${accessToken}`)}'
- - -

POST /api/lists – {t('createList')}

- +
+
+
+
+
+ +
+
+

{t('createListDescription')}

@@ -423,10 +523,19 @@ export default class API extends Component { -d 'PUBLIC_SUBSCRIBE=1' \
-d 'LISTUNSUBSCRIBE_DISABLED=0' - - -

DELETE /api/lists/:listId – {t('deleteList')}

- +

+ {t('Response example')}: +

+
"data": ("id":"WSGjaP1fY")
+
+
+
+
+
+ +
+
+

{t('deleteListDescription')}

@@ -442,11 +551,20 @@ export default class API extends Component { {t('example')}

-
curl -XDELETE '{getUrl(`api/list/B16uVTdW?access_token=${accessToken}`)}'
- - -

GET /api/rss/fetch/:campaignCid – {t('triggerFetchOfACampaign')}

- +
curl -XDELETE '{getUrl(`api/list/WSGjaP1fY?access_token=${accessToken}`)}'
+

+ {t('Response example')}: +

+
{t('Empty object')}
+
+
+
+
+
+ +
+
+

{t('forcesTheRssFeedCheckToImmediatelyCheck')}

@@ -463,9 +581,15 @@ export default class API extends Component {

curl -XGET '{getUrl(`api/rss/fetch/5OOnZKrp0?access_token=${accessToken}`)}'
- -

POST /api/templates/:templateId/send – {t('sendTransactionalEmail')}

- +
+
+
+
+
+ +
+
+

{t('sendSingleEmailByTemplateWithGiven')}

@@ -494,6 +618,13 @@ export default class API extends Component {
curl -XPOST '{getUrl(`api/templates/1/send?access_token=${accessToken}`)}' \
--data 'EMAIL=test@example.com&SUBJECT=Test&TAGS[FOO]=bar&TAGS[TEST]=example'
+
+
+
+
+ + + ); } diff --git a/server/models/subscriptions.js b/server/models/subscriptions.js index 82efd052..03ef63a6 100644 --- a/server/models/subscriptions.js +++ b/server/models/subscriptions.js @@ -866,13 +866,14 @@ async function getListsWithEmail(context, email) { // FIXME - this methods is rather suboptimal if there are many lists. It quite needs permission caching in shares.js return await knex.transaction(async tx => { - const lsts = await tx('lists').select(['id', 'cid', 'name']); + const lsts = await tx('lists').select(['id', 'cid', 'name', 'description']); const result = []; for (const list of lsts) { await shares.enforceEntityPermissionTx(tx, context, 'list', list.id, 'viewSubscriptions'); const entity = await tx(getSubscriptionTableName(list.id)).where('hash_email', hashEmail(email)).whereNotNull('email').first(); if (entity) { + list.status=entity.status; result.push(list); } } diff --git a/server/routes/api.js b/server/routes/api.js index caeb26f2..aac6c2a4 100644 --- a/server/routes/api.js +++ b/server/routes/api.js @@ -110,7 +110,7 @@ router.postAsync('/unsubscribe/:listCid', passport.loggedIn, async (req, res) => res.status(200); res.json({ data: { - id: subscription.id, + id: subscription.cid, unsubscribed: true } }); @@ -133,7 +133,7 @@ router.postAsync('/delete/:listCid', passport.loggedIn, async (req, res) => { res.status(200); res.json({ data: { - id: subscription.id, + id: subscription.cid, deleted: true } }); @@ -227,7 +227,7 @@ router.postAsync('/field/:listCid', passport.loggedIn, async (req, res) => { input[(key || '').toString().trim().toUpperCase()] = (req.body[key] || '').toString().trim(); }); - const key = (input.NAME || '').toString().trim() || slugify('merge ' + name, '_').toUpperCase(); + const key = slugify('merge ' + input.NAME, '_').toUpperCase(); const visible = ['false', 'no', '0', ''].indexOf((input.VISIBLE || '').toString().toLowerCase().trim()) < 0; const groupTemplate = (input.GROUP_TEMPLATE || '').toString().toLowerCase().trim();