()
| 212 | } |
| 213 | |
| 214 | func (s *StatusGetter) CurrentUsername() (string, error) { |
| 215 | s.usernameMu.Lock() |
| 216 | defer s.usernameMu.Unlock() |
| 217 | |
| 218 | if s.currentUsername != "" { |
| 219 | return s.currentUsername, nil |
| 220 | } |
| 221 | |
| 222 | cachedClient := s.CachedClient(time.Hour * 48) |
| 223 | cachingAPIClient := api.NewClientFromHTTP(cachedClient) |
| 224 | currentUsername, err := api.CurrentLoginName(cachingAPIClient, s.hostname()) |
| 225 | if err != nil { |
| 226 | return "", fmt.Errorf("failed to get current username: %w", err) |
| 227 | } |
| 228 | |
| 229 | s.currentUsername = currentUsername |
| 230 | return currentUsername, nil |
| 231 | } |
| 232 | |
| 233 | func (s *StatusGetter) ActualMention(commentURL safeurl.SafeURL) (string, error) { |
| 234 | currentUsername, err := s.CurrentUsername() |
no test coverage detected