@@ -13,14 +13,15 @@ import (
13
13
// NewAdminService creates an instance of AdminService.
14
14
func NewAdminService (
15
15
accountManager AccountManager ,
16
- buddyListRetriever BuddyListRetriever ,
16
+ buddyIconManager BuddyIconManager ,
17
+ relationshipFetcher RelationshipFetcher ,
17
18
messageRelayer MessageRelayer ,
18
19
sessionRetriever SessionRetriever ,
19
20
logger * slog.Logger ,
20
21
) * AdminService {
21
22
return & AdminService {
22
23
accountManager : accountManager ,
23
- buddyBroadcaster : newBuddyNotifier (buddyListRetriever , messageRelayer , sessionRetriever ),
24
+ buddyBroadcaster : newBuddyNotifier (buddyIconManager , relationshipFetcher , messageRelayer , sessionRetriever ),
24
25
messageRelayer : messageRelayer ,
25
26
logger : logger ,
26
27
}
@@ -52,21 +53,21 @@ func (s AdminService) ConfirmRequest(ctx context.Context, sess *state.Session, f
52
53
}
53
54
}
54
55
55
- _ , err := s .accountManager .EmailAddressByName ( sess .IdentScreenName ())
56
+ _ , err := s .accountManager .EmailAddress ( ctx , sess .IdentScreenName ())
56
57
if errors .Is (err , state .ErrNoEmailAddress ) {
57
58
return getAdminConfirmReply (wire .AdminAcctConfirmStatusServerError ), nil
58
59
} else if err != nil {
59
60
return wire.SNACMessage {}, err
60
61
}
61
62
62
- accountConfirmed , err := s .accountManager .ConfirmStatusByName ( sess .IdentScreenName ())
63
+ accountConfirmed , err := s .accountManager .ConfirmStatus ( ctx , sess .IdentScreenName ())
63
64
if err != nil {
64
65
return wire.SNACMessage {}, err
65
66
}
66
67
if accountConfirmed {
67
68
return getAdminConfirmReply (wire .AdminAcctConfirmStatusAlreadyConfirmed ), nil
68
69
}
69
- if err := s .accountManager .UpdateConfirmStatus (true , sess .IdentScreenName ()); err != nil {
70
+ if err := s .accountManager .UpdateConfirmStatus (ctx , sess .IdentScreenName (), true ); err != nil {
70
71
return wire.SNACMessage {}, err
71
72
}
72
73
sess .ClearUserInfoFlag (wire .OServiceUserFlagUnconfirmed )
@@ -77,7 +78,7 @@ func (s AdminService) ConfirmRequest(ctx context.Context, sess *state.Session, f
77
78
}
78
79
79
80
// InfoQuery returns the requested information about the account
80
- func (s AdminService ) InfoQuery (_ context.Context , sess * state.Session , frame wire.SNACFrame , body wire.SNAC_0x07_0x02_AdminInfoQuery ) (wire.SNACMessage , error ) {
81
+ func (s AdminService ) InfoQuery (ctx context.Context , sess * state.Session , frame wire.SNACFrame , body wire.SNAC_0x07_0x02_AdminInfoQuery ) (wire.SNACMessage , error ) {
81
82
// getAdminInfoReply returns an AdminInfoReply SNAC
82
83
var getAdminInfoReply = func (tlvList wire.TLVList ) wire.SNACMessage {
83
84
return wire.SNACMessage {
@@ -98,7 +99,7 @@ func (s AdminService) InfoQuery(_ context.Context, sess *state.Session, frame wi
98
99
tlvList := wire.TLVList {}
99
100
100
101
if _ , hasRegStatus := body .TLVRestBlock .Bytes (wire .AdminTLVRegistrationStatus ); hasRegStatus {
101
- regStatus , err := s .accountManager .RegStatusByName ( sess .IdentScreenName ())
102
+ regStatus , err := s .accountManager .RegStatus ( ctx , sess .IdentScreenName ())
102
103
if err != nil {
103
104
return wire.SNACMessage {}, err
104
105
}
@@ -107,7 +108,7 @@ func (s AdminService) InfoQuery(_ context.Context, sess *state.Session, frame wi
107
108
}
108
109
109
110
if _ , hasEmail := body .TLVRestBlock .Bytes (wire .AdminTLVEmailAddress ); hasEmail {
110
- e , err := s .accountManager .EmailAddressByName ( sess .IdentScreenName ())
111
+ e , err := s .accountManager .EmailAddress ( ctx , sess .IdentScreenName ())
111
112
if errors .Is (err , state .ErrNoEmailAddress ) {
112
113
tlvList .Append (wire .NewTLVBE (wire .AdminTLVEmailAddress , "" ))
113
114
} else if err != nil {
@@ -205,7 +206,7 @@ func (s AdminService) InfoChangeRequest(ctx context.Context, sess *state.Session
205
206
tlvList .Append (wire .NewTLVBE (wire .AdminTLVUrl , "" ))
206
207
return getAdminChangeReply (tlvList ), nil
207
208
}
208
- if err := s .accountManager .UpdateDisplayScreenName (proposedName ); err != nil {
209
+ if err := s .accountManager .UpdateDisplayScreenName (ctx , proposedName ); err != nil {
209
210
return wire.SNACMessage {}, err
210
211
}
211
212
sess .SetDisplayScreenName (proposedName )
@@ -233,7 +234,7 @@ func (s AdminService) InfoChangeRequest(ctx context.Context, sess *state.Session
233
234
return getAdminChangeReply (tlvList ), nil
234
235
235
236
}
236
- if err := s .accountManager .UpdateEmailAddress (e , sess .IdentScreenName ()); err != nil {
237
+ if err := s .accountManager .UpdateEmailAddress (ctx , sess .IdentScreenName (), e ); err != nil {
237
238
return wire.SNACMessage {}, err
238
239
}
239
240
tlvList .Append (wire .NewTLVBE (wire .AdminTLVEmailAddress , e .Address ))
@@ -246,7 +247,7 @@ func (s AdminService) InfoChangeRequest(ctx context.Context, sess *state.Session
246
247
wire .AdminInfoRegStatusFullDisclosure ,
247
248
wire .AdminInfoRegStatusLimitDisclosure ,
248
249
wire .AdminInfoRegStatusNoDisclosure :
249
- if err := s .accountManager .UpdateRegStatus (regStatus , sess .IdentScreenName ()); err != nil {
250
+ if err := s .accountManager .UpdateRegStatus (ctx , sess .IdentScreenName (), regStatus ); err != nil {
250
251
return wire.SNACMessage {}, err
251
252
}
252
253
tlvList .Append (wire .NewTLVBE (wire .AdminTLVRegistrationStatus , regStatus ))
@@ -267,7 +268,7 @@ func (s AdminService) InfoChangeRequest(ctx context.Context, sess *state.Session
267
268
return getAdminChangeReply (tlvList ), nil
268
269
}
269
270
270
- u , err := s .accountManager .User (sess .IdentScreenName ())
271
+ u , err := s .accountManager .User (ctx , sess .IdentScreenName ())
271
272
if err != nil || u == nil {
272
273
if err != nil {
273
274
s .logger .ErrorContext (ctx , "accountManager.User: runtime error" , "err" , err )
@@ -283,7 +284,7 @@ func (s AdminService) InfoChangeRequest(ctx context.Context, sess *state.Session
283
284
return getAdminChangeReply (tlvList ), nil
284
285
}
285
286
286
- if err := s .accountManager .SetUserPassword (sess .IdentScreenName (), newPass ); err != nil {
287
+ if err := s .accountManager .SetUserPassword (ctx , sess .IdentScreenName (), newPass ); err != nil {
287
288
if errors .Is (err , state .ErrPasswordInvalid ) {
288
289
tlvList .Append (wire .NewTLVBE (wire .AdminTLVErrorCode , wire .AdminInfoErrorInvalidPasswordLength ))
289
290
} else {
0 commit comments