🐛 Fix destination loading

This commit is contained in:
2024-12-29 00:03:00 +08:00
parent cd0141f5b1
commit 3a00a06541
4 changed files with 16 additions and 13 deletions

View File

@@ -77,7 +77,7 @@ func OpenAttachmentByRID(rid string, region ...string) (url string, mimetype str
var rawDest []byte
if len(region) > 0 {
if des, ok := destinationsByRegion[region[0]]; ok {
if des, ok := DestinationsByRegion[region[0]]; ok {
for _, boost := range result.Boosts {
if boost.Destination == des.Index {
rawDest = des.Raw
@@ -89,12 +89,12 @@ func OpenAttachmentByRID(rid string, region ...string) (url string, mimetype str
if rawDest == nil {
if len(result.Boosts) > 0 {
randomIdx := rand.IntN(len(result.Boosts))
if des, ok := destinationsByIndex[randomIdx]; ok {
if des, ok := DestinationsByIndex[randomIdx]; ok {
rawDest = des.Raw
json.Unmarshal(rawDest, &dest)
}
} else {
if des, ok := destinationsByIndex[result.Attachment.Destination]; ok {
if des, ok := DestinationsByIndex[result.Attachment.Destination]; ok {
rawDest = des.Raw
json.Unmarshal(rawDest, &dest)
}