init
This commit is contained in:
parent
aa14ae0f1f
commit
353d50953c
13 changed files with 119 additions and 9 deletions
0
apps/chat/__init__.py
Normal file
0
apps/chat/__init__.py
Normal file
3
apps/chat/admin.py
Normal file
3
apps/chat/admin.py
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
||||||
5
apps/chat/apps.py
Normal file
5
apps/chat/apps.py
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class ChatConfig(AppConfig):
|
||||||
|
name = 'apps.chat'
|
||||||
0
apps/chat/migrations/__init__.py
Normal file
0
apps/chat/migrations/__init__.py
Normal file
3
apps/chat/models.py
Normal file
3
apps/chat/models.py
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
3
apps/chat/tests.py
Normal file
3
apps/chat/tests.py
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
||||||
3
apps/chat/views.py
Normal file
3
apps/chat/views.py
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
# Create your views here.
|
||||||
78
delme.py
Normal file
78
delme.py
Normal 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
16
env.sample
Normal 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
|
||||||
|
|
@ -46,24 +46,16 @@ INSTALLED_APPS = [
|
||||||
'drf_spectacular',
|
'drf_spectacular',
|
||||||
'oauth2_provider',
|
'oauth2_provider',
|
||||||
'rest_framework',
|
'rest_framework',
|
||||||
'rest_framework_gis',
|
|
||||||
'corsheaders',
|
'corsheaders',
|
||||||
'crispy_forms',
|
'crispy_forms',
|
||||||
'crispy_bootstrap5',
|
'crispy_bootstrap5',
|
||||||
'django_filters',
|
'django_filters',
|
||||||
# 'jalali_date',
|
# 'jalali_date',
|
||||||
'taggit',
|
|
||||||
'colorfield',
|
|
||||||
# 'django_minio_backend',
|
|
||||||
'django_minio_backend.apps.DjangoMinioBackendConfig',
|
|
||||||
|
|
||||||
# local apps
|
# local apps
|
||||||
'apps.core',
|
'apps.core',
|
||||||
'apps.users',
|
'apps.users',
|
||||||
'apps.gooyal_oauth2',
|
'apps.gooyal_oauth2',
|
||||||
'apps.stores',
|
|
||||||
'apps.suggestions',
|
|
||||||
'apps.crm'
|
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
|
@ -260,3 +252,4 @@ from main.other_settings.logging import get_logging_setting
|
||||||
LOGGING = get_logging_setting()
|
LOGGING = get_logging_setting()
|
||||||
|
|
||||||
NOTIFICATIONS_BASE_PUBLIC_URL = config('NOTIFICATIONS_BASE_PUBLIC_URL', default=None, cast=str)
|
NOTIFICATIONS_BASE_PUBLIC_URL = config('NOTIFICATIONS_BASE_PUBLIC_URL', default=None, cast=str)
|
||||||
|
MATTERMOST_TOKEN = config('MATTERMOST_TOKEN', default=None, cast=str)
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ urlpatterns = [
|
||||||
path('swagger/redoc/', SpectacularRedocView.as_view(url_name='schema'), name='redoc'),
|
path('swagger/redoc/', SpectacularRedocView.as_view(url_name='schema'), name='redoc'),
|
||||||
|
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
path('', include('apps.pg.urls')),
|
# path('', include('apps.pg.urls')),
|
||||||
# path('users/', include('apps.users.urls')),
|
# path('users/', include('apps.users.urls')),
|
||||||
path('oauth2/', include('oauth2_provider.urls', namespace='oauth2_provider')),
|
path('oauth2/', include('oauth2_provider.urls', namespace='oauth2_provider')),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -20,3 +20,4 @@ django-redis
|
||||||
xlsxwriter
|
xlsxwriter
|
||||||
xlrd
|
xlrd
|
||||||
django_admin_logs
|
django_admin_logs
|
||||||
|
mattermostdriver
|
||||||
|
|
@ -111,6 +111,8 @@ jwcrypto==1.5.7
|
||||||
# via django-oauth-toolkit
|
# via django-oauth-toolkit
|
||||||
kombu==5.6.2
|
kombu==5.6.2
|
||||||
# via celery
|
# via celery
|
||||||
|
mattermostdriver==7.3.2
|
||||||
|
# via -r requirements.in
|
||||||
oauthlib==3.3.1
|
oauthlib==3.3.1
|
||||||
# via django-oauth-toolkit
|
# via django-oauth-toolkit
|
||||||
packaging==26.2
|
packaging==26.2
|
||||||
|
|
@ -147,6 +149,7 @@ requests==2.33.1
|
||||||
# via
|
# via
|
||||||
# -r requirements.in
|
# -r requirements.in
|
||||||
# django-oauth-toolkit
|
# django-oauth-toolkit
|
||||||
|
# mattermostdriver
|
||||||
rpds-py==0.30.0
|
rpds-py==0.30.0
|
||||||
# via
|
# via
|
||||||
# jsonschema
|
# jsonschema
|
||||||
|
|
@ -174,6 +177,8 @@ vine==5.1.0
|
||||||
# kombu
|
# kombu
|
||||||
wcwidth==0.7.0
|
wcwidth==0.7.0
|
||||||
# via prompt-toolkit
|
# via prompt-toolkit
|
||||||
|
websockets==16.0
|
||||||
|
# via mattermostdriver
|
||||||
xlrd==2.0.2
|
xlrd==2.0.2
|
||||||
# via -r requirements.in
|
# via -r requirements.in
|
||||||
xlsxwriter==3.2.9
|
xlsxwriter==3.2.9
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue