maintenance 링크를 잘못 만들던 문제 수정
This commit is contained in:
@ -2,20 +2,18 @@ package core
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"path"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
common "repositories.action2quare.com/ayo/gocommon"
|
||||
"repositories.action2quare.com/ayo/gocommon"
|
||||
"repositories.action2quare.com/ayo/gocommon/logger"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
@ -139,9 +137,9 @@ type serviceDescription struct {
|
||||
ServerApiTokens []primitive.ObjectID `bson:"api_tokens" json:"api_tokens"`
|
||||
Admins []string `bson:"admins" json:"admins"`
|
||||
|
||||
auths *common.AuthCollection
|
||||
auths *gocommon.AuthCollection
|
||||
wl *whitelist
|
||||
mongoClient common.MongoClient
|
||||
mongoClient gocommon.MongoClient
|
||||
sessionTTL time.Duration
|
||||
MaximumNumLinkAccount int64
|
||||
|
||||
@ -238,11 +236,16 @@ func (sh *serviceDescription) prepare(mg *Maingate) error {
|
||||
} else if strings.HasPrefix(div.Maintenance.Notice, "http") {
|
||||
div.Maintenance.link = div.Maintenance.Notice
|
||||
} else {
|
||||
hasher := md5.New()
|
||||
hasher.Write(sh.Id[:])
|
||||
subfolder := hex.EncodeToString(hasher.Sum(nil))[:8]
|
||||
var fd FileDocumentDesc
|
||||
if err := sh.mongoClient.FindOneAs(CollectionFile, bson.M{
|
||||
"key": div.Maintenance.Notice,
|
||||
}, &fd, options.FindOne().SetProjection(bson.M{"link": 1})); err != nil {
|
||||
logger.Println(err)
|
||||
return err
|
||||
}
|
||||
|
||||
div.Maintenance.link = path.Join("static", subfolder, div.Maintenance.Notice)
|
||||
div.Maintenance.link = fd.Link
|
||||
logger.Println("div.Maintenance.link :", fd.Link)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -687,7 +690,7 @@ func (sh *serviceDescription) authorize(w http.ResponseWriter, r *http.Request)
|
||||
|
||||
newsession := primitive.NewObjectID()
|
||||
expired := primitive.NewDateTimeFromTime(time.Now().UTC().Add(sh.sessionTTL))
|
||||
newauth := common.Authinfo{
|
||||
newauth := gocommon.Authinfo{
|
||||
Accid: accid,
|
||||
ServiceCode: sh.ServiceCode,
|
||||
Platform: authtype,
|
||||
|
||||
Reference in New Issue
Block a user