Skip to content

Commit

Permalink
fix: params
Browse files Browse the repository at this point in the history
  • Loading branch information
paulclindo committed Nov 6, 2023
1 parent fd8499e commit d50e1be
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 51 deletions.
7 changes: 3 additions & 4 deletions apps/shinkai-app/src/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,15 @@ const MessageButton = ({ inbox }: { inbox: SmartInbox }) => {
if (!auth) return;
console.log('data', data);
await updateInboxName({
sender: auth.shinkai_identity,
senderSubidentity: auth.profile,
receiver: `${auth.shinkai_identity}`,
sender: auth?.shinkai_identity ?? '',
senderSubidentity: `${auth?.profile}/device/${auth?.registration_name}`,
receiver: auth.shinkai_identity,
receiverSubidentity: '',
my_device_encryption_sk: auth.my_device_encryption_sk,
my_device_identity_sk: auth.my_device_identity_sk,
node_encryption_pk: auth.node_encryption_pk,
profile_encryption_sk: auth.profile_encryption_sk,
profile_identity_sk: auth.profile_identity_sk,

inboxId: decodeURIComponent(inbox.inbox_id),
inboxName: data.inboxName,
});
Expand Down
6 changes: 3 additions & 3 deletions libs/shinkai-message-ts/src/api/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,10 @@ export const updateInboxName = async (
setupDetailsState.my_device_encryption_sk,
setupDetailsState.my_device_identity_sk,
setupDetailsState.node_encryption_pk,
sender,
sender_subidentity,
sender + '/' + sender_subidentity,
"",
receiver,
receiver_subidentity,
"",
inboxId,
inboxName
);
Expand Down
47 changes: 3 additions & 44 deletions libs/shinkai-node-state/src/lib/mutations/updateInboxName/index.ts
Original file line number Diff line number Diff line change
@@ -1,56 +1,15 @@
import { ApiConfig, handleHttpError } from "@shinkai_network/shinkai-message-ts/api";
import {
type CredentialsPayload,
updateInboxName as updateInboxNameApi,
} from '@shinkai_network/shinkai-message-ts/api';
import {
type ShinkaiMessage,
} from "@shinkai_network/shinkai-message-ts/models";
import {
ShinkaiMessageBuilderWrapper,
} from "@shinkai_network/shinkai-message-ts/wasm";

export type SmartInbox = {
custom_name: string;
inbox_id: string;
last_message: ShinkaiMessage;
};

export const updateInboxNameApi = async (
sender: string,
sender_subidentity: string,
receiver: string,
receiver_subidentity: string,
setupDetailsState: CredentialsPayload,
inboxName: string,
inboxId: string
): Promise<SmartInbox[]> => {
try {
const messageString = ShinkaiMessageBuilderWrapper.update_shinkai_inbox_name(
setupDetailsState.my_device_encryption_sk,
setupDetailsState.my_device_identity_sk,
setupDetailsState.node_encryption_pk,
sender,
sender_subidentity,
receiver,
receiver_subidentity,
inboxId,
inboxName
);

const message = JSON.parse(messageString);

const apiEndpoint = ApiConfig.getInstance().getEndpoint();
const response = await fetch(`${apiEndpoint}/v1/update_smart_inbox_name`, {
method: "POST",
body: JSON.stringify(message),
headers: { "Content-Type": "application/json" },
});
const data = await response.json();
await handleHttpError(response);
return data.data;
} catch (error) {
console.error("Error updating inbox name:", error);
throw error;
}
};

export const updateInboxName = async ({
senderSubidentity,
Expand Down

0 comments on commit d50e1be

Please sign in to comment.