mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-02 23:28:07 -06:00
[performance] Add dereference shortcuts to avoid making http calls to self (#430)
* update transport (controller) to allow shortcuts * go fmt * expose underlying sig transport to allow test sigs
This commit is contained in:
parent
4b4c935e02
commit
e63b653199
7 changed files with 114 additions and 22 deletions
|
|
@ -23,6 +23,8 @@ import (
|
|||
"net/url"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
)
|
||||
|
||||
func (t *transport) BatchDeliver(ctx context.Context, b []byte, recipients []*url.URL) error {
|
||||
|
|
@ -30,6 +32,11 @@ func (t *transport) BatchDeliver(ctx context.Context, b []byte, recipients []*ur
|
|||
}
|
||||
|
||||
func (t *transport) Deliver(ctx context.Context, b []byte, to *url.URL) error {
|
||||
// if the 'to' host is our own, just skip this delivery since we by definition already have the message!
|
||||
if to.Host == viper.GetString(config.Keys.Host) {
|
||||
return nil
|
||||
}
|
||||
|
||||
l := logrus.WithField("func", "Deliver")
|
||||
l.Debugf("performing POST to %s", to.String())
|
||||
return t.sigTransport.Deliver(ctx, b, to)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue