MCPcopy Create free account
hub / github.com/daodst/chat / SendPresence

Method SendPresence

federationapi/producers/syncapi.go:150–165  ·  view source on GitHub ↗
(
	ctx context.Context, userID string, presence types.Presence, statusMsg *string, lastActiveAgo int64,
)

Source from the content-addressed store, hash-verified

148}
149
150func (p *SyncAPIProducer) SendPresence(
151 ctx context.Context, userID string, presence types.Presence, statusMsg *string, lastActiveAgo int64,
152) error {
153 m := nats.NewMsg(p.TopicPresenceEvent)
154 m.Header.Set(jetstream.UserID, userID)
155 m.Header.Set("presence", presence.String())
156 if statusMsg != nil {
157 m.Header.Set("status_msg", *statusMsg)
158 }
159 lastActiveTS := gomatrixserverlib.AsTimestamp(time.Now().Add(-(time.Duration(lastActiveAgo) * time.Millisecond)))
160
161 m.Header.Set("last_active_ts", strconv.Itoa(int(lastActiveTS)))
162 log.Tracef("Sending presence to syncAPI: %+v", m.Header)
163 _, err := p.JetStream.PublishMsg(m, nats.Context(ctx))
164 return err
165}
166
167func (p *SyncAPIProducer) SendDeviceListUpdate(
168 ctx context.Context, deviceListUpdate *gomatrixserverlib.DeviceListUpdateEvent,

Callers

nothing calls this directly

Calls 5

AddMethod · 0.80
PublishMsgMethod · 0.80
ContextMethod · 0.80
SetMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected