(ctx context.Context, id int64, currentUser string)
| 41 | } |
| 42 | |
| 43 | func (c *MirrorSourceComponent) Get(ctx context.Context, id int64, currentUser string) (*database.MirrorSource, error) { |
| 44 | user, err := c.userStore.FindByUsername(ctx, currentUser) |
| 45 | if err != nil { |
| 46 | return nil, errors.New("user does not exist") |
| 47 | } |
| 48 | if !user.CanAdmin() { |
| 49 | return nil, errors.New("user does not have admin permission") |
| 50 | } |
| 51 | ms, err := c.msStore.Get(ctx, id) |
| 52 | if err != nil { |
| 53 | return nil, fmt.Errorf("failed to get mirror source, error: %w", err) |
| 54 | } |
| 55 | return ms, nil |
| 56 | } |
| 57 | |
| 58 | func (c *MirrorSourceComponent) Index(ctx context.Context, currentUser string) ([]database.MirrorSource, error) { |
| 59 | user, err := c.userStore.FindByUsername(ctx, currentUser) |
no test coverage detected