계정 제재 동작 오류 수정
This commit is contained in:
22
core/api.go
22
core/api.go
@ -165,13 +165,27 @@ func (caller apiCaller) blockAPI(w http.ResponseWriter, r *http.Request) error {
|
||||
enc.Encode(mg.bl.all())
|
||||
} else if r.Method == "PUT" {
|
||||
body, _ := io.ReadAll(r.Body)
|
||||
var bi blockinfo
|
||||
if err := json.Unmarshal(body, &bi); err != nil {
|
||||
|
||||
var bipl blockinfoWithStringId
|
||||
if err := json.Unmarshal(body, &bipl); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, _, err := mg.mongoClient.Update(CollectionBlock, bson.M{
|
||||
"_id": primitive.NewObjectID(),
|
||||
accid, err := primitive.ObjectIDFromHex(bipl.StrId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
bi := blockinfo{
|
||||
Start: primitive.NewDateTimeFromTime(time.Unix(bipl.StartUnix, 0)),
|
||||
End: primitive.NewDateTimeFromTime(time.Unix(bipl.EndUnix, 0)),
|
||||
Reason: bipl.Reason,
|
||||
}
|
||||
|
||||
logger.Println("bi :", accid, bi)
|
||||
|
||||
_, _, err = mg.mongoClient.Update(CollectionBlock, bson.M{
|
||||
"_id": accid,
|
||||
}, bson.M{
|
||||
"$set": &bi,
|
||||
}, options.Update().SetUpsert(true))
|
||||
|
||||
Reference in New Issue
Block a user