aboutsummaryrefslogtreecommitdiff
path: root/telegram
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2023-08-02 20:53:34 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2023-08-02 20:53:34 +0300
commit3c917c16983c1afdd4a21d8021461585a1e785c9 (patch)
treed7c3fe010d6b8e685e9346c7c1af91057ffb9bf5 /telegram
parent8fc9edd7e70aeca266ab2860198de49bdc2ab585 (diff)
Carbons in group chats
Diffstat (limited to 'telegram')
-rw-r--r--telegram/utils.go18
1 files changed, 8 insertions, 10 deletions
diff --git a/telegram/utils.go b/telegram/utils.go
index cd25c22..a91c6da 100644
--- a/telegram/utils.go
+++ b/telegram/utils.go
@@ -837,12 +837,15 @@ func (c *Client) messageToPrefix(message *client.Message, previewString string,
if err != nil {
log.Errorf("Could not determine if chat is PM: %v", err)
}
+ isCarbonsEnabled := gateway.MessageOutgoingPermission && c.Session.Carbons
+ // with carbons, hide for all messages in PM and only for outgoing in group chats
+ hideSender := isCarbonsEnabled && (message.IsOutgoing || isPM)
var replyStart, replyEnd int
prefix := []string{}
// message direction
var directionChar string
- if !isPM || !gateway.MessageOutgoingPermission || !c.Session.Carbons {
+ if !hideSender {
if c.Session.AsciiArrows {
if message.IsOutgoing {
directionChar = "> "
@@ -861,7 +864,7 @@ func (c *Client) messageToPrefix(message *client.Message, previewString string,
prefix = append(prefix, directionChar+strconv.FormatInt(message.Id, 10))
}
// show sender in group chats
- if !isPM {
+ if !hideSender {
sender := c.formatSender(message)
if sender != "" {
prefix = append(prefix, sender)
@@ -912,17 +915,12 @@ func (c *Client) ensureDownloadFile(file *client.File) *client.File {
// ProcessIncomingMessage transfers a message to XMPP side and marks it as read on Telegram side
func (c *Client) ProcessIncomingMessage(chatId int64, message *client.Message, ignoredResource string) {
- var isPM bool
- var err error
+ var isCarbon bool
+ isOutgoing := message.IsOutgoing
if gateway.MessageOutgoingPermission && c.Session.Carbons {
- isPM, err = c.IsPM(chatId)
- if err != nil {
- log.Errorf("Could not determine if chat is PM: %v", err)
- }
+ isCarbon = isOutgoing
}
- isOutgoing := message.IsOutgoing
- isCarbon := isPM && isOutgoing
jids := c.getCarbonFullJids(isOutgoing, ignoredResource)
if len(jids) == 0 {
log.Info("The only resource is ignored, aborting")