-1

我正在尝试将 phabricator 与 jabber 聊天集成。我创建了一个机器人,可以在 jabber 聊天中针对每个新的提要查询向提交作者发送消息。我的要求是,如果提要故事是一个问题、审计或commnet,我如何获得提交的原始作者。我想将提交的任何问题通知提交者。我需要分析故事来获得这些信息吗?我该怎么做呢?

提前致谢

4

3 回答 3

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"
        ]
    }
}

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

于 2014-09-05T23:29:42.040 回答
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"]
...
这将return "authorPHID": "PHID-USER-xxxxx", and "reviewers": ["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 );
    }
}
于 2015-01-09T15:57:13.780 回答
0

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

于 2014-09-08T16:03:22.440 回答