Skip to content

Commit

Permalink
Merge pull request #4462 from Countly/hotfix/push
Browse files Browse the repository at this point in the history
[push] Docs: fixing required fields, adding example
  • Loading branch information
Cookiezaurs authored Aug 21, 2023
2 parents c805bcf + 71a84f1 commit 49b4f82
Showing 1 changed file with 95 additions and 10 deletions.
105 changes: 95 additions & 10 deletions plugins/push/api/api-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ module.exports.one = async params => {
* @apiSuccess {Object} [notifications] Map of notification ID to array of epochs this message was sent to the user
* @apiSuccess {Object[]} [messages] Array of messages, returned if "messages" param is set to "true"
*
* @apiDeprecated use now (#Push Notifications:notifications)
* @apiDeprecated use now (#Push_Notifications:notifications)
* @apiUse PushValidationError
* @apiError NotFound Message Not Found
* @apiErrorExample {json} NotFound
Expand Down Expand Up @@ -808,23 +808,27 @@ module.exports.user = async params => {
* @param {object} params params
* @returns {Promise} resolves to true
*
* @api {GET} o/push/notifications User notifications
* @api {GET} o/push/notifications Sent notifications
* @apiName notifications
* @apiDescription Get notifications sent to a particular user.
* Makes a look up either by user id (uid) or did (device id). Returns notifications sent to a user if any.
* @apiGroup Push Notifications
*
* @apiQuery {String} app_id REQUIRED, Application ID
* @apiQuery {String} [id] User ID (uid)
* @apiQuery {String} [did] User device ID (did)
* @apiQuery {Boolean} [full] REQUIRED, return full messages along with simplified notifications. Note that true here will limit number of returned notifications to 10.
* @apiQuery {String} [platform] REQUIRED, filter messages by platform
* @apiQuery {Integer} [skip] REQUIRED, messages pagination skip
* @apiQuery {Integer} [limit] REQUIRED, messages pagination limit, must be in 1..50 range
* @apiQuery {String} app_id, Application ID
* @apiQuery {String} [id] User ID (uid). Either id or did must be specified.
* @apiQuery {String} [did] User device ID (did). Either id or did must be specified.
* @apiQuery {Boolean} full Return full messages along with simplified notifications. Note that true here will limit number of returned notifications to 10.
* @apiQuery {String} platform Platform for notifications to return
* @apiQuery {Integer} skip Pagination skip
* @apiQuery {Integer} limit Pagination limit, must be in 1..50 range
*
* @apiSuccess {Object[]} [notifications] Array of simplified notifications objects with id, title, message and date properties representing a notification sent to a user at a particular date.
* @apiSuccess {Object[]} notifications Array of simplified notifications objects with _id, title, message and date properties representing a notification sent to a user at a particular date.
* Please note that returned title & message might not be accurate for cases when notification content was overridden in a message/push call as Countly doesn't keep this data after sending notifications. Default title & message will be returned in such cases.
* Also note that current user profile properties are used for message content personalization when it's set.
* @apiSuccess {String} notifications._id Noficiation message id
* @apiSuccess {String} notifications.date ISO date when notification was sent to this user, +- few seconds
* @apiSuccess {String} [notifications.title] Noficiation title string, if any
* @apiSuccess {String} [notifications.message] Noficiation message string, if any
*
* @apiUse PushValidationError
* @apiError NotFound Message Not Found
Expand All @@ -833,6 +837,87 @@ module.exports.user = async params => {
* {
* "errors": ["User with the did specified is not found"]
* }
* @apiSuccessExample {json} Success-Response
* HTTP/1.1 200 Success
* {
* "notifications": [
* {
* "_id": "6480d8a03f9ea25502c816ce",
* "title": "Offers!",
* "message": "Hi James, check out your personal limited offer",
* "date": "2023-06-07T19:26:08.683Z"
* },
* {
* "_id": "6465fede1276bf50b2662765",
* "title": "Balance",
* "message": "James, your balance is reaching 0",
* "date": "2023-06-08T19:00:08.683Z"
* }
* ]
* }
*
* @apiSuccessExample {json} Success-Response-full=true
* HTTP/1.1 200 Success
* {
* "notifications": [
* {
* "_id": "6480d8a03f9ea25502c816ce",
* "title": "Offers!",
* "message": "Hi James, check out your personal limited offer",
* "date": "2023-06-07T19:26:08.683Z"
* },
* {
* "_id": "6465fede1276bf50b2662765",
* "title": "Balance",
* "message": "James, your balance is reaching 0",
* "date": "2023-06-08T19:00:08.683Z"
* }
* ],
* "messages": [
* {
* "_id": "6480d8a03f9ea25502c816ce",
* "app": "5fbb72974e19c6614411d95f",
* "contents": [
* {
* "title": "Offers!",
* "message": "Hi James, check out your personal limited offer",
* "expiration": 604800000
* },
* {
* "p": "a",
* "sound": "default"
* },
* {
* "p": "i",
* "sound": "default"
* }
* ],
* "filter": {},
* "other message fields": "..."
* },
* {
* "_id": "6465fede1276bf50b2662765",
* "app": "5fbb72974e19c6614411d95f",
* "contents": [
* {
* "title": "Balance",
* "message": "James, your balance is reaching 0",
* "expiration": 604800000
* },
* {
* "p": "a",
* "sound": "default"
* },
* {
* "p": "i",
* "sound": "default"
* }
* ],
* "filter": {},
* "other message fields": "..."
* }
* ]
* }
*/
module.exports.notificationsForUser = async params => {
let data = common.validateArgs(params.qstring, {
Expand Down

0 comments on commit 49b4f82

Please sign in to comment.