mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-12-04 20:52:54 +01:00
chatinfo: make archive and pinned tags configurable
This commit is contained in:
parent
8b6dd4201c
commit
1a48dc16ba
4 changed files with 18 additions and 9 deletions
|
@ -62,7 +62,7 @@ func (wa *WhatsAppClient) getChatInfo(ctx context.Context, portalJID types.JID,
|
|||
}
|
||||
}
|
||||
if conv != nil {
|
||||
applyHistoryInfo(wrapped, conv)
|
||||
wa.applyHistoryInfo(wrapped, conv)
|
||||
}
|
||||
wa.applyChatSettings(ctx, portalJID, wrapped)
|
||||
return wrapped, nil
|
||||
|
@ -96,13 +96,13 @@ func (wa *WhatsAppClient) applyChatSettings(ctx context.Context, chatID types.JI
|
|||
MutedUntil: ptr.Ptr(chat.MutedUntil),
|
||||
}
|
||||
if chat.Pinned {
|
||||
info.UserLocal.Tag = ptr.Ptr(event.RoomTagFavourite)
|
||||
info.UserLocal.Tag = ptr.Ptr(wa.Main.Config.PinnedTag)
|
||||
} else if chat.Archived {
|
||||
info.UserLocal.Tag = ptr.Ptr(event.RoomTagLowPriority)
|
||||
info.UserLocal.Tag = ptr.Ptr(wa.Main.Config.ArchiveTag)
|
||||
}
|
||||
}
|
||||
|
||||
func applyHistoryInfo(info *bridgev2.ChatInfo, conv *wadb.Conversation) {
|
||||
func (wa *WhatsAppClient) applyHistoryInfo(info *bridgev2.ChatInfo, conv *wadb.Conversation) {
|
||||
if conv == nil {
|
||||
return
|
||||
}
|
||||
|
@ -111,9 +111,9 @@ func applyHistoryInfo(info *bridgev2.ChatInfo, conv *wadb.Conversation) {
|
|||
MutedUntil: ptr.Ptr(conv.MuteEndTime),
|
||||
}
|
||||
if ptr.Val(conv.Pinned) {
|
||||
info.UserLocal.Tag = ptr.Ptr(event.RoomTagFavourite)
|
||||
info.UserLocal.Tag = ptr.Ptr(wa.Main.Config.PinnedTag)
|
||||
} else if ptr.Val(conv.Archived) {
|
||||
info.UserLocal.Tag = ptr.Ptr(event.RoomTagLowPriority)
|
||||
info.UserLocal.Tag = ptr.Ptr(wa.Main.Config.ArchiveTag)
|
||||
}
|
||||
if info.Disappear == nil && ptr.Val(conv.EphemeralExpiration) > 0 {
|
||||
info.Disappear = &database.DisappearingSetting{
|
||||
|
|
|
@ -40,6 +40,8 @@ type Config struct {
|
|||
DisableStatusBroadcastSend bool `yaml:"disable_status_broadcast_send"`
|
||||
MuteStatusBroadcast bool `yaml:"mute_status_broadcast"`
|
||||
StatusBroadcastTag event.RoomTag `yaml:"status_broadcast_tag"`
|
||||
PinnedTag event.RoomTag `yaml:"pinned_tag"`
|
||||
ArchiveTag event.RoomTag `yaml:"archive_tag"`
|
||||
WhatsappThumbnail bool `yaml:"whatsapp_thumbnail"`
|
||||
URLPreviews bool `yaml:"url_previews"`
|
||||
ExtEvPolls bool `yaml:"extev_polls"`
|
||||
|
@ -101,7 +103,9 @@ func upgradeConfig(helper up.Helper) {
|
|||
helper.Copy(up.Bool, "enable_status_broadcast")
|
||||
helper.Copy(up.Bool, "disable_status_broadcast_send")
|
||||
helper.Copy(up.Bool, "mute_status_broadcast")
|
||||
helper.Copy(up.Str, "status_broadcast_tag")
|
||||
helper.Copy(up.Str|up.Null, "status_broadcast_tag")
|
||||
helper.Copy(up.Str|up.Null, "pinned_tag")
|
||||
helper.Copy(up.Str|up.Null, "archive_tag")
|
||||
helper.Copy(up.Bool, "whatsapp_thumbnail")
|
||||
helper.Copy(up.Bool, "url_previews")
|
||||
helper.Copy(up.Bool, "extev_polls")
|
||||
|
|
|
@ -35,6 +35,11 @@ disable_status_broadcast_send: true
|
|||
# Should the status broadcast room be muted and moved into low priority by default?
|
||||
# This is only applied when creating the room, the user can unmute it later.
|
||||
mute_status_broadcast: true
|
||||
# Tag to apply to pinned chats on WhatsApp.
|
||||
pinned_tag: m.favourite
|
||||
# Tag to apply to archived chats on WhatsApp.
|
||||
# Set to m.lowpriority to move them to low priority.
|
||||
archive_tag:
|
||||
# Tag to apply to the status broadcast room.
|
||||
status_broadcast_tag: m.lowpriority
|
||||
# Should the bridge use thumbnails from WhatsApp?
|
||||
|
|
|
@ -608,7 +608,7 @@ func (wa *WhatsAppClient) handleWAMute(evt *events.Mute) {
|
|||
func (wa *WhatsAppClient) handleWAArchive(evt *events.Archive) {
|
||||
var tag event.RoomTag
|
||||
if evt.Action.GetArchived() {
|
||||
tag = event.RoomTagLowPriority
|
||||
tag = wa.Main.Config.ArchiveTag
|
||||
}
|
||||
wa.handleWAUserLocalPortalInfo(evt.JID, evt.Timestamp, &bridgev2.UserLocalPortalInfo{
|
||||
Tag: &tag,
|
||||
|
@ -618,7 +618,7 @@ func (wa *WhatsAppClient) handleWAArchive(evt *events.Archive) {
|
|||
func (wa *WhatsAppClient) handleWAPin(evt *events.Pin) {
|
||||
var tag event.RoomTag
|
||||
if evt.Action.GetPinned() {
|
||||
tag = event.RoomTagFavourite
|
||||
tag = wa.Main.Config.PinnedTag
|
||||
}
|
||||
wa.handleWAUserLocalPortalInfo(evt.JID, evt.Timestamp, &bridgev2.UserLocalPortalInfo{
|
||||
Tag: &tag,
|
||||
|
|
Loading…
Reference in a new issue