|
@@ -22,9 +22,9 @@ type Client struct {
|
|
UnderlyingConn *websocket.Conn
|
|
UnderlyingConn *websocket.Conn
|
|
online *models.Online
|
|
online *models.Online
|
|
|
|
|
|
- isRemotely bool // isRemotely 是否是远程连接
|
|
|
|
- isSimpleMsg bool // isSimpleMsg 是否是简单消息
|
|
|
|
- localization string // localization 国际码
|
|
|
|
|
|
+ isSimpleMsg bool // isSimpleMsg 是否是简单消息
|
|
|
|
+ localization string // localization 国际码
|
|
|
|
+ firebaseToken string // firebaseToken FCM 推送的 token
|
|
|
|
|
|
// Send message channel 发送消息
|
|
// Send message channel 发送消息
|
|
// 当用户在线时会通过 Send channel 发送在线消息 但如果用户不在线,
|
|
// 当用户在线时会通过 Send channel 发送在线消息 但如果用户不在线,
|
|
@@ -81,7 +81,18 @@ func (c *Client) reader() {
|
|
messaging.Content = chatingContent
|
|
messaging.Content = chatingContent
|
|
zlog.Info("Send message to ", id)
|
|
zlog.Info("Send message to ", id)
|
|
|
|
|
|
- c.hub.Message <- &messaging
|
|
|
|
|
|
+ // Check if the user is online
|
|
|
|
+ if c.firebaseToken != "" {
|
|
|
|
+ var online bool
|
|
|
|
+ if online, err = c.repos.OnlineRepository.Is(c.ctx, id); err != nil {
|
|
|
|
+ zlog.Error(eris.Wrap(err, "unable to find online user"))
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if online {
|
|
|
|
+ c.hub.Message <- &messaging
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
// Reply message id
|
|
// Reply message id
|