chore: format
This commit is contained in:
@@ -5,7 +5,7 @@ type ChannelForm = {
|
||||
data?: object;
|
||||
meta?: object;
|
||||
access_control?: object;
|
||||
}
|
||||
};
|
||||
|
||||
export const createNewChannel = async (token: string = '', channel: ChannelForm) => {
|
||||
let error = null;
|
||||
@@ -70,7 +70,6 @@ export const getChannels = async (token: string = '') => {
|
||||
return res;
|
||||
};
|
||||
|
||||
|
||||
export const getChannelById = async (token: string = '', channel_id: string) => {
|
||||
let error = null;
|
||||
|
||||
@@ -100,9 +99,13 @@ export const getChannelById = async (token: string = '', channel_id: string) =>
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
export const updateChannelById = async (token: string = '', channel_id: string, channel: ChannelForm) => {
|
||||
export const updateChannelById = async (
|
||||
token: string = '',
|
||||
channel_id: string,
|
||||
channel: ChannelForm
|
||||
) => {
|
||||
let error = null;
|
||||
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/channels/${channel_id}/update`, {
|
||||
@@ -132,7 +135,7 @@ export const updateChannelById = async (token: string = '', channel_id: string,
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
export const deleteChannelById = async (token: string = '', channel_id: string) => {
|
||||
let error = null;
|
||||
@@ -163,20 +166,27 @@ export const deleteChannelById = async (token: string = '', channel_id: string)
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const getChannelMessages = async (token: string = '', channel_id: string, skip: number = 0, limit: number = 50) => {
|
||||
export const getChannelMessages = async (
|
||||
token: string = '',
|
||||
channel_id: string,
|
||||
skip: number = 0,
|
||||
limit: number = 50
|
||||
) => {
|
||||
let error = null;
|
||||
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/channels/${channel_id}/messages?skip=${skip}&limit=${limit}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
authorization: `Bearer ${token}`
|
||||
const res = await fetch(
|
||||
`${WEBUI_API_BASE_URL}/channels/${channel_id}/messages?skip=${skip}&limit=${limit}`,
|
||||
{
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
authorization: `Bearer ${token}`
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
.then(async (res) => {
|
||||
if (!res.ok) throw await res.json();
|
||||
return res.json();
|
||||
@@ -195,14 +205,13 @@ export const getChannelMessages = async (token: string = '', channel_id: string,
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
type MessageForm = {
|
||||
content: string;
|
||||
data?: object;
|
||||
meta?: object;
|
||||
|
||||
}
|
||||
meta?: object;
|
||||
};
|
||||
|
||||
export const sendMessage = async (token: string = '', channel_id: string, message: MessageForm) => {
|
||||
let error = null;
|
||||
@@ -234,20 +243,28 @@ export const sendMessage = async (token: string = '', channel_id: string, messag
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
export const updateMessage = async (token: string = '', channel_id: string, message_id: string, message: MessageForm) => {
|
||||
export const updateMessage = async (
|
||||
token: string = '',
|
||||
channel_id: string,
|
||||
message_id: string,
|
||||
message: MessageForm
|
||||
) => {
|
||||
let error = null;
|
||||
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/channels/${channel_id}/messages/${message_id}/update`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
authorization: `Bearer ${token}`
|
||||
},
|
||||
body: JSON.stringify({ ...message })
|
||||
})
|
||||
const res = await fetch(
|
||||
`${WEBUI_API_BASE_URL}/channels/${channel_id}/messages/${message_id}/update`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
authorization: `Bearer ${token}`
|
||||
},
|
||||
body: JSON.stringify({ ...message })
|
||||
}
|
||||
)
|
||||
.then(async (res) => {
|
||||
if (!res.ok) throw await res.json();
|
||||
return res.json();
|
||||
@@ -266,19 +283,22 @@ export const updateMessage = async (token: string = '', channel_id: string, mess
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
export const deleteMessage = async (token: string = '', channel_id: string, message_id: string) => {
|
||||
let error = null;
|
||||
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/channels/${channel_id}/messages/${message_id}/delete`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
authorization: `Bearer ${token}`
|
||||
const res = await fetch(
|
||||
`${WEBUI_API_BASE_URL}/channels/${channel_id}/messages/${message_id}/delete`,
|
||||
{
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
authorization: `Bearer ${token}`
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
.then(async (res) => {
|
||||
if (!res.ok) throw await res.json();
|
||||
return res.json();
|
||||
@@ -297,4 +317,4 @@ export const deleteMessage = async (token: string = '', channel_id: string, mess
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user