From a7f729c1302721e1a37f871686499b36e1266ea6 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sat, 7 Feb 2026 19:44:36 +0000 Subject: [PATCH] v9 --- core/__pycache__/views.cpython-311.pyc | Bin 4344 -> 5360 bytes core/views.py | 18 ++++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc index 773a0deafbdf5c642ebc2e675e0dd4379f619276..0cf97aba83fb436d847ff6b4f83149bd9cf41eab 100644 GIT binary patch delta 1931 zcmaJ?OH3O_7@l3@$J)F08Vtrf$2>|%Q>UqvmhfnmhfR>EKz2;1kqX8;;04=j?Jm$D zx26(Rdx+Yk(*sgeHK()@RDE#hp_d$5gmURR@}aUs6{+ITo1?TUN_*(6i32VXvpfIH zeE<9ZceH!nVt3b<9A^b&{PWp|;t&VG@A{!U3{N+Y|Gn82%mTrb;3Ax07Ay&S(h+ea z`3RqMMx4p&NHqlr&LnD*u84~QG(g;3ZP^T}yF&r6PUilIxCQGfh}0vaU|R)u2)JHm zfry8o>=Cp98BYq_5x5bV1^W@S>ANRCP!zZMJw0VGRTI<7ef*2rvw6m}Mp2!c_sumF zbrSz(8MK)RQ%~~oR|fntQ*XRM$({^$n!Px|d@yh$L(3nly3Erdm@?EYl4yp$1wOB; zOo{@kr7Q=)oDrY0wzx9%hNV*Mwi$a3Z9c`6p#^51)-~jo3Ln-=1!C8UkbG9;mngf$Te#iD=`{6J=Lc`GlcQ@iKTmQM`QW<(mY&5vN$8gqN*sRU{qC6GOfawU{VrLFI;9$K~TTqa78x@lcJK0sVmTD z|DP|E64H{GQeiX}LyCd~xF|;9v@9(tNQNf{{a4_UsK%uQ6{e$dG>KFsE8WX-AR0r{ zdO6Bv@s|yW3bCb%i^vB@vk4Sc5L_TrjT1&VI1I%Uye2Kk@R^14=`>W3s*0&u1+>X<1C+Z`jMmfdf#qB80p-ek{+AY5W)w(mIB;U|4gH z<=kU=w+U sL#E*)cb;ij>&Y=4d8T8LyaG4o2DAI2TNlmwKeerq!tw^3#F0n+Qw!pY}SKC zOACQs3dPPrPu7#AD5Vh49$V@kuu4v$1)+HACB+J%r_RPiEk2mXd%rio_kM4t6e+ia z-?J{4|o9nX18IVJSRz(<<3Atl|(I3MX<3FY=00bV49mB`PB*F42W! zItN6zY>}88SjXgzS|=cSmi9f-I$UDUmAtZ5a-2hb`Bu0MA)POpQUv7kH^?nWw&I4_ zDC#5qh_@ZVFe0hJixvzL_#D2)f|tPpm^m3M!6%g^)Q{*p6++8Y&NaMXQU^8i$v$wWq?r`|9>=7WoId% zIZv50_?3?h3$47pk*zW4E8&55RA!o>ANlN!{b#4K$I7ZiJShaUKrI8{0#NH0E!tUz zL*h1Rv}JD#oke-cd0uryKxVcV&9kk2u1Q%cSpx3o>}I!>FD*MBRQG8Gx1<7*`FMqOeW9>7ZV&sQjxXCvy$40B^HTCGFs(^ z&@b+GpdSP6_+&-g^99(qI&#lfJbTuljt2P=l;W4S9HoWWY zD0n+`zT<$a*Bh>W4(VKcmx~v;xNeK@Q~c}T%C$YJMW$y5U>Xr<#n%8Sa- diff --git a/core/views.py b/core/views.py index 4bf003d..ecf11d6 100644 --- a/core/views.py +++ b/core/views.py @@ -4,9 +4,12 @@ from django.views.decorators.csrf import csrf_exempt from django.http import HttpResponse from django.utils import timezone import json +import logging from .models import Fanpage, Flow, MessageLog, ChatSession from .utils import handle_webhook_event +logger = logging.getLogger(__name__) + def home(request): if request.user.is_authenticated: return redirect('dashboard') @@ -50,12 +53,22 @@ def webhook(request): challenge = request.GET.get('hub.challenge') if mode == 'subscribe' and token: + print(f"DEBUG: Webhook verification attempt - mode: {mode}, token: {token}") # Check if this token matches any Fanpage verify_token - # or the one specifically mentioned by the user + # or the default 'pages_messaging' if Fanpage.objects.filter(verify_token=token).exists() or token == 'pages_messaging': + print(f"DEBUG: Webhook verification SUCCESS") return HttpResponse(challenge) + else: + print(f"DEBUG: Webhook verification FAILED - Token mismatch: {token}") + return HttpResponse('Verification failed: Token mismatch', status=403) - return HttpResponse('Verification failed', status=403) + # If no parameters, return 200 with instructions instead of 403 to avoid confusion + if not mode and not token: + print(f"DEBUG: Webhook endpoint accessed via browser (GET without parameters)") + return HttpResponse('Facebook Webhook Endpoint is active. Please use this URL in your Facebook App settings for Webhooks configuration.', status=200) + + return HttpResponse('Verification failed: Missing parameters', status=403) elif request.method == 'POST': # Handle incoming messages @@ -66,6 +79,7 @@ def webhook(request): return HttpResponse('EVENT_RECEIVED') except Exception as e: # Log the error if necessary + print(f"ERROR processing webhook: {str(e)}") return HttpResponse('Error processing request', status=400) return HttpResponse('Method not allowed', status=405) \ No newline at end of file