Replace subscribe/unsubscribe for projects with explicit mail setting
Summary:
Ref T10054. Ref T6113. Users can currently subscribe to projects, which causes them to receive:
# mail about project membership changes, description changes, etc; and
# mail to the project, e.g. when the project is added as a subscriber on a task, or a reviewer on a revision.
Almost no one cares about (1), and after D15061 you can use Herald to get this stuff if you really want it. (It will get progressively more annoying in the future with external membership sources causing automated project membership updates.)
A lot of users are confused about (2) and how it relates to membership, watching, etc, and most users who want (2) don't want (1).
Instead, add an explicit option for this and explain what it does.
This is fairly verbose but I've hidden it on the member/watch screen, which is now the "explain how projects work" screen, I guess.
Test Plan:
{F1064929}
{F1064930}
{F1064931}
- Disabled/enabled mail for a project.
- Sent mail to a project with mail disabled, verified I didn't get a copy.
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T6113, T10054
Differential Revision: https://secure.phabricator.com/D15065
2016-01-20 03:56:15 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorProjectSilenceController
|
|
|
|
extends PhabricatorProjectController {
|
|
|
|
|
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
|
|
$viewer = $request->getViewer();
|
|
|
|
$id = $request->getURIData('id');
|
|
|
|
$action = $request->getURIData('action');
|
|
|
|
|
|
|
|
$project = id(new PhabricatorProjectQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withIDs(array($id))
|
|
|
|
->needMembers(true)
|
|
|
|
->executeOne();
|
|
|
|
if (!$project) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
$edge_type = PhabricatorProjectSilencedEdgeType::EDGECONST;
|
|
|
|
$done_uri = "/project/members/{$id}/";
|
|
|
|
$viewer_phid = $viewer->getPHID();
|
|
|
|
|
|
|
|
if (!$project->isUserMember($viewer_phid)) {
|
|
|
|
return $this->newDialog()
|
|
|
|
->setTitle(pht('Not a Member'))
|
|
|
|
->appendParagraph(
|
|
|
|
pht(
|
|
|
|
'You are not a project member, so you do not receive mail sent '.
|
|
|
|
'to members of this project.'))
|
|
|
|
->addCancelButton($done_uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
$silenced = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
|
|
|
$project->getPHID(),
|
|
|
|
$edge_type);
|
|
|
|
$silenced = array_fuse($silenced);
|
|
|
|
$is_silenced = isset($silenced[$viewer_phid]);
|
|
|
|
|
|
|
|
if ($request->isDialogFormPost()) {
|
|
|
|
if ($is_silenced) {
|
|
|
|
$edge_action = '-';
|
|
|
|
} else {
|
|
|
|
$edge_action = '+';
|
|
|
|
}
|
|
|
|
|
|
|
|
$xactions = array();
|
|
|
|
$xactions[] = id(new PhabricatorProjectTransaction())
|
|
|
|
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
|
|
|
->setMetadataValue('edge:type', $edge_type)
|
|
|
|
->setNewValue(
|
|
|
|
array(
|
|
|
|
$edge_action => array($viewer_phid => $viewer_phid),
|
|
|
|
));
|
|
|
|
|
2017-02-17 11:10:15 +01:00
|
|
|
$editor = id(new PhabricatorProjectTransactionEditor())
|
Replace subscribe/unsubscribe for projects with explicit mail setting
Summary:
Ref T10054. Ref T6113. Users can currently subscribe to projects, which causes them to receive:
# mail about project membership changes, description changes, etc; and
# mail to the project, e.g. when the project is added as a subscriber on a task, or a reviewer on a revision.
Almost no one cares about (1), and after D15061 you can use Herald to get this stuff if you really want it. (It will get progressively more annoying in the future with external membership sources causing automated project membership updates.)
A lot of users are confused about (2) and how it relates to membership, watching, etc, and most users who want (2) don't want (1).
Instead, add an explicit option for this and explain what it does.
This is fairly verbose but I've hidden it on the member/watch screen, which is now the "explain how projects work" screen, I guess.
Test Plan:
{F1064929}
{F1064930}
{F1064931}
- Disabled/enabled mail for a project.
- Sent mail to a project with mail disabled, verified I didn't get a copy.
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T6113, T10054
Differential Revision: https://secure.phabricator.com/D15065
2016-01-20 03:56:15 +01:00
|
|
|
->setActor($viewer)
|
|
|
|
->setContentSourceFromRequest($request)
|
|
|
|
->setContinueOnNoEffect(true)
|
|
|
|
->setContinueOnMissingFields(true)
|
|
|
|
->applyTransactions($project, $xactions);
|
|
|
|
|
|
|
|
return id(new AphrontRedirectResponse())->setURI($done_uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($is_silenced) {
|
|
|
|
$title = pht('Enable Mail');
|
|
|
|
$body = pht(
|
|
|
|
'When mail is sent to members of this project, you will receive a '.
|
|
|
|
'copy.');
|
|
|
|
$button = pht('Enable Project Mail');
|
|
|
|
} else {
|
|
|
|
$title = pht('Disable Mail');
|
|
|
|
$body = pht(
|
|
|
|
'When mail is sent to members of this project, you will no longer '.
|
|
|
|
'receive a copy.');
|
|
|
|
$button = pht('Disable Project Mail');
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->newDialog()
|
|
|
|
->setTitle($title)
|
|
|
|
->appendParagraph($body)
|
|
|
|
->addCancelButton($done_uri)
|
|
|
|
->addSubmitButton($button);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|