正在显示
1 个修改的文件
包含
10 行增加
和
2 行删除
| @@ -8,6 +8,7 @@ import ( | @@ -8,6 +8,7 @@ import ( | ||
| 8 | "openapi/pkg/infrastructure/push/getui" | 8 | "openapi/pkg/infrastructure/push/getui" |
| 9 | "openapi/pkg/infrastructure/repository" | 9 | "openapi/pkg/infrastructure/repository" |
| 10 | "openapi/pkg/infrastructure/utils" | 10 | "openapi/pkg/infrastructure/utils" |
| 11 | + "strings" | ||
| 11 | ) | 12 | ) |
| 12 | 13 | ||
| 13 | //推送信息 | 14 | //推送信息 |
| @@ -105,9 +106,12 @@ func NotificationOriginal(header *protocol.RequestHeader, request *protocol.Push | @@ -105,9 +106,12 @@ func NotificationOriginal(header *protocol.RequestHeader, request *protocol.Push | ||
| 105 | 106 | ||
| 106 | //更新设备信息 | 107 | //更新设备信息 |
| 107 | func UpdateDevice(header *protocol.RequestHeader, request *protocol.UpdateDeviceRequest) (rsp *protocol.UpdateDeviceResponse, err error) { | 108 | func UpdateDevice(header *protocol.RequestHeader, request *protocol.UpdateDeviceRequest) (rsp *protocol.UpdateDeviceResponse, err error) { |
| 108 | - var () | 109 | + var ( |
| 110 | + device *protocol.Device | ||
| 111 | + ) | ||
| 112 | + rsp = &protocol.UpdateDeviceResponse{} | ||
| 109 | rep, _ := repository.NewPushDeviceRepository(nil) | 113 | rep, _ := repository.NewPushDeviceRepository(nil) |
| 110 | - if _, err = rep.FindOne(map[string]interface{}{"uid": request.Muid}); err != nil { | 114 | + if device, err = rep.FindOne(map[string]interface{}{"uid": request.Muid}); err != nil { |
| 111 | if err == protocol.ERR_DB_NOT_FOUND { | 115 | if err == protocol.ERR_DB_NOT_FOUND { |
| 112 | err = nil | 116 | err = nil |
| 113 | rep.Save(request) | 117 | rep.Save(request) |
| @@ -116,6 +120,10 @@ func UpdateDevice(header *protocol.RequestHeader, request *protocol.UpdateDevice | @@ -116,6 +120,10 @@ func UpdateDevice(header *protocol.RequestHeader, request *protocol.UpdateDevice | ||
| 116 | log.Error(err) | 120 | log.Error(err) |
| 117 | return | 121 | return |
| 118 | } | 122 | } |
| 123 | + if device.ClientId == strings.TrimSpace(request.ClientId) && device.DeviceToken == strings.TrimSpace(request.DeviceToken) { | ||
| 124 | + err = protocol.NewSuccessWithMessage("更新成功") | ||
| 125 | + return | ||
| 126 | + } | ||
| 119 | if err = rep.UpdateDevice(request.Muid, request.ClientId, request.DeviceToken); err != nil { | 127 | if err = rep.UpdateDevice(request.Muid, request.ClientId, request.DeviceToken); err != nil { |
| 120 | log.Error(err) | 128 | log.Error(err) |
| 121 | } | 129 | } |
-
请 注册 或 登录 后发表评论