Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F452484
PhabricatorBotDifferentialNotificationHandler.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
PhabricatorBotDifferentialNotificationHandler.php
View Options
<?php
/**
* @group irc
*/
final
class
PhabricatorBotDifferentialNotificationHandler
extends
PhabricatorBotHandler
{
private
$skippedOldEvents
;
public
function
receiveMessage
(
PhabricatorBotMessage
$message
)
{
return
;
}
public
function
runBackgroundTasks
()
{
$iterator
=
new
PhabricatorTimelineIterator
(
'ircdiffx'
,
array
(
'difx'
));
$show
=
$this
->
getConfig
(
'notification.actions'
);
if
(!
$this
->
skippedOldEvents
)
{
// Since we only want to post notifications about new events, skip
// everything that's happened in the past when we start up so we'll
// only process real-time events.
foreach
(
$iterator
as
$event
)
{
// Ignore all old events.
}
$this
->
skippedOldEvents
=
true
;
return
;
}
foreach
(
$iterator
as
$event
)
{
$data
=
$event
->
getData
();
if
(!
$data
||
(
$show
!==
null
&&
!
in_array
(
$data
[
'action'
],
$show
)))
{
continue
;
}
$actor_phid
=
$data
[
'actor_phid'
];
$phids
=
array
(
$actor_phid
);
$handles
=
id
(
new
PhabricatorObjectHandleData
(
$phids
))->
loadHandles
();
$verb
=
DifferentialAction
::
getActionPastTenseVerb
(
$data
[
'action'
]);
$actor_name
=
$handles
[
$actor_phid
]->
getName
();
$message_body
=
"{$actor_name} {$verb} revision D"
.
$data
[
'revision_id'
].
"."
;
$channels
=
$this
->
getConfig
(
'notification.channels'
,
array
());
foreach
(
$channels
as
$channel
)
{
$this
->
writeMessage
(
id
(
new
PhabricatorBotMessage
())
->
setCommand
(
'MESSAGE'
)
->
setTarget
(
$channel
)
->
setBody
(
$message_body
));
}
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, May 5, 12:38 AM (1 d, 10 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
68792
Default Alt Text
PhabricatorBotDifferentialNotificationHandler.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment