2017-02-10 06:10:44 +01:00
|
|
|
from titanembeds.database import db
|
|
|
|
import datetime
|
2017-03-27 04:46:06 +02:00
|
|
|
import time
|
2017-02-10 06:10:44 +01:00
|
|
|
|
|
|
|
class AuthenticatedUsers(db.Model):
|
|
|
|
__tablename__ = "authenticated_users"
|
2017-06-04 07:05:55 +02:00
|
|
|
id = db.Column(db.Integer, primary_key=True) # Auto increment id
|
|
|
|
guild_id = db.Column(db.String(255), nullable=False) # Guild pretaining to the authenticated user
|
|
|
|
client_id = db.Column(db.String(255), nullable=False) # Client ID of the authenticated user
|
|
|
|
last_timestamp = db.Column(db.TIMESTAMP, nullable=False) # The timestamp of when the user has last sent the heartbeat
|
2017-02-10 06:10:44 +01:00
|
|
|
|
|
|
|
def __init__(self, guild_id, client_id):
|
|
|
|
self.guild_id = guild_id
|
|
|
|
self.client_id = client_id
|
2017-03-27 04:46:06 +02:00
|
|
|
self.last_timestamp = datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S')
|
2017-02-10 06:10:44 +01:00
|
|
|
|
|
|
|
def bumpTimestamp(self):
|
2017-03-27 04:46:06 +02:00
|
|
|
self.last_timestamp = datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S')
|
2017-02-10 06:10:44 +01:00
|
|
|
db.session.commit()
|
|
|
|
return self.last_timestamp
|