事件回调修改

This commit is contained in:
AKW 2023-12-25 14:35:54 +08:00
parent 238e00d2fc
commit 1a3b8a6751
4 changed files with 37 additions and 9 deletions

View File

@ -59,8 +59,8 @@ class JQRQrcodeCallbackPubSub:
handler(qrcodeid, userid, externaluserid, corpinfo) handler(qrcodeid, userid, externaluserid, corpinfo)
# if not settings.DEBUG: if not settings.DEBUG:
t = Thread(target=JQREventCallbackPubSub.event_callback_listener) t = Thread(target=JQREventCallbackPubSub.event_callback_listener)
t.start() t.start()
t2 = Thread(target=JQRQrcodeCallbackPubSub.qrcode_callback_listener) t2 = Thread(target=JQRQrcodeCallbackPubSub.qrcode_callback_listener)
t2.start() t2.start()

View File

@ -6,6 +6,7 @@ from django.db.models import Count, Sum, When, Case, Value
from apps.jqr.choices import JqrWechatbizuserinfoDeleteTypeChoices, JqrAddTypeChoices from apps.jqr.choices import JqrWechatbizuserinfoDeleteTypeChoices, JqrAddTypeChoices
from apps.jqr.pubsub import JQRQrcodeCallbackPubSub from apps.jqr.pubsub import JQRQrcodeCallbackPubSub
from apps.jqr.ws import WS
from apps.qc.choices import QcWechatbizeventAddcontactIsDeleteChoices, QcQrcodesEditLogOperateTypeChoices, \ from apps.qc.choices import QcWechatbizeventAddcontactIsDeleteChoices, QcQrcodesEditLogOperateTypeChoices, \
QcQrcodesEditLogTypeChoices QcQrcodesEditLogTypeChoices
from apps.qc.models import QcWechatbizeventAddcontact, QcQrcodes, QcWechatbizuserinfo, QcQrcodesEditLog, QcCorpinfo from apps.qc.models import QcWechatbizeventAddcontact, QcQrcodes, QcWechatbizuserinfo, QcQrcodesEditLog, QcCorpinfo
@ -76,7 +77,7 @@ def save_add_contact_by_channel(data, corpinfo, *args, **kwargs):
}) })
# 修复客户关系 # 修复客户关系
edit_add_contact(data, corpinfo, *args, **kwargs) edit_add_contact(data, corpinfo, *args, **kwargs)
# TODO 请求API 发送消息 WS.transfer_external_userid_to_vid(f'{corpid}_{userid}', externaluserid)
@shared_task(name='edit_add_contact', queue='contact') @shared_task(name='edit_add_contact', queue='contact')

27
apps/jqr/ws.py Normal file
View File

@ -0,0 +1,27 @@
import requests
class WS:
BASE_URL = f'http://ws.xbtool.cn'
@classmethod
def transfer_external_userid_to_vid(cls, client_id, external_user_ids):
payload = {
"clientId": client_id,
"externalUserIds": external_user_ids
}
url = f'{cls.BASE_URL}/api/hook/websocket/transferexternaluseridtovid'
response = requests.post(url, json=payload)
@classmethod
def transfer_groupid_to_roomid(cls, client_id, group_ids):
payload = {
"clientId": client_id,
"groupIds": group_ids
}
url = f'{cls.BASE_URL}/api/hook/websocket/transferexternaluseridtovid'
response = requests.post(url, json=payload)
@classmethod
def send_wx_work_msg(cls):
url = f'{cls.BASE_URL}/api/hook/websocket/sendwxworkmsg'

View File

@ -43,6 +43,6 @@ class JQRMSGPubSub:
cls.msg_list.clear() cls.msg_list.clear()
# if not settings.DEBUG: if not settings.DEBUG:
t = Thread(target=JQRMSGPubSub.listen) t = Thread(target=JQRMSGPubSub.listen)
t.start() t.start()