Something went wrong. Try again.
@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
Something went wrong. Try again.
2.5 kB · 88 lines
PHP
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889<?php
final class PhabricatorSubscriptionsMuteController extends PhabricatorController {
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $phid = $request->getURIData('phid');
$handle = id(new PhabricatorHandleQuery()) ->setViewer($viewer) ->withPHIDs(array($phid)) ->executeOne();
$object = id(new PhabricatorObjectQuery()) ->setViewer($viewer) ->withPHIDs(array($phid)) ->executeOne();
if (!($object instanceof PhabricatorSubscribableInterface)) { return new Aphront400Response(); }
$muted_type = PhabricatorMutedByEdgeType::EDGECONST;
$edge_query = id(new PhabricatorEdgeQuery()) ->withSourcePHIDs(array($object->getPHID())) ->withEdgeTypes(array($muted_type)) ->withDestinationPHIDs(array($viewer->getPHID()));
$edge_query->execute();
$is_mute = !$edge_query->getDestinationPHIDs(); $object_uri = $handle->getURI();
if ($request->isFormPost()) { if ($is_mute) { $xaction_value = array( '+' => array_fuse(array($viewer->getPHID())), ); } else { $xaction_value = array( '-' => array_fuse(array($viewer->getPHID())), ); }
$xaction = id($object->getApplicationTransactionTemplate()) ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) ->setMetadataValue('edge:type', $muted_type) ->setNewValue($xaction_value);
$editor = id($object->getApplicationTransactionEditor()) ->setActor($viewer) ->setContinueOnNoEffect(true) ->setContinueOnMissingFields(true) ->setContentSourceFromRequest($request);
$editor->applyTransactions($object, array($xaction));
return id(new AphrontReloadResponse())->setURI($object_uri); }
$dialog = $this->newDialog() ->addCancelButton($object_uri);
if ($is_mute) { $dialog ->setTitle(pht('Mute Notifications')) ->appendParagraph( pht( 'Mute this object? You will no longer receive notifications or '. 'email about it.')) ->addSubmitButton(pht('Mute')); } else { $dialog ->setTitle(pht('Unmute Notifications')) ->appendParagraph( pht( 'Unmute this object? You will receive notifications and email '. 'again.')) ->addSubmitButton(pht('Unmute')); }
return $dialog; }
}