|
1 | | -from flask import Flask, request |
2 | | -from datetime import datetime |
3 | 1 | from argparse import ArgumentParser |
| 2 | +from datetime import datetime |
| 3 | +import json |
| 4 | +import logging |
| 5 | +import os |
| 6 | +import signal |
4 | 7 | import subprocess |
5 | 8 | import sys |
6 | | -import json |
7 | 9 | import time |
8 | 10 | import webbrowser |
9 | | -import logging |
| 11 | + |
| 12 | +from flask import Flask, request |
| 13 | +from pyngrok import ngrok |
| 14 | +from pyngrok.conf import PyngrokConfig |
10 | 15 | import TouchPortalAPI as TP |
11 | 16 | from TouchPortalAPI.logger import Logger |
| 17 | + |
12 | 18 | from TPPEntry import TP_PLUGIN_SETTINGS, PLUGIN_ID, TP_PLUGIN_INFO, __version__ |
13 | 19 | from createDefaultConfig import create_default_yaml_file |
14 | 20 | from updateConfig import update_config_file |
15 | | -import os |
16 | | -import signal |
17 | | - |
18 | | -from pyngrok import ngrok |
19 | | -from pyngrok.conf import PyngrokConfig |
20 | 21 |
|
21 | 22 |
|
22 | 23 | ## • figure out how to set a static location for pyngrok to download the ngrok.exe file rather than it doing it every time? |
@@ -60,7 +61,7 @@ def start_ngrok(self): |
60 | 61 | try: |
61 | 62 | # ngrok_command = "ngrok start --config=ngrok.yaml --all" |
62 | 63 | # subprocess.Popen(ngrok_command, shell=True) |
63 | | - g_log.info("Starting ngrok server...") |
| 64 | + # g_log.info("Starting ngrok server...") |
64 | 65 | self.http_tunnel = ngrok.connect(name='TP_NGROK', pyngrok_config=self.ngrok_config) |
65 | 66 | self.ngrok_running = True |
66 | 67 | except Exception as e: |
@@ -224,7 +225,8 @@ def formatTimestamp(self, timestamp:str): |
224 | 225 | def webhook(): |
225 | 226 | if request.method == 'POST': |
226 | 227 | data = json.loads(request.form['data']) |
227 | | - if data['verification_token'] != TP_PLUGIN_SETTINGS['Kofi Verification Token']: |
| 228 | + if data['verification_token'] != TP_PLUGIN_SETTINGS['Kofi Verification Token']['value']: |
| 229 | + g_log.error("Verification token does not match.") |
228 | 230 | return '', 403 |
229 | 231 |
|
230 | 232 | KofiManager.process_webhook_data(data) |
|
0 commit comments