Updated GCM serialization for Teams Messages
* addded team_id * fixed dates times (UTC epoch) Change-Id: I6739b627f48f76312aea3b9142628417b9db99c7
This commit is contained in:
@@ -23,13 +23,13 @@ final class ChatTeamInvitationSerializer extends SilverStripeSerializer
|
||||
{
|
||||
protected static $array_mappings = array
|
||||
(
|
||||
'TeamId' => 'team_id:json_int',
|
||||
'InviteeId' => 'invitee_id:json_int',
|
||||
'InviterId' => 'inviter_id:json_int',
|
||||
'Permission' => 'permission:json_string',
|
||||
'IsAccepted' => 'is_accepted:json_boolean',
|
||||
'Created' => 'created_at:datetime_epoch',
|
||||
'LastEdited' => 'updated_at:datetime_epoch',
|
||||
'TeamId' => 'team_id:json_int',
|
||||
'InviteeId' => 'invitee_id:json_int',
|
||||
'InviterId' => 'inviter_id:json_int',
|
||||
'Permission' => 'permission:json_string',
|
||||
'IsAccepted' => 'is_accepted:json_boolean',
|
||||
'CreatedUTC' => 'created_at:datetime_epoch',
|
||||
'LastEditedUTC' => 'updated_at:datetime_epoch',
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,11 +24,11 @@ final class ChatTeamSerializer extends SilverStripeSerializer
|
||||
{
|
||||
protected static $array_mappings = array
|
||||
(
|
||||
'Name' => 'name:json_string',
|
||||
'Description' => 'description:json_string',
|
||||
'OwnerId' => 'owner_id:json_int',
|
||||
'Created' => 'created_at:datetime_epoch',
|
||||
'LastEdited' => 'updated_at:datetime_epoch',
|
||||
'Name' => 'name:json_string',
|
||||
'Description' => 'description:json_string',
|
||||
'OwnerId' => 'owner_id:json_int',
|
||||
'CreatedUTC' => 'created_at:datetime_epoch',
|
||||
'LastEditedUTC' => 'updated_at:datetime_epoch',
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
@@ -125,6 +125,13 @@ class PushNotificationMessage extends SilverstripeBaseModel
|
||||
return $this->sent_date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getSentDateUTC(){
|
||||
return $this->getDateFromLocalToUTC($this->sent_date);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $sent_date
|
||||
*/
|
||||
|
||||
@@ -35,6 +35,13 @@ class SilverstripeBaseModel implements IEntity
|
||||
return $this->created;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getCreatedUTC(){
|
||||
return $this->getDateFromLocalToUTC($this->created);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $created
|
||||
*/
|
||||
@@ -51,6 +58,26 @@ class SilverstripeBaseModel implements IEntity
|
||||
return $this->last_edited;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getLastEditedUTC(){
|
||||
return $this->getDateFromLocalToUTC($this->last_edited);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $value
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
protected function getDateFromLocalToUTC(\DateTime $value){
|
||||
if(is_null($value)) return null;
|
||||
$default_timezone = new \DateTimeZone(self::DefaultTimeZone);
|
||||
$utc_timezone = new \DateTimeZone("UTC");
|
||||
$timestamp = $value->format('Y-m-d H:i:s');
|
||||
$local_date = new \DateTime($timestamp, $default_timezone);
|
||||
return $local_date->setTimezone($utc_timezone);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $last_edited
|
||||
*/
|
||||
|
||||
@@ -369,7 +369,8 @@ final class ChatTeamService implements IChatTeamService
|
||||
'from_id' => intval($message->getOwner()->getId()),
|
||||
'from_first_name' => $message->getOwner()->getFirstName(),
|
||||
'from_last_name' => $message->getOwner()->getLastName(),
|
||||
'created_at' => intval($message->getCreated()->getTimestamp()),
|
||||
'created_at' => intval($message->getCreatedUTC()->getTimestamp()),
|
||||
'team_id' => intval($message->getTeamId())
|
||||
];
|
||||
|
||||
$this->push_sender_service->sendPush([sprintf('team_%s', $team_id)], $data);
|
||||
|
||||
Reference in New Issue
Block a user