mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-10 04:30:25 +02:00
Always use remote url for discord rpc image (#2009)
* add option to force remote url for api calls * force remote url for discord rpc image
This commit is contained in:
@@ -404,11 +404,12 @@ export const createAuthHeader = (): string => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const jfApiClient = (args: {
|
export const jfApiClient = (args: {
|
||||||
|
forceRemoteUrl?: boolean;
|
||||||
server: null | ServerListItemWithCredential;
|
server: null | ServerListItemWithCredential;
|
||||||
signal?: AbortSignal;
|
signal?: AbortSignal;
|
||||||
url?: string;
|
url?: string;
|
||||||
}) => {
|
}) => {
|
||||||
const { server, signal, url } = args;
|
const { forceRemoteUrl, server, signal, url } = args;
|
||||||
|
|
||||||
return initClient(contract, {
|
return initClient(contract, {
|
||||||
api: async ({ body, headers, method, path }) => {
|
api: async ({ body, headers, method, path }) => {
|
||||||
@@ -418,7 +419,7 @@ export const jfApiClient = (args: {
|
|||||||
const { params, path: api } = parsePath(path);
|
const { params, path: api } = parsePath(path);
|
||||||
|
|
||||||
if (server) {
|
if (server) {
|
||||||
const serverUrl = getServerUrl(server);
|
const serverUrl = getServerUrl(server, forceRemoteUrl);
|
||||||
baseUrl = serverUrl;
|
baseUrl = serverUrl;
|
||||||
token = server?.credential;
|
token = server?.credential;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -479,11 +479,12 @@ axiosClient.interceptors.response.use(
|
|||||||
);
|
);
|
||||||
|
|
||||||
export const ndApiClient = (args: {
|
export const ndApiClient = (args: {
|
||||||
|
forceRemoteUrl?: boolean;
|
||||||
server: null | ServerListItemWithCredential;
|
server: null | ServerListItemWithCredential;
|
||||||
signal?: AbortSignal;
|
signal?: AbortSignal;
|
||||||
url?: string;
|
url?: string;
|
||||||
}) => {
|
}) => {
|
||||||
const { server, signal, url } = args;
|
const { forceRemoteUrl, server, signal, url } = args;
|
||||||
|
|
||||||
return initClient(contract, {
|
return initClient(contract, {
|
||||||
api: async ({ body, headers, method, path }) => {
|
api: async ({ body, headers, method, path }) => {
|
||||||
@@ -493,7 +494,7 @@ export const ndApiClient = (args: {
|
|||||||
const { params, path: api } = parsePath(path);
|
const { params, path: api } = parsePath(path);
|
||||||
|
|
||||||
if (server) {
|
if (server) {
|
||||||
const serverUrl = getServerUrl(server);
|
const serverUrl = getServerUrl(server, forceRemoteUrl);
|
||||||
baseUrl = serverUrl ? `${serverUrl}/api` : undefined;
|
baseUrl = serverUrl ? `${serverUrl}/api` : undefined;
|
||||||
token = server?.ndCredential;
|
token = server?.ndCredential;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -428,12 +428,13 @@ const silentlyTransformResponse = (data: any) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const ssApiClient = (args: {
|
export const ssApiClient = (args: {
|
||||||
|
forceRemoteUrl?: boolean;
|
||||||
server: null | ServerListItemWithCredential;
|
server: null | ServerListItemWithCredential;
|
||||||
signal?: AbortSignal;
|
signal?: AbortSignal;
|
||||||
silent?: boolean;
|
silent?: boolean;
|
||||||
url?: string;
|
url?: string;
|
||||||
}) => {
|
}) => {
|
||||||
const { server, signal, silent, url } = args;
|
const { forceRemoteUrl, server, signal, silent, url } = args;
|
||||||
|
|
||||||
return initClient(contract, {
|
return initClient(contract, {
|
||||||
api: async ({ body, headers, method, path, rawQuery }) => {
|
api: async ({ body, headers, method, path, rawQuery }) => {
|
||||||
@@ -443,7 +444,7 @@ export const ssApiClient = (args: {
|
|||||||
const { params, path: api } = parsePath(path);
|
const { params, path: api } = parsePath(path);
|
||||||
|
|
||||||
if (server) {
|
if (server) {
|
||||||
const serverUrl = getServerUrl(server);
|
const serverUrl = getServerUrl(server, forceRemoteUrl);
|
||||||
baseUrl = serverUrl ? `${serverUrl}/rest` : undefined;
|
baseUrl = serverUrl ? `${serverUrl}/rest` : undefined;
|
||||||
const token = server.credential;
|
const token = server.credential;
|
||||||
const params = token.split(/&?\w=/gm);
|
const params = token.split(/&?\w=/gm);
|
||||||
|
|||||||
@@ -284,7 +284,10 @@ export const useDiscordRpc = () => {
|
|||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
const info = await api.controller.getAlbumInfo({
|
const info = await api.controller.getAlbumInfo({
|
||||||
apiClientProps: { serverId: song._serverId },
|
apiClientProps: {
|
||||||
|
forceRemoteUrl: true,
|
||||||
|
serverId: song._serverId,
|
||||||
|
},
|
||||||
query: { id: song.albumId },
|
query: { id: song.albumId },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -421,6 +421,7 @@ type ApiContext = {
|
|||||||
|
|
||||||
type BaseEndpointArgs = {
|
type BaseEndpointArgs = {
|
||||||
apiClientProps: {
|
apiClientProps: {
|
||||||
|
forceRemoteUrl?: boolean;
|
||||||
server?: null | ServerListItemWithCredential;
|
server?: null | ServerListItemWithCredential;
|
||||||
serverId: string;
|
serverId: string;
|
||||||
signal?: AbortSignal;
|
signal?: AbortSignal;
|
||||||
|
|||||||
Reference in New Issue
Block a user