1
0
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:
Zhiyuan Zheng
2021-06-21 11:59:29 +02:00
parent f3abcf640c
commit 927e7df4e9
11 changed files with 137 additions and 51 deletions

View File

@ -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
})

View File

@ -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,

View File

@ -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,

View File

@ -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: {