V0.38.5 git board rewrite (#238)
Co-authored-by: gobha <jasafpro@gmail.com> Co-committed-by: gobha <jasafpro@gmail.com>
This commit is contained in:
@@ -1392,6 +1392,10 @@ type ConnectionStore interface {
|
||||
// to the user (personal + team + global).
|
||||
ResolveAll(ctx context.Context, userID, connType string) ([]models.ExtConnection, error)
|
||||
|
||||
// ListAccessible returns all connections accessible to the user across
|
||||
// all types: personal + team memberships + global.
|
||||
ListAccessible(ctx context.Context, userID string) ([]models.ExtConnection, error)
|
||||
|
||||
// DeleteByIDAndScope deletes a connection only if it matches the given
|
||||
// scope and owner. Returns rows affected (0 or 1).
|
||||
DeleteByIDAndScope(ctx context.Context, id, scope, ownerID string) (int64, error)
|
||||
|
||||
@@ -117,6 +117,26 @@ func (s *ConnectionStore) ResolveAll(ctx context.Context, userID, connType strin
|
||||
return scanConnections(rows)
|
||||
}
|
||||
|
||||
// ListAccessible returns all connections accessible to the user across all types.
|
||||
func (s *ConnectionStore) ListAccessible(ctx context.Context, userID string) ([]models.ExtConnection, error) {
|
||||
rows, err := DB.QueryContext(ctx, fmt.Sprintf(`
|
||||
SELECT %s FROM ext_connections
|
||||
WHERE is_active = true
|
||||
AND (
|
||||
(scope = 'personal' AND owner_id = $1)
|
||||
OR (scope = 'team' AND owner_id IN (
|
||||
SELECT team_id FROM team_members WHERE user_id = $1
|
||||
))
|
||||
OR (scope = 'global')
|
||||
)
|
||||
ORDER BY type ASC, scope ASC, name ASC`, connCols), userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
return scanConnections(rows)
|
||||
}
|
||||
|
||||
// DeleteByIDAndScope deletes a connection only if it matches the scope/owner.
|
||||
func (s *ConnectionStore) DeleteByIDAndScope(ctx context.Context, id, scope, ownerID string) (int64, error) {
|
||||
res, err := DB.ExecContext(ctx,
|
||||
|
||||
@@ -122,6 +122,25 @@ func (s *ConnectionStore) ResolveAll(ctx context.Context, userID, connType strin
|
||||
return scanConnections(rows)
|
||||
}
|
||||
|
||||
func (s *ConnectionStore) ListAccessible(ctx context.Context, userID string) ([]models.ExtConnection, error) {
|
||||
rows, err := DB.QueryContext(ctx, fmt.Sprintf(`
|
||||
SELECT %s FROM ext_connections
|
||||
WHERE is_active = 1
|
||||
AND (
|
||||
(scope = 'personal' AND owner_id = ?)
|
||||
OR (scope = 'team' AND owner_id IN (
|
||||
SELECT team_id FROM team_members WHERE user_id = ?
|
||||
))
|
||||
OR (scope = 'global')
|
||||
)
|
||||
ORDER BY type ASC, scope ASC, name ASC`, connCols), userID, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
return scanConnections(rows)
|
||||
}
|
||||
|
||||
func (s *ConnectionStore) DeleteByIDAndScope(ctx context.Context, id, scope, ownerID string) (int64, error) {
|
||||
res, err := DB.ExecContext(ctx,
|
||||
`DELETE FROM ext_connections WHERE id = ? AND scope = ? AND owner_id = ?`,
|
||||
|
||||
Reference in New Issue
Block a user