neynarxyz / nodejs-sdk

Typescript SDK for Neynar APIs
https://neynar.com
MIT License
53 stars 11 forks source link

feat: add priority mode for notifications #175

Closed valerierose closed 1 month ago

valerierose commented 2 months ago

Overview

Adds a priorityMode option for notifications. This returns only notifications from users that the given user follows and users that have a power badge.

Example

With priorityMode: false

# index.js
const result = await client.fetchAllNotifications(489795, {priorityMode: false});
console.log(JSON.stringify(result));
$ node index.js node index.js | jq '.notifications[] | {
  "type": .type,
  "username": .cast.author.username,
  "power_badge": .cast.author.power_badge,
  "following": .cast.author.viewer_context.following
}'

{
  "type": "reply",
  "username": "pobstudio",
  "power_badge": false,
  "following": true
}
{
  "type": "reply",
  "username": "g4mer15",
  "power_badge": false,
  "following": false
}
{
  "type": "reply",
  "username": "g4mer15",
  "power_badge": false,
  "following": false
}

With priorityMode: true

# index.js
const result = await client.fetchAllNotifications(489795, {priorityMode: true});
console.log(JSON.stringify(result));
$ node index.js node index.js | jq '.notifications[] | {
  "type": .type,
  "username": .cast.author.username,
  "power_badge": .cast.author.power_badge,
  "following": .cast.author.viewer_context.following
}'

{
  "type": "reply",
  "username": "pobstudio",
  "power_badge": false,
  "following": true
}
{
  "type": "mention",
  "username": "icetoad.eth",
  "power_badge": true,
  "following": true
}
{
  "type": "reply",
  "username": "emilee",
  "power_badge": false,
  "following": true
}