Skip to content

Commit

Permalink
Add dmarc and spf indicators in mail view the-djmaze#1820
Browse files Browse the repository at this point in the history
Signed-off-by: David Edler <[email protected]>
  • Loading branch information
edlerd committed Nov 12, 2024
1 parent 8b55471 commit 3ee9784
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
37 changes: 36 additions & 1 deletion dev/View/User/MailBox/MessageView.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ export class MailMessageView extends AbstractViewRight {
// viewer
viewFromShort: '',
dkimData: ['none', '', ''],
spfData: ['none', '', ''],
dmarcData: ['none', '', ''],
nowTracking: false
});

Expand Down Expand Up @@ -205,12 +207,43 @@ export class MailMessageView extends AbstractViewRight {
}
},
dkimIconClass: () => 'pass' === this.dkimData()[0] ? 'iconcolor-green' : 'iconcolor-red',

dkimTitle:() => {
const dkim = this.dkimData();
return dkim[0] ? dkim[2] || 'DKIM: ' + dkim[0] : '';
},

spfIcon: () => {
switch (this.spfData()[0]) {
case 'none':
return '';
case 'pass':
return '✔';
default:
return '✖';
}
},
spfIconClass: () => 'pass' === this.spfData()[0] ? 'iconcolor-green' : 'iconcolor-red',
spfTitle:() => {
const spf = this.spfData();
return spf[0] ? spf[2] || 'SPF: ' + spf[0] : '';
},

dmarcIcon: () => {
switch (this.dmarcData()[0]) {
case 'none':
return '';
case 'pass':
return '✔';
default:
return '✖';
}
},
dmarcIconClass: () => 'pass' === this.dmarcData()[0] ? 'iconcolor-green' : 'iconcolor-red',
dmarcTitle:() => {
const dmarc = this.dmarcData();
return dmarc[0] ? dmarc[2] || 'DMARC: ' + dmarc[0] : '';
},

showWhitelistOptions: () => 'match' === SettingsUserStore.viewImages(),

firstUnsubsribeLink: () => currentMessage()?.unsubsribeLinks()[0] || '',
Expand All @@ -233,6 +266,8 @@ export class MailMessageView extends AbstractViewRight {
// TODO: make first param a user setting #683
this.viewFromShort(message.from.toString(false, true));
this.dkimData(message.dkim[0] || ['none', '', '']);
this.spfData(message.spf[0] || ['none', '', '']);
this.dmarcData(message.dmarc[0] || ['none', '', '']);
this.nowTracking(false);
} else {
MessagelistUserStore.selectedMessage(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@
<div class="informationShort">
<span class="from" data-bind="html: viewFromShort, attr:{ title: message().from }"></span>
<i class="fontastic" data-bind="text: dkimIcon, css: dkimIconClass, attr:{ title: dkimTitle }"></i>
<i class="fontastic" data-bind="text: dmarcIcon, css: dmarcIconClass, attr:{ title: dmarcTitle }"></i>
<i class="fontastic" data-bind="text: spfIcon, css: spfIconClass, attr:{ title: spfTitle }"></i>
</div>
</div>
<div id="messageItem">
Expand Down

0 comments on commit 3ee9784

Please sign in to comment.