Add shared inbox support for ActivityPub delivery (#4755)
* feat(ap): add support for shared inboxes to reduce outbound load * feat(db): refactor ap followers db into followers repository * fix(ap): use the updated activity library to pull out the shared inbox endpoint * chore(deps): point at updated build of owncast/activity * fix(ap): typeless endpoints * feat(test): update ActivityPub test to support shared inboxes * chore(test): remove unused variable * fix: feedback from review. Guard against SSRF/non-HTTPS/local and handle transaction errors
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"math/rand"
|
||||
"net/url"
|
||||
"os"
|
||||
@@ -422,6 +423,17 @@ func IntPercentage(x, total int) int {
|
||||
return int(float64(x) / float64(total) * 100)
|
||||
}
|
||||
|
||||
// SafeIntToInt32 safely converts an int to int32, clamping to int32 bounds.
|
||||
func SafeIntToInt32(n int) int32 {
|
||||
if n > math.MaxInt32 {
|
||||
return math.MaxInt32
|
||||
}
|
||||
if n < math.MinInt32 {
|
||||
return math.MinInt32
|
||||
}
|
||||
return int32(n)
|
||||
}
|
||||
|
||||
// DecodeBase64Image decodes a base64 image string into a byte array, returning the extension (including dot) for the content type.
|
||||
func DecodeBase64Image(url string) (bytes []byte, extension string, err error) {
|
||||
s := strings.SplitN(url, ",", 2)
|
||||
|
||||
Reference in New Issue
Block a user