Carbons in group chats

dev
Bohdan Horbeshko 9 months ago
parent 8fc9edd7e7
commit 3c917c1698

@ -15,7 +15,7 @@ import (
goxmpp "gosrc.io/xmpp"
)
var version string = "1.7.2"
var version string = "1.8.0-dev"
var commit string
var sm *goxmpp.StreamManager

@ -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")

Loading…
Cancel
Save