10
10
11
11
using System ;
12
12
using System . Collections . Generic ;
13
+ using static libsignalservice . push . DataMessage ;
13
14
14
15
namespace libsignalservice . crypto
15
16
{
@@ -97,7 +98,7 @@ public SignalServiceContent Decrypt(SignalServiceEnvelope envelope)
97
98
{
98
99
content = new SignalServiceContent ( )
99
100
{
100
- ReadMessage = createReceiptMessage ( envelope , message . ReceiptMessage )
101
+ ReadMessage = CreateReceiptMessage ( envelope , message . ReceiptMessage )
101
102
} ;
102
103
}
103
104
}
@@ -142,19 +143,11 @@ private SignalServiceDataMessage CreateSignalServiceMessage(SignalServiceEnvelop
142
143
bool endSession = ( ( content . Flags & ( uint ) DataMessage . Types . Flags . EndSession ) != 0 ) ;
143
144
bool expirationUpdate = ( ( content . Flags & ( uint ) DataMessage . Types . Flags . ExpirationTimerUpdate ) != 0 ) ;
144
145
bool profileKeyUpdate = ( ( content . Flags & ( uint ) DataMessage . Types . Flags . ProfileKeyUpdate ) != 0 ) ;
146
+ SignalServiceDataMessage . SignalServiceQuote quote = CreateQuote ( envelope , content ) ;
145
147
146
148
foreach ( AttachmentPointer pointer in content . Attachments )
147
149
{
148
- attachments . Add ( new SignalServiceAttachmentPointer ( pointer . Id ,
149
- pointer . ContentType ,
150
- pointer . Key . ToByteArray ( ) ,
151
- envelope . getRelay ( ) ,
152
- pointer . SizeOneofCase == AttachmentPointer . SizeOneofOneofCase . Size ? pointer . Size : 0 ,
153
- pointer . ThumbnailOneofCase == AttachmentPointer . ThumbnailOneofOneofCase . Thumbnail ? pointer . Thumbnail . ToByteArray ( ) : null ,
154
- ( int ) pointer . Width , ( int ) pointer . Height ,
155
- pointer . DigestOneofCase == AttachmentPointer . DigestOneofOneofCase . Digest ? pointer . Digest . ToByteArray ( ) : null ,
156
- pointer . FileNameOneofCase == AttachmentPointer . FileNameOneofOneofCase . FileName ? pointer . FileName : null ,
157
- pointer . FlagsOneofCase == AttachmentPointer . FlagsOneofOneofCase . Flags && ( pointer . Flags & ( uint ) AttachmentPointer . Types . Flags . VoiceMessage ) != 0 ) ) ;
150
+ attachments . Add ( CreateAttachmentPointer ( envelope , pointer ) ) ;
158
151
}
159
152
160
153
if ( content . TimestampOneofCase == DataMessage . TimestampOneofOneofCase . Timestamp && ( long ) content . Timestamp != envelope . getTimestamp ( ) )
@@ -172,7 +165,8 @@ private SignalServiceDataMessage CreateSignalServiceMessage(SignalServiceEnvelop
172
165
ExpiresInSeconds = ( int ) content . ExpireTimer ,
173
166
ExpirationUpdate = expirationUpdate ,
174
167
ProfileKey = content . ProfileKeyOneofCase == DataMessage . ProfileKeyOneofOneofCase . ProfileKey ? content . ProfileKey . ToByteArray ( ) : null ,
175
- ProfileKeyUpdate = profileKeyUpdate
168
+ ProfileKeyUpdate = profileKeyUpdate ,
169
+ Quote = quote
176
170
} ;
177
171
}
178
172
@@ -306,7 +300,7 @@ private SignalServiceCallMessage CreateCallMessage(CallMessage content)
306
300
return new SignalServiceCallMessage ( ) ;
307
301
}
308
302
309
- private SignalServiceReceiptMessage createReceiptMessage ( SignalServiceEnvelope envelope , ReceiptMessage content )
303
+ private SignalServiceReceiptMessage CreateReceiptMessage ( SignalServiceEnvelope envelope , ReceiptMessage content )
310
304
{
311
305
SignalServiceReceiptMessage . Type type ;
312
306
@@ -342,6 +336,44 @@ private SignalServiceReceiptMessage createReceiptMessage(SignalServiceEnvelope e
342
336
} ;
343
337
}
344
338
339
+ private SignalServiceDataMessage . SignalServiceQuote CreateQuote ( SignalServiceEnvelope envelope , DataMessage content )
340
+ {
341
+ if ( content . QuoteOneofCase != QuoteOneofOneofCase . Quote )
342
+ return null ;
343
+
344
+ List < SignalServiceAttachment > attachments = new List < SignalServiceAttachment > ( ) ;
345
+
346
+ foreach ( AttachmentPointer pointer in content . Quote . Attachments )
347
+ {
348
+ attachments . Add ( CreateAttachmentPointer ( envelope , pointer ) ) ;
349
+ }
350
+
351
+ return new SignalServiceDataMessage . SignalServiceQuote ( ( long ) content . Quote . Id ,
352
+ new SignalServiceAddress ( content . Quote . Author ) ,
353
+ content . Quote . Text ,
354
+ attachments ) ;
355
+ }
356
+
357
+ private SignalServiceAttachmentPointer CreateAttachmentPointer ( SignalServiceEnvelope envelope , AttachmentPointer pointer )
358
+ {
359
+ uint ? size = null ;
360
+ if ( pointer . SizeOneofCase == AttachmentPointer . SizeOneofOneofCase . Size )
361
+ {
362
+ size = pointer . Size ;
363
+ }
364
+ return new SignalServiceAttachmentPointer ( pointer . Id ,
365
+ pointer . ContentType ,
366
+ pointer . Key . ToByteArray ( ) ,
367
+ envelope . getRelay ( ) ,
368
+ size ,
369
+ pointer . ThumbnailOneofCase == AttachmentPointer . ThumbnailOneofOneofCase . Thumbnail ? pointer . Thumbnail . ToByteArray ( ) : null ,
370
+ ( int ) pointer . Width ,
371
+ ( int ) pointer . Height ,
372
+ pointer . DigestOneofCase == AttachmentPointer . DigestOneofOneofCase . Digest ? pointer . Digest . ToByteArray ( ) : null ,
373
+ pointer . FileNameOneofCase == AttachmentPointer . FileNameOneofOneofCase . FileName ? pointer . FileName : null ,
374
+ ( pointer . Flags & ( uint ) AttachmentPointer . Types . Flags . VoiceMessage ) != 0 ) ;
375
+ }
376
+
345
377
private SignalServiceGroup CreateGroupInfo ( SignalServiceEnvelope envelope , DataMessage content )
346
378
{
347
379
if ( content . GroupOneofCase == DataMessage . GroupOneofOneofCase . None ) return null ;
0 commit comments