MCPcopy
hub / github.com/tinode/chat / presSubsOffline

Method presSubsOffline

server/pres.go:432–475  ·  view source on GitHub ↗

Publish to topic subscribers's sessions currently offline in the topic, on their 'me' Group and P2P. Case E: topic came online, "on" Case F: topic went offline, "off" Case G: topic updated 'public', "upd", who Case H: topic deleted, "gone" Case K.3: user altered WANT, "acs" to admins Case L.4: Admin

(what string, params *presParams,
	filterSource *presFilters, filterTarget *presFilters, skipSid string, offlineOnly bool)

Source from the content-addressed store, hash-verified

430// Case T: message sent, "msg" to all with 'R'
431// Case W.1: messages hard-deleted, "del" to all with 'R'
432func (t *Topic) presSubsOffline(what string, params *presParams,
433 filterSource *presFilters, filterTarget *presFilters, skipSid string, offlineOnly bool) {
434 var skipTopic string
435 if offlineOnly {
436 skipTopic = t.name
437 }
438
439 for uid, pud := range t.perUser {
440 if pud.deleted || !presOfflineFilter(pud.modeGiven&pud.modeWant, what, filterSource) {
441 continue
442 }
443
444 user := uid.UserId()
445 actor := params.actor
446 target := params.target
447 if actor == user {
448 actor = ""
449 }
450
451 if target == user {
452 target = ""
453 }
454
455 globals.hub.routeSrv <- &ServerComMessage{
456 Pres: &MsgServerPres{
457 Topic: "me",
458 What: what,
459 Src: t.original(uid),
460 Acs: params.packAcs(),
461 AcsActor: actor,
462 AcsTarget: target,
463 SeqId: params.seqID,
464 DelId: params.delID,
465 FilterIn: int(filterTarget.filterIn),
466 FilterOut: int(filterTarget.filterOut),
467 SingleUser: filterTarget.singleUser,
468 ExcludeUser: filterTarget.excludeUser,
469 SkipTopic: skipTopic,
470 },
471 RcptTo: user,
472 SkipSid: skipSid,
473 }
474 }
475}
476
477// Publish {info what=read|recv|kp} to topic subscribers's sessions currently offline in the topic,
478// on subscriber's 'me'. Group and P2P.

Callers 7

handleTopicTimeoutMethod · 0.95
sendSubNotificationsMethod · 0.95
replySetDescMethod · 0.95
replyDelMsgMethod · 0.95
notifySubChangeMethod · 0.95

Calls 4

originalMethod · 0.95
presOfflineFilterFunction · 0.85
UserIdMethod · 0.80
packAcsMethod · 0.80

Tested by

no test coverage detected