bluecherrydvr / bluecherry-apps

Bluecherry surveillance system (server application)
http://www.bluecherrydvr.com
GNU General Public License v2.0
200 stars 64 forks source link

Remove unneeded ID number, we just need the manufacturer name for mysql inserts #648

Open curtishall opened 6 months ago

curtishall commented 6 months ago

Remove unneeded ID number, we just need the manufacturer name

Fixes #647

We were pulling the following json via API...however were added the Manufactuer AND the ID (for unknown reasons) which was being inserted into the database like 'IP Camera - recpSlTQIiaJez87D' which should never have happened and the model insert into mysql was too long anyway causing an ajax error.

{
    "id": "recpSlTQIiaJez87D",
    "createdTime": "2017-08-12T02:06:43.000Z",
    "fields": {
        "ManufacturerLink": [
            "recpeE5rOIW7SRmsC"
        ],
        "id": 967,
        "JPEG path": "cgi-bin/guest/Video.cgi?media=JPEG",
        "Model": "Default",
        "Manufacturer": [
            "IP Camera"
        ],
        "RTSP path fixed": "/"
    }
}
andrey-utkin commented 6 months ago

I have doubt that the fix proposed is going to work. I'd need some more time to understand how the key strings of $list generated there end up in $data[model] being inserted.

Devices.model DB field is limited to 30 characters (see misc/sql/schema_mysql.sql), I think we should give it more:

CREATE TABLE `Devices` (
...
  `model` varchar(30) DEFAULT NULL,