mirror of
				https://github.com/tooot-app/app
				synced 2025-06-05 22:19:13 +02:00 
			
		
		
		
	Merge pull request #184 from tooot-app/main
Final test of new push system
This commit is contained in:
		| @@ -59,7 +59,7 @@ const apiGeneral = async <T = unknown>({ | |||||||
|     }) |     }) | ||||||
|     .catch(error => { |     .catch(error => { | ||||||
|       if (sentry) { |       if (sentry) { | ||||||
|         Sentry.Native.setExtras(error.response) |         Sentry.Native.setExtras(error.response || error.request) | ||||||
|         Sentry.Native.captureException(error) |         Sentry.Native.captureException(error) | ||||||
|       } |       } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -57,7 +57,7 @@ const apiTooot = async <T = unknown>({ | |||||||
|     }) |     }) | ||||||
|     .catch(error => { |     .catch(error => { | ||||||
|       if (sentry) { |       if (sentry) { | ||||||
|         Sentry.Native.setExtras(error.response) |         Sentry.Native.setExtras(error.response || error.request) | ||||||
|         Sentry.Native.captureException(error) |         Sentry.Native.captureException(error) | ||||||
|       } |       } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -25,12 +25,8 @@ const pushUseConnect = ({ mode, t, instances, dispatch }: Params) => { | |||||||
|       ).data |       ).data | ||||||
|  |  | ||||||
|       apiTooot({ |       apiTooot({ | ||||||
|         method: 'post', |         method: 'get', | ||||||
|         service: 'push', |         url: `push/connect/${expoToken}`, | ||||||
|         url: 'connect', |  | ||||||
|         body: { |  | ||||||
|           expoToken |  | ||||||
|         }, |  | ||||||
|         sentry: true |         sentry: true | ||||||
|       }).catch(error => { |       }).catch(error => { | ||||||
|         if (error.status == 410) { |         if (error.status == 410) { | ||||||
| @@ -76,7 +72,7 @@ const pushUseConnect = ({ mode, t, instances, dispatch }: Params) => { | |||||||
|  |  | ||||||
|     const pushEnabled = instances.filter(instance => instance.push.global.value) |     const pushEnabled = instances.filter(instance => instance.push.global.value) | ||||||
|     if (pushEnabled.length) { |     if (pushEnabled.length) { | ||||||
|       // connect() |       connect() | ||||||
|     } |     } | ||||||
|   }, [instances]) |   }, [instances]) | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,7 +1,6 @@ | |||||||
| import apiTooot from '@api/tooot' | import apiTooot from '@api/tooot' | ||||||
| import haptics from '@components/haptics' | import haptics from '@components/haptics' | ||||||
| import { AxiosError } from 'axios' | import { AxiosError } from 'axios' | ||||||
| import * as Crypto from 'expo-crypto' |  | ||||||
| import { useQuery, UseQueryOptions } from 'react-query' | import { useQuery, UseQueryOptions } from 'react-query' | ||||||
|  |  | ||||||
| type Translations = { | type Translations = { | ||||||
| @@ -13,7 +12,6 @@ type Translations = { | |||||||
| export type QueryKeyTranslate = [ | export type QueryKeyTranslate = [ | ||||||
|   'Translate', |   'Translate', | ||||||
|   { |   { | ||||||
|     uri: string |  | ||||||
|     source: string |     source: string | ||||||
|     target: string |     target: string | ||||||
|     text: string[] |     text: string[] | ||||||
| @@ -21,23 +19,11 @@ export type QueryKeyTranslate = [ | |||||||
| ] | ] | ||||||
|  |  | ||||||
| const queryFunction = async ({ queryKey }: { queryKey: QueryKeyTranslate }) => { | const queryFunction = async ({ queryKey }: { queryKey: QueryKeyTranslate }) => { | ||||||
|   const { uri, source, target, text } = queryKey[1] |   const { source, target, text } = queryKey[1] | ||||||
|  |  | ||||||
|   const uriEncoded = await Crypto.digestStringAsync( |  | ||||||
|     Crypto.CryptoDigestAlgorithm.SHA256, |  | ||||||
|     uri.replace(/https?:\/\//, ''), |  | ||||||
|     { encoding: Crypto.CryptoEncoding.HEX } |  | ||||||
|   ) |  | ||||||
|   const original = await Crypto.digestStringAsync( |  | ||||||
|     Crypto.CryptoDigestAlgorithm.SHA256, |  | ||||||
|     JSON.stringify({ source, text }), |  | ||||||
|     { encoding: Crypto.CryptoEncoding.HEX } |  | ||||||
|   ) |  | ||||||
|  |  | ||||||
|   const res = await apiTooot<Translations>({ |   const res = await apiTooot<Translations>({ | ||||||
|     method: 'get', |     method: 'post', | ||||||
|     url: '/translate', |     url: 'translate', | ||||||
|     headers: { original }, |  | ||||||
|     body: { source, target, text } |     body: { source, target, text } | ||||||
|   }) |   }) | ||||||
|   haptics('Light') |   haptics('Light') | ||||||
|   | |||||||
| @@ -77,7 +77,7 @@ const pushRegister = async ( | |||||||
|     accountId, |     accountId, | ||||||
|     accountFull, |     accountFull, | ||||||
|     serverKey: res.body.server_key, |     serverKey: res.body.server_key, | ||||||
|     auth |     auth: instancePush.decode.value === false ? null : auth | ||||||
|   }) |   }) | ||||||
|  |  | ||||||
|   if (Platform.OS === 'android') { |   if (Platform.OS === 'android') { | ||||||
|   | |||||||
| @@ -29,7 +29,7 @@ export const updateInstancePushDecode = createAsyncThunk( | |||||||
|       method: 'put', |       method: 'put', | ||||||
|       url: `/push/update-decode/${expoToken}/${instance.url}/${instance.account.id}`, |       url: `/push/update-decode/${expoToken}/${instance.url}/${instance.account.id}`, | ||||||
|       body: { |       body: { | ||||||
|         auth: disable ? null : instance.push.keys.auth |         auth: !disable ? null : instance.push.keys.auth | ||||||
|       }, |       }, | ||||||
|       sentry: true |       sentry: true | ||||||
|     }) |     }) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user