【问题标题】:phabricator get commit author from feed story for stories that are concerns , comments and auditsphabricator 从提要故事中获取提交作者,以获取关注、评论和审核的故事
【发布时间】:2014-09-04 08:32:05
【问题描述】:

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

提前致谢

【问题讨论】:

  • downvoter 请告诉我这个问题有什么问题。

标签: php xmpp phabricator


【解决方案1】:

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

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

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

【讨论】:

    【解决方案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”和“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 );
        }
    }
    

    【讨论】:

      【解决方案3】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-10-16
        • 1970-01-01
        • 2020-11-17
        • 1970-01-01
        • 1970-01-01
        • 2021-11-13
        相关资源
        最近更新 更多