mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Use new api gateway
This commit is contained in:
@@ -1,12 +1,9 @@
|
||||
import apiGeneral from '@api/general'
|
||||
import apiTooot from '@api/tooot'
|
||||
import { displayMessage } from '@components/Message'
|
||||
import { NavigationContainerRef } from '@react-navigation/native'
|
||||
import { Dispatch } from '@reduxjs/toolkit'
|
||||
import {
|
||||
disableAllPushes,
|
||||
Instance,
|
||||
PUSH_SERVER
|
||||
} from '@utils/slices/instancesSlice'
|
||||
import { disableAllPushes, Instance } from '@utils/slices/instancesSlice'
|
||||
import * as Notifications from 'expo-notifications'
|
||||
import { useEffect } from 'react'
|
||||
import { TFunction } from 'react-i18next'
|
||||
@@ -34,10 +31,10 @@ const pushUseConnect = ({
|
||||
})
|
||||
).data
|
||||
|
||||
apiGeneral({
|
||||
apiTooot({
|
||||
method: 'post',
|
||||
domain: PUSH_SERVER,
|
||||
url: 'v1/connect',
|
||||
service: 'push',
|
||||
url: 'connect',
|
||||
body: {
|
||||
expoToken
|
||||
},
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import apiGeneral from '@api/general'
|
||||
import apiTooot from '@api/tooot'
|
||||
import haptics from '@components/haptics'
|
||||
import { AxiosError } from 'axios'
|
||||
import { Buffer } from 'buffer'
|
||||
@@ -21,16 +21,7 @@ export type QueryKeyTranslate = [
|
||||
}
|
||||
]
|
||||
|
||||
export const TRANSLATE_SERVER = __DEV__
|
||||
? 'testtranslate.tooot.app'
|
||||
: 'translate.tooot.app'
|
||||
|
||||
const queryFunction = async ({ queryKey }: { queryKey: QueryKeyTranslate }) => {
|
||||
const key = Constants.manifest.extra?.translateKey
|
||||
if (!key) {
|
||||
return Promise.reject()
|
||||
}
|
||||
|
||||
const { uri, source, target, text } = queryKey[1]
|
||||
|
||||
const uriEncoded = Buffer.from(uri.replace(/https?:\/\//, ''))
|
||||
@@ -42,11 +33,11 @@ const queryFunction = async ({ queryKey }: { queryKey: QueryKeyTranslate }) => {
|
||||
'base64'
|
||||
)
|
||||
|
||||
const res = await apiGeneral<Translations>({
|
||||
domain: TRANSLATE_SERVER,
|
||||
const res = await apiTooot<Translations>({
|
||||
method: 'get',
|
||||
url: `v1/translate/${uriEncoded}/${target}`,
|
||||
headers: { key, original }
|
||||
service: 'translate',
|
||||
url: `source/${uriEncoded}/target/${target}`,
|
||||
headers: { original }
|
||||
})
|
||||
haptics('Light')
|
||||
return res.body
|
||||
|
@@ -1,12 +1,8 @@
|
||||
import apiGeneral from '@api/general'
|
||||
import apiInstance from '@api/instance'
|
||||
import apiTooot from '@api/tooot'
|
||||
import i18n from '@root/i18n/i18n'
|
||||
import { RootState } from '@root/store'
|
||||
import {
|
||||
getInstance,
|
||||
Instance,
|
||||
PUSH_SERVER
|
||||
} from '@utils/slices/instancesSlice'
|
||||
import { getInstance, Instance } from '@utils/slices/instancesSlice'
|
||||
import * as Notifications from 'expo-notifications'
|
||||
import { Platform } from 'react-native'
|
||||
import androidDefaults from './androidDefaults'
|
||||
@@ -22,13 +18,13 @@ const register1 = async ({
|
||||
accountId: Mastodon.Account['id']
|
||||
accountFull: string
|
||||
}) => {
|
||||
return apiGeneral<{
|
||||
return apiTooot<{
|
||||
endpoint: string
|
||||
keys: { public: string; private: string; auth: string }
|
||||
}>({
|
||||
method: 'post',
|
||||
domain: PUSH_SERVER,
|
||||
url: 'v1/register1',
|
||||
service: 'push',
|
||||
url: 'register1',
|
||||
body: { expoToken, instanceUrl, accountId, accountFull },
|
||||
sentry: true
|
||||
})
|
||||
@@ -47,10 +43,10 @@ const register2 = async ({
|
||||
accountId: Mastodon.Account['id']
|
||||
removeKeys: boolean
|
||||
}) => {
|
||||
return apiGeneral({
|
||||
return apiTooot({
|
||||
method: 'post',
|
||||
domain: PUSH_SERVER,
|
||||
url: 'v1/register2',
|
||||
service: 'push',
|
||||
url: 'register2',
|
||||
body: { expoToken, instanceUrl, accountId, serverKey, removeKeys },
|
||||
sentry: true
|
||||
})
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import apiGeneral from '@api/general'
|
||||
import apiInstance from '@api/instance'
|
||||
import apiTooot from '@api/tooot'
|
||||
import { RootState } from '@root/store'
|
||||
import { getInstance, PUSH_SERVER } from '@utils/slices/instancesSlice'
|
||||
import { getInstance } from '@utils/slices/instancesSlice'
|
||||
import * as Notifications from 'expo-notifications'
|
||||
import { Platform } from 'react-native'
|
||||
|
||||
@@ -19,10 +19,10 @@ const pushUnregister = async (state: RootState, expoToken: string) => {
|
||||
url: 'push/subscription'
|
||||
})
|
||||
|
||||
await apiGeneral<{ endpoint: string; publicKey: string; auth: string }>({
|
||||
await apiTooot<{ endpoint: string; publicKey: string; auth: string }>({
|
||||
method: 'post',
|
||||
domain: PUSH_SERVER,
|
||||
url: 'v1/unregister',
|
||||
service: 'push',
|
||||
url: 'unregister',
|
||||
body: {
|
||||
expoToken,
|
||||
instanceUrl: instance.url,
|
||||
|
@@ -1,10 +1,10 @@
|
||||
import apiGeneral from '@api/general'
|
||||
import apiTooot from '@api/tooot'
|
||||
import { createAsyncThunk } from '@reduxjs/toolkit'
|
||||
import i18n from '@root/i18n/i18n'
|
||||
import { RootState } from '@root/store'
|
||||
import * as Notifications from 'expo-notifications'
|
||||
import { Platform } from 'react-native'
|
||||
import { getInstance, Instance, PUSH_SERVER } from '../instancesSlice'
|
||||
import { getInstance, Instance } from '../instancesSlice'
|
||||
import androidDefaults from './push/androidDefaults'
|
||||
|
||||
export const updateInstancePushDecode = createAsyncThunk(
|
||||
@@ -25,10 +25,10 @@ export const updateInstancePushDecode = createAsyncThunk(
|
||||
})
|
||||
).data
|
||||
|
||||
await apiGeneral({
|
||||
await apiTooot({
|
||||
method: 'post',
|
||||
domain: PUSH_SERVER,
|
||||
url: 'v1/update-decode',
|
||||
service: 'push',
|
||||
url: 'update-decode',
|
||||
body: {
|
||||
expoToken,
|
||||
instanceUrl: instance.url,
|
||||
|
@@ -11,8 +11,6 @@ import { updateInstancePush } from './instances/updatePush'
|
||||
import { updateInstancePushAlert } from './instances/updatePushAlert'
|
||||
import { updateInstancePushDecode } from './instances/updatePushDecode'
|
||||
|
||||
export const PUSH_SERVER = __DEV__ ? 'testpush.tooot.app' : 'push.tooot.app'
|
||||
|
||||
export type Instance = {
|
||||
active: boolean
|
||||
appData: {
|
||||
|
Reference in New Issue
Block a user