@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add an X-Phabricator-Projects header to outbound mail

Summary: Fixes T4973. For `PhabricatorProjectInterface` objects, add a header to let clients do mail filtering.

Test Plan: Saw `X-Phabricator-Projects: <#goat_farm>` in outbound mail.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: rush898, epriestley

Maniphest Tasks: T4973

Differential Revision: https://secure.phabricator.com/D10256

+45 -3
+45 -3
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 1886 1886 $template->addHeader('X-Herald-Rules', $herald_header); 1887 1887 } 1888 1888 1889 + if ($object instanceof PhabricatorProjectInterface) { 1890 + $this->addMailProjectMetadata($object, $template); 1891 + } 1892 + 1889 1893 if ($this->getParentMessageID()) { 1890 1894 $template->setParentMessageID($this->getParentMessageID()); 1891 1895 } 1892 1896 1893 1897 $mails = $reply_handler->multiplexMail( 1894 - $template, 1895 - array_select_keys($handles, $email_to), 1896 - array_select_keys($handles, $email_cc)); 1898 + $template, 1899 + array_select_keys($handles, $email_to), 1900 + array_select_keys($handles, $email_cc)); 1897 1901 1898 1902 foreach ($mails as $mail) { 1899 1903 $mail->saveAndSend(); ··· 1904 1908 1905 1909 return $template; 1906 1910 } 1911 + 1912 + private function addMailProjectMetadata( 1913 + PhabricatorLiskDAO $object, 1914 + PhabricatorMetaMTAMail $template) { 1915 + 1916 + $project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( 1917 + $object->getPHID(), 1918 + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); 1919 + 1920 + if (!$project_phids) { 1921 + return; 1922 + } 1923 + 1924 + // TODO: This viewer isn't quite right. It would be slightly better to use 1925 + // the mail recipient, but that's not very easy given the way rendering 1926 + // works today. 1927 + 1928 + $handles = id(new PhabricatorHandleQuery()) 1929 + ->setViewer($this->requireActor()) 1930 + ->withPHIDs($project_phids) 1931 + ->execute(); 1932 + 1933 + $project_tags = array(); 1934 + foreach ($handles as $handle) { 1935 + if (!$handle->isComplete()) { 1936 + continue; 1937 + } 1938 + $project_tags[] = '<'.$handle->getObjectName().'>'; 1939 + } 1940 + 1941 + if (!$project_tags) { 1942 + return; 1943 + } 1944 + 1945 + $project_tags = implode(', ', $project_tags); 1946 + $template->addHeader('X-Phabricator-Projects', $project_tags); 1947 + } 1948 + 1907 1949 1908 1950 protected function getMailThreadID(PhabricatorLiskDAO $object) { 1909 1951 return $object->getPHID();