2014-09-04 60 views
-1

我正在尝试将phabricator与jabber聊天集成。我已经创建了一个僵尸工具,用于向每个新的提要查询的jabber聊天中的提交作者发送消息。我的要求是,如果Feed的故事是关注点,审计或通讯,我如何获得提交的原始作者。我想通知提交人提交他提交的任何问题。我需要分析故事才能得到这个信息吗? 我该如何去做这件事?phabricator从供稿故事中获取关注,评论和审核的故事

在此先感谢

+0

downvoter请告诉我什么是错的问题。 – 2014-09-04 13:51:15

回答

2

故事的对象应该有一个数据元素,其中将包括关于作者和提交者信息。像这样:

"PHID-STRY-spjfpdv4wuigblmh3ygb" : { 
    "class"   : "PhabricatorFeedStoryCommit", 
    "epoch"   : 1409840112, 
    "authorPHID"  : "PHID-USER-tcyihgi43sw6o7yrnhu5", 
    "chronologicalKey" : "6055220066741547443", 
    "data"    : { 
     "commitPHID" : "PHID-CMIT-ievqiimtsnlfhlk5imqq", 
     "summary"  : "[blah]", 
     "authorName" : "Author Name <[email protected]>", 
     "authorPHID" : "PHID-USER-tcyihgi43sw6o7yrnhu5", 
     "committerName" : "Commiter Name <[email protected]>", 
     "committerPHID" : "PHID-USER-tcyihgi43sw6o7yrnhu5" 
    } 
} 

如果不是,它应该有一个objectPHID:

"PHID-STRY-mqlkjzwkbr3th4h5n2eg" : { 
    "class"   : "PhabricatorApplicationTransactionFeedStory", 
    "epoch"   : 1409841382, 
    "authorPHID"  : "PHID-USER-2bubef6xonwicvaool4w", 
    "chronologicalKey" : "6055222630292077307", 
    "data"    : { 
     "objectPHID"  : "PHID-CMIT-is7pmo5nyvv4eruq2msn", 
     "transactionPHIDs" : [ 
      "PHID-XACT-CMIT-svvkzf7dfplzdxp" 
     ] 
    } 
} 

你可以从那里通过管道来电查询。

0

我查询了feed.query。如果可用,则提取authorPHIDobjectPHID。用objectPHID我查询了differnetial.query导管法找出reviewersccsccs是必须接收cc消息的用户数组。然后我使用管道方法来提取用户名并将它们映射到jabber用户名并发送消息。

2

了解和测试,这是下面 http://phabricator.yourhost.com/conduit/method/feed.query/
点击[呼叫方法]最好的办法
这将返回修改的列表,你会感兴趣的:“objectPHID”:“PHID-DREV-XXXXXXX “
...
现在http://phabricator.yourhost.com/conduit/method/differential.query/
集phids => [ ”PHID-DREV-XXXXXXX“]
...
这将返回 ”authorPHID“: ”PHID-USER-XXXXX“ 和”评论家“:[”xxxx“,”xxxx“,”xxxx“]
...
我也建议您检阅/src/infrastructure/daemon/bot/handler/PhabricatorBotFeedNotificationHandler.php

现在代码

$stories = $this->getConduit()->callMethodSynchronous(
    'feed.query', 
    array(
     'limit' => $config_page_size, 
     'after' => $chrono_key_cursor, 
     'view' => 'text', 
    ) 
); 

foreach ($stories as $story) { 
    $objects = $this->getConduit()->callMethodSynchronous(
     'phid.lookup', 
     array(
      'names' => array($story['objectPHID']), 
     ) 
    ); 

    $diff_query_results = $this->getConduit()->callMethodSynchronous(
     'differential.query', 
     array(
      'phids' => array($story['objectPHID']), 
    )); 

    foreach ($diff_query_results as $diff_query) { 
     $authorResults = $this->getConduit()->callMethodSynchronous(
     'phid.lookup', 
     array(
      'names' => array($diff_query['authorPHID']), 
     ) 
    ); 

    $message .= ' '.$objects[$story['objectPHID']]['uri']; 
    foreach ($authorResults as $author) { 
     $authorName = $author['name']; 
     print_r ($authorName); 
    } 

    $reviewersResults = $this->getConduit()->callMethodSynchronous(
     'phid.lookup', 
     array(
      'names' => $diff_query['reviewers'], 
     ) 
    ); 


    foreach ($reviewersResults as $reviewer) { 
     $reviewerName = $reviewer['name']; 
     print_r ($reviewerName); 
    } 
}