2022-06-23 09:48:01 +00:00
|
|
|
import { request } from "../client";
|
2022-07-08 15:29:50 +00:00
|
|
|
import { decodeDisplayName } from "../../utils";
|
2022-07-12 07:22:19 +00:00
|
|
|
import { FolderType } from "../../constants";
|
2022-06-23 09:48:01 +00:00
|
|
|
|
|
|
|
export function getRooms(filter) {
|
|
|
|
const options = {
|
|
|
|
method: "get",
|
|
|
|
url: `/files/rooms?${filter.toApiUrlParams()}`,
|
|
|
|
};
|
|
|
|
|
|
|
|
return request(options).then((res) => {
|
2022-07-08 15:22:11 +00:00
|
|
|
res.files = decodeDisplayName(res.files);
|
|
|
|
res.folders = decodeDisplayName(res.folders);
|
2022-07-12 07:22:19 +00:00
|
|
|
|
|
|
|
if (res.current.rootFolderType === FolderType.Archive) {
|
|
|
|
res.folders.forEach((room) => (room.isArchive = true));
|
|
|
|
}
|
|
|
|
|
2022-06-23 09:48:01 +00:00
|
|
|
return res;
|
|
|
|
});
|
|
|
|
}
|
2022-06-28 10:24:31 +00:00
|
|
|
|
2022-07-16 06:50:32 +00:00
|
|
|
export function getRoomInfo(id) {
|
2022-07-01 15:28:24 +00:00
|
|
|
const options = {
|
|
|
|
method: "get",
|
|
|
|
url: `/files/rooms/${id}`,
|
|
|
|
};
|
|
|
|
|
|
|
|
return request(options).then((res) => {
|
|
|
|
return res;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-09-06 20:36:59 +00:00
|
|
|
export function getRoomMembers(id) {
|
|
|
|
const options = {
|
|
|
|
method: "get",
|
|
|
|
url: `/files/rooms/${id}/share`,
|
|
|
|
};
|
|
|
|
|
|
|
|
return request(options).then((res) => {
|
|
|
|
return res;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-10-31 15:27:03 +00:00
|
|
|
export function updateRoomMemberRole(id, data) {
|
|
|
|
const options = {
|
|
|
|
method: "put",
|
|
|
|
url: `/files/rooms/${id}/share`,
|
|
|
|
data,
|
|
|
|
};
|
|
|
|
|
|
|
|
return request(options).then((res) => {
|
|
|
|
return res;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-09-26 07:37:57 +00:00
|
|
|
export function getHistory(module, id) {
|
|
|
|
const options = {
|
|
|
|
method: "get",
|
|
|
|
url: `/feed/filter?module=${module}&withRelated=true&id=${id}`,
|
|
|
|
};
|
|
|
|
|
|
|
|
return request(options).then((res) => {
|
|
|
|
return res;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-09-16 12:12:37 +00:00
|
|
|
export function getRoomHistory(id) {
|
|
|
|
const options = {
|
|
|
|
method: "get",
|
|
|
|
url: `/feed/filter?module=rooms&withRelated=true&id=${id}`,
|
|
|
|
};
|
|
|
|
|
|
|
|
return request(options).then((res) => {
|
|
|
|
return res;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-09-26 07:37:57 +00:00
|
|
|
export function getFileHistory(id) {
|
|
|
|
const options = {
|
|
|
|
method: "get",
|
|
|
|
url: `/feed/filter?module=files&withRelated=true&id=${id}`,
|
|
|
|
};
|
|
|
|
|
|
|
|
return request(options).then((res) => {
|
2022-07-01 15:28:24 +00:00
|
|
|
return res;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-06-28 10:24:31 +00:00
|
|
|
export function createRoom(data) {
|
|
|
|
const options = { method: "post", url: `/files/rooms`, data };
|
|
|
|
|
|
|
|
return request(options).then((res) => {
|
|
|
|
return res;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-07-19 23:08:51 +00:00
|
|
|
export function createRoomInThirdpary(id, data) {
|
|
|
|
const options = {
|
|
|
|
method: "post",
|
2022-07-25 15:14:16 +00:00
|
|
|
url: `/files/rooms/thirdparty/${id}`,
|
2022-07-19 23:08:51 +00:00
|
|
|
data,
|
|
|
|
};
|
|
|
|
|
|
|
|
return request(options).then((res) => {
|
|
|
|
return res;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-08-01 06:51:55 +00:00
|
|
|
export function editRoom(id, data) {
|
|
|
|
const options = { method: "put", url: `/files/rooms/${id}`, data };
|
|
|
|
|
|
|
|
return request(options).then((res) => {
|
|
|
|
return res;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-06-28 10:24:31 +00:00
|
|
|
export function pinRoom(id) {
|
|
|
|
const options = { method: "put", url: `/files/rooms/${id}/pin` };
|
|
|
|
|
|
|
|
return request(options).then((res) => {
|
|
|
|
return res;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
export function unpinRoom(id) {
|
|
|
|
const options = { method: "put", url: `/files/rooms/${id}/unpin` };
|
|
|
|
|
|
|
|
return request(options).then((res) => {
|
|
|
|
return res;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-07-16 06:50:32 +00:00
|
|
|
export function deleteRoom(id, deleteAfter = true) {
|
|
|
|
const data = { deleteAfter };
|
|
|
|
|
2022-06-28 10:24:31 +00:00
|
|
|
const options = {
|
|
|
|
method: "delete",
|
|
|
|
url: `/files/rooms/${id}`,
|
2022-07-16 06:50:32 +00:00
|
|
|
data,
|
2022-06-28 10:24:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return request(options).then((res) => {
|
|
|
|
return res;
|
|
|
|
});
|
|
|
|
}
|
2022-07-01 08:58:41 +00:00
|
|
|
|
2022-10-20 16:34:21 +00:00
|
|
|
export function archiveRoom(id, deleteAfter = false) {
|
2022-07-16 06:50:32 +00:00
|
|
|
const data = { deleteAfter };
|
|
|
|
|
2022-07-01 08:58:41 +00:00
|
|
|
const options = {
|
|
|
|
method: "put",
|
|
|
|
url: `/files/rooms/${id}/archive`,
|
2022-07-16 06:50:32 +00:00
|
|
|
data,
|
2022-07-01 08:58:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return request(options).then((res) => {
|
|
|
|
return res;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-07-16 06:50:32 +00:00
|
|
|
export function unarchiveRoom(id, deleteAfter = true) {
|
|
|
|
const data = { deleteAfter };
|
2022-07-01 08:58:41 +00:00
|
|
|
const options = {
|
|
|
|
method: "put",
|
|
|
|
url: `/files/rooms/${id}/unarchive`,
|
2022-07-16 06:50:32 +00:00
|
|
|
data,
|
2022-07-01 08:58:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return request(options).then((res) => {
|
|
|
|
return res;
|
|
|
|
});
|
|
|
|
}
|
2022-07-08 07:41:00 +00:00
|
|
|
|
2022-07-25 15:14:16 +00:00
|
|
|
export function createTag(name) {
|
|
|
|
const data = { name };
|
|
|
|
const options = {
|
|
|
|
method: "post",
|
|
|
|
url: "/files/tags",
|
|
|
|
data,
|
|
|
|
};
|
|
|
|
|
|
|
|
return request(options).then((res) => {
|
|
|
|
return res;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
export function addTagsToRoom(id, tagArray) {
|
|
|
|
const data = { names: tagArray };
|
|
|
|
const options = {
|
|
|
|
method: "put",
|
|
|
|
url: `/files/rooms/${id}/tags`,
|
|
|
|
data,
|
|
|
|
};
|
|
|
|
|
|
|
|
return request(options).then((res) => {
|
|
|
|
return res;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-08-01 06:51:55 +00:00
|
|
|
export function removeTagsFromRoom(id, tagArray) {
|
|
|
|
const data = { names: tagArray };
|
|
|
|
const options = {
|
|
|
|
method: "delete",
|
|
|
|
url: `/files/rooms/${id}/tags`,
|
|
|
|
data,
|
|
|
|
};
|
|
|
|
|
|
|
|
return request(options).then((res) => {
|
|
|
|
return res;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-07-08 07:41:00 +00:00
|
|
|
export function getTags() {
|
|
|
|
const options = {
|
|
|
|
method: "get",
|
|
|
|
url: "/files/tags",
|
|
|
|
};
|
|
|
|
|
|
|
|
return request(options).then((res) => {
|
|
|
|
return res;
|
|
|
|
});
|
|
|
|
}
|
2022-08-15 12:54:46 +00:00
|
|
|
|
|
|
|
export function uploadRoomLogo(data) {
|
|
|
|
const options = {
|
|
|
|
method: "post",
|
|
|
|
url: `/files/logos`,
|
|
|
|
data,
|
|
|
|
};
|
|
|
|
|
|
|
|
return request(options).then((res) => {
|
|
|
|
return res;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
export function addLogoToRoom(id, data) {
|
|
|
|
const options = {
|
|
|
|
method: "post",
|
|
|
|
url: `/files/rooms/${id}/logo`,
|
|
|
|
data,
|
|
|
|
};
|
|
|
|
|
|
|
|
return request(options).then((res) => {
|
|
|
|
return res;
|
|
|
|
});
|
|
|
|
}
|
2022-08-23 11:29:47 +00:00
|
|
|
|
|
|
|
export function removeLogoFromRoom(id) {
|
|
|
|
const options = {
|
|
|
|
method: "delete",
|
|
|
|
url: `/files/rooms/${id}/logo`,
|
|
|
|
};
|
|
|
|
|
|
|
|
return request(options).then((res) => {
|
|
|
|
return res;
|
|
|
|
});
|
|
|
|
}
|
2022-09-21 07:41:11 +00:00
|
|
|
|
2022-10-28 08:24:25 +00:00
|
|
|
export const setInvitationLinks = async (roomId, linkId, title, access) => {
|
2022-09-21 07:41:11 +00:00
|
|
|
const options = {
|
2022-09-22 15:10:07 +00:00
|
|
|
method: "put",
|
2022-10-28 08:24:25 +00:00
|
|
|
url: `/files/rooms/${roomId}/links`,
|
2022-09-21 07:41:11 +00:00
|
|
|
data: {
|
2022-09-22 15:10:07 +00:00
|
|
|
linkId,
|
|
|
|
title,
|
2022-09-21 07:41:11 +00:00
|
|
|
access,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const res = await request(options);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
};
|
|
|
|
|
2022-09-22 15:10:07 +00:00
|
|
|
export const resendEmailInvitations = async (id, usersIds) => {
|
2022-09-21 07:41:11 +00:00
|
|
|
const options = {
|
|
|
|
method: "put",
|
2022-09-22 15:10:07 +00:00
|
|
|
url: `/files/rooms/${id}/resend`,
|
2022-09-21 07:41:11 +00:00
|
|
|
data: {
|
2022-09-22 15:10:07 +00:00
|
|
|
usersIds,
|
2022-09-21 07:41:11 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const res = await request(options);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
};
|
|
|
|
|
2022-09-22 15:10:07 +00:00
|
|
|
export const getRoomSecurityInfo = async (id) => {
|
|
|
|
const options = {
|
|
|
|
method: "get",
|
|
|
|
url: `/files/rooms/${id}/share`,
|
|
|
|
};
|
|
|
|
|
|
|
|
const res = await request(options);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const setRoomSecurity = async (id, data) => {
|
2022-09-21 07:41:11 +00:00
|
|
|
const options = {
|
|
|
|
method: "put",
|
2022-09-22 15:10:07 +00:00
|
|
|
url: `/files/rooms/${id}/share`,
|
|
|
|
data,
|
2022-09-21 07:41:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const res = await request(options);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
};
|
2022-09-22 15:10:07 +00:00
|
|
|
|
|
|
|
export const acceptInvitationByLink = async () => {
|
|
|
|
const options = {
|
|
|
|
method: "post",
|
|
|
|
url: `/files/rooms/accept`,
|
|
|
|
};
|
|
|
|
|
|
|
|
return await request(options);
|
|
|
|
};
|