Generate the client_id on the client, so we don't need a round trip to get it before we can send arbitrary RPCs.

This changes the Profile/Client relationship; we never needed to be transactional with them, so split them up entirely so we can reparent Clients.
This commit is contained in:
Ian Gulliver
2014-05-31 23:25:15 -07:00
parent 0ab2fe620c
commit fd5569c5dc
4 changed files with 49 additions and 47 deletions

21
api.py
View File

@@ -36,14 +36,14 @@ def CreateChannel(google_user, client, instance_id, args):
events = []
if google_user:
events.append({
'event_type': 'login',
'profile': str(client.parent_key()),
'google_user': google_user.email(),
'event_type': 'login',
'profile': str(models.Client.profile.get_value_for_datastore(client)),
'google_user': google_user.email(),
})
else:
events.append({
'event_type': 'logout',
'profile': str(client.parent_key()),
'profile': str(models.Client.profile.get_value_for_datastore(client)),
})
return {
@@ -66,7 +66,10 @@ def Pin(google_user, client, instance_id, args):
try:
models.Subject.FindOrCreate(subject).Pin(
message, client.parent_key(), sender_message_id, instance)
message,
models.Client.profile.get_value_for_datastore(client),
sender_message_id,
instance)
except models.DuplicateMessage:
logging.warning('Duplicate pin: %s', sender_message_id)
return {
@@ -90,7 +93,9 @@ def SendMessage(google_user, client, instance_id, args):
try:
models.Subject.FindOrCreate(subject).SendMessage(
message, client.parent_key(), sender_message_id)
message,
models.Client.profile.get_value_for_datastore(client),
sender_message_id)
except models.DuplicateMessage:
logging.warning('Duplicate message: %s', sender_message_id)
return {
@@ -139,7 +144,9 @@ def Unpin(google_user, client, instance_id, args):
try:
models.Subject.FindOrCreate(subject).Unpin(
client.parent_key(), sender_message_id, instance.key())
models.Client.profile.get_value_for_datastore(client),
sender_message_id,
instance.key())
except models.AccessDenied:
logging.warning('Pin access denied')
return {