mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-11-16 18:36:19 +00:00
Fixed schedule task delete issue
This commit is contained in:
@@ -194,7 +194,7 @@ with app.app_context():
|
|||||||
DashboardConfig = DashboardConfig()
|
DashboardConfig = DashboardConfig()
|
||||||
EmailSender = EmailSender(DashboardConfig)
|
EmailSender = EmailSender(DashboardConfig)
|
||||||
AllPeerShareLinks: PeerShareLinks = PeerShareLinks(DashboardConfig, WireguardConfigurations)
|
AllPeerShareLinks: PeerShareLinks = PeerShareLinks(DashboardConfig, WireguardConfigurations)
|
||||||
AllPeerJobs: PeerJobs = PeerJobs(DashboardConfig, WireguardConfigurations)
|
AllPeerJobs: PeerJobs = PeerJobs(DashboardConfig, WireguardConfigurations, AllPeerShareLinks)
|
||||||
DashboardLogger: DashboardLogger = DashboardLogger()
|
DashboardLogger: DashboardLogger = DashboardLogger()
|
||||||
DashboardPlugins: DashboardPlugins = DashboardPlugins(app, WireguardConfigurations)
|
DashboardPlugins: DashboardPlugins = DashboardPlugins(app, WireguardConfigurations)
|
||||||
DashboardWebHooks: DashboardWebHooks = DashboardWebHooks(DashboardConfig)
|
DashboardWebHooks: DashboardWebHooks = DashboardWebHooks(DashboardConfig)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from datetime import datetime
|
|||||||
from flask import current_app
|
from flask import current_app
|
||||||
|
|
||||||
class PeerJobs:
|
class PeerJobs:
|
||||||
def __init__(self, DashboardConfig, WireguardConfigurations):
|
def __init__(self, DashboardConfig, WireguardConfigurations, AllPeerShareLinks):
|
||||||
self.Jobs: list[PeerJob] = []
|
self.Jobs: list[PeerJob] = []
|
||||||
self.engine = db.create_engine(ConnectionString('wgdashboard_job'))
|
self.engine = db.create_engine(ConnectionString('wgdashboard_job'))
|
||||||
self.metadata = db.MetaData()
|
self.metadata = db.MetaData()
|
||||||
@@ -28,6 +28,7 @@ class PeerJobs:
|
|||||||
self.__getJobs()
|
self.__getJobs()
|
||||||
self.JobLogger: PeerJobLogger = PeerJobLogger(self, DashboardConfig)
|
self.JobLogger: PeerJobLogger = PeerJobLogger(self, DashboardConfig)
|
||||||
self.WireguardConfigurations = WireguardConfigurations
|
self.WireguardConfigurations = WireguardConfigurations
|
||||||
|
self.AllPeerShareLinks = AllPeerShareLinks
|
||||||
|
|
||||||
def __getJobs(self):
|
def __getJobs(self):
|
||||||
self.Jobs.clear()
|
self.Jobs.clear()
|
||||||
@@ -162,7 +163,7 @@ class PeerJobs:
|
|||||||
if job.Action == "restrict":
|
if job.Action == "restrict":
|
||||||
s, msg = c.restrictPeers([fp.id])
|
s, msg = c.restrictPeers([fp.id])
|
||||||
elif job.Action == "delete":
|
elif job.Action == "delete":
|
||||||
s, msg = c.deletePeers([fp.id])
|
s, msg = c.deletePeers([fp.id], self, self.AllPeerShareLinks)
|
||||||
elif job.Action == "reset_total_data_usage":
|
elif job.Action == "reset_total_data_usage":
|
||||||
s = fp.resetDataUsage("total")
|
s = fp.resetDataUsage("total")
|
||||||
c.restrictPeers([fp.id])
|
c.restrictPeers([fp.id])
|
||||||
@@ -179,12 +180,10 @@ class PeerJobs:
|
|||||||
f"Peer {fp.id} from {c.Name} failed {job.Action}ed."
|
f"Peer {fp.id} from {c.Name} failed {job.Action}ed."
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
current_app.logger.warning(f"Somehow can't find this peer {job.Peer} from {c.Name} failed {job.Action}ed.")
|
|
||||||
self.JobLogger.log(job.JobID, False,
|
self.JobLogger.log(job.JobID, False,
|
||||||
f"Somehow can't find this peer {job.Peer} from {c.Name} failed {job.Action}ed."
|
f"Somehow can't find this peer {job.Peer} from {c.Name} failed {job.Action}ed."
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
current_app.logger.warning(f"Somehow can't find this peer {job.Peer} from {job.Configuration} failed {job.Action}ed.")
|
|
||||||
self.JobLogger.log(job.JobID, False,
|
self.JobLogger.log(job.JobID, False,
|
||||||
f"Somehow can't find this peer {job.Peer} from {job.Configuration} failed {job.Action}ed."
|
f"Somehow can't find this peer {job.Peer} from {job.Configuration} failed {job.Action}ed."
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user