inbox bandaid (#179)

Reviewed-on: https://git.ptzo.gdn/feditools/relay/pulls/179
Co-authored-by: Tyr Mactire <tyr@pettingzoo.co>
Co-committed-by: Tyr Mactire <tyr@pettingzoo.co>
This commit is contained in:
Tyr Mactire 2022-12-31 02:23:59 +00:00 committed by PettingZoo Gitea
parent 52120e9cf8
commit 9e3542beea
No known key found for this signature in database
GPG Key ID: 39788A4390A1372F
5 changed files with 5 additions and 11 deletions

View File

@ -27,10 +27,6 @@ func (c CacheMem) ReadInstanceByDomain(ctx context.Context, domain string) (inst
return c.db.ReadInstanceByDomain(ctx, domain)
}
func (c CacheMem) ReadInstanceByServerHostname(ctx context.Context, serverHostname string) (instance *models.Instance, err db.Error) {
return c.db.ReadInstanceByServerHostname(ctx, serverHostname)
}
func (c CacheMem) ReadInstances(ctx context.Context, ids ...int64) (instances []*models.Instance, err db.Error) {
return c.db.ReadInstances(ctx, ids...)
}

View File

@ -17,8 +17,6 @@ type Instance interface {
ReadInstanceByActorIRI(ctx context.Context, actorIRI string) (instance *models.Instance, err Error)
// ReadInstanceByDomain returns one federated social instance
ReadInstanceByDomain(ctx context.Context, domain string) (instance *models.Instance, err Error)
// ReadInstanceByServerHostname returns one federated social instance
ReadInstanceByServerHostname(ctx context.Context, serverHostname string) (instance *models.Instance, err Error)
// ReadInstances returns a set of requested of federated social instances
ReadInstances(ctx context.Context, ids ...int64) (instances []*models.Instance, err Error)
// ReadInstancesPage returns a page of federated social instances

View File

@ -73,7 +73,7 @@ func (m *Module) inboxPostHandler(w nethttp.ResponseWriter, r *nethttp.Request)
return
}
case fedihelper.TypePerson:
instance, err = m.logic.GetInstanceForServerHostname(r.Context(), actorIRI.Host)
instance, err = m.logic.GetInstanceForDomain(r.Context(), actorIRI.Host)
if err != nil {
if errors.Is(err, db.ErrNoEntries) {
nethttp.Error(w, nethttp.StatusText(nethttp.StatusUnauthorized), nethttp.StatusUnauthorized)

View File

@ -10,7 +10,7 @@ type Instance interface {
EnqueueInstanceInfoUpdates(ctx context.Context) error
GetInstance(ctx context.Context, domain string) (*models.Instance, error)
GetInstanceForActor(ctx context.Context, actorID *url.URL) (*models.Instance, error)
GetInstanceForServerHostname(ctx context.Context, serverHostname string) (*models.Instance, error)
GetInstanceForDomain(ctx context.Context, domain string) (*models.Instance, error)
GetInstanceSelf(ctx context.Context) (*models.Instance, error)
KickInstance(ctx context.Context, instance *models.Instance, account *models.Account, admin bool) error
ReadInstanceByToken(ctx context.Context, t string) (*models.Instance, error)

View File

@ -120,11 +120,11 @@ func (l *Logic) GetInstanceForActor(ctx context.Context, actorID *url.URL) (*mod
return newInstance, nil
}
func (l *Logic) GetInstanceForServerHostname(ctx context.Context, serverHostname string) (*models.Instance, error) {
log := logger.WithField("func", "GetInstanceForServerHostname")
func (l *Logic) GetInstanceForDomain(ctx context.Context, domain string) (*models.Instance, error) {
log := logger.WithField("func", "GetInstanceForDomain")
// try to get instance from db
instance, err := l.db.ReadInstanceByServerHostname(ctx, serverHostname)
instance, err := l.db.ReadInstanceByDomain(ctx, domain)
if err != nil {
if !errors.Is(err, db.ErrNoEntries) {
log.Errorf("db read: %s", err.Error())