复制项目
This commit is contained in:
55
internal/push/offlinepush/offlinepusher.go
Normal file
55
internal/push/offlinepush/offlinepusher.go
Normal file
@@ -0,0 +1,55 @@
|
||||
// Copyright © 2023 OpenIM. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package offlinepush
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"git.imall.cloud/openim/open-im-server-deploy/internal/push/offlinepush/dummy"
|
||||
"git.imall.cloud/openim/open-im-server-deploy/internal/push/offlinepush/fcm"
|
||||
"git.imall.cloud/openim/open-im-server-deploy/internal/push/offlinepush/getui"
|
||||
"git.imall.cloud/openim/open-im-server-deploy/internal/push/offlinepush/jpush"
|
||||
"git.imall.cloud/openim/open-im-server-deploy/internal/push/offlinepush/options"
|
||||
"git.imall.cloud/openim/open-im-server-deploy/pkg/common/config"
|
||||
"git.imall.cloud/openim/open-im-server-deploy/pkg/common/storage/cache"
|
||||
)
|
||||
|
||||
const (
|
||||
geTUI = "getui"
|
||||
firebase = "fcm"
|
||||
jPush = "jpush"
|
||||
)
|
||||
|
||||
// OfflinePusher Offline Pusher.
|
||||
type OfflinePusher interface {
|
||||
Push(ctx context.Context, userIDs []string, title, content string, opts *options.Opts) error
|
||||
}
|
||||
|
||||
func NewOfflinePusher(pushConf *config.Push, cache cache.ThirdCache, fcmConfigPath string) (OfflinePusher, error) {
|
||||
var offlinePusher OfflinePusher
|
||||
pushConf.Enable = strings.ToLower(pushConf.Enable)
|
||||
switch pushConf.Enable {
|
||||
case geTUI:
|
||||
offlinePusher = getui.NewClient(pushConf, cache)
|
||||
case firebase:
|
||||
return fcm.NewClient(pushConf, cache, fcmConfigPath)
|
||||
case jPush:
|
||||
offlinePusher = jpush.NewClient(pushConf)
|
||||
default:
|
||||
offlinePusher = dummy.NewClient()
|
||||
}
|
||||
return offlinePusher, nil
|
||||
}
|
||||
Reference in New Issue
Block a user