Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: tweaked parameters #1137

Merged
merged 2 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export const getChannelNotifications = async (
}
);
const requestUrl = `${apiEndpoint}/${_channel}/notifications?${query}`;

return await axiosGet(requestUrl)
.then((response) => {
if (raw) return {feeds: response.data?.feeds ?? [], itemcount:response.data?.itemcount} ;
Expand Down
7 changes: 7 additions & 0 deletions packages/restapi/src/lib/constantsV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ const CONSTANTS = {
},
ALPHA_FEATURES: ALPHA_FEATURES,
USER: { ENCRYPTION_TYPE: ENCRYPTION_TYPE },
NOTIFICATION: {
TYPE: {
BROADCAST: 1,
SUBSET: 4,
TARGETTED: 3
}
}
};

export default CONSTANTS;
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ export type NotificationSetting = {
export type NotificationSettings = NotificationSetting[];

export type ChannelFeedsOptions = {
account?: string;
page?: number;
limit?: number;
raw?: boolean;
Expand Down
7 changes: 5 additions & 2 deletions packages/restapi/src/lib/pushNotification/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
getCAIPDetails,
validateCAIP,
getFallbackETHCAIPAddress,
pCAIP10ToWallet,
} from '../helpers';
import PROGRESSHOOK from '../progressHook';
import * as viem from 'viem';
Expand Down Expand Up @@ -412,15 +413,17 @@ export class Channel extends PushNotificationBaseClass {
}
};

notifications = async(options?:ChannelFeedsOptions) => {
notifications = async(account: string, options?:ChannelFeedsOptions) => {
try{
const {
account = this.account,
page,
limit,
filter = null,
raw = true
} = options || {}
if(account.split(":").length == 2){
account = pCAIP10ToWallet(account)
}
return await PUSH_CHANNEL.getChannelNotifications({
channel: account as string,
env: this.env,
Expand Down
13 changes: 4 additions & 9 deletions packages/restapi/tests/lib/notification/channel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ import {
createPublicClient,
} from 'viem';
import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';

export enum NotifictaionType {
BROADCAT = 1,
TARGETTED = 3,
SUBSET = 4
}
import CONSTANTS from '../../../src/lib/constantsV2';

describe('PushAPI.channel functionality', () => {
let userAlice: PushAPI;
Expand Down Expand Up @@ -571,19 +566,19 @@ describe('PushAPI.channel functionality', () => {

describe("notifications", async()=>{
it("Should fetch channel specific feeds", async()=>{
const res = await userAlice.channel.notifications({raw: false})
const res = await userAlice.channel.notifications("eip155:11155111:0xD8634C39BBFd4033c0d3289C4515275102423681",{raw: false})
console.log(res)
expect(res).not.null
})

it("Should fetch channel specific feeds in raw fomrta", async()=>{
const res = await userAlice.channel.notifications({raw: true})
const res = await userAlice.channel.notifications("eip155:0xD8634C39BBFd4033c0d3289C4515275102423681",{raw: true})
console.log(res)
expect(res).not.null
})

it("Should fetch channel specific feeds broadcast type", async()=>{
const res = await userAlice.channel.notifications({raw: true, filter: NotifictaionType.BROADCAT})
const res = await userAlice.channel.notifications("0xD8634C39BBFd4033c0d3289C4515275102423681",{raw: false, filter: CONSTANTS.NOTIFICATION.TYPE.TARGETTED})
console.log(res)
expect(res).not.null
})
Expand Down
Loading