mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-28 04:33:32 -06:00
[chore/bugfix] Domain block tidying up, Implement first pass of 207 Multi-Status (#1886)
* [chore/refactor] update domain block processing * expose domain block import errors a lil better * move/remove unused query keys
This commit is contained in:
parent
d9c69f6ce0
commit
e70bf8a6c8
19 changed files with 969 additions and 380 deletions
|
|
@ -42,7 +42,7 @@ func (d *domainDB) CreateDomainBlock(ctx context.Context, block *gtsmodel.Domain
|
|||
return err
|
||||
}
|
||||
|
||||
// Attempt to store domain in DB
|
||||
// Attempt to store domain block in DB
|
||||
if _, err := d.conn.NewInsert().
|
||||
Model(block).
|
||||
Exec(ctx); err != nil {
|
||||
|
|
@ -82,6 +82,33 @@ func (d *domainDB) GetDomainBlock(ctx context.Context, domain string) (*gtsmodel
|
|||
return &block, nil
|
||||
}
|
||||
|
||||
func (d *domainDB) GetDomainBlocks(ctx context.Context) ([]*gtsmodel.DomainBlock, error) {
|
||||
blocks := []*gtsmodel.DomainBlock{}
|
||||
|
||||
if err := d.conn.
|
||||
NewSelect().
|
||||
Model(&blocks).
|
||||
Scan(ctx); err != nil {
|
||||
return nil, d.conn.ProcessError(err)
|
||||
}
|
||||
|
||||
return blocks, nil
|
||||
}
|
||||
|
||||
func (d *domainDB) GetDomainBlockByID(ctx context.Context, id string) (*gtsmodel.DomainBlock, db.Error) {
|
||||
var block gtsmodel.DomainBlock
|
||||
|
||||
q := d.conn.
|
||||
NewSelect().
|
||||
Model(&block).
|
||||
Where("? = ?", bun.Ident("domain_block.id"), id)
|
||||
if err := q.Scan(ctx); err != nil {
|
||||
return nil, d.conn.ProcessError(err)
|
||||
}
|
||||
|
||||
return &block, nil
|
||||
}
|
||||
|
||||
func (d *domainDB) DeleteDomainBlock(ctx context.Context, domain string) db.Error {
|
||||
// Normalize the domain as punycode
|
||||
domain, err := util.Punify(domain)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue