@@ -36,7 +36,7 @@ def check_duplicates(
3636 self ,
3737 chat_id : int ,
3838 group_id : int ,
39- collection_slug : str | None ,
39+ collection_id : int | None ,
4040 category : str | None ,
4141 entity_id : int | None = None ,
4242 ) -> None :
@@ -47,7 +47,7 @@ def check_duplicates(
4747
4848 :param chat_id: The unique identifier for the chat where the rule applies.
4949 :param group_id: The unique identifier for the group where the rule applies.
50- :param collection_slug : The slug identifying the collection; can be None if not applicable.
50+ :param collection_id : The id identifying the collection; can be None if not applicable.
5151 :param category: The category to which the rule applies; can be None if not applicable.
5252 :param entity_id: Optional identifier for the specific entity to exclude from duplicate checks.
5353
@@ -56,7 +56,7 @@ def check_duplicates(
5656 existing_rules = self .service .find (
5757 chat_id = chat_id ,
5858 group_id = group_id ,
59- collection_slug = collection_slug ,
59+ collection_id = collection_id ,
6060 category = category ,
6161 )
6262 if next (filter (lambda rule : rule .id != entity_id , existing_rules ), None ):
@@ -67,41 +67,41 @@ def check_duplicates(
6767
6868 def validate_params (
6969 self ,
70- collection_slug : str | None ,
70+ collection_id : int | None ,
7171 model : str | None ,
7272 backdrop : str | None ,
7373 pattern : str | None ,
7474 ) -> None :
75- # If the collection slug is not set or attributes are not selected – no need to validate them
76- if not collection_slug or not any ((model , backdrop , pattern )):
75+ # If the collection id is not set or attributes are not selected – no need to validate them
76+ if not collection_id or not any ((model , backdrop , pattern )):
7777 return
7878
79- options = self . gift_unique_service . get_unique_options (
80- collection_slug = collection_slug
81- )
79+ # FIXME: Rewrite disabled for now since it needs refactoring
80+ # options = self.gift_unique_service.get_unique_options("...")
81+ options = {}
8282
8383 if model and model not in options .get ("models" , []):
8484 raise HTTPException (
8585 status_code = HTTP_400_BAD_REQUEST ,
86- detail = f"Model { model !r} is not available for the collection { collection_slug !r} ." ,
86+ detail = f"Model { model !r} is not available for the collection { collection_id !r} ." ,
8787 )
8888
8989 if backdrop and backdrop not in options .get ("backdrops" , []):
9090 raise HTTPException (
9191 status_code = HTTP_400_BAD_REQUEST ,
92- detail = f"Backdrop { backdrop !r} is not available for the collection { collection_slug !r} ." ,
92+ detail = f"Backdrop { backdrop !r} is not available for the collection { collection_id !r} ." ,
9393 )
9494
9595 if pattern and pattern not in options .get ("patterns" , []):
9696 raise HTTPException (
9797 status_code = HTTP_400_BAD_REQUEST ,
98- detail = f"Pattern { pattern !r} is not available for the collection { collection_slug !r} ." ,
98+ detail = f"Pattern { pattern !r} is not available for the collection { collection_id !r} ." ,
9999 )
100100
101101 async def create (
102102 self ,
103103 group_id : int | None ,
104- collection_slug : str | None ,
104+ collection_id : int | None ,
105105 model : str | None ,
106106 backdrop : str | None ,
107107 pattern : str | None ,
@@ -113,16 +113,16 @@ async def create(
113113 self .check_duplicates (
114114 chat_id = self .chat .id ,
115115 group_id = group_id ,
116- collection_slug = collection_slug ,
116+ collection_id = collection_id ,
117117 category = category ,
118118 )
119- self .validate_params (collection_slug , model , backdrop , pattern )
119+ self .validate_params (collection_id , model , backdrop , pattern )
120120
121121 new_rule = self .service .create (
122122 CreateTelegramChatGiftCollectionRuleDTO (
123123 chat_id = self .chat .id ,
124124 group_id = group_id ,
125- collection_slug = collection_slug ,
125+ collection_id = collection_id ,
126126 model = model ,
127127 backdrop = backdrop ,
128128 pattern = pattern ,
@@ -139,7 +139,7 @@ async def create(
139139 async def update (
140140 self ,
141141 rule_id : int ,
142- collection_slug : str | None ,
142+ collection_id : int | None ,
143143 category : str | None ,
144144 model : str | None ,
145145 backdrop : str | None ,
@@ -155,16 +155,16 @@ async def update(
155155 self .check_duplicates (
156156 chat_id = self .chat .id ,
157157 group_id = rule .group_id ,
158- collection_slug = collection_slug ,
158+ collection_id = collection_id ,
159159 category = category ,
160160 entity_id = rule_id ,
161161 )
162- self .validate_params (collection_slug , model , backdrop , pattern )
162+ self .validate_params (collection_id , model , backdrop , pattern )
163163
164164 updated_rule = self .service .update (
165165 rule = rule ,
166166 dto = UpdateTelegramChatGiftCollectionRuleDTO (
167- collection_slug = collection_slug ,
167+ collection_id = collection_id ,
168168 category = category ,
169169 threshold = threshold ,
170170 is_enabled = is_enabled ,
0 commit comments