|
9 | 9 | from abc import ABC, abstractmethod |
10 | 10 | from typing import TYPE_CHECKING, Any, Literal, overload |
11 | 11 |
|
12 | | -from modmail.enum import ProfileType, ThreadStatus |
| 12 | +from modmail.enum import ProfileType, TicketStatus |
13 | 13 |
|
14 | 14 | if TYPE_CHECKING: |
15 | 15 | from modmail.config import Config |
16 | 16 |
|
17 | | - from .models import ProfileModel, SettingsModel, ThreadMessageModel, ThreadModel, ThreadUserModel |
| 17 | + from .models import ProfileModel, SettingsModel, TicketMessageModel, TicketModel, TicketUserModel |
18 | 18 |
|
19 | 19 | __all__ = ["DBClientBase"] |
20 | 20 |
|
@@ -86,10 +86,10 @@ async def sync_profiles(self) -> None: |
86 | 86 | """ |
87 | 87 |
|
88 | 88 | @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. |
91 | 91 |
|
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. |
93 | 93 | """ |
94 | 94 |
|
95 | 95 | @abstractmethod |
@@ -121,112 +121,112 @@ async def delete_profile(self, profile_id: int) -> None: |
121 | 121 | """ |
122 | 122 |
|
123 | 123 | @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. |
126 | 126 |
|
127 | 127 | Returns: |
128 | | - A list of open threads. |
| 128 | + A list of open tickets. |
129 | 129 | """ |
130 | 130 |
|
131 | 131 | @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. |
134 | 134 |
|
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. |
136 | 136 |
|
137 | 137 | Args: |
138 | 138 | recipient_id: The identifier of the recipient. |
139 | 139 |
|
140 | 140 | Returns: |
141 | | - The thread if found, otherwise None. |
| 141 | + The ticket if found, otherwise None. |
142 | 142 | """ |
143 | 143 |
|
144 | 144 | @overload |
145 | | - async def get_all_threads_by_recipient( |
| 145 | + async def get_all_tickets_by_recipient( |
146 | 146 | self, recipient_id: int, *, count: Literal[True] = True, only_closed: bool = False |
147 | 147 | ) -> int: ... |
148 | 148 |
|
149 | 149 | @overload |
150 | | - async def get_all_threads_by_recipient( |
| 150 | + async def get_all_tickets_by_recipient( |
151 | 151 | self, recipient_id: int, *, count: Literal[False] = False, only_closed: bool = False |
152 | | - ) -> list[ThreadModel]: ... |
| 152 | + ) -> list[TicketModel]: ... |
153 | 153 |
|
154 | 154 | @abstractmethod |
155 | | - async def get_all_threads_by_recipient( |
| 155 | + async def get_all_tickets_by_recipient( |
156 | 156 | 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. |
159 | 159 |
|
160 | 160 | Args: |
161 | 161 | 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. |
164 | 164 |
|
165 | 165 | 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. |
167 | 167 | """ |
168 | 168 |
|
169 | 169 | @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. |
172 | 172 |
|
173 | 173 | 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. |
176 | 176 |
|
177 | 177 | Returns: |
178 | | - The thread if found, otherwise None. |
| 178 | + The ticket if found, otherwise None. |
179 | 179 | """ |
180 | 180 |
|
181 | 181 | @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. |
184 | 184 |
|
185 | 185 | Args: |
186 | 186 | 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. |
188 | 188 |
|
189 | 189 | Returns: |
190 | | - The thread if found, otherwise None. |
| 190 | + The ticket if found, otherwise None. |
191 | 191 | """ |
192 | 192 |
|
193 | 193 | @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. |
196 | 196 |
|
197 | 197 | Args: |
198 | | - thread: The thread object to create. |
| 198 | + ticket: The ticket object to create. |
199 | 199 |
|
200 | 200 | Raises: |
201 | | - ThreadRecipientOccupiedError: If the recipient is already in another open thread. |
| 201 | + TicketRecipientOccupiedError: If the recipient is already in another open ticket. |
202 | 202 | """ |
203 | 203 |
|
204 | 204 | @abstractmethod |
205 | | - async def save_message(self, thread_message: ThreadMessageModel) -> None: |
| 205 | + async def save_message(self, ticket_message: TicketMessageModel) -> None: |
206 | 206 | """Saves a message to the database. |
207 | 207 |
|
208 | 208 | Args: |
209 | | - thread_message: The thread message object to save. |
| 209 | + ticket_message: The ticket message object to save. |
210 | 210 |
|
211 | 211 | Raises: |
212 | | - ThreadNotFoundError: If the thread is not found. |
| 212 | + TicketNotFoundError: If the ticket is not found. |
213 | 213 | """ |
214 | 214 |
|
215 | 215 | @abstractmethod |
216 | | - async def close_thread( |
| 216 | + async def close_ticket( |
217 | 217 | self, |
218 | | - thread_key: str, |
219 | | - closer: ThreadUserModel, |
| 218 | + ticket_key: str, |
| 219 | + closer: TicketUserModel, |
220 | 220 | *, |
221 | | - thread_status: ThreadStatus = ThreadStatus.closed_by_command, |
| 221 | + ticket_status: TicketStatus = TicketStatus.closed_by_command, |
222 | 222 | ) -> None: |
223 | | - """Closes a thread in the database. |
| 223 | + """Closes a ticket in the database. |
224 | 224 |
|
225 | 225 | 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. |
229 | 229 |
|
230 | 230 | 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. |
232 | 232 | """ |
0 commit comments