-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcron.php
More file actions
64 lines (46 loc) · 1.34 KB
/
cron.php
File metadata and controls
64 lines (46 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
echo "Processing Message Queues.<br /><br />";
/*
get N messages from each queue:
i) new meetings
ii) responses
*/
$ironmq = new IronMQ();
$newMeetingQueue = $ironmq->getMessages( 'new-meetings', 5 );
$responseQueue = $ironmq->getMessages( 'responses', 5 );
// process new meetings
foreach( (array)$newMeetingQueue as $message )
{
echo "Processing new meeting:<br />";
// decode the message
$newMeetingMessage = json_decode( $message->body, true );
$meeting = new Meeting( val( $newMeetingMessage, 'id' ) );
// pre-load info
$meeting->loadInfo();
print_pre($meeting->name());
if( !$meeting->active() || $meeting->kickOff() )
{
// delete the message
$ironmq->deleteMessage( 'new-meetings', $message->id);
}
}
echo '<br />';
// process responses
foreach( (array)$responseQueue as $message )
{
echo "Processing response:<br />";
// decode the message
$response = json_decode( $message->body, true );
print_pre($message->body);
$meeting = new Meeting( val( $response, 'meeting' ) );
$user = new User( val( $response, 'user' ) );
// pre-load info
$meeting->loadInfo();
$user->loadInfo();
if( !$meeting->active() || $meeting->processResponse( val( $response, 'response' ), $user, val( $response, 'method' ) ) )
{
// delete the message
$ironmq->deleteMessage( 'responses', $message->id );
}
}
echo '<p>Finished.</p>';