Skip to content

Commit

Permalink
HasAddress: Remove rocketchat support
Browse files Browse the repository at this point in the history
As the plugins provide there own config elements, hardcoded check for rocketchat and email isn't ideal.
But exceptionally, the email check remains as it is the most used at the moment.
  • Loading branch information
sukhwinder33445 committed Nov 20, 2023
1 parent e58a2f6 commit 0bc7727
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 20 deletions.
10 changes: 2 additions & 8 deletions application/controllers/ContactsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,8 @@ public function init()

public function indexAction()
{
$contacts = Contact::on($this->db);

$contacts->withColumns(
[
'has_email',
'has_rc'
]
);
$contacts = Contact::on($this->db)
->withColumns('has_email');

$limitControl = $this->createLimitControl();
$paginationControl = $this->createPaginationControl($contacts);
Expand Down
10 changes: 4 additions & 6 deletions library/Notifications/Model/Behavior/HasAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function setQuery(Query $query)
public function rewriteColumn($column, ?string $relation = null)
{
if ($this->isSelectableColumn($column)) {
$type = $column === 'has_email' ? 'email' : 'rocketchat';
$type = 'email';

$subQueryRelation = $relation !== null ? $relation . '.contact.contact_address' : 'contact.contact_address';

Expand All @@ -53,17 +53,15 @@ public function rewriteColumn($column, ?string $relation = null)

public function isSelectableColumn(string $name): bool
{
return $name === 'has_email' || $name === 'has_rc';
return $name === 'has_email';
}

public function rewriteColumnDefinition(ColumnDefinition $def, string $relation): void
{
$name = $def->getName();

if ($this->isSelectableColumn($name)) {
$label = $name === 'has_email' ? t('Has Email Address') : t('Has Rocket.Chat Username');

$def->setLabel($label);
$def->setLabel(t('Has Email Address'));
}
}

Expand All @@ -72,7 +70,7 @@ public function rewriteCondition(Filter\Condition $condition, $relation = null)
$column = substr($condition->getColumn(), strlen($relation));

if ($this->isSelectableColumn($column)) {
$type = $column === 'has_email' ? 'email' : 'rocketchat';
$type = 'email';

$subQuery = $this->query->createSubQuery(new ContactAddress(), $relation)
->limit(1)
Expand Down
4 changes: 2 additions & 2 deletions library/Notifications/Model/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ public function getIcon(): Icon
{
switch ($this->type) {
case 'rocketchat':
$icon = new Icon('rocketchat');
$icon = new Icon('comment-dots');
break;
case 'email':
$icon = new Icon('envelope');
break;
default:
$icon = new Icon('comment-dots');
$icon = new Icon('comments'); //TODO: what should be the default icon
}

return $icon;
Expand Down
4 changes: 0 additions & 4 deletions library/Notifications/Widget/ItemList/ContactListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ protected function assembleFooter(BaseHtmlElement $footer): void
$contactIcons->addHtml(new Icon('envelope'));
}

if ($this->item->has_rc) {
$contactIcons->addHtml(new Icon('comment-dots'));
}

$footer->addHtml($contactIcons);
}

Expand Down

0 comments on commit 0bc7727

Please sign in to comment.