1- import { CommentVo , ReplyVo } from '@halo-dev/api-client' ;
1+ import type { CommentVo , ReplyVo } from '@halo-dev/api-client' ;
22import { getAvatarProvider } from './providers' ;
33
44abstract class AvatarPolicy {
5- abstract applyCommentPolicy ( comment : CommentVo | undefined ) : string | undefined ;
5+ abstract applyCommentPolicy (
6+ comment : CommentVo | undefined
7+ ) : string | undefined ;
68 abstract applyReplyPolicy ( reply : ReplyVo | undefined ) : string | undefined ;
79}
810
@@ -15,15 +17,19 @@ class AnonymousUserPolicy extends AvatarPolicy {
1517 const avatarProvider = getAvatarProvider ( ) ;
1618 const isAnonymous = comment ?. owner . kind === emailKind ;
1719 if ( isAnonymous ) {
18- return avatarProvider ?. getAvatarSrc ( comment ?. spec . owner . annotations ?. [ emailHash ] ) ;
20+ return avatarProvider ?. getAvatarSrc (
21+ comment ?. spec . owner . annotations ?. [ emailHash ]
22+ ) ;
1923 }
2024 return comment ?. owner . avatar ;
2125 }
2226 applyReplyPolicy ( reply : ReplyVo | undefined ) : string | undefined {
2327 const avatarProvider = getAvatarProvider ( ) ;
2428 const isAnonymous = reply ?. owner . kind === emailKind ;
2529 if ( isAnonymous ) {
26- return avatarProvider ?. getAvatarSrc ( reply ?. spec . owner . annotations ?. [ emailHash ] ) ;
30+ return avatarProvider ?. getAvatarSrc (
31+ reply ?. spec . owner . annotations ?. [ emailHash ]
32+ ) ;
2733 }
2834 return reply ?. owner . avatar ;
2935 }
@@ -32,11 +38,15 @@ class AnonymousUserPolicy extends AvatarPolicy {
3238class AllUserPolicy extends AvatarPolicy {
3339 applyCommentPolicy ( comment : CommentVo | undefined ) : string | undefined {
3440 const avatarProvider = getAvatarProvider ( ) ;
35- return avatarProvider ?. getAvatarSrc ( comment ?. spec . owner . annotations ?. [ emailHash ] ) ;
41+ return avatarProvider ?. getAvatarSrc (
42+ comment ?. spec . owner . annotations ?. [ emailHash ]
43+ ) ;
3644 }
3745 applyReplyPolicy ( reply : ReplyVo | undefined ) : string | undefined {
3846 const avatarProvider = getAvatarProvider ( ) ;
39- return avatarProvider ?. getAvatarSrc ( reply ?. spec . owner . annotations ?. [ emailHash ] ) ;
47+ return avatarProvider ?. getAvatarSrc (
48+ reply ?. spec . owner . annotations ?. [ emailHash ]
49+ ) ;
4050 }
4151}
4252
@@ -46,7 +56,9 @@ class NoAvatarUserPolicy extends AvatarPolicy {
4656 const isAnonymous = comment ?. owner . kind === emailKind ;
4757 const avatar = comment ?. owner . avatar ;
4858 if ( isAnonymous || ! avatar ) {
49- return avatarProvider ?. getAvatarSrc ( comment ?. spec . owner . annotations ?. [ emailHash ] ) ;
59+ return avatarProvider ?. getAvatarSrc (
60+ comment ?. spec . owner . annotations ?. [ emailHash ]
61+ ) ;
5062 }
5163 return avatar ;
5264 }
@@ -55,7 +67,9 @@ class NoAvatarUserPolicy extends AvatarPolicy {
5567 const isAnonymous = reply ?. owner . kind === emailKind ;
5668 const avatar = reply ?. owner . avatar ;
5769 if ( isAnonymous || ! avatar ) {
58- return avatarProvider ?. getAvatarSrc ( reply ?. spec . owner . annotations ?. [ emailHash ] ) ;
70+ return avatarProvider ?. getAvatarSrc (
71+ reply ?. spec . owner . annotations ?. [ emailHash ]
72+ ) ;
5973 }
6074 return avatar ;
6175 }
0 commit comments