django-chelseru 1.1.8__tar.gz → 2.0.0__tar.gz

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.
Files changed (54) hide show
  1. django_chelseru-2.0.0/PKG-INFO +475 -0
  2. django_chelseru-2.0.0/README.md +436 -0
  3. django_chelseru-2.0.0/django_chelseru.egg-info/PKG-INFO +475 -0
  4. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/setup.py +2 -2
  5. django_chelseru-1.1.8/PKG-INFO +0 -312
  6. django_chelseru-1.1.8/README.md +0 -273
  7. django_chelseru-1.1.8/django_chelseru.egg-info/PKG-INFO +0 -312
  8. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/LICENSE +0 -0
  9. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/MANIFEST.in +0 -0
  10. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/README_PA.md +0 -0
  11. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/django_chelseru.egg-info/SOURCES.txt +0 -0
  12. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/django_chelseru.egg-info/dependency_links.txt +0 -0
  13. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/django_chelseru.egg-info/requires.txt +0 -0
  14. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/django_chelseru.egg-info/top_level.txt +0 -0
  15. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/__init__.py +0 -0
  16. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/admin.py +0 -0
  17. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/apps.py +0 -0
  18. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/consumers.py +0 -0
  19. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/middlewares.py +0 -0
  20. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/migrations/0001_initial.py +0 -0
  21. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/migrations/0002_otpcode_session_user.py +0 -0
  22. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/migrations/0003_rename_mobile_otpcode_mobile_number.py +0 -0
  23. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/migrations/0004_rename_message_message_sms.py +0 -0
  24. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/migrations/0005_rename_message_sms_messagesms_chatroom_messagechat.py +0 -0
  25. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/migrations/0006_alter_chatroom_user_1_alter_chatroom_user_2_and_more.py +0 -0
  26. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/migrations/0007_chatroom_pinned_for_chatroom_status_chatroom_users_and_more.py +0 -0
  27. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/migrations/0008_alter_chatroompermissions_user.py +0 -0
  28. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/migrations/0009_alter_chatroom_status.py +0 -0
  29. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/migrations/0010_chatroom_banneds_chatroom_descriptions_chatroom_name_and_more.py +0 -0
  30. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/migrations/0011_alter_chatroom_user_1_alter_chatroom_user_2.py +0 -0
  31. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/migrations/0012_payment.py +0 -0
  32. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/migrations/0013_payment_authority_payment_data_payment_status_code.py +0 -0
  33. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/migrations/0014_payment_gateway_title_payment_gateway_url.py +0 -0
  34. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/migrations/0015_payment_message.py +0 -0
  35. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/migrations/0016_payment_card_hash_payment_card_pan_and_more.py +0 -0
  36. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/migrations/0017_alter_payment_callback_url_alter_payment_gateway_url.py +0 -0
  37. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/migrations/0018_alter_payment_ref_id.py +0 -0
  38. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/migrations/0019_payment_created_at_payment_status_payment_updated_at.py +0 -0
  39. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/migrations/0020_payment_paid_at.py +0 -0
  40. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/migrations/0021_alter_payment_message.py +0 -0
  41. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/migrations/0022_payment_pay_mode_wallet.py +0 -0
  42. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/migrations/__init__.py +0 -0
  43. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/models.py +0 -0
  44. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/routing.py +0 -0
  45. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/serializers.py +0 -0
  46. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/services.py +0 -0
  47. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/settings.py +0 -0
  48. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/signals.py +0 -0
  49. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/tests.py +0 -0
  50. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/urls.py +0 -0
  51. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/validators.py +0 -0
  52. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/drfchelseru/views.py +0 -0
  53. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/pyproject.toml +0 -0
  54. {django_chelseru-1.1.8 → django_chelseru-2.0.0}/setup.cfg +0 -0
@@ -0,0 +1,475 @@
1
+ Metadata-Version: 2.4
2
+ Name: django-chelseru
3
+ Version: 2.0.0
4
+ Summary: Authentication system, online and real-time chat, SMS & BANK system for Iranian SMS services.
5
+ Home-page: https://pipdjango.chelseru.com
6
+ Author: Sobhan Bahman Rashnu
7
+ Author-email: bahmanrashnu@gmail.com
8
+ Project-URL: Documentation, https://github.com/Chelseru/django-chelseru-lour/
9
+ Project-URL: Telegram Group, https://t.me/bahmanpy
10
+ Project-URL: Telegram Channel, https://t.me/ChelseruCom
11
+ Keywords: djangochelseruchat djangochat drfchat online-chat online real-time chat iran chelseru lor lur bahman rashnu rashno lak lour sms djangoauth auth ywt otpauth otp authentication djangootp djangoiransms iransms djangosms djangokavenegar djangomelipayamak sobhan چت سبحان بهمن رشنو چلسرو جنگو پایتون لر لور آنلاین ریل تایم
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Framework :: Django
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Requires-Python: >=3.11
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: Django>=5.1.6
20
+ Requires-Dist: djangorestframework==3.15.2
21
+ Requires-Dist: djangorestframework_simplejwt==5.5.0
22
+ Requires-Dist: channels==4.2.2
23
+ Requires-Dist: channels_redis==4.2.1
24
+ Requires-Dist: daphne==4.1.2
25
+ Requires-Dist: zeep==4.3.1
26
+ Requires-Dist: user-agents==2.2.0
27
+ Dynamic: author
28
+ Dynamic: author-email
29
+ Dynamic: classifier
30
+ Dynamic: description
31
+ Dynamic: description-content-type
32
+ Dynamic: home-page
33
+ Dynamic: keywords
34
+ Dynamic: license-file
35
+ Dynamic: project-url
36
+ Dynamic: requires-dist
37
+ Dynamic: requires-python
38
+ Dynamic: summary
39
+
40
+ # django-chelseru Django Package
41
+
42
+ ## Overview
43
+
44
+ django-chelseru is a Django package developed by Sobhan Bahman Rashnu for real-time chatting via WebSocket, OTP-based SMS verification, and SMS sending with Iranian providers. It also supports payment integrations.
45
+
46
+ Useful for building applications requiring secure authentication, messaging, real-time chat, and online payments.
47
+
48
+ ## Features
49
+
50
+ - **Authentication**: OTP and PASSWD methods using rest_framework_simplejwt.
51
+ - **SMS Services**: PARSIAN_WEBCO_IR, MELI_PAYAMAK_COM, KAVENEGAR_COM.
52
+ - **Payment Gateways**: PAYPING_IR, ZARINPAL_COM.
53
+ - **Real-time Chat**: WebSocket/Channels for messaging.
54
+ - Session management and API endpoints for OTP, authentication, SMS, payments, and chat.
55
+
56
+ ## Requirements
57
+
58
+ - Python 3.8+
59
+ - Django 4.x
60
+ - django-rest-framework
61
+ - djangorestframework-simplejwt
62
+ - django-channels
63
+ - user-agents
64
+ - requests
65
+ - Other dependencies: See `requirements.txt`
66
+
67
+ ## Installation
68
+
69
+ 1. Install the package:
70
+
71
+ ```bash
72
+ pip install django-chelseru
73
+ ```
74
+ 2. Add to `INSTALLED_APPS` in `settings.py`:
75
+
76
+ ```python
77
+ INSTALLED_APPS = [
78
+ ...
79
+ 'rest_framework',
80
+ 'rest_framework_simplejwt',
81
+ 'channels',
82
+ 'drfchelseru',
83
+ ]
84
+ ```
85
+ 3. Configure middleware and ASGI in `settings.py`.
86
+ 4. Apply migrations:
87
+
88
+ ```bash
89
+ python manage.py makemigrations
90
+ python manage.py migrate
91
+ ```
92
+ 5. Run the server (use ASGI for WebSocket):
93
+
94
+ ```bash
95
+ daphne -b 0.0.0.0 -p 8000 project.asgi:application
96
+ ```
97
+
98
+ ## Project Structure
99
+
100
+ - **models.py**: Defines models for users, OTP codes, sessions, SMS messages, organizations, chat rooms, chat permissions, messages, wallets, and payments.
101
+ - **views.py**: Handles API endpoints for OTP authentication, SMS, payments, and chat.
102
+ - **urls.py**: Maps URL patterns to views for API routes.
103
+ - **consumers.py**: Implements WebSocket consumer for real-time chat.
104
+ - **middlewares.py**: Includes `TakeUserSessionMiddlaware` for session management and `JWTAuthMiddleware` for WebSocket authentication.
105
+
106
+ ## Models
107
+
108
+ - **User**: Extends Django's User model with mobile number and group.
109
+ - **OTPCode**: Stores OTP codes for authentication with expiration logic.
110
+ - **Session**: Tracks user sessions with IP, device, and browser info.
111
+ - **MessageSMS**: Logs SMS messages sent to users.
112
+ - **Organization**: Represents organizations owned by users.
113
+ - **ChatRoomPermissions**: Defines access levels for chat room actions.
114
+ - **ChatRoom**: Manages chat rooms with users, status, and permissions.
115
+ - **MessageChat**: Stores chat messages with sender and timestamp.
116
+ - **Wallet**: Tracks user wallet balances for payments.
117
+ - **Payment**: Manages payment transactions with gateway integration.
118
+
119
+ ## Configuration
120
+
121
+ Update your Django `settings.py`:
122
+
123
+ ```python
124
+ MIDDLEWARE = [
125
+ ...
126
+ 'drfchelseru.middlewares.TakeUserSessionMiddlaware',
127
+ ]
128
+
129
+ ASGI_APPLICATION = 'yourproject.asgi.application'
130
+
131
+ CHANNEL_LAYERS = {
132
+ 'default': {
133
+ 'BACKEND': 'channels_redis.core.RedisChannelLayer',
134
+ 'CONFIG': {
135
+ 'hosts': [('127.0.0.1', 6379)],
136
+ },
137
+ },
138
+ }
139
+
140
+ DJANGO_CHELSERU = {
141
+ 'AUTH': {
142
+ 'AUTH_METHOD': 'OTP',
143
+ 'AUTH_SERVICE': 'rest_framework_simplejwt',
144
+ 'OPTIONS': {
145
+ 'OTP_LENGTH': 8,
146
+ 'OTP_EXPIRE_PER_MINUTES': 4,
147
+ 'OTP_SMS_TEMPLATE_ID': 5,
148
+ }
149
+ },
150
+ 'SMS': {
151
+ 'SMS_SERVICE': 'PARSIAN_WEBCO_IR',
152
+ 'SETTINGS': {
153
+ 'PARSIAN_WEBCO_IR_API_KEY': '',
154
+ 'MELI_PAYAMAK_COM_USERNAME': '',
155
+ 'MELI_PAYAMAK_COM_PASSWORD': '',
156
+ 'MELI_PAYAMAK_COM_FROM': '',
157
+ 'KAVENEGAR_COM_API_KEY': '',
158
+ 'KAVENEGAR_COM_FROM': '',
159
+ },
160
+ 'TEMPLATES': {
161
+ 'T1': 1,
162
+ 'T2': 2,
163
+ 'T3': 3,
164
+ }
165
+ },
166
+ 'BANK': {
167
+ 'GATEWAY': 'PAYPING_IR',
168
+ 'SETTINGS': {
169
+ 'MERCHANT_ID': '',
170
+ 'CALLBACK_URL': '',
171
+ 'CURRENCY': 'IRT'
172
+ }
173
+ }
174
+ }
175
+ ```
176
+
177
+ ## API Endpoints
178
+
179
+ - **POST /drfchelseru/message/send/**: Send SMS.
180
+
181
+ - Request: `{ "mobile_number": "09211892425", "message_text": "Hello", "template_id": 1 }`
182
+ - Response: `{ "details": "The Message was sent correctly." }` (200 OK)
183
+
184
+ - **POST /drfchelseru/otp/send/**: Request OTP code.
185
+
186
+ - Request: `{ "mobile_number": "09211892425" }`
187
+ - Response: `{ "details": "The OTP code was sent correctly." }` (200 OK)
188
+
189
+ - **POST /drfchelseru/authenticate/**: Authenticate with OTP.
190
+
191
+ - Request: `{ "mobile_number": "09211892425", "code": "652479", "group": 0 }`
192
+ - Response: `{ "access": "<access_token>", "refresh": "<refresh_token>" }` (200 OK)
193
+
194
+ - **GET /drfchelseru/sessions/**: List user sessions (authenticated users only).
195
+
196
+ - Headers: `Authorization: Bearer <access_token>`
197
+ - Response: List of sessions (200 OK)
198
+
199
+ - **POST /drfchelseru/payment/create/**: Initiate payment.
200
+
201
+ - Request: `{ "order_id": "123", "amount": 1000.0, "description": "Test payment", "callback_url": "http://example.com/callback", "mobile": "09211892425", "email": "user@example.com", "currency": "IRT" }`
202
+ - Response: `{ "details": { "gateway_url": "<url>", ... } }` (200 OK)
203
+
204
+ - **GET/POST /drfchelseru/payment/verify/**: Verify payment.
205
+
206
+ - GET Query: `?Authority=<authority>&Status=OK`
207
+ - POST Body: `{ "paymentCode": "<code>", "paymentRefId": "<refid>", ... }`
208
+ - Response: `{ "details": { "is_pay": 1, ... } }` (200 OK)
209
+
210
+ - **/drfchelseru/chat/chatrooms/**: CRUD for chat rooms (authenticated users only).
211
+
212
+ - POST Request: `{ "user": 2 }` (to create room with user ID 2)
213
+ - Headers: `Authorization: Bearer <access_token>`
214
+ - Response: Chat room details (201 Created)
215
+
216
+ - **/drfchelseru/chat/messages/**: CRUD for chat messages (authenticated users only).
217
+
218
+ - POST Request: `{ "chat_room": 1, "text": "Hello" }`
219
+ - GET Query: `?chat_room=1`
220
+ - Headers: `Authorization: Bearer <access_token>`
221
+ - Response: Message details or list (200 OK / 201 Created)
222
+
223
+ ## WebSocket Usage
224
+
225
+ - Connect to a chat room for real-time messaging:
226
+
227
+ ```bash
228
+ wscat -c wss://<your-domain>/drfchelseru/chat/<chat_room_id>/?token=<jwt_token>
229
+ ```
230
+ - Example token: `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzYxMDE5NTY3LCJpYXQiOjE3NTU4MzU1NjcsImp0aSI6IjhhYTY1Y2I3ZDhmMjRmMzliYjFmNDFkZmJiYjcyYmVmIiwidXNlcl9pZCI6Mzl9.mHmIjbTl3X1cd3Ky5HFCD6gy4kGxMVcActo9JXtT9JQ`
231
+ - Replace `<chat_room_id>` (e.g., 17) with the desired room ID and provide a valid JWT token.
232
+
233
+ ## Middleware
234
+
235
+ - **TakeUserSessionMiddlaware**: Logs user session data (IP, user agent, device, browser) for HTTP requests.
236
+ - **JWTAuthMiddleware**: Authenticates WebSocket connections using JWT tokens.
237
+
238
+ ## Usage
239
+
240
+ - Access the API at `http://<your-domain>/drfchelseru/`.
241
+ - Connect to WebSocket at `ws://<your-domain>/drfchelseru/chat/<chat_room_id>/?token=<jwt_token>`.
242
+ - Admin panel: Create a superuser with `python manage.py createsuperuser`.
243
+
244
+ ## Contributing
245
+
246
+ 1. Fork the repository.
247
+ 2. Create a new branch (`git checkout -b feature-branch`).
248
+ 3. Commit your changes (`git commit -m "Add feature"`).
249
+ 4. Push to the branch (`git push origin feature-branch`).
250
+ 5. Open a pull request.
251
+
252
+ ## License
253
+
254
+ MIT License
255
+
256
+
257
+
258
+ _______________________________________________________________________________________________________________________
259
+
260
+
261
+ # django-chelseru پکیج جنگو
262
+
263
+ ## بررسی اجمالی
264
+
265
+ django-chelseru یک پکیج جنگو است که توسط سبحان بهمن رشنو توسعه یافته برای گفتگوهای همزمان از راه وب‌سوکت، تایید پیامکی بر پایه OTP، و فرستادن پیامک با فراهم‌کنندگان ایرانی. همچنین از یکپارچگی پرداخت پشتیبانی می‌کند.
266
+
267
+ کاربردی برای ساخت برنامه‌هایی که نیاز به تایید امن، پیام‌رسانی، گفتگو همزمان، و پرداخت برخط دارند.
268
+
269
+ ## ویژگی‌ها
270
+
271
+ - **تایید**: روش‌های OTP و PASSWD با بهره‌گیری از rest_framework_simplejwt.
272
+ - **خدمات پیامک**: PARSIAN_WEBCO_IR، MELI_PAYAMAK_COM، KAVENEGAR_COM.
273
+ - **درگاه‌های پرداخت**: PAYPING_IR، ZARINPAL_COM.
274
+ - **گفتگو همزمان**: وب‌سوکت/کانال‌ها برای پیام‌رسانی.
275
+ - مدیریت نشست و نقاط پایانی API برای OTP، تایید، پیامک، پرداخت‌ها، و گفتگو.
276
+
277
+ ## نیازمندی‌ها
278
+
279
+ - Python 3.8+
280
+ - Django 4.x
281
+ - django-rest-framework
282
+ - djangorestframework-simplejwt
283
+ - django-channels
284
+ - user-agents
285
+ - requests
286
+ - دیگر وابستگی‌ها: ببینید `requirements.txt`
287
+
288
+ ## نصب
289
+
290
+ 1. پکیج را نصب کنید:
291
+
292
+ ```bash
293
+ pip install django-chelseru
294
+ ```
295
+ 2. به `INSTALLED_APPS` در `settings.py` بیفزایید:
296
+
297
+ ```python
298
+ INSTALLED_APPS = [
299
+ ...
300
+ 'rest_framework',
301
+ 'rest_framework_simplejwt',
302
+ 'channels',
303
+ 'drfchelseru',
304
+ ]
305
+ ```
306
+ 3. میان‌گیر و ASGI را در `settings.py` پیکربندی کنید.
307
+ 4. مهاجرت‌ها را اعمال کنید:
308
+
309
+ ```bash
310
+ python manage.py makemigrations
311
+ python manage.py migrate
312
+ ```
313
+ 5. کارساز را اجرا کنید (برای وب‌سوکت از ASGI بهره ببرید):
314
+
315
+ ```bash
316
+ daphne -b 0.0.0.0 -p 8000 project.asgi:application
317
+ ```
318
+
319
+ ## ساختار پروژه
320
+
321
+ - **models.py**: مدل‌ها را برای کاربران، کدهای OTP، نشست‌ها، پیامک‌ها، سازمان‌ها، اتاق‌های گفتگو، دسترسی‌های اتاق گفتگو، پیام‌ها، کیف‌پول‌ها، و پرداخت‌ها تعریف می‌کند.
322
+ - **views.py**: نقاط پایانی API برای تایید OTP، پیامک، پرداخت‌ها، و گفتگو را مدیریت می‌کند.
323
+ - **urls.py**: الگوهای URL را به نما‌ها برای مسیرهای API نگاشت می‌کند.
324
+ - **consumers.py**: مصرف‌کننده وب‌سوکت را برای گفتگو همزمان پیاده‌سازی می‌کند.
325
+ - **middlewares.py**: شامل `TakeUserSessionMiddlaware` برای مدیریت نشست و `JWTAuthMiddleware` برای تایید وب‌سوکت.
326
+
327
+ ## مدل‌ها
328
+
329
+ - **User**: مدل کاربر جنگو را با شماره همراه و گروه گسترش می‌دهد.
330
+ - **OTPCode**: کدهای OTP را برای تایید با منطق انقضا ذخیره می‌کند.
331
+ - **Session**: نشست‌های کاربر را با IP، دستگاه، و داده‌های مرورگر پیگیری می‌کند.
332
+ - **MessageSMS**: پیامک‌های فرستاده‌شده به کاربران را ثبت می‌کند.
333
+ - **Organization**: سازمان‌هایی را که مالک کاربران هستند نشان می‌دهد.
334
+ - **ChatRoomPermissions**: سطوح دسترسی برای کارهای اتاق گفتگو را تعریف می‌کند.
335
+ - **ChatRoom**: اتاق‌های گفتگو را با کاربران، وضعیت، و دسترسی‌ها مدیریت می‌کند.
336
+ - **MessageChat**: پیام‌های گفتگو را با فرستنده و زمان‌نگار ذخیره می‌کند.
337
+ - **Wallet**: مانده کیف‌پول کاربران را برای پرداخت‌ها پیگیری می‌کند.
338
+ - **Payment**: تراکنش‌های پرداخت را با یکپارچگی درگاه مدیریت می‌کند.
339
+
340
+ ## پیکربندی
341
+
342
+ `settings.py` جنگو را به‌روزرسانی کنید:
343
+
344
+ ```python
345
+ MIDDLEWARE = [
346
+ ...
347
+ 'drfchelseru.middlewares.TakeUserSessionMiddlaware',
348
+ ]
349
+
350
+ ASGI_APPLICATION = 'yourproject.asgi.application'
351
+
352
+ CHANNEL_LAYERS = {
353
+ 'default': {
354
+ 'BACKEND': 'channels_redis.core.RedisChannelLayer',
355
+ 'CONFIG': {
356
+ 'hosts': [('127.0.0.1', 6379)],
357
+ },
358
+ },
359
+ }
360
+
361
+ DJANGO_CHELSERU = {
362
+ 'AUTH': {
363
+ 'AUTH_METHOD': 'OTP',
364
+ 'AUTH_SERVICE': 'rest_framework_simplejwt',
365
+ 'OPTIONS': {
366
+ 'OTP_LENGTH': 8,
367
+ 'OTP_EXPIRE_PER_MINUTES': 4,
368
+ 'OTP_SMS_TEMPLATE_ID': 5,
369
+ }
370
+ },
371
+ 'SMS': {
372
+ 'SMS_SERVICE': 'PARSIAN_WEBCO_IR',
373
+ 'SETTINGS': {
374
+ 'PARSIAN_WEBCO_IR_API_KEY': '',
375
+ 'MELI_PAYAMAK_COM_USERNAME': '',
376
+ 'MELI_PAYAMAK_COM_PASSWORD': '',
377
+ 'MELI_PAYAMAK_COM_FROM': '',
378
+ 'KAVENEGAR_COM_API_KEY': '',
379
+ 'KAVENEGAR_COM_FROM': '',
380
+ },
381
+ 'TEMPLATES': {
382
+ 'T1': 1,
383
+ 'T2': 2,
384
+ 'T3': 3,
385
+ }
386
+ },
387
+ 'BANK': {
388
+ 'GATEWAY': 'PAYPING_IR',
389
+ 'SETTINGS': {
390
+ 'MERCHANT_ID': '',
391
+ 'CALLBACK_URL': '',
392
+ 'CURRENCY': 'IRT'
393
+ }
394
+ }
395
+ }
396
+ ```
397
+
398
+ ## نقاط پایانی API
399
+
400
+ - **POST /drfchelseru/message/send/**: فرستادن پیامک.
401
+
402
+ - درخواست: `{ "mobile_number": "09211892425", "message_text": "Hello", "template_id": 1 }`
403
+ - پاسخ: `{ "details": "The Message was sent correctly." }` (200 OK)
404
+
405
+ - **POST /drfchelseru/otp/send/**: درخواست کد OTP.
406
+
407
+ - درخواست: `{ "mobile_number": "09211892425" }`
408
+ - پاسخ: `{ "details": "The OTP code was sent correctly." }` (200 OK)
409
+
410
+ - **POST /drfchelseru/authenticate/**: تایید با OTP.
411
+
412
+ - درخواست: `{ "mobile_number": "09211892425", "code": "652479", "group": 0 }`
413
+ - پاسخ: `{ "access": "<access_token>", "refresh": "<refresh_token>" }` (200 OK)
414
+
415
+ - **GET /drfchelseru/sessions/**: فهرست نشست‌های کاربر (فقط کاربران تاییدشده).
416
+
417
+ - سرآیندها: `Authorization: Bearer <access_token>`
418
+ - پاسخ: فهرست نشست‌ها (200 OK)
419
+
420
+ - **POST /drfchelseru/payment/create/**: آغاز پرداخت.
421
+
422
+ - درخواست: `{ "order_id": "123", "amount": 1000.0, "description": "Test payment", "callback_url": "http://example.com/callback", "mobile": "09211892425", "email": "user@example.com", "currency": "IRT" }`
423
+ - پاسخ: `{ "details": { "gateway_url": "<url>", ... } }` (200 OK)
424
+
425
+ - **GET/POST /drfchelseru/payment/verify/**: تایید پرداخت.
426
+
427
+ - جستجوی GET: `?Authority=<authority>&Status=OK`
428
+ - بدنه POST: `{ "paymentCode": "<code>", "paymentRefId": "<refid>", ... }`
429
+ - پاسخ: `{ "details": { "is_pay": 1, ... } }` (200 OK)
430
+
431
+ - **/drfchelseru/chat/chatrooms/**: CRUD برای اتاق‌های گفتگو (فقط کاربران تاییدشده).
432
+
433
+ - درخواست POST: `{ "user": 2 }` (برای ساخت اتاق با شناسه کاربر 2)
434
+ - سرآیندها: `Authorization: Bearer <access_token>`
435
+ - پاسخ: جزئیات اتاق گفتگو (201 Created)
436
+
437
+ - **/drfchelseru/chat/messages/**: CRUD برای پیام‌های گفتگو (فقط کاربران تاییدشده).
438
+
439
+ - درخواست POST: `{ "chat_room": 1, "text": "Hello" }`
440
+ - جستجوی GET: `?chat_room=1`
441
+ - سرآیندها: `Authorization: Bearer <access_token>`
442
+ - پاسخ: جزئیات پیام یا فهرست (200 OK / 201 Created)
443
+
444
+ ## بهره‌گیری از وب‌سوکت
445
+
446
+ - پیوستن به اتاق گفتگو برای پیام‌رسانی همزمان:
447
+
448
+ ```bash
449
+ wscat -c wss://<your-domain>/drfchelseru/chat/<chat_room_id>/?token=<jwt_token>
450
+ ```
451
+ - نمونه نشانه: `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzYxMDE5NTY3LCJpYXQiOjE3NTU4MzU1NjcsImp0aSI6IjhhYTY1Y2I3ZDhmMjRmMzliYjFmNDFkZmJiYjcyYmVmIiwidXNlcl9pZCI6Mzl9.mHmIjbTl3X1cd3Ky5HFCD6gy4kGxMVcActo9JXtT9JQ`
452
+ - &lt;chat_room_id&gt; (مانند 17) را با شناسه اتاق دلخواه جایگزین کنید و نشانه JWT معتبر فراهم کنید.
453
+
454
+ ## میان‌گیرها
455
+
456
+ - **TakeUserSessionMiddlaware**: داده‌های نشست کاربر (IP، عامل کاربر، دستگاه، مرورگر) را برای درخواست‌های HTTP ثبت می‌کند.
457
+ - **JWTAuthMiddleware**: اتصال‌های وب‌سوکت را با نشانه‌های JWT تایید می‌کند.
458
+
459
+ ## بهره‌گیری
460
+
461
+ - به API در `http://<your-domain>/drfchelseru/` دسترسی یابید.
462
+ - به وب‌سوکت در `ws://<your-domain>/drfchelseru/chat/<chat_room_id>/?token=<jwt_token>` وصل شوید.
463
+ - پنل مدیر: ابرکاربر را با `python manage.py createsuperuser` بسازید.
464
+
465
+ ## همکاری
466
+
467
+ 1. مخزن را فورک کنید.
468
+ 2. شاخه نو بسازید (`git checkout -b feature-branch`).
469
+ 3. تغییرات را کامیت کنید (`git commit -m "Add feature"`).
470
+ 4. به شاخه بفرستید (`git push origin feature-branch`).
471
+ 5. درخواست کشیدن باز کنید.
472
+
473
+ ## پروانه
474
+
475
+ MIT License