...
|
...
|
@@ -13,14 +13,13 @@ import ( |
|
|
//推送信息
|
|
|
func Notification(header *protocol.RequestHeader, request *protocol.PushInfoRequest) (rsp *protocol.PushInfoResponse, err error) {
|
|
|
var (
|
|
|
repApp, _ = repository.NewAppInfoRepository(nil)
|
|
|
repDevice, _ = repository.NewPushDeviceRepository(nil)
|
|
|
repProject, _ = repository.NewProjectRepository()
|
|
|
appInfo *protocol.AppInfo
|
|
|
project *protocol.Project
|
|
|
receivers []string
|
|
|
receiverIds []int64
|
|
|
deviceList []*protocol.Device
|
|
|
repApp, _ = repository.NewAppInfoRepository(nil)
|
|
|
repDevice, _ = repository.NewPushDeviceRepository(nil)
|
|
|
repProject, _ = repository.NewProjectRepository()
|
|
|
appInfo *protocol.AppInfo
|
|
|
project *protocol.Project
|
|
|
receiverIds []int64
|
|
|
|
|
|
requestOriginal *protocol.PushInfoOriginalRequest = &protocol.PushInfoOriginalRequest{
|
|
|
Type: request.Type,
|
|
|
Title: request.Title,
|
...
|
...
|
@@ -33,6 +32,8 @@ func Notification(header *protocol.RequestHeader, request *protocol.PushInfoRequ |
|
|
projectKeys = request.ProjectKeys
|
|
|
}
|
|
|
for i := 0; i < len(projectKeys); i++ {
|
|
|
var receivers []string
|
|
|
var deviceList []*protocol.Device
|
|
|
projectKey := projectKeys[i]
|
|
|
rsp = &protocol.PushInfoResponse{}
|
|
|
if project, err = repProject.FindOne(map[string]interface{}{"project_slave_key": projectKey}); err != nil {
|
...
|
...
|
@@ -58,7 +59,13 @@ func Notification(header *protocol.RequestHeader, request *protocol.PushInfoRequ |
|
|
requestOriginal.Ext["intent"] = extInfo.Intent
|
|
|
}
|
|
|
if len(extInfo.Sound) > 0 {
|
|
|
requestOriginal.Ext["sound"] = extInfo.Sound
|
|
|
requestOriginal.SetExt(push.Sound, extInfo.Sound, false)
|
|
|
}
|
|
|
if len(extInfo.HWSound) > 0 {
|
|
|
requestOriginal.SetExt(push.SoundHW, extInfo.HWSound, false)
|
|
|
}
|
|
|
if len(extInfo.XMSound) > 0 {
|
|
|
requestOriginal.SetExt(push.SoundXM, extInfo.XMSound, false)
|
|
|
}
|
|
|
}
|
|
|
if len(deviceList) == 0 {
|
...
|
...
|
@@ -142,16 +149,23 @@ func NotificationOriginal(header *protocol.RequestHeader, request *protocol.Push |
|
|
//更新设备信息
|
|
|
func UpdateDevice(header *protocol.RequestHeader, request *protocol.UpdateDeviceRequest) (rsp *protocol.UpdateDeviceResponse, err error) {
|
|
|
var (
|
|
|
//device *protocol.Device
|
|
|
//device *protocol.Device
|
|
|
project *protocol.Project
|
|
|
repProject, _ = repository.NewProjectRepository()
|
|
|
rep, _ = repository.NewPushDeviceRepository(nil)
|
|
|
)
|
|
|
rsp = &protocol.UpdateDeviceResponse{}
|
|
|
rep, _ := repository.NewPushDeviceRepository(nil)
|
|
|
|
|
|
if project, err = repProject.FindOne(map[string]interface{}{"project_master_key": request.ProjectMasterKey}); err != nil {
|
|
|
log.Error(err)
|
|
|
err = protocol.NewCustomMessage(1, fmt.Sprintf("project_key:%v not found", request.ProjectMasterKey))
|
|
|
return
|
|
|
}
|
|
|
if _, err = rep.FindOne(map[string]interface{}{
|
|
|
"uid": request.Muid,
|
|
|
"project_master_key": request.ProjectKey,
|
|
|
"project_master_key": request.ProjectMasterKey,
|
|
|
}); err != nil {
|
|
|
if err == protocol.ERR_DB_NOT_FOUND {
|
|
|
request.Project = project.Project
|
|
|
err = rep.Save(request)
|
|
|
if err != nil {
|
|
|
log.Error(err)
|
...
|
...
|
@@ -161,7 +175,7 @@ func UpdateDevice(header *protocol.RequestHeader, request *protocol.UpdateDevice |
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
if err = rep.UpdateDevice(request.Muid, request.ClientId, request.DeviceToken, request.ProjectKey, request.Phone); err != nil {
|
|
|
if err = rep.UpdateDevice(request.Muid, request.ClientId, request.DeviceToken, request.ProjectMasterKey, request.Phone, request.Project); err != nil {
|
|
|
log.Error(err)
|
|
|
}
|
|
|
err = protocol.NewSuccessWithMessage("更新成功")
|
...
|
...
|
|