This commit is contained in:
Sayyid Hamid Mahdavi 2026-06-08 12:05:24 +03:30
parent aa14ae0f1f
commit 353d50953c
13 changed files with 119 additions and 9 deletions

0
apps/chat/__init__.py Normal file
View file

3
apps/chat/admin.py Normal file
View file

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

5
apps/chat/apps.py Normal file
View file

@ -0,0 +1,5 @@
from django.apps import AppConfig
class ChatConfig(AppConfig):
name = 'apps.chat'

View file

3
apps/chat/models.py Normal file
View file

@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

3
apps/chat/tests.py Normal file
View file

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

3
apps/chat/views.py Normal file
View file

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.

78
delme.py Normal file
View file

@ -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"
}))

16
env.sample Normal file
View file

@ -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

View file

@ -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)

View file

@ -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')),
]

View file

@ -20,3 +20,4 @@ django-redis
xlsxwriter
xlrd
django_admin_logs
mattermostdriver

View file

@ -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