slidge 0.2.11__py3-none-any.whl → 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- slidge/__init__.py +5 -2
- slidge/command/adhoc.py +9 -3
- slidge/command/admin.py +16 -12
- slidge/command/base.py +16 -12
- slidge/command/chat_command.py +25 -16
- slidge/command/user.py +7 -8
- slidge/contact/contact.py +123 -210
- slidge/contact/roster.py +108 -105
- slidge/core/config.py +2 -43
- slidge/core/dispatcher/caps.py +9 -2
- slidge/core/dispatcher/disco.py +13 -3
- slidge/core/dispatcher/message/__init__.py +1 -1
- slidge/core/dispatcher/message/chat_state.py +17 -8
- slidge/core/dispatcher/message/marker.py +7 -5
- slidge/core/dispatcher/message/message.py +120 -93
- slidge/core/dispatcher/muc/__init__.py +1 -1
- slidge/core/dispatcher/muc/admin.py +4 -4
- slidge/core/dispatcher/muc/mam.py +10 -6
- slidge/core/dispatcher/muc/misc.py +4 -2
- slidge/core/dispatcher/muc/owner.py +5 -3
- slidge/core/dispatcher/muc/ping.py +3 -1
- slidge/core/dispatcher/presence.py +26 -15
- slidge/core/dispatcher/registration.py +20 -12
- slidge/core/dispatcher/search.py +7 -3
- slidge/core/dispatcher/session_dispatcher.py +13 -5
- slidge/core/dispatcher/util.py +37 -27
- slidge/core/dispatcher/vcard.py +7 -4
- slidge/core/gateway.py +177 -87
- slidge/core/mixins/__init__.py +1 -11
- slidge/core/mixins/attachment.py +200 -147
- slidge/core/mixins/avatar.py +105 -177
- slidge/core/mixins/base.py +3 -1
- slidge/core/mixins/db.py +50 -2
- slidge/core/mixins/disco.py +1 -1
- slidge/core/mixins/message.py +19 -17
- slidge/core/mixins/message_maker.py +29 -15
- slidge/core/mixins/message_text.py +67 -30
- slidge/core/mixins/presence.py +94 -37
- slidge/core/pubsub.py +42 -47
- slidge/core/session.py +95 -60
- slidge/db/alembic/versions/cef02a8b1451_initial_schema.py +361 -0
- slidge/db/avatar.py +150 -119
- slidge/db/meta.py +33 -22
- slidge/db/models.py +69 -117
- slidge/db/store.py +414 -1094
- slidge/group/archive.py +65 -55
- slidge/group/bookmarks.py +96 -59
- slidge/group/participant.py +150 -144
- slidge/group/room.py +351 -328
- slidge/main.py +34 -22
- slidge/migration.py +17 -29
- slidge/slixfix/__init__.py +20 -4
- slidge/slixfix/delivery_receipt.py +6 -4
- slidge/slixfix/link_preview/link_preview.py +1 -1
- slidge/slixfix/link_preview/stanza.py +1 -1
- slidge/slixfix/roster.py +5 -7
- slidge/slixfix/xep_0077/register.py +8 -8
- slidge/slixfix/xep_0077/stanza.py +7 -7
- slidge/slixfix/xep_0100/gateway.py +12 -13
- slidge/slixfix/xep_0153/vcard_avatar.py +1 -1
- slidge/slixfix/xep_0292/vcard4.py +12 -2
- slidge/util/archive_msg.py +11 -5
- slidge/util/conf.py +27 -21
- slidge/util/jid_escaping.py +1 -1
- slidge/{core/mixins → util}/lock.py +6 -6
- slidge/util/test.py +30 -29
- slidge/util/types.py +24 -18
- slidge/util/util.py +26 -22
- {slidge-0.2.11.dist-info → slidge-0.3.0.dist-info}/METADATA +1 -1
- slidge-0.3.0.dist-info/RECORD +95 -0
- {slidge-0.2.11.dist-info → slidge-0.3.0.dist-info}/WHEEL +1 -1
- slidge/db/alembic/versions/04cf35e3cf85_add_participant_nickname_no_illegal.py +0 -33
- slidge/db/alembic/versions/09f27f098baa_add_missing_attributes_in_room.py +0 -36
- slidge/db/alembic/versions/15b0bd83407a_remove_bogus_unique_constraints_on_room_.py +0 -85
- slidge/db/alembic/versions/2461390c0af2_store_contacts_caps_verstring_in_db.py +0 -36
- slidge/db/alembic/versions/29f5280c61aa_store_subject_setter_in_room.py +0 -37
- slidge/db/alembic/versions/2b1f45ab7379_store_room_subject_setter_by_nickname.py +0 -41
- slidge/db/alembic/versions/3071e0fa69d4_add_contact_client_type.py +0 -52
- slidge/db/alembic/versions/45c24cc73c91_add_bob.py +0 -42
- slidge/db/alembic/versions/5bd48bfdffa2_lift_room_legacy_id_constraint.py +0 -61
- slidge/db/alembic/versions/82a4af84b679_add_muc_history_filled.py +0 -48
- slidge/db/alembic/versions/8b993243a536_add_vcard_content_to_contact_table.py +0 -43
- slidge/db/alembic/versions/8d2ced764698_rely_on_db_to_store_contacts_rooms_and_.py +0 -139
- slidge/db/alembic/versions/aa9d82a7f6ef_db_creation.py +0 -50
- slidge/db/alembic/versions/abba1ae0edb3_store_avatar_legacy_id_in_the_contact_.py +0 -79
- slidge/db/alembic/versions/b33993e87db3_move_everything_to_persistent_db.py +0 -214
- slidge/db/alembic/versions/b64b1a793483_add_source_and_legacy_id_for_archived_.py +0 -52
- slidge/db/alembic/versions/c4a8ec35a0e8_per_room_user_nick.py +0 -34
- slidge/db/alembic/versions/e91195719c2c_store_users_avatars_persistently.py +0 -26
- slidge-0.2.11.dist-info/RECORD +0 -112
- {slidge-0.2.11.dist-info → slidge-0.3.0.dist-info}/entry_points.txt +0 -0
- {slidge-0.2.11.dist-info → slidge-0.3.0.dist-info}/licenses/LICENSE +0 -0
- {slidge-0.2.11.dist-info → slidge-0.3.0.dist-info}/top_level.txt +0 -0
@@ -1,139 +0,0 @@
|
|
1
|
-
"""Rely on DB to store contacts, rooms and participants
|
2
|
-
|
3
|
-
Revision ID: 8d2ced764698
|
4
|
-
Revises: b33993e87db3
|
5
|
-
Create Date: 2024-07-08 14:39:47.022088
|
6
|
-
|
7
|
-
"""
|
8
|
-
|
9
|
-
from typing import Sequence, Union
|
10
|
-
|
11
|
-
import sqlalchemy as sa
|
12
|
-
from alembic import op
|
13
|
-
|
14
|
-
import slidge.db.meta
|
15
|
-
|
16
|
-
# revision identifiers, used by Alembic.
|
17
|
-
revision: str = "8d2ced764698"
|
18
|
-
down_revision: Union[str, None] = "b33993e87db3"
|
19
|
-
branch_labels: Union[str, Sequence[str], None] = None
|
20
|
-
depends_on: Union[str, Sequence[str], None] = None
|
21
|
-
|
22
|
-
|
23
|
-
def upgrade() -> None:
|
24
|
-
op.create_table(
|
25
|
-
"hat",
|
26
|
-
sa.Column("id", sa.Integer(), nullable=False),
|
27
|
-
sa.Column("title", sa.String(), nullable=False),
|
28
|
-
sa.Column("uri", sa.String(), nullable=False),
|
29
|
-
sa.PrimaryKeyConstraint("id"),
|
30
|
-
sa.UniqueConstraint("title", "uri"),
|
31
|
-
)
|
32
|
-
op.create_table(
|
33
|
-
"contact_sent",
|
34
|
-
sa.Column("id", sa.Integer(), nullable=False),
|
35
|
-
sa.Column("contact_id", sa.Integer(), nullable=False),
|
36
|
-
sa.Column("msg_id", sa.String(), nullable=False),
|
37
|
-
sa.ForeignKeyConstraint(
|
38
|
-
["contact_id"],
|
39
|
-
["contact.id"],
|
40
|
-
),
|
41
|
-
sa.PrimaryKeyConstraint("id"),
|
42
|
-
sa.UniqueConstraint("contact_id", "msg_id"),
|
43
|
-
)
|
44
|
-
op.create_table(
|
45
|
-
"participant",
|
46
|
-
sa.Column("id", sa.Integer(), nullable=False),
|
47
|
-
sa.Column("room_id", sa.Integer(), nullable=False),
|
48
|
-
sa.Column("contact_id", sa.Integer(), nullable=True),
|
49
|
-
sa.Column("is_user", sa.Boolean(), nullable=False),
|
50
|
-
sa.Column(
|
51
|
-
"affiliation",
|
52
|
-
sa.Enum("outcast", "member", "admin", "owner", "none", native_enum=False),
|
53
|
-
nullable=False,
|
54
|
-
),
|
55
|
-
sa.Column(
|
56
|
-
"role",
|
57
|
-
sa.Enum("moderator", "participant", "visitor", "none", native_enum=False),
|
58
|
-
nullable=False,
|
59
|
-
),
|
60
|
-
sa.Column("presence_sent", sa.Boolean(), nullable=False),
|
61
|
-
sa.Column("resource", sa.String(), nullable=True),
|
62
|
-
sa.Column("nickname", sa.String(), nullable=True),
|
63
|
-
sa.Column("extra_attributes", slidge.db.meta.JSONEncodedDict(), nullable=True),
|
64
|
-
sa.ForeignKeyConstraint(
|
65
|
-
["contact_id"],
|
66
|
-
["contact.id"],
|
67
|
-
),
|
68
|
-
sa.ForeignKeyConstraint(
|
69
|
-
["room_id"],
|
70
|
-
["room.id"],
|
71
|
-
),
|
72
|
-
sa.PrimaryKeyConstraint("id"),
|
73
|
-
)
|
74
|
-
op.create_table(
|
75
|
-
"participant_hats",
|
76
|
-
sa.Column("participant_id", sa.Integer(), nullable=False),
|
77
|
-
sa.Column("hat_id", sa.Integer(), nullable=False),
|
78
|
-
sa.ForeignKeyConstraint(
|
79
|
-
["hat_id"],
|
80
|
-
["hat.id"],
|
81
|
-
),
|
82
|
-
sa.ForeignKeyConstraint(
|
83
|
-
["participant_id"],
|
84
|
-
["participant.id"],
|
85
|
-
),
|
86
|
-
sa.PrimaryKeyConstraint("participant_id", "hat_id"),
|
87
|
-
)
|
88
|
-
op.add_column("contact", sa.Column("is_friend", sa.Boolean(), nullable=False))
|
89
|
-
op.add_column("contact", sa.Column("added_to_roster", sa.Boolean(), nullable=False))
|
90
|
-
op.add_column(
|
91
|
-
"contact",
|
92
|
-
sa.Column("extra_attributes", slidge.db.meta.JSONEncodedDict(), nullable=True),
|
93
|
-
)
|
94
|
-
op.add_column("contact", sa.Column("updated", sa.Boolean(), nullable=False))
|
95
|
-
op.add_column("room", sa.Column("description", sa.String(), nullable=True))
|
96
|
-
op.add_column("room", sa.Column("subject", sa.String(), nullable=True))
|
97
|
-
op.add_column("room", sa.Column("subject_date", sa.DateTime(), nullable=True))
|
98
|
-
|
99
|
-
if op.get_bind().engine.name == "postgresql":
|
100
|
-
op.execute(
|
101
|
-
"CREATE TYPE muctype AS ENUM ('GROUP', 'CHANNEL', 'CHANNEL_NON_ANONYMOUS')"
|
102
|
-
)
|
103
|
-
|
104
|
-
op.add_column(
|
105
|
-
"room",
|
106
|
-
sa.Column(
|
107
|
-
"muc_type",
|
108
|
-
sa.Enum("GROUP", "CHANNEL", "CHANNEL_NON_ANONYMOUS", name="muctype"),
|
109
|
-
nullable=True,
|
110
|
-
),
|
111
|
-
)
|
112
|
-
op.add_column("room", sa.Column("user_resources", sa.String(), nullable=True))
|
113
|
-
op.add_column(
|
114
|
-
"room", sa.Column("participants_filled", sa.Boolean(), nullable=False)
|
115
|
-
)
|
116
|
-
op.add_column(
|
117
|
-
"room",
|
118
|
-
sa.Column("extra_attributes", slidge.db.meta.JSONEncodedDict(), nullable=True),
|
119
|
-
)
|
120
|
-
op.add_column("room", sa.Column("updated", sa.Boolean(), nullable=False))
|
121
|
-
|
122
|
-
|
123
|
-
def downgrade() -> None:
|
124
|
-
op.drop_column("room", "updated")
|
125
|
-
op.drop_column("room", "extra_attributes")
|
126
|
-
op.drop_column("room", "participants_filled")
|
127
|
-
op.drop_column("room", "user_resources")
|
128
|
-
op.drop_column("room", "muc_type")
|
129
|
-
op.drop_column("room", "subject_date")
|
130
|
-
op.drop_column("room", "subject")
|
131
|
-
op.drop_column("room", "description")
|
132
|
-
op.drop_column("contact", "updated")
|
133
|
-
op.drop_column("contact", "extra_attributes")
|
134
|
-
op.drop_column("contact", "added_to_roster")
|
135
|
-
op.drop_column("contact", "is_friend")
|
136
|
-
op.drop_table("participant_hats")
|
137
|
-
op.drop_table("participant")
|
138
|
-
op.drop_table("contact_sent")
|
139
|
-
op.drop_table("hat")
|
@@ -1,50 +0,0 @@
|
|
1
|
-
"""DB Creation
|
2
|
-
|
3
|
-
Including a migration from the user_store shelf
|
4
|
-
|
5
|
-
Revision ID: aa9d82a7f6ef
|
6
|
-
Revises:
|
7
|
-
Create Date: 2024-04-17 20:57:01.357041
|
8
|
-
|
9
|
-
"""
|
10
|
-
|
11
|
-
from typing import Sequence, Union
|
12
|
-
|
13
|
-
import sqlalchemy as sa
|
14
|
-
from alembic import op
|
15
|
-
|
16
|
-
import slidge.db.meta
|
17
|
-
|
18
|
-
# revision identifiers, used by Alembic.
|
19
|
-
revision: str = "aa9d82a7f6ef"
|
20
|
-
down_revision: Union[str, None] = None
|
21
|
-
branch_labels: Union[str, Sequence[str], None] = None
|
22
|
-
depends_on: Union[str, Sequence[str], None] = None
|
23
|
-
|
24
|
-
|
25
|
-
def upgrade() -> None:
|
26
|
-
# ### commands auto generated by Alembic - please adjust! ###
|
27
|
-
accounts = op.create_table(
|
28
|
-
"user_account",
|
29
|
-
sa.Column("id", sa.Integer(), nullable=False),
|
30
|
-
sa.Column("jid", slidge.db.meta.JIDType(), nullable=False),
|
31
|
-
sa.Column(
|
32
|
-
"registration_date",
|
33
|
-
sa.DateTime(),
|
34
|
-
server_default=sa.text("(CURRENT_TIMESTAMP)"),
|
35
|
-
nullable=False,
|
36
|
-
),
|
37
|
-
sa.Column(
|
38
|
-
"legacy_module_data", slidge.db.meta.JSONEncodedDict(), nullable=False
|
39
|
-
),
|
40
|
-
sa.Column("preferences", slidge.db.meta.JSONEncodedDict(), nullable=False),
|
41
|
-
sa.PrimaryKeyConstraint("id"),
|
42
|
-
sa.UniqueConstraint("jid"),
|
43
|
-
)
|
44
|
-
# ### end Alembic commands ###
|
45
|
-
|
46
|
-
|
47
|
-
def downgrade() -> None:
|
48
|
-
# ### commands auto generated by Alembic - please adjust! ###
|
49
|
-
op.drop_table("user_account")
|
50
|
-
# ### end Alembic commands ###
|
@@ -1,79 +0,0 @@
|
|
1
|
-
"""Store avatar legacy ID in the Contact and Room table
|
2
|
-
|
3
|
-
Revision ID: abba1ae0edb3
|
4
|
-
Revises: 8b993243a536
|
5
|
-
Create Date: 2024-07-29 15:44:41.557388
|
6
|
-
|
7
|
-
"""
|
8
|
-
|
9
|
-
from typing import Sequence, Union
|
10
|
-
|
11
|
-
import sqlalchemy as sa
|
12
|
-
from alembic import op
|
13
|
-
|
14
|
-
from slidge.db.models import Contact, Room
|
15
|
-
|
16
|
-
# revision identifiers, used by Alembic.
|
17
|
-
revision: str = "abba1ae0edb3"
|
18
|
-
down_revision: Union[str, None] = "8b993243a536"
|
19
|
-
branch_labels: Union[str, Sequence[str], None] = None
|
20
|
-
depends_on: Union[str, Sequence[str], None] = None
|
21
|
-
|
22
|
-
|
23
|
-
def upgrade() -> None:
|
24
|
-
conn = op.get_bind()
|
25
|
-
room_avatars = conn.execute(
|
26
|
-
sa.text(
|
27
|
-
"select room.id, avatar.legacy_id from room join avatar on room.avatar_id = avatar.id"
|
28
|
-
)
|
29
|
-
).all()
|
30
|
-
contact_avatars = conn.execute(
|
31
|
-
sa.text(
|
32
|
-
"select contact.id, avatar.legacy_id from contact join avatar on contact.avatar_id = avatar.id"
|
33
|
-
)
|
34
|
-
).all()
|
35
|
-
with op.batch_alter_table("contact", schema=None) as batch_op:
|
36
|
-
batch_op.add_column(sa.Column("avatar_legacy_id", sa.String(), nullable=True))
|
37
|
-
|
38
|
-
with op.batch_alter_table("room", schema=None) as batch_op:
|
39
|
-
batch_op.add_column(sa.Column("avatar_legacy_id", sa.String(), nullable=True))
|
40
|
-
if op.get_bind().engine.name != "postgresql":
|
41
|
-
batch_op.create_unique_constraint(
|
42
|
-
"uq_room_user_account_id_jid", ["user_account_id", "jid"]
|
43
|
-
)
|
44
|
-
batch_op.create_unique_constraint(
|
45
|
-
"uq_room_user_account_id_legacy_id", ["user_account_id", "legacy_id"]
|
46
|
-
)
|
47
|
-
|
48
|
-
for room_pk, avatar_legacy_id in room_avatars:
|
49
|
-
conn.execute(
|
50
|
-
sa.update(Room)
|
51
|
-
.where(Room.id == room_pk)
|
52
|
-
.values(avatar_legacy_id=avatar_legacy_id)
|
53
|
-
)
|
54
|
-
for contact_pk, avatar_legacy_id in contact_avatars:
|
55
|
-
conn.execute(
|
56
|
-
sa.update(Contact)
|
57
|
-
.where(Contact.id == contact_pk)
|
58
|
-
.values(avatar_legacy_id=avatar_legacy_id)
|
59
|
-
)
|
60
|
-
# conn.commit()
|
61
|
-
|
62
|
-
with op.batch_alter_table("avatar", schema=None) as batch_op:
|
63
|
-
batch_op.drop_column("legacy_id")
|
64
|
-
|
65
|
-
|
66
|
-
def downgrade() -> None:
|
67
|
-
# ### commands auto generated by Alembic - please adjust! ###
|
68
|
-
with op.batch_alter_table("room", schema=None) as batch_op:
|
69
|
-
batch_op.drop_constraint("uq_room_user_account_id_legacy_id", type_="unique")
|
70
|
-
batch_op.drop_constraint("uq_room_user_account_id_jid", type_="unique")
|
71
|
-
batch_op.drop_column("avatar_legacy_id")
|
72
|
-
|
73
|
-
with op.batch_alter_table("contact", schema=None) as batch_op:
|
74
|
-
batch_op.drop_column("avatar_legacy_id")
|
75
|
-
|
76
|
-
with op.batch_alter_table("avatar", schema=None) as batch_op:
|
77
|
-
batch_op.add_column(sa.Column("legacy_id", sa.VARCHAR(), nullable=True))
|
78
|
-
|
79
|
-
# ### end Alembic commands ###
|
@@ -1,214 +0,0 @@
|
|
1
|
-
"""Move everything to persistent DB
|
2
|
-
|
3
|
-
Revision ID: b33993e87db3
|
4
|
-
Revises: e91195719c2c
|
5
|
-
Create Date: 2024-06-25 16:09:36.663953
|
6
|
-
|
7
|
-
"""
|
8
|
-
|
9
|
-
import shutil
|
10
|
-
from typing import Sequence, Union
|
11
|
-
|
12
|
-
import sqlalchemy as sa
|
13
|
-
from alembic import op
|
14
|
-
|
15
|
-
import slidge.db.meta
|
16
|
-
from slidge import global_config
|
17
|
-
|
18
|
-
# revision identifiers, used by Alembic.
|
19
|
-
revision: str = "b33993e87db3"
|
20
|
-
down_revision: Union[str, None] = "e91195719c2c"
|
21
|
-
branch_labels: Union[str, Sequence[str], None] = None
|
22
|
-
depends_on: Union[str, Sequence[str], None] = None
|
23
|
-
|
24
|
-
|
25
|
-
def upgrade() -> None:
|
26
|
-
# ### commands auto generated by Alembic - please adjust! ###
|
27
|
-
op.create_table(
|
28
|
-
"avatar",
|
29
|
-
sa.Column("id", sa.Integer(), nullable=False),
|
30
|
-
sa.Column("filename", sa.String(), nullable=False),
|
31
|
-
sa.Column("hash", sa.String(), nullable=False),
|
32
|
-
sa.Column("height", sa.Integer(), nullable=False),
|
33
|
-
sa.Column("width", sa.Integer(), nullable=False),
|
34
|
-
sa.Column("legacy_id", sa.String(), nullable=True),
|
35
|
-
sa.Column("url", sa.String(), nullable=True),
|
36
|
-
sa.Column("etag", sa.String(), nullable=True),
|
37
|
-
sa.Column("last_modified", sa.String(), nullable=True),
|
38
|
-
sa.PrimaryKeyConstraint("id"),
|
39
|
-
sa.UniqueConstraint("filename"),
|
40
|
-
sa.UniqueConstraint("hash"),
|
41
|
-
sa.UniqueConstraint("legacy_id"),
|
42
|
-
)
|
43
|
-
op.create_table(
|
44
|
-
"attachment",
|
45
|
-
sa.Column("id", sa.Integer(), nullable=False),
|
46
|
-
sa.Column("user_account_id", sa.Integer(), nullable=False),
|
47
|
-
sa.Column("legacy_file_id", sa.String(), nullable=True),
|
48
|
-
sa.Column("url", sa.String(), nullable=False),
|
49
|
-
sa.Column("sims", sa.String(), nullable=True),
|
50
|
-
sa.Column("sfs", sa.String(), nullable=True),
|
51
|
-
sa.ForeignKeyConstraint(
|
52
|
-
["user_account_id"],
|
53
|
-
["user_account.id"],
|
54
|
-
),
|
55
|
-
sa.PrimaryKeyConstraint("id"),
|
56
|
-
)
|
57
|
-
op.create_index(
|
58
|
-
op.f("ix_attachment_legacy_file_id"),
|
59
|
-
"attachment",
|
60
|
-
["legacy_file_id"],
|
61
|
-
unique=False,
|
62
|
-
)
|
63
|
-
op.create_index(op.f("ix_attachment_url"), "attachment", ["url"], unique=False)
|
64
|
-
op.create_table(
|
65
|
-
"contact",
|
66
|
-
sa.Column("id", sa.Integer(), nullable=False),
|
67
|
-
sa.Column("user_account_id", sa.Integer(), nullable=False),
|
68
|
-
sa.Column("legacy_id", sa.String(), nullable=False),
|
69
|
-
sa.Column("jid", slidge.db.meta.JIDType(), nullable=False),
|
70
|
-
sa.Column("avatar_id", sa.Integer(), nullable=True),
|
71
|
-
sa.Column("nick", sa.String(), nullable=True),
|
72
|
-
sa.Column("cached_presence", sa.Boolean(), nullable=False),
|
73
|
-
sa.Column("last_seen", sa.DateTime(), nullable=True),
|
74
|
-
sa.Column("ptype", sa.String(), nullable=True),
|
75
|
-
sa.Column("pstatus", sa.String(), nullable=True),
|
76
|
-
sa.Column("pshow", sa.String(), nullable=True),
|
77
|
-
sa.ForeignKeyConstraint(
|
78
|
-
["avatar_id"],
|
79
|
-
["avatar.id"],
|
80
|
-
),
|
81
|
-
sa.ForeignKeyConstraint(
|
82
|
-
["user_account_id"],
|
83
|
-
["user_account.id"],
|
84
|
-
),
|
85
|
-
sa.PrimaryKeyConstraint("id"),
|
86
|
-
sa.UniqueConstraint("user_account_id", "jid"),
|
87
|
-
sa.UniqueConstraint("user_account_id", "legacy_id"),
|
88
|
-
)
|
89
|
-
op.create_table(
|
90
|
-
"legacy_ids_multi",
|
91
|
-
sa.Column("id", sa.Integer(), nullable=False),
|
92
|
-
sa.Column("user_account_id", sa.Integer(), nullable=False),
|
93
|
-
sa.Column("legacy_id", sa.String(), nullable=False),
|
94
|
-
sa.ForeignKeyConstraint(
|
95
|
-
["user_account_id"],
|
96
|
-
["user_account.id"],
|
97
|
-
),
|
98
|
-
sa.PrimaryKeyConstraint("id"),
|
99
|
-
)
|
100
|
-
op.create_index(
|
101
|
-
"legacy_ids_multi_user_account_id_legacy_id",
|
102
|
-
"legacy_ids_multi",
|
103
|
-
["user_account_id", "legacy_id"],
|
104
|
-
unique=True,
|
105
|
-
)
|
106
|
-
op.create_table(
|
107
|
-
"room",
|
108
|
-
sa.Column("id", sa.Integer(), nullable=False),
|
109
|
-
sa.Column("user_account_id", sa.Integer(), nullable=False),
|
110
|
-
sa.Column("legacy_id", sa.String(), nullable=False),
|
111
|
-
sa.Column("jid", slidge.db.meta.JIDType(), nullable=False),
|
112
|
-
sa.Column("avatar_id", sa.Integer(), nullable=True),
|
113
|
-
sa.Column("name", sa.String(), nullable=True),
|
114
|
-
sa.ForeignKeyConstraint(
|
115
|
-
["avatar_id"],
|
116
|
-
["avatar.id"],
|
117
|
-
),
|
118
|
-
sa.ForeignKeyConstraint(
|
119
|
-
["user_account_id"],
|
120
|
-
["user_account.id"],
|
121
|
-
),
|
122
|
-
sa.PrimaryKeyConstraint("id"),
|
123
|
-
sa.UniqueConstraint("jid"),
|
124
|
-
sa.UniqueConstraint("legacy_id"),
|
125
|
-
)
|
126
|
-
op.create_table(
|
127
|
-
"xmpp_to_legacy_ids",
|
128
|
-
sa.Column("id", sa.Integer(), nullable=False),
|
129
|
-
sa.Column("user_account_id", sa.Integer(), nullable=False),
|
130
|
-
sa.Column("xmpp_id", sa.String(), nullable=False),
|
131
|
-
sa.Column("legacy_id", sa.String(), nullable=False),
|
132
|
-
sa.Column(
|
133
|
-
"type",
|
134
|
-
sa.Enum("DM", "GROUP_CHAT", "THREAD", name="xmpptolegacyenum"),
|
135
|
-
nullable=False,
|
136
|
-
),
|
137
|
-
sa.ForeignKeyConstraint(
|
138
|
-
["user_account_id"],
|
139
|
-
["user_account.id"],
|
140
|
-
),
|
141
|
-
sa.PrimaryKeyConstraint("id"),
|
142
|
-
)
|
143
|
-
op.create_index(
|
144
|
-
"xmpp_legacy",
|
145
|
-
"xmpp_to_legacy_ids",
|
146
|
-
["user_account_id", "xmpp_id", "legacy_id"],
|
147
|
-
unique=True,
|
148
|
-
)
|
149
|
-
op.create_table(
|
150
|
-
"mam",
|
151
|
-
sa.Column("id", sa.Integer(), nullable=False),
|
152
|
-
sa.Column("room_id", sa.Integer(), nullable=False),
|
153
|
-
sa.Column("stanza_id", sa.String(), nullable=False),
|
154
|
-
sa.Column("timestamp", sa.DateTime(), nullable=False),
|
155
|
-
sa.Column("author_jid", slidge.db.meta.JIDType(), nullable=False),
|
156
|
-
sa.Column("stanza", sa.String(), nullable=False),
|
157
|
-
sa.ForeignKeyConstraint(
|
158
|
-
["room_id"],
|
159
|
-
["room.id"],
|
160
|
-
),
|
161
|
-
sa.PrimaryKeyConstraint("id"),
|
162
|
-
sa.UniqueConstraint("room_id", "stanza_id"),
|
163
|
-
)
|
164
|
-
op.create_table(
|
165
|
-
"xmpp_ids_multi",
|
166
|
-
sa.Column("id", sa.Integer(), nullable=False),
|
167
|
-
sa.Column("user_account_id", sa.Integer(), nullable=False),
|
168
|
-
sa.Column("xmpp_id", sa.String(), nullable=False),
|
169
|
-
sa.Column("legacy_ids_multi_id", sa.Integer(), nullable=False),
|
170
|
-
sa.ForeignKeyConstraint(
|
171
|
-
["legacy_ids_multi_id"],
|
172
|
-
["legacy_ids_multi.id"],
|
173
|
-
),
|
174
|
-
sa.ForeignKeyConstraint(
|
175
|
-
["user_account_id"],
|
176
|
-
["user_account.id"],
|
177
|
-
),
|
178
|
-
sa.PrimaryKeyConstraint("id"),
|
179
|
-
)
|
180
|
-
op.create_index(
|
181
|
-
"legacy_ids_multi_user_account_id_xmpp_id",
|
182
|
-
"xmpp_ids_multi",
|
183
|
-
["user_account_id", "xmpp_id"],
|
184
|
-
unique=True,
|
185
|
-
)
|
186
|
-
|
187
|
-
try:
|
188
|
-
shutil.rmtree(global_config.HOME_DIR / "slidge_avatars_v2")
|
189
|
-
except (FileNotFoundError, AttributeError):
|
190
|
-
pass
|
191
|
-
|
192
|
-
# ### end Alembic commands ###
|
193
|
-
|
194
|
-
|
195
|
-
def downgrade() -> None:
|
196
|
-
# ### commands auto generated by Alembic - please adjust! ###
|
197
|
-
op.drop_index(
|
198
|
-
"legacy_ids_multi_user_account_id_xmpp_id", table_name="xmpp_ids_multi"
|
199
|
-
)
|
200
|
-
op.drop_table("xmpp_ids_multi")
|
201
|
-
op.drop_table("mam")
|
202
|
-
op.drop_index("xmpp_legacy", table_name="xmpp_to_legacy_ids")
|
203
|
-
op.drop_table("xmpp_to_legacy_ids")
|
204
|
-
op.drop_table("room")
|
205
|
-
op.drop_index(
|
206
|
-
"legacy_ids_multi_user_account_id_legacy_id", table_name="legacy_ids_multi"
|
207
|
-
)
|
208
|
-
op.drop_table("legacy_ids_multi")
|
209
|
-
op.drop_table("contact")
|
210
|
-
op.drop_index(op.f("ix_attachment_url"), table_name="attachment")
|
211
|
-
op.drop_index(op.f("ix_attachment_legacy_file_id"), table_name="attachment")
|
212
|
-
op.drop_table("attachment")
|
213
|
-
op.drop_table("avatar")
|
214
|
-
# ### end Alembic commands ###
|
@@ -1,52 +0,0 @@
|
|
1
|
-
"""Add source and legacy ID for archived messages
|
2
|
-
|
3
|
-
Revision ID: b64b1a793483
|
4
|
-
Revises: 82a4af84b679
|
5
|
-
Create Date: 2024-07-22 21:06:35.020569
|
6
|
-
|
7
|
-
"""
|
8
|
-
|
9
|
-
from typing import Sequence, Union
|
10
|
-
|
11
|
-
import sqlalchemy as sa
|
12
|
-
from alembic import op
|
13
|
-
|
14
|
-
from slidge.db.models import ArchivedMessage
|
15
|
-
|
16
|
-
# revision identifiers, used by Alembic.
|
17
|
-
revision: str = "b64b1a793483"
|
18
|
-
down_revision: Union[str, None] = "82a4af84b679"
|
19
|
-
branch_labels: Union[str, Sequence[str], None] = None
|
20
|
-
depends_on: Union[str, Sequence[str], None] = None
|
21
|
-
|
22
|
-
|
23
|
-
def upgrade() -> None:
|
24
|
-
# since we don't want source to be nullable, we drop all rows first.
|
25
|
-
# This is what you get by using alpha versions!
|
26
|
-
op.execute(sa.delete(ArchivedMessage))
|
27
|
-
|
28
|
-
if op.get_bind().engine.name == "postgresql":
|
29
|
-
op.execute("CREATE TYPE archivedmessagesource AS ENUM ('LIVE', 'BACKFILL')")
|
30
|
-
|
31
|
-
# ### commands auto generated by Alembic - please adjust! ###
|
32
|
-
|
33
|
-
with op.batch_alter_table("mam", schema=None) as batch_op:
|
34
|
-
batch_op.add_column(
|
35
|
-
sa.Column(
|
36
|
-
"source",
|
37
|
-
sa.Enum("LIVE", "BACKFILL", name="archivedmessagesource"),
|
38
|
-
nullable=False,
|
39
|
-
)
|
40
|
-
)
|
41
|
-
batch_op.add_column(sa.Column("legacy_id", sa.String(), nullable=True))
|
42
|
-
|
43
|
-
# ### end Alembic commands ###
|
44
|
-
|
45
|
-
|
46
|
-
def downgrade() -> None:
|
47
|
-
# ### commands auto generated by Alembic - please adjust! ###
|
48
|
-
with op.batch_alter_table("mam", schema=None) as batch_op:
|
49
|
-
batch_op.drop_column("legacy_id")
|
50
|
-
batch_op.drop_column("source")
|
51
|
-
|
52
|
-
# ### end Alembic commands ###
|
@@ -1,34 +0,0 @@
|
|
1
|
-
"""Per-room user nick
|
2
|
-
|
3
|
-
Revision ID: c4a8ec35a0e8
|
4
|
-
Revises: 09f27f098baa
|
5
|
-
Create Date: 2024-07-12 06:27:47.397925
|
6
|
-
|
7
|
-
"""
|
8
|
-
|
9
|
-
from typing import Sequence, Union
|
10
|
-
|
11
|
-
import sqlalchemy as sa
|
12
|
-
from alembic import op
|
13
|
-
|
14
|
-
# revision identifiers, used by Alembic.
|
15
|
-
revision: str = "c4a8ec35a0e8"
|
16
|
-
down_revision: Union[str, None] = "09f27f098baa"
|
17
|
-
branch_labels: Union[str, Sequence[str], None] = None
|
18
|
-
depends_on: Union[str, Sequence[str], None] = None
|
19
|
-
|
20
|
-
|
21
|
-
def upgrade() -> None:
|
22
|
-
# ### commands auto generated by Alembic - please adjust! ###
|
23
|
-
with op.batch_alter_table("room", schema=None) as batch_op:
|
24
|
-
batch_op.add_column(sa.Column("user_nick", sa.String(), nullable=True))
|
25
|
-
|
26
|
-
# ### end Alembic commands ###
|
27
|
-
|
28
|
-
|
29
|
-
def downgrade() -> None:
|
30
|
-
# ### commands auto generated by Alembic - please adjust! ###
|
31
|
-
with op.batch_alter_table("room", schema=None) as batch_op:
|
32
|
-
batch_op.drop_column("user_nick")
|
33
|
-
|
34
|
-
# ### end Alembic commands ###
|
@@ -1,26 +0,0 @@
|
|
1
|
-
"""Store users' avatars' hashes persistently
|
2
|
-
|
3
|
-
Revision ID: e91195719c2c
|
4
|
-
Revises: aa9d82a7f6ef
|
5
|
-
Create Date: 2024-06-01 14:14:51.984943
|
6
|
-
|
7
|
-
"""
|
8
|
-
|
9
|
-
from typing import Sequence, Union
|
10
|
-
|
11
|
-
import sqlalchemy as sa
|
12
|
-
from alembic import op
|
13
|
-
|
14
|
-
# revision identifiers, used by Alembic.
|
15
|
-
revision: str = "e91195719c2c"
|
16
|
-
down_revision: Union[str, None] = "aa9d82a7f6ef"
|
17
|
-
branch_labels: Union[str, Sequence[str], None] = None
|
18
|
-
depends_on: Union[str, Sequence[str], None] = None
|
19
|
-
|
20
|
-
|
21
|
-
def upgrade() -> None:
|
22
|
-
op.add_column("user_account", sa.Column("avatar_hash", sa.String(), nullable=True))
|
23
|
-
|
24
|
-
|
25
|
-
def downgrade() -> None:
|
26
|
-
op.drop_column("user_account", "avatar_hash")
|