mirror of
https://github.com/sky-systems/sky_phone.git
synced 2026-08-28 17:01:18 +00:00
FIX - map company contacts from config
Use each company definition's validated HTTPS LogoUrl for automatic Phone contacts and populate Company or Group with the configured company name. Keep uploaded company logos as profile overrides, update browser mocks and tests, and document the required LogoUrl config field.
This commit is contained in:
@@ -166,4 +166,33 @@ describe('calls store', () => {
|
||||
expect(nuiCall).toHaveBeenNthCalledWith(2, 'contacts:list')
|
||||
expect(calls.contacts[0]?.favorite).toBe(true)
|
||||
})
|
||||
|
||||
it('keeps configured company branding on system contacts', async () => {
|
||||
vi.mocked(nuiCall).mockResolvedValueOnce({
|
||||
success: true,
|
||||
data: [
|
||||
{
|
||||
avatar_url:
|
||||
'https://picsum.photos/seed/companies-police-logo/180/180',
|
||||
companyId: 'police',
|
||||
id: 'company:police',
|
||||
name: 'Los Santos Police Department',
|
||||
organization: 'Los Santos Police Department',
|
||||
phone_number: '911',
|
||||
readonly: true,
|
||||
source: 'company',
|
||||
},
|
||||
],
|
||||
})
|
||||
const calls = useCallsStore()
|
||||
|
||||
await calls.loadContacts()
|
||||
|
||||
expect(calls.contacts[0]).toMatchObject({
|
||||
avatar_url:
|
||||
'https://picsum.photos/seed/companies-police-logo/180/180',
|
||||
organization: 'Los Santos Police Department',
|
||||
source: 'company',
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -17,7 +17,6 @@ export type PhoneContact = {
|
||||
created_at?: string
|
||||
favorite?: boolean | number
|
||||
id: string
|
||||
icon?: string
|
||||
name: string
|
||||
notes?: string | null
|
||||
organization?: string | null
|
||||
|
||||
@@ -280,7 +280,7 @@ function openContact(contact?: PhoneContact, number = ''): void {
|
||||
contactNotes.value = contact?.notes ?? ''
|
||||
contactNumber.value = contact?.phone_number ?? number
|
||||
contactAvatarMediaId.value = contact?.avatar_media_id ?? null
|
||||
contactAvatarUrl.value = contact?.avatar_url ?? contact?.icon ?? ''
|
||||
contactAvatarUrl.value = contact?.avatar_url ?? ''
|
||||
error.value = ''
|
||||
editorOpened.value = true
|
||||
}
|
||||
@@ -971,8 +971,8 @@ onBeforeUnmount(() => {
|
||||
<div class="phone-contact-hero">
|
||||
<div class="phone-contact-avatar phone-contact-avatar--large">
|
||||
<img
|
||||
v-if="selectedContact?.avatar_url || selectedContact?.icon"
|
||||
:src="selectedContact.avatar_url ?? selectedContact.icon"
|
||||
v-if="selectedContact?.avatar_url"
|
||||
:src="selectedContact.avatar_url"
|
||||
alt=""
|
||||
/>
|
||||
<span v-else-if="contactInitials(selectedNumber)">{{
|
||||
@@ -1297,8 +1297,8 @@ onBeforeUnmount(() => {
|
||||
>
|
||||
<span class="phone-contact-avatar">
|
||||
<img
|
||||
v-if="contact.avatar_url || contact.icon"
|
||||
:src="contact.avatar_url ?? contact.icon"
|
||||
v-if="contact.avatar_url"
|
||||
:src="contact.avatar_url"
|
||||
alt=""
|
||||
/>
|
||||
<template v-else>{{
|
||||
@@ -1331,8 +1331,8 @@ onBeforeUnmount(() => {
|
||||
>
|
||||
<span class="phone-contact-avatar">
|
||||
<img
|
||||
v-if="contact.avatar_url || contact.icon"
|
||||
:src="contact.avatar_url ?? contact.icon"
|
||||
v-if="contact.avatar_url"
|
||||
:src="contact.avatar_url"
|
||||
alt=""
|
||||
/>
|
||||
<template v-else>{{
|
||||
@@ -1394,8 +1394,8 @@ onBeforeUnmount(() => {
|
||||
>
|
||||
<span class="phone-keypad-suggestion__avatar">
|
||||
<img
|
||||
v-if="contact.avatar_url || contact.icon"
|
||||
:src="contact.avatar_url ?? contact.icon"
|
||||
v-if="contact.avatar_url"
|
||||
:src="contact.avatar_url"
|
||||
alt=""
|
||||
/>
|
||||
<template v-else>{{
|
||||
|
||||
@@ -1422,9 +1422,10 @@ const contacts = [
|
||||
canCall: true,
|
||||
canMessage: false,
|
||||
companyId: 'police',
|
||||
icon: 'https://picsum.photos/seed/companies-police-logo/180/180',
|
||||
avatar_url: 'https://picsum.photos/seed/companies-police-logo/180/180',
|
||||
id: 'company:police',
|
||||
name: 'Los Santos Police',
|
||||
organization: 'Los Santos Police',
|
||||
phone_number: '911',
|
||||
readonly: true,
|
||||
source: 'company',
|
||||
@@ -1434,9 +1435,10 @@ const contacts = [
|
||||
canCall: true,
|
||||
canMessage: false,
|
||||
companyId: 'ambulance',
|
||||
icon: 'https://picsum.photos/seed/companies-ems-logo/180/180',
|
||||
avatar_url: 'https://picsum.photos/seed/companies-ems-logo/180/180',
|
||||
id: 'company:ambulance',
|
||||
name: 'Los Santos Medical',
|
||||
organization: 'Los Santos Medical',
|
||||
phone_number: '912',
|
||||
readonly: true,
|
||||
source: 'company',
|
||||
@@ -1446,9 +1448,10 @@ const contacts = [
|
||||
canCall: true,
|
||||
canMessage: true,
|
||||
companyId: 'bennys',
|
||||
icon: 'https://picsum.photos/seed/companies-bennys-logo/180/180',
|
||||
avatar_url: 'https://picsum.photos/seed/companies-bennys-logo/180/180',
|
||||
id: 'company:bennys',
|
||||
name: "Benny's Motor Works",
|
||||
organization: "Benny's Motor Works",
|
||||
phone_number: '5550102',
|
||||
readonly: true,
|
||||
source: 'company',
|
||||
|
||||
@@ -59,6 +59,7 @@ Config.Companies = {
|
||||
Emergency = true,
|
||||
Verified = true,
|
||||
Icon = "shield",
|
||||
LogoUrl = "https://picsum.photos/seed/companies-police-logo/180/180",
|
||||
Description = "Public safety, emergency response, and police services.",
|
||||
DefaultAvailability = "closed",
|
||||
AcceptsRequests = false,
|
||||
@@ -93,6 +94,7 @@ Config.Companies = {
|
||||
Emergency = true,
|
||||
Verified = true,
|
||||
Icon = "medical",
|
||||
LogoUrl = "https://picsum.photos/seed/companies-ems-logo/180/180",
|
||||
Description = "Emergency medical response and patient care.",
|
||||
DefaultAvailability = "closed",
|
||||
AcceptsRequests = false,
|
||||
@@ -127,6 +129,7 @@ Config.Companies = {
|
||||
Emergency = true,
|
||||
Verified = true,
|
||||
Icon = "flame",
|
||||
LogoUrl = "https://picsum.photos/seed/companies-fire-logo/180/180",
|
||||
Description = "Fire response, rescue, and public safety services.",
|
||||
DefaultAvailability = "closed",
|
||||
AcceptsRequests = false,
|
||||
@@ -161,6 +164,7 @@ Config.Companies = {
|
||||
Emergency = false,
|
||||
Verified = true,
|
||||
Icon = "wrench",
|
||||
LogoUrl = "https://picsum.photos/seed/companies-mechanic-logo/180/180",
|
||||
Description = "Vehicle diagnostics, repairs, and roadside assistance.",
|
||||
DefaultAvailability = "closed",
|
||||
AcceptsRequests = true,
|
||||
@@ -210,6 +214,7 @@ Config.Companies = {
|
||||
Emergency = false,
|
||||
Verified = true,
|
||||
Icon = "car",
|
||||
LogoUrl = "https://picsum.photos/seed/companies-taxi-logo/180/180",
|
||||
Description = "Staffed taxi rides throughout Los Santos and Blaine County.",
|
||||
DefaultAvailability = "closed",
|
||||
AcceptsRequests = true,
|
||||
|
||||
@@ -272,11 +272,13 @@ local function validate_configuration()
|
||||
true
|
||||
)
|
||||
local address = valid_text(definition.Address or "", Config.Companies.AddressMaxLength, true)
|
||||
local logo_url = valid_text(definition.LogoUrl, 2048, false)
|
||||
if not description or not district or not location_label or not address
|
||||
or type(definition.Public) ~= "boolean" or type(definition.Emergency) ~= "boolean"
|
||||
or type(definition.Verified) ~= "boolean" or type(definition.AcceptsRequests) ~= "boolean"
|
||||
or not Config.Companies.AvailabilityStatuses[definition.DefaultAvailability]
|
||||
or not valid_text(definition.Icon, 64, false)
|
||||
or not logo_url or not logo_url:match("^https://[^%s]+$")
|
||||
or (definition.Emergency and definition.AcceptsRequests)
|
||||
then
|
||||
error(("[sky_phone] Company definition '%s' has invalid public profile defaults."):format(company_id))
|
||||
@@ -286,6 +288,7 @@ local function validate_configuration()
|
||||
definition.District = district
|
||||
definition.LocationLabel = location_label
|
||||
definition.Address = address
|
||||
definition.LogoUrl = logo_url
|
||||
if definition.Location ~= nil then
|
||||
local location_type = type(definition.Location)
|
||||
if location_type ~= "table" and location_type ~= "vector3" then
|
||||
@@ -558,13 +561,14 @@ function SkyPhoneCompanies.GetSystemContacts()
|
||||
id = "company:" .. company_id,
|
||||
companyId = company_id,
|
||||
name = definition.Name,
|
||||
organization = definition.Name,
|
||||
phone_number = line.Number,
|
||||
avatar_url = definition.LogoUrl,
|
||||
source = "company",
|
||||
readonly = true,
|
||||
canCall = line.CanCall == true,
|
||||
canMessage = line.CanMessage == true,
|
||||
verified = definition.Verified == true,
|
||||
icon = definition.Icon,
|
||||
}
|
||||
end
|
||||
end
|
||||
@@ -829,7 +833,7 @@ local function company_payload(company_id, include_inactive_services)
|
||||
canCall = line and line.CanCall == true or false,
|
||||
canMessage = line and line.CanMessage == true or false,
|
||||
location = location,
|
||||
logoUrl = row.logo_url,
|
||||
logoUrl = row.logo_url or definition.LogoUrl,
|
||||
coverUrl = row.cover_url,
|
||||
serviceSummary = services[1] and services[1].title or "",
|
||||
announcement = current_announcement(company_id),
|
||||
|
||||
Reference in New Issue
Block a user