修复邮件详情序列化遗漏黑名单及已读标记
This commit is contained in:
parent
f18c21d7ef
commit
0572bd3ac7
@ -1,6 +1,10 @@
|
||||
package response
|
||||
|
||||
import "git.pcux.cn/xuans/Smail/models"
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"git.pcux.cn/xuans/Smail/models"
|
||||
)
|
||||
|
||||
type EmailResponseData struct {
|
||||
models.Email `xorm:"extends"`
|
||||
@ -12,6 +16,30 @@ type EmailResponseData struct {
|
||||
IsBlacklisted bool `xorm:"-" json:"is_blacklisted"`
|
||||
}
|
||||
|
||||
func (d *EmailResponseData) MarshalJSON() ([]byte, error) {
|
||||
data, err := d.Email.MarshalJSON()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var fields map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &fields); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for name, value := range map[string]any{
|
||||
"is_read": d.IsRead,
|
||||
"serial_number": d.SerialNumber,
|
||||
"ue_id": d.UeId,
|
||||
"is_blacklisted": d.IsBlacklisted,
|
||||
} {
|
||||
encoded, err := json.Marshal(value)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fields[name] = encoded
|
||||
}
|
||||
return json.Marshal(fields)
|
||||
}
|
||||
|
||||
type UserEmailUIDData struct {
|
||||
models.UserEmail `xorm:"extends"`
|
||||
SerialNumber int `json:"serial_number"`
|
||||
|
||||
Loading…
Reference in New Issue
Block a user