Skip to content

Commit

Permalink
fix: Merge branch 'main' into deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammeds1992 committed Jan 4, 2024
2 parents 57aaf3f + d738ead commit d82102c
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export enum FeedType {
export type FeedsOptions = {
account?: string;
//TODO: change it to string[] once we start supporting multiple channel
channels?: [string];
channels?: string[];
page?: number;
limit?: number;
raw?: boolean;
Expand Down
22 changes: 14 additions & 8 deletions packages/restapi/src/lib/pushNotification/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,21 @@ export class Notification extends PushNotificationBaseClass {
env: this.env,
});
} else {
return await PUSH_USER.getFeedsPerChannel({
user: nonCaipAccount!,
page: page,
limit: limit,
spam: FEED_MAP[spam],
raw: raw,
env: this.env,
channels: channels,
const promises = channels.map(async (channel) => {
return await PUSH_USER.getFeedsPerChannel({
user: nonCaipAccount!,
page: page,
limit: limit,
spam: FEED_MAP[spam],
raw: raw,
env: this.env,
channels: [channel],
});
});

const results = await Promise.all(promises);
const feedRes = results.flat();
return feedRes;
}
} catch (error) {
throw new Error(`Push SDK Error: API : notifcaiton::list : ${error}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
getContract,
WalletClient,
Chain,
toHex,
} from 'viem';
import * as PUSH_CHANNEL from '../channels';
import {
Expand Down Expand Up @@ -457,7 +458,7 @@ export class PushNotificationBaseClass {
throw new Error('viem signer is not provided');
}
const createChannelPromise = contract.write.createChannelWithPUSH({
args: [channelType, identityBytes, fees, this.getTimeBound()],
args: [channelType, toHex(new Uint8Array(identityBytes)), fees, this.getTimeBound()],
});
createChannelRes = await createChannelPromise;
}
Expand Down Expand Up @@ -501,8 +502,8 @@ export class PushNotificationBaseClass {
if (!contract.write) {
throw new Error('viem signer is not provided');
}
const updateChannelPromise = contract.write.createChannelWithPUSH({
args: [account, identityBytes, fees],
const updateChannelPromise = contract.write.updateChannelMeta({
args: [account, toHex(new Uint8Array(identityBytes)), fees],
});
updateChannelRes = await updateChannelPromise;
}
Expand Down
6 changes: 4 additions & 2 deletions packages/restapi/src/lib/user/getFeedsPerChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ import { parseApiResponse } from '../utils';
export type FeedsPerChannelOptionsType = {
user: string;
env?: ENV;
channels?: [string];
channels?: string[];
page?: number;
limit?: number;
spam?: boolean;
raw?: boolean;
};

export const getFeedsPerChannel = async (options: FeedsPerChannelOptionsType) => {
export const getFeedsPerChannel = async (
options: FeedsPerChannelOptionsType
) => {
const {
user,
env = Constants.ENV.PROD,
Expand Down
15 changes: 13 additions & 2 deletions packages/restapi/tests/lib/notification/channel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ describe('PushAPI.channel functionality', () => {
});
});

describe.skip('channel :: update', () => {
describe('channel :: update', () => {
it('Should update channel meta', async () => {
const res = await userKate.channel.update({
name: 'Updated Name',
Expand All @@ -421,6 +421,17 @@ describe('PushAPI.channel functionality', () => {
// console.log(res)
expect(res).not.null;
}, 10000000000);

it('Should update channel meta', async () => {
const res = await viemUser.channel.update({
name: 'Updated Name',
description: 'Testing new description',
url: 'https://google.com',
icon: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAz0lEQVR4AcXBsU0EQQyG0e+saWJ7oACiKYDMEZVs6GgSpC2BIhzRwAS0sgk9HKn3gpFOAv3v3V4/3+4U4Z1q5KTy42Ql940qvFONnFSGmCFmiN2+fj7uCBlihpgh1ngwcvKfwjuVIWaIGWKNB+GdauSk8uNkJfeNKryzYogZYoZY40m5b/wlQ8wQM8TayMlKeKcaOVkJ71QjJyuGmCFmiDUe+HFy4VyEd57hx0mV+0ZliBlihlgL71w4FyMnVXhnZeSkiu93qheuDDFDzBD7BcCyMAOfy204AAAAAElFTkSuQmCC',
});
// console.log(res)
expect(res).not.null;
}, 10000000000);
});

describe.skip('channel :: create', () => {
Expand Down Expand Up @@ -488,7 +499,7 @@ describe('PushAPI.channel functionality', () => {
expect(res).not.null;
}, 10000000000);

it.only('Should create channel setting viem signer', async () => {
it('Should create channel setting viem signer', async () => {
const res = await viemUser.channel.setting([
{
type: 1,
Expand Down
26 changes: 26 additions & 0 deletions packages/restapi/tests/lib/notification/notification.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,32 @@ describe('PushAPI.notification functionality', () => {
// console.log(response)
expect(response).not.null;
});

it('Should return feeds when signer with provider is used', async () => {
const response = await userKate.notification.list('INBOX', {
account: '0xD8634C39BBFd4033c0d3289C4515275102423681',
channels: [
'0xD8634C39BBFd4033c0d3289C4515275102423681',
'0x53474D90663de06BEf5D0017F450730D83168063',
],
raw: true,
});
// console.log(response)
expect(response).not.null;
});

it('Should return feeds when signer with provider is used', async () => {
const response = await userKate.notification.list('INBOX', {
account: 'eip155:11155111:0xD8634C39BBFd4033c0d3289C4515275102423681',
channels: [
'eip155:11155111:0xD8634C39BBFd4033c0d3289C4515275102423681',
'eip155:11155111:0x53474D90663de06BEf5D0017F450730D83168063',
],
raw: true,
});
// console.log(response);
expect(response).not.null;
});
});

describe('notification :: subscribe', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export const ChatViewList: React.FC<IChatViewListProps> = (

//moniters socket changes
useEffect(() => {
if (checkIfSameChat(messagesSinceLastConnection, account!, chatId)) {
if (checkIfSameChat(messagesSinceLastConnection, account!, chatId.includes(":") ? chatId.split(":")[1] : chatId)) {
const updatedChatFeed = chatFeed;
updatedChatFeed.msg = messagesSinceLastConnection;
if (!Object.keys(messages || {}).length) {
Expand All @@ -150,7 +150,6 @@ export const ChatViewList: React.FC<IChatViewListProps> = (
[messagesSinceLastConnection],
false
);

setFilteredMessages(newChatViewList as IMessageIPFSWithCID[]);
}
setChatStatusText('');
Expand Down

0 comments on commit d82102c

Please sign in to comment.