mirror of
https://github.com/mautrix/telegram.git
synced 2026-05-17 07:25:46 +03:00
db/puppet: add contact_info_set flag
Signed-off-by: Sumner Evans <sumner@beeper.com>
This commit is contained in:
@@ -48,6 +48,7 @@ class Puppet:
|
||||
avatar_url: ContentURI | None
|
||||
name_set: bool
|
||||
avatar_set: bool
|
||||
contact_info_set: bool
|
||||
is_bot: bool | None
|
||||
is_channel: bool
|
||||
is_premium: bool
|
||||
@@ -68,7 +69,7 @@ class Puppet:
|
||||
columns: ClassVar[str] = (
|
||||
"id, is_registered, displayname, displayname_source, displayname_contact, "
|
||||
"displayname_quality, disable_updates, username, phone, photo_id, avatar_url, "
|
||||
"name_set, avatar_set, is_bot, is_channel, is_premium, "
|
||||
"name_set, avatar_set, contact_info_set, is_bot, is_channel, is_premium, "
|
||||
"custom_mxid, access_token, next_batch, base_url"
|
||||
)
|
||||
|
||||
@@ -108,6 +109,7 @@ class Puppet:
|
||||
self.avatar_url,
|
||||
self.name_set,
|
||||
self.avatar_set,
|
||||
self.contact_info_set,
|
||||
self.is_bot,
|
||||
self.is_channel,
|
||||
self.is_premium,
|
||||
@@ -122,8 +124,9 @@ class Puppet:
|
||||
UPDATE puppet
|
||||
SET is_registered=$2, displayname=$3, displayname_source=$4, displayname_contact=$5,
|
||||
displayname_quality=$6, disable_updates=$7, username=$8, phone=$9, photo_id=$10,
|
||||
avatar_url=$11, name_set=$12, avatar_set=$13, is_bot=$14, is_channel=$15,
|
||||
is_premium=$16, custom_mxid=$17, access_token=$18, next_batch=$19, base_url=$20
|
||||
avatar_url=$11, name_set=$12, avatar_set=$13, contact_info_set=$14, is_bot=$15,
|
||||
is_channel=$16, is_premium=$17, custom_mxid=$18, access_token=$19, next_batch=$20,
|
||||
base_url=$21
|
||||
WHERE id=$1
|
||||
"""
|
||||
await self.db.execute(q, *self._values)
|
||||
@@ -133,9 +136,9 @@ class Puppet:
|
||||
INSERT INTO puppet (
|
||||
id, is_registered, displayname, displayname_source, displayname_contact,
|
||||
displayname_quality, disable_updates, username, phone, photo_id, avatar_url, name_set,
|
||||
avatar_set, is_bot, is_channel, is_premium, custom_mxid, access_token, next_batch,
|
||||
base_url
|
||||
avatar_set, contact_info_set, is_bot, is_channel, is_premium, custom_mxid,
|
||||
access_token, next_batch, base_url
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18,
|
||||
$19, $20)
|
||||
$19, $20, $21)
|
||||
"""
|
||||
await self.db.execute(q, *self._values)
|
||||
|
||||
@@ -20,4 +20,5 @@ from . import (
|
||||
v15_backfill_anchor_id,
|
||||
v16_backfill_type,
|
||||
v17_message_find_recent,
|
||||
v18_puppet_contact_info_set,
|
||||
)
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
from mautrix.util.async_db import Connection, Scheme
|
||||
|
||||
latest_version = 17
|
||||
latest_version = 18
|
||||
|
||||
|
||||
async def create_latest_tables(conn: Connection, scheme: Scheme) -> int:
|
||||
@@ -113,6 +113,7 @@ async def create_latest_tables(conn: Connection, scheme: Scheme) -> int:
|
||||
avatar_url TEXT,
|
||||
name_set BOOLEAN NOT NULL DEFAULT false,
|
||||
avatar_set BOOLEAN NOT NULL DEFAULT false,
|
||||
contact_info_set BOOLEAN NOT NULL DEFAULT false,
|
||||
is_bot BOOLEAN,
|
||||
is_channel BOOLEAN NOT NULL DEFAULT false,
|
||||
is_premium BOOLEAN NOT NULL DEFAULT false,
|
||||
|
||||
25
mautrix_telegram/db/upgrade/v18_puppet_contact_info_set.py
Normal file
25
mautrix_telegram/db/upgrade/v18_puppet_contact_info_set.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# mautrix-telegram - A Matrix-Telegram puppeting bridge
|
||||
# Copyright (C) 2022 Tulir Asokan
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
from mautrix.util.async_db import Connection
|
||||
|
||||
from . import upgrade_table
|
||||
|
||||
|
||||
@upgrade_table.register(description="Add contact_info_set column to puppet table")
|
||||
async def upgrade_v18(conn: Connection) -> None:
|
||||
await conn.execute(
|
||||
"ALTER TABLE puppet ADD COLUMN contact_info_set BOOLEAN NOT NULL DEFAULT false"
|
||||
)
|
||||
@@ -78,6 +78,7 @@ class Puppet(DBPuppet, BasePuppet):
|
||||
avatar_url: ContentURI | None = None,
|
||||
name_set: bool = False,
|
||||
avatar_set: bool = False,
|
||||
contact_info_set: bool = False,
|
||||
is_bot: bool = False,
|
||||
is_channel: bool = False,
|
||||
is_premium: bool = False,
|
||||
@@ -100,6 +101,7 @@ class Puppet(DBPuppet, BasePuppet):
|
||||
avatar_url=avatar_url,
|
||||
name_set=name_set,
|
||||
avatar_set=avatar_set,
|
||||
contact_info_set=contact_info_set,
|
||||
is_bot=is_bot,
|
||||
is_channel=is_channel,
|
||||
is_premium=is_premium,
|
||||
|
||||
@@ -541,7 +541,7 @@ class User(DBUser, AbstractUser, BaseUser):
|
||||
await self.stop()
|
||||
return None
|
||||
|
||||
async def update_info(self, info: TLUser = None) -> None:
|
||||
async def update_info(self, info: TLUser | None = None) -> None:
|
||||
if not info:
|
||||
info = await self.get_me()
|
||||
if not info:
|
||||
|
||||
Reference in New Issue
Block a user