phabricator从饲料故事中获取提交作者关于关注,评论和审核的故事

时间:2014-09-04 08:32:06

标签: php xmpp phabricator

我正在尝试整合phabricator和jabber聊天。我创建了一个机器人,在jabber聊天中为每个新的feed查询发送消息给提交作者。我的要求是如果Feed故事是一个问题,审计或通信,我如何获得提交的原始作者。我想通知作者提交他提交的任何问题。我是否需要分析故事以获取此信息? 我该怎么做呢?

提前致谢

3 个答案:

答案 0 :(得分:2)

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

"PHID-STRY-spjfpdv4wuigblmh3ygb" : {
    "class"            : "PhabricatorFeedStoryCommit",
    "epoch"            : 1409840112,
    "authorPHID"       : "PHID-USER-tcyihgi43sw6o7yrnhu5",
    "chronologicalKey" : "6055220066741547443",
    "data"             : {
      "commitPHID"    : "PHID-CMIT-ievqiimtsnlfhlk5imqq",
      "summary"       : "[blah]",
      "authorName"    : "Author Name <author_email@example.com>",
      "authorPHID"    : "PHID-USER-tcyihgi43sw6o7yrnhu5",
      "committerName" : "Commiter Name <commiter_email@example.com>",
      "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"
        ]
    }
}

您可以使用管道调用从那里进行查询。

答案 1 :(得分:2)

理解和测试这个的最佳方法如下 http://phabricator.yourhost.com/conduit/method/feed.query/
点击[通话方式]
这将返回您感兴趣的更改列表:“objectPHID”:“PHID-DREV-xxxxxxx”,
...
现在http://phabricator.yourhost.com/conduit/method/differential.query/
set phids =&gt; [ “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 );
    }
}

答案 2 :(得分:0)

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

相关问题