55namespace Nockx . Base . Util ;
66
77public class Message {
8- public long Id , Timestamp ;
9- public string Body , ReceiverEncryptedKey , SenderEncryptedKey , Signature , SenderDisplayName , ReceiverDisplayName ;
10- public RsaKeyParameters Sender , Receiver ;
8+ public long Id , ChatId , Timestamp ;
9+ public string Body , ReceiverEncryptedKey , SenderEncryptedKey , Signature , SenderDisplayName ;
10+ public RsaKeyParameters Sender ;
1111 public bool IsRead ;
1212
1313 public static Message Parse ( JsonObject jsonMessage ) {
1414 Message message ;
1515 try {
1616 message = new Message {
1717 Id = jsonMessage [ "id" ] ! . GetValue < long > ( ) ,
18+ ChatId = jsonMessage [ "chatId" ] ! . GetValue < long > ( ) ,
1819 Body = jsonMessage [ "text" ] ! . GetValue < string > ( ) ,
1920 ReceiverEncryptedKey = jsonMessage [ "receiverEncryptedKey" ] ! . GetValue < string > ( ) ,
2021 SenderEncryptedKey = jsonMessage [ "senderEncryptedKey" ] ? . GetValue < string > ( ) ,
2122 Timestamp = jsonMessage [ "timestamp" ] ! . GetValue < long > ( ) ,
2223 Signature = jsonMessage [ "signature" ] ! . GetValue < string > ( ) ,
2324 Sender = RsaKeyParametersExtension . FromBase64String ( jsonMessage [ "sender" ] ! [ "key" ] ! . GetValue < string > ( ) ) ,
24- Receiver = jsonMessage [ "receiver" ] == null ? null : RsaKeyParametersExtension . FromBase64String ( jsonMessage [ "receiver" ] ! [ "key" ] ! . GetValue < string > ( ) ) ,
2525 SenderDisplayName = jsonMessage [ "sender" ] ! [ "displayName" ] ! . GetValue < string > ( ) ,
26- ReceiverDisplayName = jsonMessage [ "receiver" ] ! [ "displayName" ] ! . GetValue < string > ( ) ,
2726 IsRead = jsonMessage [ "isRead" ] ! . GetValue < bool > ( )
2827 } ;
2928 } catch ( Exception e ) { // TODO: make this better. currently this is just easy for identifying issues between client and server
3029 Console . WriteLine ( e . Message ) ;
3130
3231 if ( jsonMessage [ "id" ] == null )
3332 Console . WriteLine ( "id null" ) ;
33+ if ( jsonMessage [ "chatId" ] == null )
34+ Console . WriteLine ( "chatId null" ) ;
3435 if ( jsonMessage [ "text" ] == null )
3536 Console . WriteLine ( "text null" ) ;
3637 if ( jsonMessage [ "receiverEncryptedKey" ] == null )
@@ -43,8 +44,6 @@ public static Message Parse(JsonObject jsonMessage) {
4344 Console . WriteLine ( "signature null" ) ;
4445 if ( jsonMessage [ "sender" ] == null )
4546 Console . WriteLine ( "sender null" ) ;
46- if ( jsonMessage [ "receiver" ] == null )
47- Console . WriteLine ( "receiver null" ) ;
4847 if ( jsonMessage [ "isRead" ] == null )
4948 Console . WriteLine ( "isRead null" ) ;
5049
0 commit comments