diff --git a/modules/activitypub/client.go b/modules/activitypub/client.go index bbc0d3de21..c23f3b18f7 100644 --- a/modules/activitypub/client.go +++ b/modules/activitypub/client.go @@ -54,6 +54,15 @@ type Client struct { pubID string } +var algos []httpsig.Algorithm + +func init() { + algos = make([]httpsig.Algorithm, len(setting.Federation.Algorithms)) + for i, algo := range setting.Federation.Algorithms { + algos[i] = httpsig.Algorithm(algo) + } +} + // NewClient function func NewClient(user *user_model.User, pubID string) (c *Client, err error) { if err = containsRequiredHTTPHeaders(http.MethodGet, setting.Federation.GetHeaders); err != nil { @@ -61,10 +70,6 @@ func NewClient(user *user_model.User, pubID string) (c *Client, err error) { } else if err = containsRequiredHTTPHeaders(http.MethodPost, setting.Federation.PostHeaders); err != nil { return } - algos := make([]httpsig.Algorithm, len(setting.Federation.Algorithms)) - for i, algo := range setting.Federation.Algorithms { - algos[i] = httpsig.Algorithm(algo) - } priv, err := GetPrivateKey(user) if err != nil {