Add reject button + email on trust center access request

Signed-off-by: Émile Ré <nemile.re@gmail.com>
This commit is contained in:
Émile Ré
2025-12-05 20:40:42 +04:00
parent 306675cd07
commit c8471cd48d
14 changed files with 3963 additions and 58 deletions

View File

@@ -16,6 +16,7 @@ package coredata
import (
"context"
"errors"
"fmt"
"maps"
"time"
@@ -77,6 +78,10 @@ LIMIT 1;
report, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[Report])
if err != nil {
if errors.Is(err, pgx.ErrNoRows) {
return &ErrDocumentNotFound{Identifier: reportID.String()}
}
return fmt.Errorf("cannot collect report: %w", err)
}
@@ -85,6 +90,50 @@ LIMIT 1;
return nil
}
func (r *Reports) LoadByIDs(
ctx context.Context,
conn pg.Conn,
scope Scoper,
reportIDs []gid.GID,
) error {
q := `
SELECT
id,
organization_id,
object_key,
mime_type,
filename,
size,
created_at,
updated_at
FROM
reports
WHERE
%s
AND id IN (SELECT id FROM UNNEST(@report_ids::text[]) AS t(id))
LIMIT 1;
`
q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{"report_ids": reportIDs}
maps.Copy(args, scope.SQLArguments())
rows, err := conn.Query(ctx, q, args)
if err != nil {
return fmt.Errorf("cannot query report: %w", err)
}
reports, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[Report])
if err != nil {
return fmt.Errorf("cannot collect reports: %w", err)
}
*r = reports
return nil
}
func (r *Report) Insert(
ctx context.Context,
conn pg.Conn,