Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/preload/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NotificationConstructorOptions, contextBridge, ipcRenderer } from 'electron'
import os from 'os'
import { electronAPI } from '@electron-toolkit/preload'
import { IPC_EVENTS } from '@shared/constants'
import {
Expand All @@ -12,6 +13,8 @@ export interface IElectronAPI {
env: NodeJS.ProcessEnv,
appVersion: string,
platform: string,
osRelease: string,
arch: string,

// Use `contextBridge` APIs to expose Electron APIs to
// renderer only if context isolation is enabled, otherwise
Expand Down Expand Up @@ -88,6 +91,8 @@ const api: IElectronAPI = {
env: process.env,
appVersion: process.env['APP_VERSION'] || '0.0.1',
platform: process.platform,
osRelease: os.release(),
arch: process.arch,
i18nextElectronBackend: preloadBindings(ipcRenderer, process),
//SYNC EMITTERS - expect response
login: setEmitterSync<Account | undefined>(IPC_EVENTS.LOGIN),
Expand Down
26 changes: 25 additions & 1 deletion src/shared/useNethVoiceAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,29 @@ import { requires2FA } from '@shared/utils/jwt'
const PRIMARY_API_BASE_PATH = '/api'
const FALLBACK_API_BASE_PATH = '/webrest'

function getNethlinkClientInfo(): {
nethlink_version: string
os_type: string
os_release: string
arch: string
} {
const api = typeof window !== 'undefined' ? (window as any).api : undefined
if (api) {
return {
nethlink_version: api.appVersion || '',
os_type: api.platform || '',
os_release: api.osRelease || '',
arch: api.arch || ''
}
}
return {
nethlink_version: (typeof process !== 'undefined' && process.env?.['APP_VERSION']) || '',
os_type: typeof process !== 'undefined' ? process.platform : '',
os_release: '',
arch: typeof process !== 'undefined' ? process.arch : ''
}
}

export const useNethVoiceAPI = (loggedAccount: Account | undefined = undefined) => {
const { GET, POST, DELETE } = useNetwork()
let isFirstHeartbeat = true
Expand Down Expand Up @@ -594,7 +617,8 @@ export const useNethVoiceAPI = (loggedAccount: Account | undefined = undefined)
all: async () => await _GET(buildApiPath('/user/all')),
all_avatars: async () => await _GET(buildApiPath('/user/all_avatars')),
all_endpoints: async () => await _GET(buildApiPath('/user/endpoints/all')),
heartbeat: async (extension: string, username: string) => await _POST(buildApiPath('/user/nethlink'), { extension, username }),
heartbeat: async (extension: string, username: string) =>
await _POST(buildApiPath('/user/nethlink'), { extension, username, ...getNethlinkClientInfo() }),
settings: async (settings: Partial<AccountData['settings']>) =>
await _POST(buildApiPath('/user/settings'), settings),
default_device: async (deviceIdInformation: Extension, force = false): Promise<boolean> => {
Expand Down
Loading