diff --git a/apps/chat/__init__.py b/apps/chat/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/apps/chat/admin.py b/apps/chat/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/apps/chat/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/apps/chat/apps.py b/apps/chat/apps.py new file mode 100644 index 0000000..45f098c --- /dev/null +++ b/apps/chat/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class ChatConfig(AppConfig): + name = 'apps.chat' diff --git a/apps/chat/migrations/__init__.py b/apps/chat/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/apps/chat/models.py b/apps/chat/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/apps/chat/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/apps/chat/tests.py b/apps/chat/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/apps/chat/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/apps/chat/views.py b/apps/chat/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/apps/chat/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/delme.py b/delme.py new file mode 100644 index 0000000..d46cc1e --- /dev/null +++ b/delme.py @@ -0,0 +1,78 @@ +from mattermostdriver import Driver +from django.conf import settings +from pprint import pprint + +mattermost = Driver({ + 'url': 'chat.addwin.ir', + # 'login_id': 'sahama', + # 'password': settings.MATTERMOST_BASE_PUBLICE_URL, + 'token': settings.MATTERMOST_TOKEN, + + 'scheme': 'https', + 'port': 443, + 'basepath': '/api/v4', + 'verify': True, # Or /path/to/file.pem + # 'mfa_token': 'YourMFAToken', + + 'auth': None, + 'timeout': 30, + + 'request_timeout': None, + 'keepalive': False, + 'keepalive_delay': 5, + + 'websocket_kw_args': None, + + 'debug': True +}) + +# mattermost.login() +# mattermost.users.create_user(options={ +# "email": "user2@example.com", +# "username": "newuser2", +# "first_name": "John", +# "last_name": "Doe", +# "password": "SecurePassword123!",} +# ) + + +user_client = Driver({ + 'url': 'chat.addwin.ir', + 'login_id': 'newuser', + 'password': 'SecurePassword123!', + # 'token': settings.MATTERMOST_TOKEN, + + 'scheme': 'https', + 'port': 443, + 'basepath': '/api/v4', + 'verify': True, # Or /path/to/file.pem + # 'mfa_token': 'YourMFAToken', + + 'auth': None, + 'timeout': 30, + + 'request_timeout': None, + 'keepalive': False, + 'keepalive_delay': 5, + + 'websocket_kw_args': None, + + 'debug': True +}) + +user_client.login() +# print(user_client.users.get_user_by_username(username='newuser')) # jrrryzhq4bfftchoe1anji6a5c +# print(user_client.users.get_user_by_username(username='newuser2')) # yy6ew7jy63dnb85ox6skgi969r +# print(user_client.users.get_user_by_username(username='sahama')) # hqst9xib4typ7fynq3wn4qnzye +print(user_client.channels.create_direct_message_channel(options=["jrrryzhq4bfftchoe1anji6a5c", "hqst9xib4typ7fynq3wn4qnzye"])) + +print(user_client.posts.create_post(options={ + "channel_id": "anth9sme4bn9tdantqxx1g4kky", + "message": "پیام از سمت پایتون" + })) + +pprint(user_client.posts.get_unread_posts_for_channel(**{ + "channel_id": "anth9sme4bn9tdantqxx1g4kky", + "user_id": "jrrryzhq4bfftchoe1anji6a5c" + })) + diff --git a/env.sample b/env.sample new file mode 100644 index 0000000..3a63c12 --- /dev/null +++ b/env.sample @@ -0,0 +1,16 @@ +DB_NAME=gooyal_chat +DB_USER=root +DB_HOST=127.0.0.1 +DB_PASSWORD=123456 +DEBUG=true + +OAUTH2_PROVIDER_BASE_PUBLIC_URL=https://accounts-staging.gooyal.ir/oauth2 +OAUTH2_PROVIDER_BASE_PRIVATE_URL=https://accounts-staging.gooyal.ir/oauth2 +OAUTH2_PROVIDER_CLIENT_ID=QkeJuvsPvwV2wjO2InQ7AIKfhCr0HqBWNtit2EHj +OAUTH2_PROVIDER_CLIENT_SECRET=S9AYajQRffgI7SzsxUmpzY7IMkVqlux8sW0A1scoBKgNfUFjXk3uwIMGbkBF9erMYONNVbSWemgODo6ArCDlg4UXYhaSZ8zolLhagfJ5Fk92RmrMLyY2rKv4cb209tPw +OAUTH2_PROVIDER_SCOPES=wallet.application.deposit:verify wallet.application.deposit:submit +REDIS_BASE_URL=redis://127.0.0.1:6379/1 + +MATTERMOST_TOKEN=3fktq5yzw7yp7m4ty7d3nx8gph +MATTERMOST_TOKEN_ID=h5h7unnmeigxdjk4yhtywxjkow +MATTERMOST_BASE_PUBLICE_URL=https://chat.addwin.ir \ No newline at end of file diff --git a/main/settings.py b/main/settings.py index a621d15..177a9c5 100644 --- a/main/settings.py +++ b/main/settings.py @@ -46,24 +46,16 @@ INSTALLED_APPS = [ 'drf_spectacular', 'oauth2_provider', 'rest_framework', - 'rest_framework_gis', 'corsheaders', 'crispy_forms', 'crispy_bootstrap5', 'django_filters', # 'jalali_date', - 'taggit', - 'colorfield', - # 'django_minio_backend', - 'django_minio_backend.apps.DjangoMinioBackendConfig', # local apps 'apps.core', 'apps.users', 'apps.gooyal_oauth2', - 'apps.stores', - 'apps.suggestions', - 'apps.crm' ] MIDDLEWARE = [ @@ -260,3 +252,4 @@ from main.other_settings.logging import get_logging_setting LOGGING = get_logging_setting() NOTIFICATIONS_BASE_PUBLIC_URL = config('NOTIFICATIONS_BASE_PUBLIC_URL', default=None, cast=str) +MATTERMOST_TOKEN = config('MATTERMOST_TOKEN', default=None, cast=str) diff --git a/main/urls.py b/main/urls.py index 292d5e0..4cdddc4 100644 --- a/main/urls.py +++ b/main/urls.py @@ -34,7 +34,7 @@ urlpatterns = [ path('swagger/redoc/', SpectacularRedocView.as_view(url_name='schema'), name='redoc'), path('admin/', admin.site.urls), - path('', include('apps.pg.urls')), + # path('', include('apps.pg.urls')), # path('users/', include('apps.users.urls')), path('oauth2/', include('oauth2_provider.urls', namespace='oauth2_provider')), ] diff --git a/requirements.in b/requirements.in index b8d94c6..1d1057a 100644 --- a/requirements.in +++ b/requirements.in @@ -20,3 +20,4 @@ django-redis xlsxwriter xlrd django_admin_logs +mattermostdriver \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index fb68c3b..eed64ab 100644 --- a/requirements.txt +++ b/requirements.txt @@ -111,6 +111,8 @@ jwcrypto==1.5.7 # via django-oauth-toolkit kombu==5.6.2 # via celery +mattermostdriver==7.3.2 + # via -r requirements.in oauthlib==3.3.1 # via django-oauth-toolkit packaging==26.2 @@ -147,6 +149,7 @@ requests==2.33.1 # via # -r requirements.in # django-oauth-toolkit + # mattermostdriver rpds-py==0.30.0 # via # jsonschema @@ -174,6 +177,8 @@ vine==5.1.0 # kombu wcwidth==0.7.0 # via prompt-toolkit +websockets==16.0 + # via mattermostdriver xlrd==2.0.2 # via -r requirements.in xlsxwriter==3.2.9