Mail notifications get pushed forward in time when a new loan is created if there is a pending notification.
This way the user can add multiple loans over time without the notification getting sent prematurely.
This commit is contained in:
parent
9307604aa0
commit
fa46874ae3
@ -42,16 +42,24 @@ class Loan extends Event {
|
|||||||
|
|
||||||
protected function queue_receipt($user) {
|
protected function queue_receipt($user) {
|
||||||
$now = time();
|
$now = time();
|
||||||
|
$sendtime = $now + 3600;
|
||||||
$pending = prepare('select * from `pending_receipt` where `user` = ?
|
$pending = prepare('select * from `pending_receipt` where `user` = ?
|
||||||
and `since_time` < ? and `send_time` > ?');
|
and `since_time` < ? and `send_time` > ?');
|
||||||
bind($pending, 'iii', $user->get_id(), $now, $now);
|
bind($pending, 'iii', $user->get_id(), $now, $now);
|
||||||
execute($pending);
|
execute($pending);
|
||||||
if(result_single($pending) === null) {
|
$result = result_single($pending);
|
||||||
|
if($result === null) {
|
||||||
$add = prepare('insert into `pending_receipt`
|
$add = prepare('insert into `pending_receipt`
|
||||||
(`user`, `since_time`, `send_time`)
|
(`user`, `since_time`, `send_time`)
|
||||||
values(?, ?, ?)');
|
values(?, ?, ?)');
|
||||||
bind($add, 'iii', $user->get_id(), $now, $now + 3600);
|
bind($add, 'iii', $user->get_id(), $now, $sendtime);
|
||||||
execute($add);
|
execute($add);
|
||||||
|
} else {
|
||||||
|
$update = prepare('update `pending_receipt` set `send_time` = ?
|
||||||
|
where `user` = ? and `since_time` < ?
|
||||||
|
and `send_time` > ?');
|
||||||
|
bind($update, 'iiii', $sendtime, $user->get_id(), $now, $now);
|
||||||
|
execute($update);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
create table `pending_receipt` (
|
|
||||||
`user` bigint(20) not null,
|
|
||||||
primary key (`user`),
|
|
||||||
constraint `pr_f_user`
|
|
||||||
foreign key(`user`) references `user`(`id`),
|
|
||||||
`send_time` bigint(20) not null,
|
|
||||||
`since_time` bigint(20) not null
|
|
||||||
) character set utf8mb4,
|
|
||||||
collate utf8mb4_unicode_ci;
|
|
Loading…
x
Reference in New Issue
Block a user