2015-04-08 16:43:28 +00:00
|
|
|
from direct.directnotify import DirectNotifyGlobal
|
|
|
|
from direct.distributed.DistributedObjectAI import DistributedObjectAI
|
|
|
|
from toontown.uberdog.ClientServicesManagerUD import executeHttpRequestAndLog
|
2015-04-08 17:19:02 +00:00
|
|
|
import ReportGlobals, threading, time
|
2015-04-08 16:43:28 +00:00
|
|
|
|
|
|
|
class DistributedReportMgrAI(DistributedObjectAI):
|
|
|
|
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedReportMgrAI")
|
|
|
|
|
|
|
|
def __init__(self, air):
|
2015-04-08 17:19:02 +00:00
|
|
|
DistributedObjectAI.__init__(self, air)
|
2015-04-08 16:43:28 +00:00
|
|
|
self.reports = []
|
|
|
|
self.interval = config.GetInt('report-interval', 600)
|
|
|
|
self.scheduleReport()
|
2015-04-29 04:01:52 +00:00
|
|
|
|
2015-04-08 16:43:28 +00:00
|
|
|
def scheduleReport(self):
|
2015-04-08 17:19:02 +00:00
|
|
|
threading.Timer(self.interval, self.sendAllReports).start()
|
2015-04-29 04:01:52 +00:00
|
|
|
|
2015-04-08 16:43:28 +00:00
|
|
|
def sendReport(self, avId, category):
|
|
|
|
if not ReportGlobals.isValidCategoryName(category) or not len(str(avId)) == 9:
|
|
|
|
return
|
2015-04-29 04:01:52 +00:00
|
|
|
|
2015-04-08 17:19:02 +00:00
|
|
|
reporter = self.air.doId2do.get(self.air.getAvatarIdFromSender())
|
2015-04-29 04:01:52 +00:00
|
|
|
|
2015-04-08 16:43:28 +00:00
|
|
|
if not reporter or reporter.isReported(avId):
|
|
|
|
return
|
2015-04-29 04:01:52 +00:00
|
|
|
|
2015-04-08 16:43:28 +00:00
|
|
|
timestamp = int(round(time.time() * 1000))
|
2015-04-08 17:19:02 +00:00
|
|
|
self.reports.append('%s|%s|%s|%s' % (timestamp, reporter.doId, avId, category))
|
2015-04-29 04:01:52 +00:00
|
|
|
|
2015-04-08 16:43:28 +00:00
|
|
|
def sendAllReports(self):
|
2015-04-08 17:22:13 +00:00
|
|
|
self.scheduleReport()
|
2015-04-29 04:01:52 +00:00
|
|
|
|
2015-04-08 17:09:38 +00:00
|
|
|
if not self.reports or config.GetString('accountdb-type', 'developer') != 'remote':
|
2015-04-08 16:43:28 +00:00
|
|
|
return
|
2015-04-29 04:01:52 +00:00
|
|
|
|
2015-04-08 16:43:28 +00:00
|
|
|
executeHttpRequestAndLog('report', reports=','.join(self.reports))
|
2015-04-29 04:01:52 +00:00
|
|
|
self.reports = []
|