(ctx context.Context, rw http.ResponseWriter, chat database.Chat, entries database.ChatACL)
| 203 | } |
| 204 | |
| 205 | func (api *API) chatACLUsers(ctx context.Context, rw http.ResponseWriter, chat database.Chat, entries database.ChatACL) ([]codersdk.ChatUser, bool) { |
| 206 | userIDs := make([]uuid.UUID, 0, len(entries)) |
| 207 | for userID := range entries { |
| 208 | id, err := uuid.Parse(userID) |
| 209 | if err != nil { |
| 210 | api.Logger.Warn(ctx, "found invalid user uuid in chat acl", slog.Error(err), slog.F("chat_id", chat.ID)) |
| 211 | continue |
| 212 | } |
| 213 | userIDs = append(userIDs, id) |
| 214 | } |
| 215 | |
| 216 | //nolint:gocritic // Users who can read the chat ACL should see shared users even without user read permission. |
| 217 | dbUsers, err := api.Database.GetUsersByIDs(dbauthz.AsSystemRestricted(ctx), userIDs) |
| 218 | if err != nil && !xerrors.Is(err, sql.ErrNoRows) { |
| 219 | httpapi.InternalServerError(rw, err) |
| 220 | return nil, false |
| 221 | } |
| 222 | |
| 223 | users := make([]codersdk.ChatUser, 0, len(dbUsers)) |
| 224 | for _, user := range dbUsers { |
| 225 | entry := entries[user.ID.String()] |
| 226 | users = append(users, codersdk.ChatUser{ |
| 227 | MinimalUser: db2sdk.MinimalUser(user), |
| 228 | Role: convertToChatRole(entry.Permissions), |
| 229 | }) |
| 230 | } |
| 231 | return users, true |
| 232 | } |
| 233 | |
| 234 | func (api *API) chatACLGroups(ctx context.Context, rw http.ResponseWriter, chat database.Chat, entries database.ChatACL) ([]codersdk.ChatGroup, bool) { |
| 235 | groupIDs := make([]uuid.UUID, 0, len(entries)) |
no test coverage detected