Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F437983
PhabricatorIRCDifferentialNotificationHandler.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
PhabricatorIRCDifferentialNotificationHandler.php
View Options
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @group irc
*/
final
class
PhabricatorIRCDifferentialNotificationHandler
extends
PhabricatorIRCHandler
{
private
$skippedOldEvents
;
public
function
receiveMessage
(
PhabricatorIRCMessage
$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
=
"{$actor_name} {$verb} revision D"
.
$data
[
'revision_id'
].
"."
;
foreach
(
$this
->
getConfig
(
'notification.channels'
)
as
$channel
)
{
$this
->
write
(
'PRIVMSG'
,
"{$channel} :{$message}"
);
}
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, May 4, 2:02 AM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
62869
Default Alt Text
PhabricatorIRCDifferentialNotificationHandler.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment