feat: add conversation system action messages

This commit is contained in:
richjohnrambo
2026-09-01 13:12:24 +08:00
parent 39e7e019c7
commit edced2675b
8 changed files with 213 additions and 41 deletions
+10 -2
View File
@@ -1060,8 +1060,7 @@ func (t *Topic) saveAndBroadcastMessage(msg *ClientComMessage, asUid types.Uid,
if msg.sess != nil && msg.sess.authLvl != auth.LevelRoot {
legacyType, _ := head["type"].(string)
productType, _ := head["x-im-type"].(string)
if legacyType == "system" || legacyType == "system_event" ||
productType == "system" || productType == "system_event" {
if isSystemGeneratedMessageType(legacyType) || isSystemGeneratedMessageType(productType) {
msg.sess.queueOut(ErrPermissionDenied(msg.Id, t.original(asUid), msg.Timestamp))
return types.ErrPermissionDenied
}
@@ -1190,6 +1189,15 @@ func (t *Topic) saveAndBroadcastMessage(msg *ClientComMessage, asUid types.Uid,
return nil
}
func isSystemGeneratedMessageType(value string) bool {
switch strings.TrimSpace(value) {
case "system", "system_notice", "system_action", "system_event":
return true
default:
return false
}
}
// handlePubBroadcast fans out {pub} -> {data} messages to recipients in a master topic.
// This is a NON-proxy broadcast.
func (t *Topic) handlePubBroadcast(msg *ClientComMessage) {