@@ -35,23 +35,24 @@ public static AvatarManager Instance
35
35
36
36
private static AvatarManager _instance = null ;
37
37
38
- [ GeneratedRegex ( @"^(?:(\d+)\+)?(.+?)@users\.noreply \.github\.com$" ) ]
38
+ [ GeneratedRegex ( @"^(?:(\d+)\+)?(.+?)@.+ \.github\.com$" ) ]
39
39
private static partial Regex REG_GITHUB_USER_EMAIL ( ) ;
40
40
41
41
private object _synclock = new object ( ) ;
42
42
private string _storePath ;
43
43
private List < IAvatarHost > _avatars = new List < IAvatarHost > ( ) ;
44
44
private Dictionary < string , Bitmap > _resources = new Dictionary < string , Bitmap > ( ) ;
45
45
private HashSet < string > _requesting = new HashSet < string > ( ) ;
46
+ private HashSet < string > _defaultAvatars = new HashSet < string > ( ) ;
46
47
47
48
public void Start ( )
48
49
{
49
50
_storePath = Path . Combine ( Native . OS . DataDir , "avatars" ) ;
50
51
if ( ! Directory . Exists ( _storePath ) )
51
52
Directory . CreateDirectory ( _storePath ) ;
52
53
53
- var icon = AssetLoader . Open ( new Uri ( $ "avares://SourceGit/Resources/Images/ github.png ", UriKind . RelativeOrAbsolute ) ) ;
54
- _resources . Add ( "noreply@github .com", new Bitmap ( icon ) ) ;
54
+ LoadDefaultAvatar ( "noreply@ github.com ", "github.png" ) ;
55
+ LoadDefaultAvatar ( "unrealbot@epicgames .com", "unreal.png" ) ;
55
56
56
57
Task . Run ( ( ) =>
57
58
{
@@ -140,7 +141,7 @@ public Bitmap Request(string email, bool forceRefetch)
140
141
{
141
142
if ( forceRefetch )
142
143
{
143
- if ( email . Equals ( "[email protected] " , StringComparison . Ordinal ) )
144
+ if ( _defaultAvatars . Contains ( email ) )
144
145
return null ;
145
146
146
147
if ( _resources . ContainsKey ( email ) )
@@ -185,6 +186,13 @@ public Bitmap Request(string email, bool forceRefetch)
185
186
return null ;
186
187
}
187
188
189
+ private void LoadDefaultAvatar ( string key , string img )
190
+ {
191
+ var icon = AssetLoader . Open ( new Uri ( $ "avares://SourceGit/Resources/Images/{ img } ", UriKind . RelativeOrAbsolute ) ) ;
192
+ _resources . Add ( key , new Bitmap ( icon ) ) ;
193
+ _defaultAvatars . Add ( key ) ;
194
+ }
195
+
188
196
private string GetEmailHash ( string email )
189
197
{
190
198
var lowered = email . ToLower ( CultureInfo . CurrentCulture ) . Trim ( ) ;
0 commit comments