The fabricator receives a message about the author from the feed history for stories that relate to issues, comments and audits

I am trying to integrate a fabricator with jabber chat. I created a bot that sends messages to the message author in jabber chat for each new feed request. My requirement is that how to get the original author of the commit if the feed history is a problem, audit or commnet. I want to notify the author of any problems associated with its commission. Do I need to analyze history to get this information? How can I do it?

Thanks in advance

-one
php xmpp phabricator
source share
3 answers

The history object must have a data element that will contain information about the Author and the committer. For example:

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

If not, it should have objectPHID:

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

You can request from there using conduit calls.

+2
source share

The best way to understand and check this out: http://phabricator.yourhost.com/conduit/method/feed.query/
press [call method]
This will return a list of changes that interest you: "objectPHID": "PHID-DREV-xxxxxxx",
...
Now http://phabricator.yourhost.com/conduit/method/differential.query/
set phids => ["PHID-DREV-xxxxxxx"]
...
This will return "authorPHID": "PHID-USER-xxxxx" and "reviewers": ["xxxx", "xxxx", "xxxx"]
...
I also suggest considering /src/infrastructure/daemon/bot/handler/PhabricatorBotFeedNotificationHandler.php

Code now

 $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
source share

I requested feed.query. and authorPHID and objectPHID , if available. Using objectPHID I requested the differnetial.query method to find out reviewers and ccs . ccs is an array of users who need to receive a piece of the message. Then I used the user.query conduit method to retrieve the usernames and matched them with jabber usernames and sent messages.

0
source share

All Articles