in apps/chat-e2e/src/testData/api/shareApiHelper.ts [19:77]
public async shareEntityByLink(
entities: Conversation[] | Prompt[],
isFolder = false,
folderToShare?: string,
) {
const resources: { url: string }[] = [];
for (const entity of entities) {
let url: string;
if (isFolder) {
if (folderToShare !== undefined) {
const folderIndex = entity.folderId.indexOf(folderToShare);
url = `${entity.folderId.substring(0, folderIndex + folderToShare.length)}/`;
} else {
url = `${entity.folderId!}/`;
}
} else {
url = entity.id!;
}
if (!resources.find((r) => r.url === url)) {
resources.push({ url: ItemUtil.getEncodedItemId(url) });
}
if ('messages' in entity) {
entity.messages.map((m) =>
m.custom_content?.attachments?.forEach((a) => {
if (a.reference_url === undefined) {
resources.push({ url: a.url! });
}
}),
);
entity.playback?.messagesStack.map((m) =>
m.custom_content?.attachments?.forEach((a) => {
if (a.reference_url === undefined) {
resources.push({ url: a.url! });
}
}),
);
}
}
// for (const r of resources) {
// r.url = ItemUtil.getEncodedItemId(r.url);
// }
const requestData: ShareRequestModel = {
invitationType: ShareRequestType.link,
resources: resources,
};
const response = await this.request.post(API.shareConversationHost, {
data: requestData,
});
expect(
response.status(),
`Successfully created share invitation link`,
).toBe(200);
const responseText = await response.text();
return JSON.parse(responseText) as ShareByLinkResponseModel;
}