Skip to content

Commit 7b130bc

Browse files
committed
Rename 'thread' to 'ticket' throughout the project
1 parent d478e05 commit 7b130bc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1404
-1403
lines changed

config.yaml.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ bot:
3636
# Required: The bot's token, REPLACE WITH YOUR BOT'S TOKEN!
3737
token: "MTIzNDU2Nzg5MDEyMzQ1Njc4OQ.12345.XYZ"
3838

39-
# Required: The ID of your staff server (the server where new threads/tickets will be created).
39+
# Required: The ID of your staff server (the server where new tickets will be created).
4040
# To find your server's ID, see https://dis.gd/findmyid.
4141
# 1. Enable Developer Mode in your Discord settings.
4242
# 2. Right-click on your server's icon in the server list.

modmail/backends/common/client_base.py

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
from abc import ABC, abstractmethod
1010
from typing import TYPE_CHECKING, Any, Literal, overload
1111

12-
from modmail.enum import ProfileType, ThreadStatus
12+
from modmail.enum import ProfileType, TicketStatus
1313

1414
if TYPE_CHECKING:
1515
from modmail.config import Config
1616

17-
from .models import ProfileModel, SettingsModel, ThreadMessageModel, ThreadModel, ThreadUserModel
17+
from .models import ProfileModel, SettingsModel, TicketMessageModel, TicketModel, TicketUserModel
1818

1919
__all__ = ["DBClientBase"]
2020

@@ -86,10 +86,10 @@ async def sync_profiles(self) -> None:
8686
"""
8787

8888
@abstractmethod
89-
async def sync_open_threads(self) -> None:
90-
"""Synchronizes the open threads with the database.
89+
async def sync_open_tickets(self) -> None:
90+
"""Synchronizes the open tickets with the database.
9191
92-
This method shouldn't need to be called directly, as the bot stores the threads in cache.
92+
This method shouldn't need to be called directly, as the bot stores the tickets in cache.
9393
"""
9494

9595
@abstractmethod
@@ -121,112 +121,112 @@ async def delete_profile(self, profile_id: int) -> None:
121121
"""
122122

123123
@abstractmethod
124-
async def get_open_threads(self) -> list[ThreadModel]:
125-
"""Retrieves all open threads from the database.
124+
async def get_open_tickets(self) -> list[TicketModel]:
125+
"""Retrieves all open tickets from the database.
126126
127127
Returns:
128-
A list of open threads.
128+
A list of open tickets.
129129
"""
130130

131131
@abstractmethod
132-
async def get_thread_by_recipient(self, recipient_id: int) -> ThreadModel | None:
133-
"""Retrieves an open thread by recipient ID.
132+
async def get_ticket_by_recipient(self, recipient_id: int) -> TicketModel | None:
133+
"""Retrieves an open ticket by recipient ID.
134134
135-
If you want to get closed threads as well, use `get_all_threads_by_recipient` instead.
135+
If you want to get closed tickets as well, use `get_all_tickets_by_recipient` instead.
136136
137137
Args:
138138
recipient_id: The identifier of the recipient.
139139
140140
Returns:
141-
The thread if found, otherwise None.
141+
The ticket if found, otherwise None.
142142
"""
143143

144144
@overload
145-
async def get_all_threads_by_recipient(
145+
async def get_all_tickets_by_recipient(
146146
self, recipient_id: int, *, count: Literal[True] = True, only_closed: bool = False
147147
) -> int: ...
148148

149149
@overload
150-
async def get_all_threads_by_recipient(
150+
async def get_all_tickets_by_recipient(
151151
self, recipient_id: int, *, count: Literal[False] = False, only_closed: bool = False
152-
) -> list[ThreadModel]: ...
152+
) -> list[TicketModel]: ...
153153

154154
@abstractmethod
155-
async def get_all_threads_by_recipient(
155+
async def get_all_tickets_by_recipient(
156156
self, recipient_id: int, *, count: bool = False, only_closed: bool = False
157-
) -> int | list[ThreadModel]:
158-
"""Retrieves all threads by recipient ID.
157+
) -> int | list[TicketModel]:
158+
"""Retrieves all tickets by recipient ID.
159159
160160
Args:
161161
recipient_id: The identifier of the recipient.
162-
count: Whether to return the count of threads or the list of thread objects.
163-
only_closed: Whether to only include closed threads.
162+
count: Whether to return the count of tickets or the list of ticket objects.
163+
only_closed: Whether to only include closed tickets.
164164
165165
Returns:
166-
A list of threads associated with the recipient or the count of threads if count is True.
166+
A list of tickets associated with the recipient or the count of tickets if count is True.
167167
"""
168168

169169
@abstractmethod
170-
async def get_thread_by_key(self, key: str, *, only_open: bool = True) -> ThreadModel | None:
171-
"""Retrieves a thread by its key.
170+
async def get_ticket_by_key(self, key: str, *, only_open: bool = True) -> TicketModel | None:
171+
"""Retrieves a ticket by its key.
172172
173173
Args:
174-
key: The key of the thread.
175-
only_open: Whether to only search for open threads.
174+
key: The key of the ticket.
175+
only_open: Whether to only search for open tickets.
176176
177177
Returns:
178-
The thread if found, otherwise None.
178+
The ticket if found, otherwise None.
179179
"""
180180

181181
@abstractmethod
182-
async def get_thread_by_channel(self, channel_id: int, *, only_open: bool = True) -> ThreadModel | None:
183-
"""Retrieves a thread by its channel ID.
182+
async def get_ticket_by_channel(self, channel_id: int, *, only_open: bool = True) -> TicketModel | None:
183+
"""Retrieves a ticket by its channel ID.
184184
185185
Args:
186186
channel_id: The identifier of the channel.
187-
only_open: Whether to only search for open threads.
187+
only_open: Whether to only search for open tickets.
188188
189189
Returns:
190-
The thread if found, otherwise None.
190+
The ticket if found, otherwise None.
191191
"""
192192

193193
@abstractmethod
194-
async def create_thread(self, thread: ThreadModel) -> None:
195-
"""Creates a new thread in the database.
194+
async def create_ticket(self, ticket: TicketModel) -> None:
195+
"""Creates a new ticket in the database.
196196
197197
Args:
198-
thread: The thread object to create.
198+
ticket: The ticket object to create.
199199
200200
Raises:
201-
ThreadRecipientOccupiedError: If the recipient is already in another open thread.
201+
TicketRecipientOccupiedError: If the recipient is already in another open ticket.
202202
"""
203203

204204
@abstractmethod
205-
async def save_message(self, thread_message: ThreadMessageModel) -> None:
205+
async def save_message(self, ticket_message: TicketMessageModel) -> None:
206206
"""Saves a message to the database.
207207
208208
Args:
209-
thread_message: The thread message object to save.
209+
ticket_message: The ticket message object to save.
210210
211211
Raises:
212-
ThreadNotFoundError: If the thread is not found.
212+
TicketNotFoundError: If the ticket is not found.
213213
"""
214214

215215
@abstractmethod
216-
async def close_thread(
216+
async def close_ticket(
217217
self,
218-
thread_key: str,
219-
closer: ThreadUserModel,
218+
ticket_key: str,
219+
closer: TicketUserModel,
220220
*,
221-
thread_status: ThreadStatus = ThreadStatus.closed_by_command,
221+
ticket_status: TicketStatus = TicketStatus.closed_by_command,
222222
) -> None:
223-
"""Closes a thread in the database.
223+
"""Closes a ticket in the database.
224224
225225
Args:
226-
thread_key: The key of the thread to close.
227-
closer: The user who is closing the thread.
228-
thread_status: The status of the thread after closing.
226+
ticket_key: The key of the ticket to close.
227+
closer: The user who is closing the ticket.
228+
ticket_status: The status of the ticket after closing.
229229
230230
Raises:
231-
ThreadNotFoundError: If the thread is not found in the database or isn't currently open.
231+
TicketNotFoundError: If the ticket is not found in the database or isn't currently open.
232232
"""

modmail/backends/common/models/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from .activity_model import *
99
from .profile_model import *
1010
from .settings_model import *
11-
from .thread_dm_message_model import *
12-
from .thread_message_model import *
13-
from .thread_model import *
14-
from .thread_user_model import *
11+
from .ticket_dm_message_model import *
12+
from .ticket_message_model import *
13+
from .ticket_model import *
14+
from .ticket_user_model import *

modmail/backends/common/models/thread_dm_message_model.py

Lines changed: 0 additions & 31 deletions
This file was deleted.

modmail/backends/common/models/thread_model.py

Lines changed: 0 additions & 68 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""Pydantic model for a direct message in a ticket.
2+
3+
This module defines the TicketDMMessageModel class, which represents a direct
4+
message (DM) in a ticket.
5+
"""
6+
7+
from __future__ import annotations
8+
9+
from pydantic import BaseModel, ConfigDict
10+
11+
from .ticket_user_model import TicketUserModel
12+
13+
__all__ = ["TicketDMMessageModel"]
14+
15+
16+
class TicketDMMessageModel(BaseModel):
17+
"""Represents a direct message in a ticket.
18+
19+
This model stores information about direct messages in a ticket.
20+
21+
Attributes:
22+
message_id: The ID of the message in the DM channel.
23+
ticket_message_id: The ID of the message in the ticket channel.
24+
recipient: The recipient of the DM message (user).
25+
"""
26+
27+
model_config = ConfigDict(from_attributes=True, frozen=True)
28+
29+
message_id: int # in the DM channel
30+
ticket_message_id: int # in the ticket channel
31+
recipient: TicketUserModel

0 commit comments

Comments
 (0)