( // 发送出席消息(比如进入某个房间) ctx context.Context, userID string, presence types.Presence, statusMsg *string, )
| 147 | } |
| 148 | |
| 149 | func (p *SyncAPIProducer) SendPresence( // 发送出席消息(比如进入某个房间) |
| 150 | ctx context.Context, userID string, presence types.Presence, statusMsg *string, |
| 151 | ) error { |
| 152 | m := nats.NewMsg(p.TopicPresenceEvent) |
| 153 | m.Header.Set(jetstream.UserID, userID) |
| 154 | m.Header.Set("presence", presence.String()) |
| 155 | if statusMsg != nil { |
| 156 | m.Header.Set("status_msg", *statusMsg) |
| 157 | } |
| 158 | |
| 159 | m.Header.Set("last_active_ts", strconv.Itoa(int(gomatrixserverlib.AsTimestamp(time.Now())))) |
| 160 | |
| 161 | _, err := p.JetStream.PublishMsg(m, nats.Context(ctx)) |
| 162 | return err |
| 163 | } |
nothing calls this directly
no test coverage detected