Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/connector/capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (tc *TelegramConnector) GetCapabilities() *bridgev2.NetworkGeneralCapabilit
CreateDM: true,
LookupPhone: true,
LookupUsername: true,
ContactList: true,
ContactList: tc.Config.ContactListEnabled(),
Search: true,
},
GroupCreation: map[string]bridgev2.GroupTypeCapabilities{
Expand Down
9 changes: 9 additions & 0 deletions pkg/connector/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ type TelegramConfig struct {

ProxyConfig ProxyConfig `yaml:"proxy"`

ContactList struct {
Enabled *bool `yaml:"enabled"`
} `yaml:"contact_list"`

Sync struct {
UpdateLimit int `yaml:"update_limit"`
CreateLimit int `yaml:"create_limit"`
Expand Down Expand Up @@ -106,6 +110,10 @@ func (c TelegramConfig) ShouldBridge(participantCount int) bool {
return c.MaxMemberCount < 0 || participantCount <= c.MaxMemberCount
}

func (c TelegramConfig) ContactListEnabled() bool {
return c.ContactList.Enabled == nil || *c.ContactList.Enabled
}

type DisplaynameParams struct {
FullName string
FirstName string
Expand Down Expand Up @@ -174,6 +182,7 @@ func upgradeConfig(helper up.Helper) {
helper.Copy(up.Str|up.Null, "proxy", "address")
helper.Copy(up.Str|up.Null, "proxy", "username")
helper.Copy(up.Str|up.Null, "proxy", "password")
helper.Copy(up.Bool, "contact_list", "enabled")
helper.Copy(up.Int, "sync", "update_limit")
helper.Copy(up.Int, "sync", "create_limit")
helper.Copy(up.Int, "sync", "login_sync_limit")
Expand Down
5 changes: 5 additions & 0 deletions pkg/connector/example-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ proxy:
username:
password:

contact_list:
# Allow clients/provisioning API to fetch Telegram contacts.
# Fetching contacts may create Matrix ghost users for those contacts.
enabled: true

sync:
# Number of most recently active dialogs to check when syncing chats.
# Set to -1 to remove limit.
Expand Down
4 changes: 4 additions & 0 deletions pkg/connector/startchat.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (

"github.com/rs/zerolog"
"go.mau.fi/util/ptr"
"maunium.net/go/mautrix"
"maunium.net/go/mautrix/bridgev2"

"go.mau.fi/mautrix-telegram/pkg/connector/ids"
Expand Down Expand Up @@ -231,6 +232,9 @@ func (tc *TelegramClient) SearchUsers(ctx context.Context, query string) (resp [
}

func (tc *TelegramClient) GetContactList(ctx context.Context) (resp []*bridgev2.ResolveIdentifierResponse, err error) {
if !tc.main.Config.ContactListEnabled() {
return nil, bridgev2.RespError(mautrix.MForbidden.WithMessage("Telegram contact list fetching is disabled"))
}
tc.contactsLock.Lock()
defer tc.contactsLock.Unlock()
var contacts *tg.ContactsContacts
Expand Down