mirror of
https://github.com/sky-systems/sky_phone.git
synced 2026-08-28 17:01:18 +00:00
ENH - expand admin device controls
This commit is contained in:
@@ -20,6 +20,17 @@ const phoneServer = readFileSync(
|
||||
new URL('../../../sky_phone/source/server/phone.lua', import.meta.url),
|
||||
'utf8',
|
||||
)
|
||||
const persistenceServer = readFileSync(
|
||||
new URL(
|
||||
'../../../sky_phone/source/server/phone_persistence.lua',
|
||||
import.meta.url,
|
||||
),
|
||||
'utf8',
|
||||
)
|
||||
const simServer = readFileSync(
|
||||
new URL('../../../sky_phone/source/server/sim.lua', import.meta.url),
|
||||
'utf8',
|
||||
)
|
||||
const phoneClient = readFileSync(
|
||||
new URL('../../../sky_phone/source/client/main.lua', import.meta.url),
|
||||
'utf8',
|
||||
@@ -61,8 +72,8 @@ describe('standalone admin panel contracts', () => {
|
||||
|
||||
it('uses a compact transparent shell with dedicated admin workspaces', () => {
|
||||
expect(source).toContain('background: transparent')
|
||||
expect(source).toContain('width: min(84vw, 1420px)')
|
||||
expect(source).toContain('height: min(82vh, 820px)')
|
||||
expect(source).toContain('width: min(76vw, 1220px)')
|
||||
expect(source).toContain('height: min(74vh, 700px)')
|
||||
expect(source).not.toContain('backdrop-filter: blur(2px)')
|
||||
|
||||
for (const tab of [
|
||||
@@ -70,7 +81,10 @@ describe('standalone admin panel contracts', () => {
|
||||
'players',
|
||||
'devices',
|
||||
'apps',
|
||||
'security',
|
||||
'accounts',
|
||||
'messages',
|
||||
'calls',
|
||||
'moderation',
|
||||
'audit',
|
||||
]) {
|
||||
expect(source).toContain(`selectTab('${tab}')`)
|
||||
@@ -78,6 +92,14 @@ describe('standalone admin panel contracts', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('removes manual reload and applies a persistent global accent choice', () => {
|
||||
expect(source).not.toContain('<RefreshCw')
|
||||
expect(source).not.toContain("kind: 'refresh'")
|
||||
expect(source).toContain("'sky-phone-admin-accent'")
|
||||
expect(source).toContain(':style="{ \'--admin-accent\': accentColor }"')
|
||||
expect(source).toContain('color-mix(in srgb, var(--admin-green)')
|
||||
})
|
||||
|
||||
it('stages app changes locally and saves them only from the toolbar action', () => {
|
||||
expect(source).toContain('const drafts = ref<')
|
||||
expect(source).toContain('@click="saveChanges"')
|
||||
@@ -90,19 +112,46 @@ describe('standalone admin panel contracts', () => {
|
||||
})
|
||||
|
||||
it('connects every operation through the standard NUI callback bridge', () => {
|
||||
expect(bridge).toContain(
|
||||
'admin = [[bootstrap player save-apps reveal-password]]',
|
||||
)
|
||||
expect(bridge).toContain('admin = [[')
|
||||
for (const endpoint of [
|
||||
'admin:bootstrap',
|
||||
'admin:player',
|
||||
'admin:save-apps',
|
||||
'admin:reveal-password',
|
||||
'admin:activity',
|
||||
'admin:reset-passcode',
|
||||
'admin:change-number',
|
||||
'admin:factory-reset',
|
||||
]) {
|
||||
expect(store).toContain(endpoint)
|
||||
}
|
||||
})
|
||||
|
||||
it('protects activity views and device moderation with ownership and audit checks', () => {
|
||||
for (const endpoint of [
|
||||
'activity',
|
||||
'reset-passcode',
|
||||
'change-number',
|
||||
'factory-reset',
|
||||
]) {
|
||||
expect(server).toContain(
|
||||
`Bridge.Callbacks.Register("sky_phone:admin:${endpoint}"`,
|
||||
)
|
||||
}
|
||||
expect(server).toContain('data.kind ~= "messages"')
|
||||
expect(server).toContain('data.kind ~= "calls"')
|
||||
expect(server).toContain('"view_messages"')
|
||||
expect(server).toContain('"view_calls"')
|
||||
expect(server).toContain('"reset_passcode"')
|
||||
expect(server).toContain('"change_number"')
|
||||
expect(server).toContain('"factory_reset"')
|
||||
expect(simServer).toContain('function SkyPhoneSim.ChangeNumber(')
|
||||
expect(simServer).toContain('UPDATE IGNORE `sky_phone_sims`')
|
||||
expect(persistenceServer).toContain(
|
||||
'function SkyPhonePersistence.FactoryReset(imei)',
|
||||
)
|
||||
})
|
||||
|
||||
it('authorizes every server request without requiring a phone session', () => {
|
||||
expect(server).not.toContain('SkyPhone.RequireSession(source)')
|
||||
expect(server).toContain(
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,8 +2,11 @@ import { defineStore } from 'pinia'
|
||||
|
||||
import type {
|
||||
AdminAuditEntry,
|
||||
AdminActivityResponse,
|
||||
AdminBootstrap,
|
||||
AdminCallActivity,
|
||||
AdminCredential,
|
||||
AdminMessageActivity,
|
||||
AdminPlayerDetail,
|
||||
AdminPlayerSummary,
|
||||
AdminStats,
|
||||
@@ -15,6 +18,7 @@ const EMPTY_STATS: AdminStats = { accounts: 0, devices: 0, online: 0 }
|
||||
export const useAdminStore = defineStore('admin', {
|
||||
state: () => ({
|
||||
actionKey: '',
|
||||
activityKey: '',
|
||||
audit: [] as AdminAuditEntry[],
|
||||
detailLoading: false,
|
||||
error: '',
|
||||
@@ -22,6 +26,10 @@ export const useAdminStore = defineStore('admin', {
|
||||
loading: false,
|
||||
players: [] as AdminPlayerSummary[],
|
||||
revealedCredentials: {} as Record<string, AdminCredential>,
|
||||
deviceActivity: {} as Record<
|
||||
string,
|
||||
{ calls?: AdminCallActivity[]; messages?: AdminMessageActivity[] }
|
||||
>,
|
||||
selectedPlayer: null as AdminPlayerDetail | null,
|
||||
stats: { ...EMPTY_STATS },
|
||||
}),
|
||||
@@ -100,5 +108,91 @@ export const useAdminStore = defineStore('admin', {
|
||||
}
|
||||
return response
|
||||
},
|
||||
async loadActivity(
|
||||
source: number,
|
||||
imei: string,
|
||||
kind: 'messages' | 'calls',
|
||||
): Promise<boolean> {
|
||||
this.activityKey = `${imei}:${kind}`
|
||||
const response = await nuiCall<AdminActivityResponse>('admin:activity', {
|
||||
imei,
|
||||
kind,
|
||||
source,
|
||||
})
|
||||
this.activityKey = ''
|
||||
if (!response.success || !response.data) {
|
||||
this.error = response.error ?? 'request_failed'
|
||||
return false
|
||||
}
|
||||
const activity = this.deviceActivity[imei] ?? {}
|
||||
if (response.data.kind === 'messages') {
|
||||
activity.messages = response.data.entries
|
||||
} else {
|
||||
activity.calls = response.data.entries
|
||||
}
|
||||
this.deviceActivity[imei] = activity
|
||||
this.error = ''
|
||||
return true
|
||||
},
|
||||
async resetPasscode(
|
||||
source: number,
|
||||
imei: string,
|
||||
): Promise<NuiResponse<AdminPlayerDetail>> {
|
||||
this.actionKey = `${imei}:reset-passcode`
|
||||
const response = await nuiCall<AdminPlayerDetail>(
|
||||
'admin:reset-passcode',
|
||||
{ imei, source },
|
||||
)
|
||||
this.actionKey = ''
|
||||
if (response.success && response.data) {
|
||||
this.selectedPlayer = response.data
|
||||
delete this.revealedCredentials[imei]
|
||||
this.error = ''
|
||||
} else {
|
||||
this.error = response.error ?? 'request_failed'
|
||||
}
|
||||
return response
|
||||
},
|
||||
async changeNumber(
|
||||
source: number,
|
||||
imei: string,
|
||||
phoneNumber: string,
|
||||
): Promise<NuiResponse<AdminPlayerDetail>> {
|
||||
this.actionKey = `${imei}:change-number`
|
||||
const response = await nuiCall<AdminPlayerDetail>('admin:change-number', {
|
||||
imei,
|
||||
phoneNumber,
|
||||
source,
|
||||
})
|
||||
this.actionKey = ''
|
||||
if (response.success && response.data) {
|
||||
this.selectedPlayer = response.data
|
||||
delete this.deviceActivity[imei]
|
||||
this.error = ''
|
||||
} else {
|
||||
this.error = response.error ?? 'request_failed'
|
||||
}
|
||||
return response
|
||||
},
|
||||
async factoryReset(
|
||||
source: number,
|
||||
imei: string,
|
||||
): Promise<NuiResponse<AdminPlayerDetail>> {
|
||||
this.actionKey = `${imei}:factory-reset`
|
||||
const response = await nuiCall<AdminPlayerDetail>('admin:factory-reset', {
|
||||
imei,
|
||||
source,
|
||||
})
|
||||
this.actionKey = ''
|
||||
if (response.success && response.data) {
|
||||
this.selectedPlayer = response.data
|
||||
delete this.deviceActivity[imei]
|
||||
delete this.revealedCredentials[imei]
|
||||
this.error = ''
|
||||
} else {
|
||||
this.error = response.error ?? 'request_failed'
|
||||
}
|
||||
return response
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
+101
-11
@@ -806,8 +806,8 @@ const citywarnFallbackLocales = {
|
||||
}
|
||||
|
||||
const adminPanelFallbackLocales = {
|
||||
name: 'Command Center',
|
||||
subtitle: 'Protected administration',
|
||||
name: 'Phone Admin',
|
||||
subtitle: 'Administration',
|
||||
navigation: 'Admin navigation',
|
||||
refresh: 'Refresh admin data',
|
||||
loading: 'Loading protected data...',
|
||||
@@ -816,28 +816,46 @@ const adminPanelFallbackLocales = {
|
||||
players: 'Players',
|
||||
devices: 'Devices',
|
||||
apps: 'Apps',
|
||||
security: 'Security',
|
||||
accounts: 'Accounts',
|
||||
messages: 'Messages',
|
||||
calls: 'Calls',
|
||||
moderation: 'Moderation',
|
||||
audit: 'Audit',
|
||||
},
|
||||
overview: {
|
||||
eyebrow: 'Live operations',
|
||||
title: 'Command Center',
|
||||
body: 'Manage active phone devices, app access, and protected account data.',
|
||||
eyebrow: 'Server',
|
||||
title: 'Dashboard',
|
||||
body: 'Players, devices, apps, and phone data.',
|
||||
stats: 'Server phone statistics',
|
||||
online: 'Online',
|
||||
devices: 'Devices',
|
||||
accounts: 'Accounts',
|
||||
audit: 'Audit entries',
|
||||
control: 'Admin modules',
|
||||
features: 'Workspace areas',
|
||||
featuresBody: 'Jump directly to a protected administration area.',
|
||||
control: 'Navigation',
|
||||
features: 'Modules',
|
||||
featuresBody: 'Open an administration module.',
|
||||
recent: 'Recent activity',
|
||||
playerFeature: 'Identity, finances, job, and duty',
|
||||
deviceFeature: 'IMEI, SIM, number, and activity',
|
||||
appFeature: 'Install or remove phone apps',
|
||||
securityFeature: 'Account access and protected credentials',
|
||||
accountFeature: 'Account access and protected credentials',
|
||||
messageFeature: 'Review recent SMS activity',
|
||||
callFeature: 'Review recent call activity',
|
||||
moderationFeature: 'Reset access, number, or device data',
|
||||
auditFeature: 'Review sensitive admin actions',
|
||||
},
|
||||
appearance: {
|
||||
eyebrow: 'Appearance',
|
||||
title: 'Accent color',
|
||||
body: 'Change the accent across the complete admin workspace.',
|
||||
colors: {
|
||||
emerald: 'Emerald',
|
||||
blue: 'Blue',
|
||||
violet: 'Violet',
|
||||
orange: 'Orange',
|
||||
red: 'Red',
|
||||
},
|
||||
},
|
||||
players: {
|
||||
eyebrow: 'Active sessions',
|
||||
title: 'Online players',
|
||||
@@ -908,9 +926,68 @@ const adminPanelFallbackLocales = {
|
||||
protected: 'System app',
|
||||
changes: '{count} pending changes',
|
||||
},
|
||||
activity: {
|
||||
protected: 'Protected activity',
|
||||
messagesTitle: 'Messages',
|
||||
messagesBody: 'Recent SMS activity for the selected SIM.',
|
||||
callsTitle: 'Calls',
|
||||
callsBody: 'Recent call activity for the selected SIM.',
|
||||
loading: 'Loading activity...',
|
||||
incoming: 'Incoming',
|
||||
outgoing: 'Outgoing',
|
||||
mediaMessage: '{type} message',
|
||||
noMessages: 'No message activity found.',
|
||||
noCalls: 'No call activity found.',
|
||||
status: {
|
||||
completed: 'Completed',
|
||||
missed: 'Missed',
|
||||
rejected: 'Rejected',
|
||||
busy: 'Busy',
|
||||
unanswered: 'Unanswered',
|
||||
cancelled: 'Cancelled',
|
||||
failed: 'Failed',
|
||||
ringing: 'Ringing',
|
||||
},
|
||||
},
|
||||
moderation: {
|
||||
eyebrow: 'Device administration',
|
||||
title: 'Moderation actions',
|
||||
body: 'Every action is server-authorized, rate-limited, and audited.',
|
||||
resetPasscode: 'Reset passcode',
|
||||
resetPasscodeBody: 'Remove the device PIN and clear failed attempts.',
|
||||
changeNumber: 'Change number',
|
||||
changeNumberBody: 'Assign a new unique number to the current SIM.',
|
||||
factoryReset: 'Factory reset',
|
||||
factoryResetBody: 'Clear local device data and disconnect the account.',
|
||||
saveFirst: 'Save or discard pending app changes first.',
|
||||
phoneNumber: 'New phone number',
|
||||
phoneNumberPlaceholder: 'Enter the full configured number',
|
||||
typeToConfirm: 'Type {word} to confirm the factory reset.',
|
||||
confirmWord: 'RESET',
|
||||
cancel: 'Cancel',
|
||||
'reset-passcodeSuccess': 'Passcode reset.',
|
||||
'change-numberSuccess': 'Phone number changed.',
|
||||
'factory-resetSuccess': 'Phone factory reset completed.',
|
||||
dialogs: {
|
||||
'reset-passcodeTitle': 'Reset device passcode?',
|
||||
'reset-passcodeBody':
|
||||
'The player can unlock this phone without the previous PIN afterward.',
|
||||
'change-numberTitle': 'Change phone number?',
|
||||
'change-numberBody':
|
||||
'The new number must match the configured server number format and be unique.',
|
||||
'factory-resetTitle': 'Factory reset this phone?',
|
||||
'factory-resetBody':
|
||||
'This clears local device data, app settings, security, and the linked account. This cannot be undone.',
|
||||
},
|
||||
confirm: {
|
||||
'reset-passcode': 'Reset passcode',
|
||||
'change-number': 'Change number',
|
||||
'factory-reset': 'Factory reset',
|
||||
},
|
||||
},
|
||||
editor: {
|
||||
brand: 'SKY PHONE',
|
||||
workspace: 'ADMIN WORKSPACE',
|
||||
workspace: 'ADMIN',
|
||||
players: 'Player directory',
|
||||
audit: 'Audit log',
|
||||
selectPlayer:
|
||||
@@ -946,6 +1023,11 @@ const adminPanelFallbackLocales = {
|
||||
grant_app: 'App installed',
|
||||
revoke_app: 'App removed',
|
||||
reveal_account_password: 'Password revealed',
|
||||
view_messages: 'Messages viewed',
|
||||
view_calls: 'Calls viewed',
|
||||
reset_passcode: 'Passcode reset',
|
||||
change_number: 'Phone number changed',
|
||||
factory_reset: 'Phone factory reset',
|
||||
},
|
||||
},
|
||||
errors: {
|
||||
@@ -958,6 +1040,14 @@ const adminPanelFallbackLocales = {
|
||||
revision_conflict:
|
||||
'The phone changed in the meantime. Refresh and try again.',
|
||||
account_not_found: 'No iFruit account is linked to this phone.',
|
||||
invalid_phone_number:
|
||||
'Enter a phone number in the configured server format.',
|
||||
phone_number_unchanged: 'This SIM already uses that phone number.',
|
||||
phone_number_taken: 'That phone number is already assigned.',
|
||||
no_sim: 'This phone has no SIM that can be changed.',
|
||||
passcode_not_set: 'This phone has no passcode configured.',
|
||||
device_not_found: 'This phone no longer exists.',
|
||||
metadata_unsupported: 'The phone inventory metadata could not be updated.',
|
||||
invalid_request: 'The admin request was invalid.',
|
||||
request_failed: 'The admin request failed.',
|
||||
default: 'The admin panel is temporarily unavailable.',
|
||||
|
||||
@@ -86,3 +86,28 @@ export type AdminCredential = {
|
||||
email: string
|
||||
password: string
|
||||
}
|
||||
|
||||
export type AdminMessageActivity = {
|
||||
body: string
|
||||
createdAt: string
|
||||
direction: 'incoming' | 'outgoing'
|
||||
id: string
|
||||
messageType: string
|
||||
otherNumber: string
|
||||
readAt: string | null
|
||||
}
|
||||
|
||||
export type AdminCallActivity = {
|
||||
answeredAt: string | null
|
||||
direction: 'incoming' | 'outgoing'
|
||||
durationSeconds: number
|
||||
endedAt: string | null
|
||||
id: string
|
||||
otherNumber: string
|
||||
startedAt: string
|
||||
status: string
|
||||
}
|
||||
|
||||
export type AdminActivityResponse =
|
||||
| { entries: AdminMessageActivity[]; kind: 'messages' }
|
||||
| { entries: AdminCallActivity[]; kind: 'calls' }
|
||||
|
||||
@@ -3098,9 +3098,7 @@ const deviceData = {
|
||||
ringtoneVolume: 80,
|
||||
streamerMode: false,
|
||||
wallpaper: 'custom',
|
||||
wallpaperHistory: [
|
||||
{ imageUrl: demoWallpaperUrl, wallpaper: 'custom' },
|
||||
],
|
||||
wallpaperHistory: [{ imageUrl: demoWallpaperUrl, wallpaper: 'custom' }],
|
||||
wallpaperImageUrl: demoWallpaperUrl,
|
||||
},
|
||||
version: 1,
|
||||
@@ -4656,26 +4654,34 @@ const adminMockApps = {
|
||||
uninstalled: ['crypto', 'skyride'],
|
||||
}
|
||||
|
||||
const adminMockDevices = {
|
||||
1: { account: true, number: '555-0101', security: true },
|
||||
2: { account: true, number: '555-0102', security: true },
|
||||
}
|
||||
|
||||
function adminMockPlayerDetail(source = 1) {
|
||||
const primary = source === 1
|
||||
const deviceState = adminMockDevices[source] ?? adminMockDevices[1]
|
||||
return {
|
||||
birthdate: primary ? '1994-04-16' : '1998-11-03',
|
||||
devices: [
|
||||
{
|
||||
account: {
|
||||
email: primary ? 'demo@ifruit.com' : 'jordan@ifruit.com',
|
||||
id: primary ? 1 : 2,
|
||||
passwordAvailable: true,
|
||||
},
|
||||
account: deviceState.account
|
||||
? {
|
||||
email: primary ? 'demo@ifruit.com' : 'jordan@ifruit.com',
|
||||
id: primary ? 1 : 2,
|
||||
passwordAvailable: true,
|
||||
}
|
||||
: null,
|
||||
apps: { ...adminMockApps },
|
||||
createdAt: '2026-08-15 18:42:00',
|
||||
imei: primary ? '356938035643809' : '356938035643810',
|
||||
name: primary ? 'Personal iFruit Phone' : 'Service iFruit Phone',
|
||||
number: primary ? '555-0101' : '555-0102',
|
||||
number: deviceState.number,
|
||||
security: {
|
||||
enabled: true,
|
||||
enabled: deviceState.security,
|
||||
failedAttempts: 0,
|
||||
length: 6,
|
||||
length: deviceState.security ? 6 : null,
|
||||
lockedUntil: 0,
|
||||
},
|
||||
simRegistered: true,
|
||||
@@ -4792,6 +4798,85 @@ app.post('/api/:endpoint', async (request, response, next) => {
|
||||
})
|
||||
return
|
||||
}
|
||||
if (endpoint === 'admin:activity') {
|
||||
if (request.body.kind === 'messages') {
|
||||
response.json({
|
||||
success: true,
|
||||
data: {
|
||||
kind: 'messages',
|
||||
entries: [
|
||||
{
|
||||
body: 'Meet at Mission Row in ten minutes.',
|
||||
createdAt: '2026-08-20 19:03:00',
|
||||
direction: 'outgoing',
|
||||
id: 'admin-message-1',
|
||||
messageType: 'text',
|
||||
otherNumber: '555-0144',
|
||||
readAt: '2026-08-20 19:03:30',
|
||||
},
|
||||
{
|
||||
body: 'Copy, I am on my way.',
|
||||
createdAt: '2026-08-20 18:58:00',
|
||||
direction: 'incoming',
|
||||
id: 'admin-message-2',
|
||||
messageType: 'text',
|
||||
otherNumber: '555-0199',
|
||||
readAt: null,
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
response.json({
|
||||
success: true,
|
||||
data: {
|
||||
kind: 'calls',
|
||||
entries: [
|
||||
{
|
||||
answeredAt: '2026-08-20 18:49:05',
|
||||
direction: 'incoming',
|
||||
durationSeconds: 184,
|
||||
endedAt: '2026-08-20 18:52:09',
|
||||
id: 'admin-call-1',
|
||||
otherNumber: '555-0177',
|
||||
startedAt: '2026-08-20 18:49:00',
|
||||
status: 'completed',
|
||||
},
|
||||
{
|
||||
answeredAt: null,
|
||||
direction: 'outgoing',
|
||||
durationSeconds: 0,
|
||||
endedAt: '2026-08-20 17:13:18',
|
||||
id: 'admin-call-2',
|
||||
otherNumber: '555-0112',
|
||||
startedAt: '2026-08-20 17:13:00',
|
||||
status: 'missed',
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
if (endpoint === 'admin:reset-passcode') {
|
||||
const source = Number(request.body.source) || 1
|
||||
adminMockDevices[source].security = false
|
||||
response.json({ success: true, data: adminMockPlayerDetail(source) })
|
||||
return
|
||||
}
|
||||
if (endpoint === 'admin:change-number') {
|
||||
const source = Number(request.body.source) || 1
|
||||
adminMockDevices[source].number = String(request.body.phoneNumber ?? '')
|
||||
response.json({ success: true, data: adminMockPlayerDetail(source) })
|
||||
return
|
||||
}
|
||||
if (endpoint === 'admin:factory-reset') {
|
||||
const source = Number(request.body.source) || 1
|
||||
adminMockDevices[source].account = false
|
||||
adminMockDevices[source].security = false
|
||||
response.json({ success: true, data: adminMockPlayerDetail(source) })
|
||||
return
|
||||
}
|
||||
if (endpoint === 'music:add-youtube') {
|
||||
const value = String(request.body.url ?? '')
|
||||
const customTitle = String(request.body.title ?? '').trim()
|
||||
|
||||
@@ -70,6 +70,7 @@ Config.AdminPanel = {
|
||||
ActionRequestsPerMinute = 30,
|
||||
CredentialRevealsPerMinute = 6,
|
||||
AuditLimit = 40,
|
||||
ActivityLimit = 40,
|
||||
}
|
||||
|
||||
Config.Sim = {
|
||||
|
||||
@@ -202,18 +202,25 @@ Locales["de"] = {
|
||||
},
|
||||
},
|
||||
AdminPanel = {
|
||||
name = "Kommandozentrale", subtitle = "Geschützte Administration", navigation = "Admin-Navigation", refresh = "Admin-Daten aktualisieren", loading = "Geschützte Daten werden geladen...",
|
||||
tabs = { overview = "Übersicht", players = "Spieler", devices = "Geräte", apps = "Apps", security = "Sicherheit", audit = "Audit" },
|
||||
overview = { eyebrow = "Live-Betrieb", title = "Kommandozentrale", body = "Verwalte aktive Handys, App-Zugriffe und geschützte Accountdaten.", stats = "Server-Handystatistik", online = "Online", devices = "Geräte", accounts = "Accounts", audit = "Audit-Einträge", control = "Admin-Module", features = "Arbeitsbereiche", featuresBody = "Öffne direkt einen geschützten Verwaltungsbereich.", recent = "Letzte Aktivitäten", playerFeature = "Identität, Finanzen, Job und Dienst", deviceFeature = "IMEI, SIM, Nummer und Aktivität", appFeature = "Handy-Apps installieren oder entfernen", securityFeature = "Accountzugriff und geschützte Zugangsdaten", auditFeature = "Sensible Admin-Aktionen prüfen" },
|
||||
name = "Phone Admin", subtitle = "Administration", navigation = "Admin-Navigation", refresh = "Admin-Daten aktualisieren", loading = "Geschützte Daten werden geladen...",
|
||||
tabs = { overview = "Übersicht", players = "Spieler", devices = "Geräte", apps = "Apps", accounts = "Accounts", messages = "Nachrichten", calls = "Anrufe", moderation = "Moderation", audit = "Audit" },
|
||||
overview = { eyebrow = "Server", title = "Dashboard", body = "Spieler, Geräte, Apps und Handydaten.", stats = "Server-Handystatistik", online = "Online", devices = "Geräte", accounts = "Accounts", audit = "Audit-Einträge", control = "Navigation", features = "Module", featuresBody = "Öffne ein Verwaltungsmodul.", recent = "Letzte Aktivitäten", playerFeature = "Identität, Finanzen, Job und Dienst", deviceFeature = "IMEI, SIM, Nummer und Aktivität", appFeature = "Handy-Apps installieren oder entfernen", accountFeature = "Accountzugriff und geschützte Zugangsdaten", messageFeature = "Letzte SMS-Aktivitäten prüfen", callFeature = "Letzte Anrufaktivitäten prüfen", moderationFeature = "Zugriff, Nummer oder Gerätedaten zurücksetzen", auditFeature = "Sensible Admin-Aktionen prüfen" },
|
||||
appearance = { eyebrow = "Darstellung", title = "Akzentfarbe", body = "Ändere den Akzent im gesamten Admin-Arbeitsbereich.", colors = { emerald = "Smaragd", blue = "Blau", violet = "Violett", orange = "Orange", red = "Rot" } },
|
||||
players = { eyebrow = "Aktive Sitzungen", title = "Online-Spieler", online = "Jetzt online", empty = "Keine Spieler gefunden", emptyBody = "Passe die Suche an oder aktualisiere die Spielerliste." },
|
||||
search = { players = "Name, ID, Job oder Nummer suchen", apps = "Apps suchen", clear = "Suche leeren" },
|
||||
detail = { character = "Charakterprofil", data = "Spielerdatenübersicht", cash = "Bargeld", bank = "Bank", job = "Job", duty = "Dienst", onDuty = "Im Dienst", offDuty = "Außer Dienst", identity = "Identität", playerData = "Spielerdaten", identifier = "Charakter-Identifier", birthdate = "Geburtsdatum", grade = "Job-Rang", unknown = "Unbekannt" },
|
||||
devices = { eyebrow = "Gerätesteuerung", title = "Handys", body = "Prüfe alle Handys des ausgewählten Spielers.", choose = "Handy auswählen", empty = "Kein Handy gefunden", emptyBody = "Dieser Spieler besitzt aktuell kein verwaltbares Handy.", noNumber = "Keine Telefonnummer", noSim = "Keine SIM", imei = "IMEI", updated = "Letzte Aktivität", apps = "Zugewiesene Apps", account = "Verknüpfter Account" },
|
||||
credentials = { eyebrow = "Geschützte Daten", title = "Zugangsdaten", email = "iFruit-E-Mail", password = "iFruit-Passwort", reveal = "Anzeigen", copy = "Passwort kopieren", copied = "Passwort kopiert.", noAccount = "Mit diesem Handy ist kein iFruit-Account verknüpft.", passcode = "Gerätecode", passcodeHashed = "{length}-stellige PIN · sicher gehasht und nicht wiederherstellbar", passcodeDisabled = "Kein Gerätecode eingerichtet", revealTitle = "Geschütztes Passwort anzeigen?", revealBody = "Diese Aktion wird serverseitig autorisiert, rate-limitiert und im Admin-Audit protokolliert.", cancel = "Abbrechen", confirmReveal = "Passwort anzeigen" },
|
||||
apps = { eyebrow = "Fernverwaltung", title = "App-Zugriff", description = "Lege App-Zugriffe für dieses Gerät als Entwurf fest. Erst Speichern übernimmt die Änderungen.", installed = "Installiert", available = "Verfügbar", protected = "System-App", changes = "{count} offene Änderungen" },
|
||||
audit = { eyebrow = "Nachvollziehbarkeit", title = "Audit-Verlauf", body = "Sensible Anzeigen und App-Änderungen werden hier protokolliert.", empty = "Noch keine Admin-Aktionen", emptyBody = "Geschützte Aktionen erscheinen hier, nachdem sie ausgeführt wurden.", by = "{actor} · Ziel-ID {target}", actions = { grant_app = "App installiert", revoke_app = "App entfernt", reveal_account_password = "Passwort angezeigt" } },
|
||||
editor = { brand = "SKY PHONE", workspace = "ADMIN WORKSPACE", players = "Spielerverzeichnis", audit = "Audit-Protokoll", selectPlayer = "Wähle einen Spieler, um Identität, Geräte, Zugangsdaten und App-Zugriffe zu prüfen.", save = "Änderungen speichern", saveHint = "Offene Änderungen übernehmen", saved = "Änderungen gespeichert.", unsaved = "Ungespeicherte Änderungen", close = "Admin-Panel schließen", refresh = "Live-Daten aktualisieren", online = "LIVE", profile = "PROFIL", financial = "FINANZEN", device = "GERÄT", security = "SICHERHEIT", noAutoSave = "Manuelles Speichern", noAutoSaveBody = "Änderungen bleiben lokal, bis der grüne Haken gedrückt wird.", discardTitle = "Ungespeicherte Änderungen verwerfen?", discardBody = "Deine vorgemerkten App-Änderungen wurden noch nicht gespeichert.", keepEditing = "Weiter bearbeiten", discard = "Änderungen verwerfen", saveFailed = "Einige Änderungen konnten nicht gespeichert werden.", noSelection = "Kein Spieler ausgewählt" },
|
||||
errors = { not_authorized = "Du hast keinen Zugriff auf das Admin-Panel.", rate_limited = "Zu viele Admin-Anfragen. Bitte warte.", player_unavailable = "Dieser Spieler ist nicht mehr online.", device_not_owned = "Dieses Handy gehört nicht mehr zum ausgewählten Spieler.", invalid_app = "Diese App ist nicht auf dem Server registriert.", app_protected = "Diese System-App kann nicht entfernt werden.", revision_conflict = "Das Handy wurde zwischenzeitlich geändert. Aktualisiere und versuche es erneut.", account_not_found = "Mit diesem Handy ist kein iFruit-Account verknüpft.", invalid_request = "Die Admin-Anfrage war ungültig.", request_failed = "Die Admin-Anfrage ist fehlgeschlagen.", default = "Das Admin-Panel ist vorübergehend nicht verfügbar." },
|
||||
activity = { protected = "Geschützte Aktivität", messagesTitle = "Nachrichten", messagesBody = "Letzte SMS-Aktivitäten der ausgewählten SIM.", callsTitle = "Anrufe", callsBody = "Letzte Anrufaktivitäten der ausgewählten SIM.", loading = "Aktivitäten werden geladen...", incoming = "Eingehend", outgoing = "Ausgehend", mediaMessage = "{type}-Nachricht", noMessages = "Keine Nachrichtenaktivität gefunden.", noCalls = "Keine Anrufaktivität gefunden.", status = { completed = "Abgeschlossen", missed = "Verpasst", rejected = "Abgelehnt", busy = "Besetzt", unanswered = "Unbeantwortet", cancelled = "Abgebrochen", failed = "Fehlgeschlagen", ringing = "Klingelt" } },
|
||||
moderation = {
|
||||
eyebrow = "Geräteverwaltung", title = "Moderationsaktionen", body = "Jede Aktion wird serverseitig autorisiert, rate-limitiert und protokolliert.", resetPasscode = "Gerätecode zurücksetzen", resetPasscodeBody = "Entfernt die Geräte-PIN und fehlgeschlagene Versuche.", changeNumber = "Nummer ändern", changeNumberBody = "Weist der aktuellen SIM eine neue eindeutige Nummer zu.", factoryReset = "Werksreset", factoryResetBody = "Löscht lokale Gerätedaten und trennt den Account.", saveFirst = "Speichere oder verwirf zuerst offene App-Änderungen.", phoneNumber = "Neue Telefonnummer", phoneNumberPlaceholder = "Vollständige konfigurierte Nummer eingeben", typeToConfirm = "Tippe {word}, um den Werksreset zu bestätigen.", confirmWord = "RESET", cancel = "Abbrechen", ["reset-passcodeSuccess"] = "Gerätecode zurückgesetzt.", ["change-numberSuccess"] = "Telefonnummer geändert.", ["factory-resetSuccess"] = "Werksreset abgeschlossen.",
|
||||
dialogs = { ["reset-passcodeTitle"] = "Gerätecode zurücksetzen?", ["reset-passcodeBody"] = "Der Spieler kann dieses Handy danach ohne die bisherige PIN entsperren.", ["change-numberTitle"] = "Telefonnummer ändern?", ["change-numberBody"] = "Die neue Nummer muss dem Serverformat entsprechen und eindeutig sein.", ["factory-resetTitle"] = "Werksreset für dieses Handy?", ["factory-resetBody"] = "Lokale Gerätedaten, App-Einstellungen, Sicherheit und der verknüpfte Account werden gelöscht. Das kann nicht rückgängig gemacht werden." },
|
||||
confirm = { ["reset-passcode"] = "Gerätecode zurücksetzen", ["change-number"] = "Nummer ändern", ["factory-reset"] = "Werksreset" },
|
||||
},
|
||||
audit = { eyebrow = "Nachvollziehbarkeit", title = "Audit-Verlauf", body = "Sensible Anzeigen und App-Änderungen werden hier protokolliert.", empty = "Noch keine Admin-Aktionen", emptyBody = "Geschützte Aktionen erscheinen hier, nachdem sie ausgeführt wurden.", by = "{actor} · Ziel-ID {target}", actions = { grant_app = "App installiert", revoke_app = "App entfernt", reveal_account_password = "Passwort angezeigt", view_messages = "Nachrichten angesehen", view_calls = "Anrufe angesehen", reset_passcode = "Gerätecode zurückgesetzt", change_number = "Telefonnummer geändert", factory_reset = "Werksreset ausgeführt" } },
|
||||
editor = { brand = "SKY PHONE", workspace = "ADMIN", players = "Spielerverzeichnis", audit = "Audit-Protokoll", selectPlayer = "Wähle einen Spieler, um Identität, Geräte, Zugangsdaten und App-Zugriffe zu prüfen.", save = "Änderungen speichern", saveHint = "Offene Änderungen übernehmen", saved = "Änderungen gespeichert.", unsaved = "Ungespeicherte Änderungen", close = "Admin-Panel schließen", refresh = "Live-Daten aktualisieren", online = "LIVE", profile = "PROFIL", financial = "FINANZEN", device = "GERÄT", security = "SICHERHEIT", noAutoSave = "Manuelles Speichern", noAutoSaveBody = "Änderungen bleiben lokal, bis der grüne Haken gedrückt wird.", discardTitle = "Ungespeicherte Änderungen verwerfen?", discardBody = "Deine vorgemerkten App-Änderungen wurden noch nicht gespeichert.", keepEditing = "Weiter bearbeiten", discard = "Änderungen verwerfen", saveFailed = "Einige Änderungen konnten nicht gespeichert werden.", noSelection = "Kein Spieler ausgewählt" },
|
||||
errors = { not_authorized = "Du hast keinen Zugriff auf das Admin-Panel.", rate_limited = "Zu viele Admin-Anfragen. Bitte warte.", player_unavailable = "Dieser Spieler ist nicht mehr online.", device_not_owned = "Dieses Handy gehört nicht mehr zum ausgewählten Spieler.", invalid_app = "Diese App ist nicht auf dem Server registriert.", app_protected = "Diese System-App kann nicht entfernt werden.", revision_conflict = "Das Handy wurde zwischenzeitlich geändert. Aktualisiere und versuche es erneut.", account_not_found = "Mit diesem Handy ist kein iFruit-Account verknüpft.", invalid_phone_number = "Gib eine Telefonnummer im konfigurierten Serverformat ein.", phone_number_unchanged = "Diese SIM verwendet diese Telefonnummer bereits.", phone_number_taken = "Diese Telefonnummer ist bereits vergeben.", no_sim = "Dieses Handy besitzt keine änderbare SIM.", passcode_not_set = "Für dieses Handy ist kein Gerätecode eingerichtet.", device_not_found = "Dieses Handy existiert nicht mehr.", metadata_unsupported = "Die Inventar-Metadaten des Handys konnten nicht aktualisiert werden.", invalid_request = "Die Admin-Anfrage war ungültig.", request_failed = "Die Admin-Anfrage ist fehlgeschlagen.", default = "Das Admin-Panel ist vorübergehend nicht verfügbar." },
|
||||
},
|
||||
Apps = {
|
||||
health = {
|
||||
|
||||
@@ -202,18 +202,25 @@ Locales["en"] = {
|
||||
},
|
||||
},
|
||||
AdminPanel = {
|
||||
name = "Command Center", subtitle = "Protected administration", navigation = "Admin navigation", refresh = "Refresh admin data", loading = "Loading protected data...",
|
||||
tabs = { overview = "Overview", players = "Players", devices = "Devices", apps = "Apps", security = "Security", audit = "Audit" },
|
||||
overview = { eyebrow = "Live operations", title = "Command Center", body = "Manage active phone devices, app access, and protected account data.", stats = "Server phone statistics", online = "Online", devices = "Devices", accounts = "Accounts", audit = "Audit entries", control = "Admin modules", features = "Workspace areas", featuresBody = "Jump directly to a protected administration area.", recent = "Recent activity", playerFeature = "Identity, finances, job, and duty", deviceFeature = "IMEI, SIM, number, and activity", appFeature = "Install or remove phone apps", securityFeature = "Account access and protected credentials", auditFeature = "Review sensitive admin actions" },
|
||||
name = "Phone Admin", subtitle = "Administration", navigation = "Admin navigation", refresh = "Refresh admin data", loading = "Loading protected data...",
|
||||
tabs = { overview = "Overview", players = "Players", devices = "Devices", apps = "Apps", accounts = "Accounts", messages = "Messages", calls = "Calls", moderation = "Moderation", audit = "Audit" },
|
||||
overview = { eyebrow = "Server", title = "Dashboard", body = "Players, devices, apps, and phone data.", stats = "Server phone statistics", online = "Online", devices = "Devices", accounts = "Accounts", audit = "Audit entries", control = "Navigation", features = "Modules", featuresBody = "Open an administration module.", recent = "Recent activity", playerFeature = "Identity, finances, job, and duty", deviceFeature = "IMEI, SIM, number, and activity", appFeature = "Install or remove phone apps", accountFeature = "Account access and protected credentials", messageFeature = "Review recent SMS activity", callFeature = "Review recent call activity", moderationFeature = "Reset access, number, or device data", auditFeature = "Review sensitive admin actions" },
|
||||
appearance = { eyebrow = "Appearance", title = "Accent color", body = "Change the accent across the complete admin workspace.", colors = { emerald = "Emerald", blue = "Blue", violet = "Violet", orange = "Orange", red = "Red" } },
|
||||
players = { eyebrow = "Active sessions", title = "Online players", online = "Online now", empty = "No players found", emptyBody = "Adjust the search or refresh the live player list." },
|
||||
search = { players = "Search name, ID, job, or number", apps = "Search apps", clear = "Clear search" },
|
||||
detail = { character = "Character profile", data = "Player data overview", cash = "Cash", bank = "Bank", job = "Job", duty = "Duty", onDuty = "On duty", offDuty = "Off duty", identity = "Identity", playerData = "Player data", identifier = "Character identifier", birthdate = "Birthdate", grade = "Job grade", unknown = "Unknown" },
|
||||
devices = { eyebrow = "Device control", title = "Phones", body = "Inspect every phone assigned to the selected player.", choose = "Choose phone", empty = "No phone found", emptyBody = "This player currently has no phone device that can be managed.", noNumber = "No phone number", noSim = "No SIM", imei = "IMEI", updated = "Last activity", apps = "Claimed apps", account = "Linked account" },
|
||||
credentials = { eyebrow = "Protected data", title = "Credentials", email = "iFruit email", password = "iFruit password", reveal = "Reveal", copy = "Copy password", copied = "Password copied.", noAccount = "No iFruit account is linked to this phone.", passcode = "Device passcode", passcodeHashed = "{length}-digit PIN · securely hashed and not recoverable", passcodeDisabled = "No passcode configured", revealTitle = "Reveal protected password?", revealBody = "This action is server-authorized, rate-limited, and written to the admin audit log.", cancel = "Cancel", confirmReveal = "Reveal password" },
|
||||
apps = { eyebrow = "Remote management", title = "App access", description = "Stage app access for this device. Nothing changes until you save.", installed = "Installed", available = "Available", protected = "System app", changes = "{count} pending changes" },
|
||||
audit = { eyebrow = "Accountability", title = "Audit trail", body = "Sensitive reveals and remote app changes are recorded here.", empty = "No admin actions yet", emptyBody = "Protected actions will appear here after they are performed.", by = "{actor} · target ID {target}", actions = { grant_app = "App installed", revoke_app = "App removed", reveal_account_password = "Password revealed" } },
|
||||
editor = { brand = "SKY PHONE", workspace = "ADMIN WORKSPACE", players = "Player directory", audit = "Audit log", selectPlayer = "Select a player to inspect identity, devices, credentials, and app access.", save = "Save changes", saveHint = "Apply pending changes", saved = "Changes saved.", unsaved = "Unsaved changes", close = "Close admin panel", refresh = "Refresh live data", online = "LIVE", profile = "PROFILE", financial = "FINANCIAL", device = "DEVICE", security = "SECURITY", noAutoSave = "Manual save", noAutoSaveBody = "Changes stay local until the green check is pressed.", discardTitle = "Discard unsaved changes?", discardBody = "Your staged app changes have not been saved.", keepEditing = "Keep editing", discard = "Discard changes", saveFailed = "Some changes could not be saved.", noSelection = "No player selected" },
|
||||
errors = { not_authorized = "You do not have access to the admin panel.", rate_limited = "Too many admin requests. Please wait.", player_unavailable = "That player is no longer online.", device_not_owned = "That phone no longer belongs to the selected player.", invalid_app = "That app is not registered on the server.", app_protected = "This system app cannot be removed.", revision_conflict = "The phone changed in the meantime. Refresh and try again.", account_not_found = "No iFruit account is linked to this phone.", invalid_request = "The admin request was invalid.", request_failed = "The admin request failed.", default = "The admin panel is temporarily unavailable." },
|
||||
activity = { protected = "Protected activity", messagesTitle = "Messages", messagesBody = "Recent SMS activity for the selected SIM.", callsTitle = "Calls", callsBody = "Recent call activity for the selected SIM.", loading = "Loading activity...", incoming = "Incoming", outgoing = "Outgoing", mediaMessage = "{type} message", noMessages = "No message activity found.", noCalls = "No call activity found.", status = { completed = "Completed", missed = "Missed", rejected = "Rejected", busy = "Busy", unanswered = "Unanswered", cancelled = "Cancelled", failed = "Failed", ringing = "Ringing" } },
|
||||
moderation = {
|
||||
eyebrow = "Device administration", title = "Moderation actions", body = "Every action is server-authorized, rate-limited, and audited.", resetPasscode = "Reset passcode", resetPasscodeBody = "Remove the device PIN and clear failed attempts.", changeNumber = "Change number", changeNumberBody = "Assign a new unique number to the current SIM.", factoryReset = "Factory reset", factoryResetBody = "Clear local device data and disconnect the account.", saveFirst = "Save or discard pending app changes first.", phoneNumber = "New phone number", phoneNumberPlaceholder = "Enter the full configured number", typeToConfirm = "Type {word} to confirm the factory reset.", confirmWord = "RESET", cancel = "Cancel", ["reset-passcodeSuccess"] = "Passcode reset.", ["change-numberSuccess"] = "Phone number changed.", ["factory-resetSuccess"] = "Phone factory reset completed.",
|
||||
dialogs = { ["reset-passcodeTitle"] = "Reset device passcode?", ["reset-passcodeBody"] = "The player can unlock this phone without the previous PIN afterward.", ["change-numberTitle"] = "Change phone number?", ["change-numberBody"] = "The new number must match the configured server number format and be unique.", ["factory-resetTitle"] = "Factory reset this phone?", ["factory-resetBody"] = "This clears local device data, app settings, security, and the linked account. This cannot be undone." },
|
||||
confirm = { ["reset-passcode"] = "Reset passcode", ["change-number"] = "Change number", ["factory-reset"] = "Factory reset" },
|
||||
},
|
||||
audit = { eyebrow = "Accountability", title = "Audit trail", body = "Sensitive reveals and remote app changes are recorded here.", empty = "No admin actions yet", emptyBody = "Protected actions will appear here after they are performed.", by = "{actor} · target ID {target}", actions = { grant_app = "App installed", revoke_app = "App removed", reveal_account_password = "Password revealed", view_messages = "Messages viewed", view_calls = "Calls viewed", reset_passcode = "Passcode reset", change_number = "Phone number changed", factory_reset = "Phone factory reset" } },
|
||||
editor = { brand = "SKY PHONE", workspace = "ADMIN", players = "Player directory", audit = "Audit log", selectPlayer = "Select a player to inspect identity, devices, credentials, and app access.", save = "Save changes", saveHint = "Apply pending changes", saved = "Changes saved.", unsaved = "Unsaved changes", close = "Close admin panel", refresh = "Refresh live data", online = "LIVE", profile = "PROFILE", financial = "FINANCIAL", device = "DEVICE", security = "SECURITY", noAutoSave = "Manual save", noAutoSaveBody = "Changes stay local until the green check is pressed.", discardTitle = "Discard unsaved changes?", discardBody = "Your staged app changes have not been saved.", keepEditing = "Keep editing", discard = "Discard changes", saveFailed = "Some changes could not be saved.", noSelection = "No player selected" },
|
||||
errors = { not_authorized = "You do not have access to the admin panel.", rate_limited = "Too many admin requests. Please wait.", player_unavailable = "That player is no longer online.", device_not_owned = "That phone no longer belongs to the selected player.", invalid_app = "That app is not registered on the server.", app_protected = "This system app cannot be removed.", revision_conflict = "The phone changed in the meantime. Refresh and try again.", account_not_found = "No iFruit account is linked to this phone.", invalid_phone_number = "Enter a phone number in the configured server format.", phone_number_unchanged = "This SIM already uses that phone number.", phone_number_taken = "That phone number is already assigned.", no_sim = "This phone has no SIM that can be changed.", passcode_not_set = "This phone has no passcode configured.", device_not_found = "This phone no longer exists.", metadata_unsupported = "The phone inventory metadata could not be updated.", invalid_request = "The admin request was invalid.", request_failed = "The admin request failed.", default = "The admin panel is temporarily unavailable." },
|
||||
},
|
||||
Apps = {
|
||||
health = {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
local callback_groups = {
|
||||
account = [[login register logout devices remove-device]],
|
||||
admin = [[bootstrap player save-apps reveal-password]],
|
||||
admin = [[
|
||||
bootstrap player save-apps reveal-password activity
|
||||
reset-passcode change-number factory-reset
|
||||
]],
|
||||
banking = [[overview transfer]],
|
||||
billing = [[overview list detail markRead pay dispute]],
|
||||
calendar = [[list create update delete]],
|
||||
|
||||
@@ -340,6 +340,17 @@ local function find_owned_device(source, imei)
|
||||
return nil, identifier
|
||||
end
|
||||
|
||||
local function load_device_sim(imei)
|
||||
local rows = Bridge.Database.Query([[
|
||||
SELECT sim.`id`, sim.`phone_number`
|
||||
FROM `sky_phone_devices` device
|
||||
JOIN `sky_phone_sims` sim ON sim.`id` = device.`sim_id`
|
||||
WHERE device.`imei` = ?
|
||||
LIMIT 1
|
||||
]], { imei })
|
||||
return rows[1]
|
||||
end
|
||||
|
||||
local function app_metadata(app_id)
|
||||
if BUILTIN_APPS[app_id] then
|
||||
return {
|
||||
@@ -636,4 +647,218 @@ Bridge.Callbacks.Register("sky_phone:admin:reveal-password", function(source, da
|
||||
},
|
||||
}
|
||||
end)
|
||||
|
||||
Bridge.Callbacks.Register("sky_phone:admin:activity", function(source, data)
|
||||
local authorized, error_response = require_admin(
|
||||
source,
|
||||
"activity",
|
||||
Config.AdminPanel.ReadRequestsPerMinute
|
||||
)
|
||||
if not authorized then
|
||||
return error_response
|
||||
end
|
||||
if type(data) ~= "table"
|
||||
or not SkyPhoneImei.IsValid(data.imei)
|
||||
or (data.kind ~= "messages" and data.kind ~= "calls")
|
||||
then
|
||||
return { success = false, error = "invalid_request" }
|
||||
end
|
||||
|
||||
local target_source = normalize_source(data.source)
|
||||
if not target_source then
|
||||
return { success = false, error = "player_unavailable" }
|
||||
end
|
||||
local device, target_identifier = find_owned_device(target_source, data.imei)
|
||||
if not device then
|
||||
return { success = false, error = "device_not_owned" }
|
||||
end
|
||||
local audit_action = data.kind == "messages" and "view_messages" or "view_calls"
|
||||
local sim = load_device_sim(data.imei)
|
||||
if not sim then
|
||||
write_audit(
|
||||
source,
|
||||
target_source,
|
||||
target_identifier,
|
||||
data.imei,
|
||||
audit_action,
|
||||
{ count = 0 }
|
||||
)
|
||||
return { success = true, data = { kind = data.kind, entries = {} } }
|
||||
end
|
||||
|
||||
local limit = math.max(1, math.min(100, math.floor(tonumber(Config.AdminPanel.ActivityLimit) or 40)))
|
||||
local entries = {}
|
||||
if data.kind == "messages" then
|
||||
local rows = Bridge.Database.Query(([[
|
||||
SELECT `id`, `sender_sim_id`, `sender_number`, `recipient_number`, `message_type`,
|
||||
`body`, `read_at`, `created_at`
|
||||
FROM `sky_phone_sms_messages`
|
||||
WHERE `sender_sim_id` = ? OR `recipient_sim_id` = ?
|
||||
ORDER BY `created_at` DESC
|
||||
LIMIT %s
|
||||
]]):format(limit), { sim.id, sim.id })
|
||||
for _, row in ipairs(rows) do
|
||||
local outgoing = row.sender_sim_id == sim.id
|
||||
entries[#entries + 1] = {
|
||||
id = row.id,
|
||||
direction = outgoing and "outgoing" or "incoming",
|
||||
otherNumber = outgoing and row.recipient_number or row.sender_number,
|
||||
messageType = row.message_type,
|
||||
body = row.body,
|
||||
readAt = row.read_at,
|
||||
createdAt = row.created_at,
|
||||
}
|
||||
end
|
||||
else
|
||||
local rows = Bridge.Database.Query(([[
|
||||
SELECT `id`, `caller_sim_id`, `caller_number`, `callee_number`, `status`,
|
||||
`started_at`, `answered_at`, `ended_at`, `duration_seconds`
|
||||
FROM `sky_phone_calls`
|
||||
WHERE `caller_sim_id` = ? OR `callee_sim_id` = ?
|
||||
ORDER BY `started_at` DESC
|
||||
LIMIT %s
|
||||
]]):format(limit), { sim.id, sim.id })
|
||||
for _, row in ipairs(rows) do
|
||||
local outgoing = row.caller_sim_id == sim.id
|
||||
entries[#entries + 1] = {
|
||||
id = row.id,
|
||||
direction = outgoing and "outgoing" or "incoming",
|
||||
otherNumber = outgoing and row.callee_number or row.caller_number,
|
||||
status = row.status,
|
||||
startedAt = row.started_at,
|
||||
answeredAt = row.answered_at,
|
||||
endedAt = row.ended_at,
|
||||
durationSeconds = tonumber(row.duration_seconds) or 0,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
write_audit(
|
||||
source,
|
||||
target_source,
|
||||
target_identifier,
|
||||
data.imei,
|
||||
audit_action,
|
||||
{ count = #entries }
|
||||
)
|
||||
return { success = true, data = { kind = data.kind, entries = entries } }
|
||||
end)
|
||||
|
||||
Bridge.Callbacks.Register("sky_phone:admin:reset-passcode", function(source, data)
|
||||
local authorized, error_response = require_admin(
|
||||
source,
|
||||
"reset_passcode",
|
||||
Config.AdminPanel.ActionRequestsPerMinute
|
||||
)
|
||||
if not authorized then
|
||||
return error_response
|
||||
end
|
||||
if type(data) ~= "table" or not SkyPhoneImei.IsValid(data.imei) then
|
||||
return { success = false, error = "invalid_request" }
|
||||
end
|
||||
|
||||
local target_source = normalize_source(data.source)
|
||||
if not target_source then
|
||||
return { success = false, error = "player_unavailable" }
|
||||
end
|
||||
local device, target_identifier = find_owned_device(target_source, data.imei)
|
||||
if not device then
|
||||
return { success = false, error = "device_not_owned" }
|
||||
end
|
||||
local result = Bridge.Database.Query(
|
||||
"DELETE FROM `sky_phone_device_security` WHERE `device_imei` = ?",
|
||||
{ data.imei }
|
||||
)
|
||||
if affected_rows(result) ~= 1 then
|
||||
return { success = false, error = "passcode_not_set" }
|
||||
end
|
||||
|
||||
write_audit(source, target_source, target_identifier, data.imei, "reset_passcode", {})
|
||||
SkyPhone.RefreshDevice(data.imei)
|
||||
return { success = true, data = load_player_detail(target_source) }
|
||||
end)
|
||||
|
||||
Bridge.Callbacks.Register("sky_phone:admin:change-number", function(source, data)
|
||||
local authorized, error_response = require_admin(
|
||||
source,
|
||||
"change_number",
|
||||
Config.AdminPanel.ActionRequestsPerMinute
|
||||
)
|
||||
if not authorized then
|
||||
return error_response
|
||||
end
|
||||
if type(data) ~= "table"
|
||||
or not SkyPhoneImei.IsValid(data.imei)
|
||||
or (type(data.phoneNumber) ~= "string" and type(data.phoneNumber) ~= "number")
|
||||
then
|
||||
return { success = false, error = "invalid_request" }
|
||||
end
|
||||
|
||||
local target_source = normalize_source(data.source)
|
||||
if not target_source then
|
||||
return { success = false, error = "player_unavailable" }
|
||||
end
|
||||
local device, target_identifier = find_owned_device(target_source, data.imei)
|
||||
if not device then
|
||||
return { success = false, error = "device_not_owned" }
|
||||
end
|
||||
local sim = load_device_sim(data.imei)
|
||||
if not sim then
|
||||
return { success = false, error = "no_sim" }
|
||||
end
|
||||
|
||||
local changed, number_or_error = SkyPhoneSim.ChangeNumber(
|
||||
target_source,
|
||||
data.imei,
|
||||
sim.id,
|
||||
data.phoneNumber
|
||||
)
|
||||
if not changed then
|
||||
return { success = false, error = number_or_error }
|
||||
end
|
||||
|
||||
SkyPhoneCompanies.ClearCallAvailability(target_source)
|
||||
SkyPhoneCalls.EndForSim(sim.id, "number_changed")
|
||||
write_audit(source, target_source, target_identifier, data.imei, "change_number", {
|
||||
previousNumber = sim.phone_number,
|
||||
phoneNumber = number_or_error,
|
||||
})
|
||||
SkyPhone.RefreshDevice(data.imei)
|
||||
return { success = true, data = load_player_detail(target_source) }
|
||||
end)
|
||||
|
||||
Bridge.Callbacks.Register("sky_phone:admin:factory-reset", function(source, data)
|
||||
local authorized, error_response = require_admin(
|
||||
source,
|
||||
"factory_reset",
|
||||
Config.AdminPanel.ActionRequestsPerMinute
|
||||
)
|
||||
if not authorized then
|
||||
return error_response
|
||||
end
|
||||
if type(data) ~= "table" or not SkyPhoneImei.IsValid(data.imei) then
|
||||
return { success = false, error = "invalid_request" }
|
||||
end
|
||||
|
||||
local target_source = normalize_source(data.source)
|
||||
if not target_source then
|
||||
return { success = false, error = "player_unavailable" }
|
||||
end
|
||||
local device, target_identifier = find_owned_device(target_source, data.imei)
|
||||
if not device then
|
||||
return { success = false, error = "device_not_owned" }
|
||||
end
|
||||
|
||||
local reset, phone_number_or_error = SkyPhonePersistence.FactoryReset(data.imei)
|
||||
if not reset then
|
||||
return { success = false, error = phone_number_or_error }
|
||||
end
|
||||
|
||||
write_audit(source, target_source, target_identifier, data.imei, "factory_reset", {})
|
||||
if phone_number_or_error then
|
||||
TriggerEvent("sky_phone:server:factoryReset", target_source, phone_number_or_error)
|
||||
end
|
||||
SkyPhone.RefreshDevice(data.imei)
|
||||
return { success = true, data = load_player_detail(target_source) }
|
||||
end)
|
||||
end)
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
Bridge.Database.AfterMigration("sky_phone", function()
|
||||
SkyPhonePersistence = {}
|
||||
|
||||
local max_device_data_bytes = 100000
|
||||
local allowed_device_namespaces = {
|
||||
settings = true,
|
||||
@@ -150,6 +152,69 @@ Bridge.Callbacks.Register("sky_phone:notifications:save", function(source, data)
|
||||
return { success = true }
|
||||
end)
|
||||
|
||||
function SkyPhonePersistence.FactoryReset(imei)
|
||||
if not SkyPhoneImei.IsValid(imei) then
|
||||
return false, "invalid_request"
|
||||
end
|
||||
|
||||
local device = SkyPhone.LoadDevice(imei)
|
||||
if not device then
|
||||
return false, "device_not_found"
|
||||
end
|
||||
local phone_number = device and device.phone_number or nil
|
||||
local media_remote_ids = SkyPhoneMedia.GetDeviceRemoteIds(imei)
|
||||
if not Bridge.Database.Transaction({
|
||||
{
|
||||
query = "DELETE FROM `sky_phone_device_security` WHERE `device_imei` = ?",
|
||||
params = { imei },
|
||||
},
|
||||
{
|
||||
query = "DELETE FROM `sky_phone_device_data` WHERE `device_imei` = ?",
|
||||
params = { imei },
|
||||
},
|
||||
{
|
||||
query = "DELETE FROM `sky_phone_custom_app_data` WHERE `device_imei` = ?",
|
||||
params = { imei },
|
||||
},
|
||||
{
|
||||
query = "DELETE FROM `sky_phone_notes` WHERE `device_imei` = ? AND `account_id` IS NULL",
|
||||
params = { imei },
|
||||
},
|
||||
{
|
||||
query = "DELETE FROM `sky_phone_media` WHERE `device_imei` = ? AND `account_id` IS NULL",
|
||||
params = { imei },
|
||||
},
|
||||
{
|
||||
query = "DELETE FROM `sky_phone_music_playlists` WHERE `device_imei` = ? AND `account_id` IS NULL",
|
||||
params = { imei },
|
||||
},
|
||||
{
|
||||
query = "DELETE FROM `sky_phone_music_youtube_songs` WHERE `device_imei` = ? AND `account_id` IS NULL",
|
||||
params = { imei },
|
||||
},
|
||||
{
|
||||
query = "DELETE FROM `sky_phone_contacts` WHERE `device_imei` = ? AND `account_id` IS NULL",
|
||||
params = { imei },
|
||||
},
|
||||
{
|
||||
query = "DELETE FROM `sky_phone_call_entries` WHERE `device_imei` = ? AND `account_id` IS NULL",
|
||||
params = { imei },
|
||||
},
|
||||
{
|
||||
query = "DELETE FROM `sky_phone_fliptok_sessions` WHERE `device_imei` = ?",
|
||||
params = { imei },
|
||||
},
|
||||
{
|
||||
query = "UPDATE `sky_phone_devices` SET `account_id` = NULL, `device_name` = ? WHERE `imei` = ?",
|
||||
params = { Config.Phone.DeviceName, imei },
|
||||
},
|
||||
}) then
|
||||
return false, "request_failed"
|
||||
end
|
||||
SkyPhoneMedia.CleanupRemoteFiles(media_remote_ids)
|
||||
return true, phone_number
|
||||
end
|
||||
|
||||
Bridge.Callbacks.Register("sky_phone:device:factory-reset", function(source)
|
||||
if not SkyPhone.AllowOperation(source, "factory_reset", 3, 60) then
|
||||
return { success = false, error = "rate_limited" }
|
||||
@@ -158,58 +223,11 @@ Bridge.Callbacks.Register("sky_phone:device:factory-reset", function(source)
|
||||
if not session then
|
||||
return error_response
|
||||
end
|
||||
local device = SkyPhone.LoadDevice(session.imei)
|
||||
local phone_number = device and device.phone_number or nil
|
||||
local media_remote_ids = SkyPhoneMedia.GetDeviceRemoteIds(session.imei)
|
||||
if not Bridge.Database.Transaction({
|
||||
{
|
||||
query = "DELETE FROM `sky_phone_device_security` WHERE `device_imei` = ?",
|
||||
params = { session.imei },
|
||||
},
|
||||
{
|
||||
query = "DELETE FROM `sky_phone_device_data` WHERE `device_imei` = ?",
|
||||
params = { session.imei },
|
||||
},
|
||||
{
|
||||
query = "DELETE FROM `sky_phone_custom_app_data` WHERE `device_imei` = ?",
|
||||
params = { session.imei },
|
||||
},
|
||||
{
|
||||
query = "DELETE FROM `sky_phone_notes` WHERE `device_imei` = ? AND `account_id` IS NULL",
|
||||
params = { session.imei },
|
||||
},
|
||||
{
|
||||
query = "DELETE FROM `sky_phone_media` WHERE `device_imei` = ? AND `account_id` IS NULL",
|
||||
params = { session.imei },
|
||||
},
|
||||
{
|
||||
query = "DELETE FROM `sky_phone_music_playlists` WHERE `device_imei` = ? AND `account_id` IS NULL",
|
||||
params = { session.imei },
|
||||
},
|
||||
{
|
||||
query = "DELETE FROM `sky_phone_music_youtube_songs` WHERE `device_imei` = ? AND `account_id` IS NULL",
|
||||
params = { session.imei },
|
||||
},
|
||||
{
|
||||
query = "DELETE FROM `sky_phone_contacts` WHERE `device_imei` = ? AND `account_id` IS NULL",
|
||||
params = { session.imei },
|
||||
},
|
||||
{
|
||||
query = "DELETE FROM `sky_phone_call_entries` WHERE `device_imei` = ? AND `account_id` IS NULL",
|
||||
params = { session.imei },
|
||||
},
|
||||
{
|
||||
query = "DELETE FROM `sky_phone_fliptok_sessions` WHERE `device_imei` = ?",
|
||||
params = { session.imei },
|
||||
},
|
||||
{
|
||||
query = "UPDATE `sky_phone_devices` SET `account_id` = NULL, `device_name` = ? WHERE `imei` = ?",
|
||||
params = { Config.Phone.DeviceName, session.imei },
|
||||
},
|
||||
}) then
|
||||
return { success = false, error = "request_failed" }
|
||||
|
||||
local reset, phone_number = SkyPhonePersistence.FactoryReset(session.imei)
|
||||
if not reset then
|
||||
return { success = false, error = phone_number }
|
||||
end
|
||||
SkyPhoneMedia.CleanupRemoteFiles(media_remote_ids)
|
||||
session.unlocked = true
|
||||
if phone_number then
|
||||
TriggerEvent("sky_phone:server:factoryReset", source, phone_number)
|
||||
|
||||
@@ -153,6 +153,62 @@ end
|
||||
|
||||
SkyPhoneSim.PrepareDevice = prepare_device
|
||||
|
||||
function SkyPhoneSim.ChangeNumber(source, imei, sim_id, value)
|
||||
local number = SkyPhoneSimNumber.Normalize(value, Config.Sim.NumberLength, Config.Sim.NumberPrefix)
|
||||
if not number or SkyPhoneCompanies.IsServiceNumber(number) then
|
||||
return false, "invalid_phone_number"
|
||||
end
|
||||
|
||||
local sim = load_sim(sim_id)
|
||||
if not sim then
|
||||
return false, "no_sim"
|
||||
end
|
||||
if sim.phone_number == number then
|
||||
return false, "phone_number_unchanged"
|
||||
end
|
||||
|
||||
local existing = Bridge.Database.Query(
|
||||
"SELECT `id` FROM `sky_phone_sims` WHERE `phone_number` = ? AND `id` <> ? LIMIT 1",
|
||||
{ number, sim_id }
|
||||
)
|
||||
if existing[1] then
|
||||
return false, "phone_number_taken"
|
||||
end
|
||||
|
||||
local phone_slot
|
||||
if unique_phones then
|
||||
for _, slot in ipairs(Bridge.Inventory.GetSlotsWithItem(source, Config.Phone.Item)) do
|
||||
if slot.metadata and slot.metadata.imei == imei then
|
||||
phone_slot = slot
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local previous_number = sim.phone_number
|
||||
sim.phone_number = number
|
||||
if phone_slot and not set_phone_sim_metadata(source, phone_slot, sim) then
|
||||
return false, "metadata_unsupported"
|
||||
end
|
||||
|
||||
local result = Bridge.Database.Query([[
|
||||
UPDATE IGNORE `sky_phone_sims`
|
||||
SET `phone_number` = ?
|
||||
WHERE `id` = ? AND `phone_number` = ?
|
||||
]], { number, sim_id, previous_number })
|
||||
if affected_rows(result) ~= 1 then
|
||||
if phone_slot then
|
||||
sim.phone_number = previous_number
|
||||
if not set_phone_sim_metadata(source, phone_slot, sim) then
|
||||
error("[sky_phone] Could not restore SIM metadata after a failed admin number change.")
|
||||
end
|
||||
end
|
||||
return false, "phone_number_taken"
|
||||
end
|
||||
|
||||
return true, number
|
||||
end
|
||||
|
||||
local function resolve_used_sim(source, used_item, item_name)
|
||||
local slot_id = used_item and (used_item.slot or used_item.id)
|
||||
local slot = slot_id and Bridge.Inventory.GetSlot(source, slot_id) or nil
|
||||
|
||||
Reference in New Issue
Block a user