Skip to content

Commit

Permalink
Merge pull request #1658 from shadow-dot-cat/castaway/1609_allowlist_…
Browse files Browse the repository at this point in the history
…button

feat(mailviewer): New allowlist sender option for mail viewer
  • Loading branch information
castaway authored Feb 5, 2025
2 parents 564feb9 + 56047ab commit fc9f9d8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
12 changes: 12 additions & 0 deletions src/app/mailviewer/rmm7messageactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,18 @@ export class RMM7MessageActions implements MessageActions {
snackBarRef.dismiss();
}

allowListSender(param) {
const msg = `AllowListing sender: ${param}`;
const snackBarRef = this.snackBar.open(msg);
this.rmmapi.allowListSender(param).subscribe((res) => {
if ( res.status === 'error' ) {
snackBarRef.dismiss();
this.snackBar.open('There was an error with Sender allowlisting functionality. Please try again.', 'Dismiss');
}
});
snackBarRef.dismiss();
}

// Update mailviewer menu flag icon after flagging?
flag() {
this.updateMessages({
Expand Down
7 changes: 5 additions & 2 deletions src/app/mailviewer/singlemailviewer.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<mat-icon svgIcon="alert-octagon-outline"></mat-icon>
</button>
</ng-container>
<button mat-icon-button *ngIf="morebuttonindex>8" matTooltip="Block Sender/Domain" [matMenuTriggerFor]="blockSenderMenu">
<button mat-icon-button *ngIf="morebuttonindex>8" matTooltip="Block/Allow Sender" [matMenuTriggerFor]="senderRulesMenu">
<mat-icon svgIcon="filter-cog"></mat-icon>
</button>
<a *ngIf="morebuttonindex>9" mat-icon-button
Expand All @@ -81,7 +81,10 @@
<mat-icon svgIcon="dots-vertical"></mat-icon>
</button>

<mat-menu #blockSenderMenu>
<mat-menu #senderRulesMenu>
<button mat-menu-item (click)="messageActionsHandler.allowListSender(mailObj.from[0].address)">
AllowList Sender
</button>
<button mat-menu-item (click)="messageActionsHandler.blockSender(mailObj.from[0].address)">
Block Sender Email
</button>
Expand Down
6 changes: 5 additions & 1 deletion src/app/rmmapi/rbwebmail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,12 @@ export class RunboxWebmailAPI {
return this.http.post('/rest/v1/spam/', JSON.stringify(params));
}

public allowListSender(param): Observable<any> {
return this.http.post('/rest/v1/rules/update_nospam_list', JSON.stringify({'email_addresses': [param]}));
}

public blockSender(param): Observable<any> {
return this.http.post('/rest/v1/rules/block_sender', JSON.stringify({'sender': param}));
return this.http.post('/rest/v1/rules/block_sender', JSON.stringify({'sender': param}));
}

// Moves to Trash if not already in Trash
Expand Down

0 comments on commit fc9f9d8

Please sign in to comment.