2013-10-17 16:33:04 +02:00
|
|
|
from django.db import models
|
2016-07-30 00:33:29 +02:00
|
|
|
from django.db.models import Manager
|
2016-10-27 23:55:31 +02:00
|
|
|
from typing import Dict, Optional, Text
|
2016-07-30 00:33:29 +02:00
|
|
|
|
2013-10-17 16:33:04 +02:00
|
|
|
import zerver.models
|
2016-10-27 23:55:31 +02:00
|
|
|
import datetime
|
2013-10-17 16:33:04 +02:00
|
|
|
|
2016-10-27 23:55:31 +02:00
|
|
|
def get_remote_server_by_uuid(uuid):
|
|
|
|
# type: (Text) -> RemoteZulipServer
|
|
|
|
return RemoteZulipServer.objects.get(uuid=uuid)
|
|
|
|
|
|
|
|
class RemoteZulipServer(models.Model):
|
2017-05-07 20:14:30 +02:00
|
|
|
uuid = models.CharField(max_length=36, unique=True) # type: Text
|
|
|
|
api_key = models.CharField(max_length=64) # type: Text
|
2016-10-27 23:55:31 +02:00
|
|
|
|
2017-05-07 20:14:30 +02:00
|
|
|
hostname = models.CharField(max_length=128, unique=True) # type: Text
|
|
|
|
contact_email = models.EmailField(blank=True, null=False) # type: Text
|
2017-05-16 01:59:07 +02:00
|
|
|
last_updated = models.DateTimeField('last updated', auto_now=True) # type: datetime.datetime
|
2016-10-27 23:55:31 +02:00
|
|
|
|
|
|
|
# Variant of PushDeviceToken for a remote server.
|
|
|
|
class RemotePushDeviceToken(zerver.models.AbstractPushDeviceToken):
|
|
|
|
server = models.ForeignKey(RemoteZulipServer) # type: RemoteZulipServer
|
|
|
|
# The user id on the remote server for this device device this is
|
|
|
|
user_id = models.BigIntegerField() # type: int
|