Files
zoneminder/web/api/app/Model/Notification.php
Pliable Pixels c6effc12ab fix: add FK constraint, auth guard, and belongsTo for Notifications refs #4684
- Add FOREIGN KEY on UserId -> Users.Id with ON DELETE CASCADE
  (both in fresh schema and migration)
- Reject push token registration when auth is disabled
  (UserId would be null, violating NOT NULL constraint)
- Add $belongsTo association to User in Notification model

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 20:04:03 -05:00

40 lines
903 B
PHP

<?php
App::uses('AppModel', 'Model');
class Notification extends AppModel {
public $useTable = 'Notifications';
public $primaryKey = 'Id';
public $displayField = 'Token';
public $belongsTo = array(
'User' => array(
'className' => 'User',
'foreignKey' => 'UserId',
),
);
public $validate = array(
'Token' => array(
'notBlank' => array(
'rule' => array('notBlank'),
'message' => 'Token is required',
),
),
'Platform' => array(
'inList' => array(
'rule' => array('inList', array('android', 'ios', 'web')),
'message' => 'Platform must be android, ios, or web',
),
),
'PushState' => array(
'inList' => array(
'rule' => array('inList', array('enabled', 'disabled')),
'message' => 'PushState must be enabled or disabled',
'allowEmpty' => true,
),
),
);
}