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

Method set

server/session.go:1143–1192  ·  view source on GitHub ↗
(msg *ClientComMessage)

Source from the content-addressed store, hash-verified

1141}
1142
1143func (s *Session) set(msg *ClientComMessage) {
1144 // Expand topic name.
1145 var resp *ServerComMessage
1146 msg.RcptTo, resp = s.expandTopicName(msg)
1147 if resp != nil {
1148 s.queueOut(resp)
1149 return
1150 }
1151
1152 if msg.Set.Desc != nil {
1153 msg.MetaWhat = constMsgMetaDesc
1154 }
1155 if msg.Set.Sub != nil {
1156 msg.MetaWhat |= constMsgMetaSub
1157 }
1158 if msg.Set.Tags != nil {
1159 msg.MetaWhat |= constMsgMetaTags
1160 }
1161 if msg.Set.Cred != nil {
1162 msg.MetaWhat |= constMsgMetaCred
1163 }
1164 if msg.Set.Aux != nil {
1165 msg.MetaWhat |= constMsgMetaAux
1166 }
1167
1168 if msg.MetaWhat == 0 {
1169 s.queueOut(ErrMalformedReply(msg, msg.Timestamp))
1170 logs.Warn.Println("s.set: nil Set action")
1171 } else if sub := s.getSub(msg.RcptTo); sub != nil {
1172 select {
1173 case sub.meta <- msg:
1174 default:
1175 // Reply with a 503 to the user.
1176 s.queueOut(ErrServiceUnavailableReply(msg, msg.Timestamp))
1177 logs.Err.Println("s.set: sub.meta channel full, topic ", msg.RcptTo, s.sid)
1178 }
1179 } else if msg.MetaWhat&(constMsgMetaTags|constMsgMetaCred|constMsgMetaAux) != 0 {
1180 logs.Warn.Println("s.set: setting tags/creds/aux is allowed for subscribed topics only", msg.MetaWhat)
1181 s.queueOut(ErrPermissionDeniedReply(msg, msg.Timestamp))
1182 } else {
1183 // Desc.Private and Sub updates are possible without the subscription.
1184 select {
1185 case globals.hub.meta <- msg:
1186 default:
1187 // Reply with a 503 to the user.
1188 s.queueOut(ErrServiceUnavailableReply(msg, msg.Timestamp))
1189 logs.Err.Println("s.set: hub.meta channel full", s.sid)
1190 }
1191 }
1192}
1193
1194func (s *Session) del(msg *ClientComMessage) {
1195 msg.MetaWhat = parseMsgClientDel(msg.Del.What)

Callers

nothing calls this directly

Calls 7

expandTopicNameMethod · 0.95
queueOutMethod · 0.95
getSubMethod · 0.95
ErrMalformedReplyFunction · 0.85
ErrPermissionDeniedReplyFunction · 0.85
PrintlnMethod · 0.80

Tested by

no test coverage detected