feat: add conversation system action messages
This commit is contained in:
+10
-2
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user