MCPcopy Index your code
hub / github.com/tinode/chat / pubMsg

Function pubMsg

tn-cli/commands.py:182–206  ·  view source on GitHub ↗
(id, cmd, ignored)

Source from the content-addressed store, hash-verified

180
181# {pub}
182def pubMsg(id, cmd, ignored):
183 if not cmd.topic:
184 cmd.topic = tn_globals.DefaultTopic
185
186 head = {}
187 if cmd.drafty or cmd.image or cmd.attachment:
188 head['mime'] = encode_to_bytes('text/x-drafty')
189
190 # Excplicitly provided 'mime' will override the one assigned above.
191 if cmd.head:
192 for h in cmd.head.split(","):
193 key, val = h.split(":")
194 head[key] = encode_to_bytes(val)
195
196 content = json.loads(cmd.drafty) if cmd.drafty \
197 else inline_image(cmd.image) if cmd.image \
198 else attachment(cmd.attachment) if cmd.attachment \
199 else cmd.content
200
201 if not content:
202 return None
203
204 return pb.ClientMsg(pub=pb.ClientPub(id=str(id), topic=cmd.topic, no_echo=True,
205 head=head, content=encode_to_bytes(content)),
206 extra=pack_extra(cmd))
207
208
209# {get}

Callers

nothing calls this directly

Calls 4

encode_to_bytesFunction · 0.90
inline_imageFunction · 0.90
attachmentFunction · 0.90
pack_extraFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…