2014-09-04 51 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); 
    } 
}