Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 2 additions & 7 deletions src/drive/share/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
UpdateUserRolePayload,
UpdateUserRoleResponse,
} from './types';
import { ItemType } from 'src/workspaces';

export * as ShareTypes from './types';

Expand Down Expand Up @@ -363,13 +364,7 @@ export class Share {
* @returns {Promise<{ data: SharingInvite[] }>} A promise containing the private folder data.
*/

public getSharedFolderInvitations({
itemId,
itemType,
}: {
itemId: string;
itemType: 'folder' | 'file';
}): Promise<any[]> {
public getSharedFolderInvitations({ itemId, itemType }: { itemId: string; itemType: ItemType }): Promise<any[]> {
return this.client.get(`sharings/${itemType}/${itemId}/invites`, this.headers());
}

Expand Down
26 changes: 22 additions & 4 deletions src/drive/share/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FolderChild } from '../storage/types';
import { ItemType } from './../../workspaces/types';

export interface GenerateShareLinkPayload {
itemId: string;
Expand Down Expand Up @@ -78,6 +79,21 @@ export interface ShareDomainsResponse {
list: string[];
}

export interface WorkspaceItemUser {
id: string;
itemId: string;
itemType: ItemType;
workspaceId: string;
createdAt: string | null;
updatedAt: string | null;
creator: {
uuid: string;
name: string;
lastname: string;
email: string;
};
}

export type ListShareLinksItem = Pick<
ShareLink,
'id' | 'token' | 'views' | 'timesValid' | 'active' | 'isFolder' | 'createdAt' | 'updatedAt' | 'fileSize'
Expand Down Expand Up @@ -113,6 +129,7 @@ export type SharedFolders = {
type: string;
updatedAt: string;
user: { avatar: string | null; email: string; lastname: string; name: string; uuid: string };
workspaceItemUser: WorkspaceItemUser;
userId: number;
uuid: string;
};
Expand All @@ -139,6 +156,7 @@ export type SharedFiles = {
thumbnails: [];
type: string;
updatedAt: string;
workspaceItemUser: WorkspaceItemUser;
userId: number;
uuid: string;
};
Expand All @@ -160,7 +178,7 @@ export type ListAllSharedFoldersResponse = {

export type ShareFolderWithUserPayload = {
itemId: string;
itemType: 'folder' | 'file';
itemType: ItemType;
notifyUser: boolean;
notificationMessage?: string;
sharedWith: string;
Expand All @@ -172,7 +190,7 @@ export type ShareFolderWithUserPayload = {

export type CreateSharingPayload = {
itemId: string;
itemType: 'folder' | 'file';
itemType: ItemType;
encryptionKey: string;
encryptionAlgorithm: string;
encryptedCode: string;
Expand Down Expand Up @@ -312,7 +330,7 @@ export type SharingInvitation = {
export type SharingInvite = {
id: string;
itemId: string;
itemType: 'file' | 'folder';
itemType: ItemType;
sharedWith: string;
encryptionKey: string;
encryptionAlgorithm: string;
Expand All @@ -325,7 +343,7 @@ export type SharingInvite = {
export type SharingMeta = {
id: string;
itemId: string;
itemType: 'file' | 'folder';
itemType: ItemType;
ownerId: string;
sharedWith: string;
encryptionKey: string;
Expand Down
15 changes: 15 additions & 0 deletions src/drive/storage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ApiSecurity, ApiUrl, AppDetails } from '../../shared';
import { CustomHeaders, addResourcesTokenToHeaders, headersWithToken } from '../../shared/headers';
import { HttpClient, RequestCanceler } from '../../shared/http/client';
import { UUID } from '../../shared/types/userSettings';
import { ItemType } from './../../workspaces/types';
import {
AddItemsToTrashPayload,
CheckDuplicatedFilesPayload,
Expand Down Expand Up @@ -642,6 +643,20 @@ export class Storage {
return this.client.get<FolderAncestor[]>(`folders/${uuid}/ancestors?isSharedItem=${isShared}`, this.headers());
}

/**
* Gets the ancestors of a given UUID and type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Gets the ancestors of an item with the given UUID and type

*
* @param {string} uuid - UUID of the item.
* @param {string} itemType - itemType to know if the item is file or folder
* @returns {Promise<FolderAncestor[]>} A promise that resolves with an array of ancestors of the given folder.
*/
public getFolderAncestorsV2(uuid: string, itemType: ItemType, resourcesToken?: string): Promise<FolderAncestor[]> {
return this.client.get<FolderAncestor[]>(
`folders/${itemType}/${uuid}/ancestors`,
addResourcesTokenToHeaders(this.headers(), resourcesToken),
);
}

/**
* Gets the meta of a given folder UUID
*
Expand Down
Loading