Skip to content

Commit 95fee69

Browse files
Added the ability to exclude user mentions from processing
1 parent 382bdcb commit 95fee69

File tree

4 files changed

+35
-10
lines changed

4 files changed

+35
-10
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,12 @@ By default, only those Issues and Pull Requests that have been closed or merged
8585
But you can define the parameters yourself:
8686

8787
```Bash
88-
-i, --except-issues Exclude issues from processing
89-
-p, --except-pulls Exclude Pull Requests from processing
90-
-o, --with-open Process including open Issues and Pull Requests
91-
-n, --no-interaction Do not ask any interactive question
92-
-q, --quiet Do not output any message
88+
-i, --except-issues Exclude issues from processing
89+
-p, --except-pulls Exclude Pull Requests from processing
90+
-m, --except-mentions Exclude notifications with your mention from processing
91+
-o, --with-open Process including open Issues and Pull Requests
92+
-n, --no-interaction Do not ask any interactive question
93+
-q, --quiet Do not output any message
9394
```
9495

9596
For example:

app/Commands/ReadCommand.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class ReadCommand extends Command
1717
. ' {repository?* : Full or partial repository names}'
1818
. ' {--i|except-issues : Exclude issues from processing}'
1919
. ' {--p|except-pulls : Exclude Pull Requests from processing}'
20+
. ' {--m|except-mentions : Exclude notifications with your mention from processing}'
2021
. ' {--o|with-open : Process including open Issues and Pull Requests}'
2122
. ' {--token= : Specifies the token to use}';
2223

@@ -57,6 +58,7 @@ protected function read(array $repositories): void
5758
->repositories($repositories)
5859
->exceptIssues($this->exceptIssues())
5960
->exceptPulls($this->exceptPulls())
61+
->exceptMentions($this->exceptMentions())
6062
->withOpen($this->withOpen())
6163
->when(
6264
$this->shouldBeAll($repositories),
@@ -70,6 +72,7 @@ protected function shouldBeAll(array $repositories): bool
7072
return empty($repositories)
7173
&& ! $this->exceptIssues()
7274
&& ! $this->exceptPulls()
75+
&& ! $this->exceptMentions()
7376
&& $this->withOpen();
7477
}
7578

@@ -103,6 +106,11 @@ protected function exceptPulls(): bool
103106
return $this->option('except-pulls');
104107
}
105108

109+
protected function exceptMentions(): bool
110+
{
111+
return $this->option('except-mentions');
112+
}
113+
106114
protected function withOpen(): bool
107115
{
108116
return $this->option('with-open');

app/Data/NotificationData.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class NotificationData extends Data
1212

1313
public string $type;
1414

15+
public string $reason;
16+
1517
public string $fullName;
1618

1719
public string $organization;
@@ -25,7 +27,8 @@ public function __construct(array $data, int $index)
2527
$this->id = (int) $this->get($data, 'id');
2628
$this->issueId = $this->issueId($data);
2729

28-
$this->type = $this->get($data, 'subject.type');
30+
$this->type = $this->get($data, 'subject.type');
31+
$this->reason = $this->get($data, 'reason');
2932

3033
$this->fullName = $this->get($data, 'repository.full_name');
3134
$this->organization = $this->get($data, 'repository.owner.login');

app/Services/GitHub.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class GitHub
2121

2222
protected bool $exceptPulls = false;
2323

24+
protected bool $exceptMentions = false;
25+
2426
protected bool $withOpen = false;
2527

2628
protected int $index = 0;
@@ -40,16 +42,23 @@ public function repositories(array $repositories): self
4042
return $this;
4143
}
4244

43-
public function exceptIssues(bool $exceptIssues): self
45+
public function exceptIssues(bool $except): self
4446
{
45-
$this->exceptIssues = $exceptIssues;
47+
$this->exceptIssues = $except;
4648

4749
return $this;
4850
}
4951

50-
public function exceptPulls(bool $exceptPulls): self
52+
public function exceptPulls(bool $except): self
5153
{
52-
$this->exceptPulls = $exceptPulls;
54+
$this->exceptPulls = $except;
55+
56+
return $this;
57+
}
58+
59+
public function exceptMentions(bool $except): self
60+
{
61+
$this->exceptMentions = $except;
5362

5463
return $this;
5564
}
@@ -159,6 +168,10 @@ protected function shouldSkip(NotificationData $notification, ItemData $item): b
159168
return true;
160169
}
161170

171+
if ($this->exceptMentions && $notification->reason === 'mention') {
172+
return true;
173+
}
174+
162175
if ($this->withOpen && $item->isOpen) {
163176
return false;
164177
}

0 commit comments

Comments
 (0)