1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 21:02:41 +01:00

Remove mailing lists application

Summary: Ref T8387. This is now completely obsoleted by mailing list users.

Test Plan: Grepped for `mailinglist` and related symbols.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: eadler, epriestley

Maniphest Tasks: T8387

Differential Revision: https://secure.phabricator.com/D13129
This commit is contained in:
epriestley 2015-06-02 15:20:30 -07:00
parent 249ee9f104
commit ba6cb62b49
19 changed files with 1 additions and 714 deletions

View file

@ -2020,15 +2020,6 @@ phutil_register_library_map(array(
'PhabricatorMailReplyHandler' => 'applications/metamta/replyhandler/PhabricatorMailReplyHandler.php',
'PhabricatorMailSetupCheck' => 'applications/config/check/PhabricatorMailSetupCheck.php',
'PhabricatorMailgunConfigOptions' => 'applications/config/option/PhabricatorMailgunConfigOptions.php',
'PhabricatorMailingListDatasource' => 'applications/mailinglists/typeahead/PhabricatorMailingListDatasource.php',
'PhabricatorMailingListListPHIDType' => 'applications/mailinglists/phid/PhabricatorMailingListListPHIDType.php',
'PhabricatorMailingListQuery' => 'applications/mailinglists/query/PhabricatorMailingListQuery.php',
'PhabricatorMailingListSearchEngine' => 'applications/mailinglists/query/PhabricatorMailingListSearchEngine.php',
'PhabricatorMailingListsApplication' => 'applications/mailinglists/application/PhabricatorMailingListsApplication.php',
'PhabricatorMailingListsController' => 'applications/mailinglists/controller/PhabricatorMailingListsController.php',
'PhabricatorMailingListsEditController' => 'applications/mailinglists/controller/PhabricatorMailingListsEditController.php',
'PhabricatorMailingListsListController' => 'applications/mailinglists/controller/PhabricatorMailingListsListController.php',
'PhabricatorMailingListsManageCapability' => 'applications/mailinglists/capability/PhabricatorMailingListsManageCapability.php',
'PhabricatorMainMenuSearchView' => 'view/page/menu/PhabricatorMainMenuSearchView.php',
'PhabricatorMainMenuView' => 'view/page/menu/PhabricatorMainMenuView.php',
'PhabricatorManagementWorkflow' => 'infrastructure/management/PhabricatorManagementWorkflow.php',
@ -2067,7 +2058,6 @@ phutil_register_library_map(array(
'PhabricatorMetaMTAMailableDatasource' => 'applications/metamta/typeahead/PhabricatorMetaMTAMailableDatasource.php',
'PhabricatorMetaMTAMailableFunctionDatasource' => 'applications/metamta/typeahead/PhabricatorMetaMTAMailableFunctionDatasource.php',
'PhabricatorMetaMTAMailgunReceiveController' => 'applications/metamta/controller/PhabricatorMetaMTAMailgunReceiveController.php',
'PhabricatorMetaMTAMailingList' => 'applications/mailinglists/storage/PhabricatorMetaMTAMailingList.php',
'PhabricatorMetaMTAMemberQuery' => 'applications/metamta/query/PhabricatorMetaMTAMemberQuery.php',
'PhabricatorMetaMTAPermanentFailureException' => 'applications/metamta/exception/PhabricatorMetaMTAPermanentFailureException.php',
'PhabricatorMetaMTAReceivedMail' => 'applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php',
@ -5435,15 +5425,6 @@ phutil_register_library_map(array(
'PhabricatorMailReceiverTestCase' => 'PhabricatorTestCase',
'PhabricatorMailSetupCheck' => 'PhabricatorSetupCheck',
'PhabricatorMailgunConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorMailingListDatasource' => 'PhabricatorTypeaheadDatasource',
'PhabricatorMailingListListPHIDType' => 'PhabricatorPHIDType',
'PhabricatorMailingListQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorMailingListSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhabricatorMailingListsApplication' => 'PhabricatorApplication',
'PhabricatorMailingListsController' => 'PhabricatorController',
'PhabricatorMailingListsEditController' => 'PhabricatorMailingListsController',
'PhabricatorMailingListsListController' => 'PhabricatorMailingListsController',
'PhabricatorMailingListsManageCapability' => 'PhabricatorPolicyCapability',
'PhabricatorMainMenuSearchView' => 'AphrontView',
'PhabricatorMainMenuView' => 'AphrontView',
'PhabricatorManagementWorkflow' => 'PhutilArgumentWorkflow',
@ -5477,11 +5458,6 @@ phutil_register_library_map(array(
'PhabricatorMetaMTAMailableDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
'PhabricatorMetaMTAMailableFunctionDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
'PhabricatorMetaMTAMailgunReceiveController' => 'PhabricatorMetaMTAController',
'PhabricatorMetaMTAMailingList' => array(
'PhabricatorMetaMTADAO',
'PhabricatorPolicyInterface',
'PhabricatorDestructibleInterface',
),
'PhabricatorMetaMTAMemberQuery' => 'PhabricatorQuery',
'PhabricatorMetaMTAPermanentFailureException' => 'Exception',
'PhabricatorMetaMTAReceivedMail' => 'PhabricatorMetaMTADAO',

View file

@ -78,7 +78,6 @@ final class DifferentialSubscribersField
array(
PhabricatorPeopleUserPHIDType::TYPECONST,
PhabricatorProjectProjectPHIDType::TYPECONST,
PhabricatorMailingListListPHIDType::TYPECONST,
));
}

View file

@ -1,48 +0,0 @@
<?php
final class PhabricatorMailingListsApplication extends PhabricatorApplication {
public function getName() {
return pht('Mailing Lists');
}
public function getBaseURI() {
return '/mailinglists/';
}
public function getShortDescription() {
return pht('Manage External Lists');
}
public function getFontIcon() {
return 'fa-mail-reply-all';
}
public function getApplicationGroup() {
return self::GROUP_ADMIN;
}
public function getRoutes() {
return array(
'/mailinglists/' => array(
'(?:query/(?P<queryKey>[^/]+)/)?'
=> 'PhabricatorMailingListsListController',
'edit/(?:(?P<id>[1-9]\d*)/)?'
=> 'PhabricatorMailingListsEditController',
),
);
}
public function getTitleGlyph() {
return '@';
}
protected function getCustomCapabilities() {
return array(
PhabricatorMailingListsManageCapability::CAPABILITY => array(
'default' => PhabricatorPolicies::POLICY_ADMIN,
),
);
}
}

View file

@ -1,16 +0,0 @@
<?php
final class PhabricatorMailingListsManageCapability
extends PhabricatorPolicyCapability {
const CAPABILITY = 'mailinglists.manage';
public function getCapabilityName() {
return pht('Can Manage Lists');
}
public function describeCapabilityRejection() {
return pht('You do not have permission to manage mailing lists.');
}
}

View file

@ -1,45 +0,0 @@
<?php
abstract class PhabricatorMailingListsController extends PhabricatorController {
public function buildSideNavView($for_app = false) {
$user = $this->getRequest()->getUser();
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
if ($for_app) {
$nav->addFilter('edit', pht('Create List'));
}
id(new PhabricatorMailingListSearchEngine())
->setViewer($user)
->addNavigationItems($nav->getMenu());
$nav->selectFilter(null);
return $nav;
}
public function buildApplicationMenu() {
return $this->buildSideNavView(true)->getMenu();
}
protected function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
$can_manage = $this->hasApplicationCapability(
PhabricatorMailingListsManageCapability::CAPABILITY);
$crumbs->addAction(
id(new PHUIListItemView())
->setName(pht('Create List'))
->setHref($this->getApplicationURI('edit/'))
->setIcon('fa-plus-square')
->setDisabled(!$can_manage)
->setWorkflow(!$can_manage));
return $crumbs;
}
}

View file

@ -1,131 +0,0 @@
<?php
final class PhabricatorMailingListsEditController
extends PhabricatorMailingListsController {
public function handleRequest(AphrontRequest $request) {
$request = $this->getRequest();
$viewer = $request->getUser();
$this->requireApplicationCapability(
PhabricatorMailingListsManageCapability::CAPABILITY);
$list_id = $request->getURIData('id');
if ($list_id) {
$page_title = pht('Edit Mailing List');
$list = id(new PhabricatorMailingListQuery())
->setViewer($viewer)
->withIDs(array($list_id))
->executeOne();
if (!$list) {
return new Aphront404Response();
}
} else {
$page_title = pht('Create Mailing List');
$list = new PhabricatorMetaMTAMailingList();
}
$e_email = true;
$e_uri = null;
$e_name = true;
$errors = array();
$crumbs = $this->buildApplicationCrumbs();
if ($request->isFormPost()) {
$list->setName($request->getStr('name'));
$list->setEmail($request->getStr('email'));
$list->setURI($request->getStr('uri'));
$e_email = null;
$e_name = null;
if (!strlen($list->getEmail())) {
$e_email = pht('Required');
$errors[] = pht('Email is required.');
}
if (!strlen($list->getName())) {
$e_name = pht('Required');
$errors[] = pht('Name is required.');
} else if (preg_match('/[ ,]/', $list->getName())) {
$e_name = pht('Invalid');
$errors[] = pht('Name must not contain spaces or commas.');
}
if ($list->getURI()) {
if (!PhabricatorEnv::isValidRemoteURIForLink($list->getURI())) {
$e_uri = pht('Invalid');
$errors[] = pht('Mailing list URI must point to a valid web page.');
}
}
if (!$errors) {
try {
$list->save();
return id(new AphrontRedirectResponse())
->setURI($this->getApplicationURI());
} catch (AphrontDuplicateKeyQueryException $ex) {
$e_email = pht('Duplicate');
$errors[] = pht('Another mailing list already uses that address.');
}
}
}
$form = new AphrontFormView();
$form->setUser($request->getUser());
if ($list->getID()) {
$form->setAction($this->getApplicationURI('/edit/'.$list->getID().'/'));
} else {
$form->setAction($this->getApplicationURI('/edit/'));
}
$form
->appendChild(
id(new AphrontFormTextControl())
->setLabel(pht('Email'))
->setName('email')
->setValue($list->getEmail())
->setCaption(pht('Email will be delivered to this address.'))
->setError($e_email))
->appendChild(
id(new AphrontFormTextControl())
->setLabel(pht('Name'))
->setName('name')
->setError($e_name)
->setCaption(pht('Human-readable display and autocomplete name.'))
->setValue($list->getName()))
->appendChild(
id(new AphrontFormTextControl())
->setLabel(pht('URI'))
->setName('uri')
->setError($e_uri)
->setCaption(pht('Optional link to mailing list archives or info.'))
->setValue($list->getURI()))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue(pht('Save'))
->addCancelButton($this->getApplicationURI()));
if ($list->getID()) {
$crumbs->addTextCrumb(pht('Edit Mailing List'));
} else {
$crumbs->addTextCrumb(pht('Create Mailing List'));
}
$form_box = id(new PHUIObjectBoxView())
->setHeaderText($page_title)
->setFormErrors($errors)
->setForm($form);
return $this->buildApplicationPage(
array(
$crumbs,
$form_box,
),
array(
'title' => $page_title,
));
}
}

View file

@ -1,25 +0,0 @@
<?php
final class PhabricatorMailingListsListController
extends PhabricatorMailingListsController {
private $queryKey;
public function shouldAllowPublic() {
return true;
}
public function willProcessRequest(array $data) {
$this->queryKey = idx($data, 'queryKey');
}
public function processRequest() {
$controller = id(new PhabricatorApplicationSearchController())
->setQueryKey($this->queryKey)
->setSearchEngine(new PhabricatorMailingListSearchEngine())
->setNavigation($this->buildSideNavView());
return $this->delegateToController($controller);
}
}

View file

@ -1,71 +0,0 @@
<?php
final class PhabricatorMailingListListPHIDType extends PhabricatorPHIDType {
const TYPECONST = 'MLST';
public function getTypeName() {
return pht('Mailing List');
}
public function getTypeIcon() {
return 'fa-envelope-o';
}
public function newObject() {
return new PhabricatorMetaMTAMailingList();
}
protected function buildQueryForObjects(
PhabricatorObjectQuery $query,
array $phids) {
return id(new PhabricatorMailingListQuery())
->withPHIDs($phids);
}
public function loadHandles(
PhabricatorHandleQuery $query,
array $handles,
array $objects) {
foreach ($handles as $phid => $handle) {
$list = $objects[$phid];
$handle->setName($list->getName());
$handle->setURI($list->getURI());
}
}
public function canLoadNamedObject($name) {
return preg_match('/^.+@.+/', $name);
}
public function loadNamedObjects(
PhabricatorObjectQuery $query,
array $names) {
$id_map = array();
foreach ($names as $name) {
// Maybe normalize these some day?
$id = $name;
$id_map[$id][] = $name;
}
$objects = id(new PhabricatorMailingListQuery())
->setViewer($query->getViewer())
->withEmails(array_keys($id_map))
->execute();
$results = array();
foreach ($objects as $id => $object) {
$email = $object->getEmail();
foreach (idx($id_map, $email, array()) as $name) {
$results[$name] = $object;
}
}
return $results;
}
}

View file

@ -1,86 +0,0 @@
<?php
final class PhabricatorMailingListQuery
extends PhabricatorCursorPagedPolicyAwareQuery {
private $phids;
private $ids;
private $emails;
private $names;
public function withIDs($ids) {
$this->ids = $ids;
return $this;
}
public function withPHIDs($phids) {
$this->phids = $phids;
return $this;
}
public function withEmails(array $emails) {
$this->emails = $emails;
return $this;
}
public function withNames(array $names) {
$this->names = $names;
return $this;
}
protected function loadPage() {
$table = new PhabricatorMetaMTAMailingList();
$conn_r = $table->establishConnection('r');
$data = queryfx_all(
$conn_r,
'SELECT * FROM %T %Q %Q %Q',
$table->getTableName(),
$this->buildWhereClause($conn_r),
$this->buildOrderClause($conn_r),
$this->buildLimitClause($conn_r));
return $table->loadAllFromArray($data);
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
$where = array();
if ($this->ids) {
$where[] = qsprintf(
$conn_r,
'id IN (%Ld)',
$this->ids);
}
if ($this->phids) {
$where[] = qsprintf(
$conn_r,
'phid IN (%Ls)',
$this->phids);
}
if ($this->names) {
$where[] = qsprintf(
$conn_r,
'name IN (%Ls)',
$this->names);
}
if ($this->emails) {
$where[] = qsprintf(
$conn_r,
'email IN (%Ls)',
$this->emails);
}
$where[] = $this->buildPagingClause($conn_r);
return $this->formatWhereClause($where);
}
public function getQueryApplicationClass() {
return 'PhabricatorMailingListsApplication';
}
}

View file

@ -1,91 +0,0 @@
<?php
final class PhabricatorMailingListSearchEngine
extends PhabricatorApplicationSearchEngine {
public function getResultTypeDescription() {
return pht('Mailing Lists');
}
public function getApplicationClassName() {
return 'PhabricatorMailingListsApplication';
}
public function buildSavedQueryFromRequest(AphrontRequest $request) {
$saved = new PhabricatorSavedQuery();
return $saved;
}
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
$query = id(new PhabricatorMailingListQuery());
return $query;
}
public function buildSearchForm(
AphrontFormView $form,
PhabricatorSavedQuery $saved_query) {
// This just makes it clear to the user that the lack of filters is
// intentional, not a bug.
$form->appendChild(
id(new AphrontFormMarkupControl())
->setValue(pht('No query filters are available for mailing lists.')));
}
protected function getURI($path) {
return '/mailinglists/'.$path;
}
protected function getBuiltinQueryNames() {
return array(
'all' => pht('All Lists'),
);
}
public function buildSavedQueryFromBuiltin($query_key) {
$query = $this->newSavedQuery();
$query->setQueryKey($query_key);
switch ($query_key) {
case 'all':
return $query;
}
return parent::buildSavedQueryFromBuiltin($query_key);
}
protected function renderResultList(
array $lists,
PhabricatorSavedQuery $query,
array $handles) {
assert_instances_of($lists, 'PhabricatorMetaMTAMailingList');
$view = id(new PHUIObjectItemListView());
$can_manage = PhabricatorPolicyFilter::hasCapability(
$this->requireViewer(),
$this->getApplication(),
PhabricatorMailingListsManageCapability::CAPABILITY);
foreach ($lists as $list) {
$item = new PHUIObjectItemView();
$item->setHeader($list->getName());
$item->setHref($list->getURI());
$item->addAttribute($list->getEmail());
$item->addAction(
id(new PHUIListItemView())
->setIcon('fa-pencil')
->setHref($this->getApplicationURI('/edit/'.$list->getID().'/'))
->setDisabled(!$can_manage)
->setWorkflow(!$can_manage));
$view->addItem($item);
}
return $view;
}
}

View file

@ -1,77 +0,0 @@
<?php
final class PhabricatorMetaMTAMailingList extends PhabricatorMetaMTADAO
implements
PhabricatorPolicyInterface,
PhabricatorDestructibleInterface {
protected $name;
protected $email;
protected $uri;
public function generatePHID() {
return PhabricatorPHID::generateNewPHID(
PhabricatorMailingListListPHIDType::TYPECONST);
}
protected function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_COLUMN_SCHEMA => array(
'name' => 'text128',
'email' => 'text128',
'uri' => 'text255?',
),
self::CONFIG_KEY_SCHEMA => array(
'key_phid' => null,
'phid' => array(
'columns' => array('phid'),
'unique' => true,
),
'email' => array(
'columns' => array('email'),
'unique' => true,
),
'name' => array(
'columns' => array('name'),
'unique' => true,
),
),
) + parent::getConfiguration();
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */
public function getCapabilities() {
return array(
PhabricatorPolicyCapability::CAN_VIEW,
);
}
public function getPolicy($capability) {
return PhabricatorPolicies::getMostOpenPolicy();
}
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */
public function destroyObjectPermanently(
PhabricatorDestructionEngine $engine) {
$this->openTransaction();
$this->delete();
$this->saveTransaction();
}
}

View file

@ -1,39 +0,0 @@
<?php
final class PhabricatorMailingListDatasource
extends PhabricatorTypeaheadDatasource {
public function getBrowseTitle() {
return pht('Browse Mailing Lists');
}
public function getPlaceholderText() {
return pht('Type a mailing list name...');
}
public function getDatasourceApplicationClass() {
return 'PhabricatorMailingListsApplication';
}
public function loadResults() {
$viewer = $this->getViewer();
$raw_query = $this->getRawQuery();
$query = id(new PhabricatorMailingListQuery());
$lists = $this->executeQuery($query);
$results = array();
foreach ($lists as $list) {
$results[] = id(new PhabricatorTypeaheadResult())
->setName($list->getName())
->setURI($list->getURI())
->setPHID($list->getPHID());
}
// TODO: It would be slightly preferable to do this as part of the query,
// this is just simpler for the moment.
return $this->filterResultsAgainstTokens($results);
}
}

View file

@ -39,9 +39,6 @@ final class PhabricatorMetaMTAActorQuery extends PhabricatorQuery {
case PhabricatorPeopleExternalPHIDType::TYPECONST:
$this->loadExternalUserActors($actors, $phids);
break;
case PhabricatorMailingListListPHIDType::TYPECONST:
$this->loadMailingListActors($actors, $phids);
break;
default:
$this->loadUnknownActors($actors, $phids);
break;
@ -124,28 +121,6 @@ final class PhabricatorMetaMTAActorQuery extends PhabricatorQuery {
}
}
private function loadMailingListActors(array $actors, array $phids) {
assert_instances_of($actors, 'PhabricatorMetaMTAActor');
$lists = id(new PhabricatorMailingListQuery())
->setViewer($this->getViewer())
->withPHIDs($phids)
->execute();
$lists = mpull($lists, null, 'getPHID');
foreach ($phids as $phid) {
$actor = $actors[$phid];
$list = idx($lists, $phid);
if (!$list) {
$actor->setUndeliverable(PhabricatorMetaMTAActor::REASON_UNLOADABLE);
continue;
}
$actor->setName($list->getName());
$actor->setEmailAddress($list->getEmail());
}
}
private function loadUnknownActors(array $actors, array $phids) {
foreach ($phids as $phid) {

View file

@ -100,13 +100,7 @@ final class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO {
}
$users = id(new PhabricatorUserEmail())
->loadAllWhere('address IN (%Ls)', $addresses);
$user_phids = mpull($users, 'getUserPHID');
$mailing_lists = id(new PhabricatorMetaMTAMailingList())
->loadAllWhere('email in (%Ls)', $addresses);
$mailing_list_phids = mpull($mailing_lists, 'getPHID');
return array_merge($user_phids, $mailing_list_phids);
return mpull($users, 'getUserPHID');
}
public function processReceivedMail() {

View file

@ -19,7 +19,6 @@ final class PhabricatorMetaMTAMailableDatasource
return array(
new PhabricatorPeopleDatasource(),
new PhabricatorProjectDatasource(),
new PhabricatorMailingListDatasource(),
);
}

View file

@ -21,7 +21,6 @@ final class PhabricatorMetaMTAMailableFunctionDatasource
new PhabricatorPeopleDatasource(),
new PhabricatorProjectMembersDatasource(),
new PhabricatorProjectDatasource(),
new PhabricatorMailingListDatasource(),
);
}

View file

@ -143,27 +143,6 @@ final class PhabricatorObjectListQuery {
}
}
$mailing_list_app = PhabricatorApplication::getByClass(
'PhabricatorMailingListsApplication');
if ($mailing_list_app->isInstalled()) {
if ($names) {
// We still haven't been able to resolve everything; try mailing lists
// by name as a last resort.
$lists = id(new PhabricatorMailingListQuery())
->setViewer($this->getViewer())
->withNames($names)
->execute();
$lists = mpull($lists, null, 'getName');
foreach ($names as $key => $name) {
if (isset($lists[$name])) {
$results[$name] = $lists[$name];
unset($names[$key]);
}
}
}
}
return $results;
}

View file

@ -484,7 +484,6 @@ abstract class PhabricatorApplicationSearchEngine {
$key,
array(
PhabricatorProjectProjectPHIDType::TYPECONST,
PhabricatorMailingListListPHIDType::TYPECONST,
));
}

View file

@ -137,10 +137,6 @@
"name": "Macro",
"include": "(^src/applications/macro/)"
},
"mailinglists": {
"name": "Mailing Lists",
"include": "(^src/applications/mailinglists/)"
},
"maniphest": {
"name": "Maniphest",
"include": "(^src/applications/maniphest/)"