add JsonPayment (#808)
This commit is contained in:
		
							parent
							
								
									d13d150fe1
								
							
						
					
					
						commit
						5cd5697aea
					
				@ -538,6 +538,16 @@
 | 
				
			|||||||
  "allDeclaredMethods":true,
 | 
					  "allDeclaredMethods":true,
 | 
				
			||||||
  "allDeclaredConstructors":true}
 | 
					  "allDeclaredConstructors":true}
 | 
				
			||||||
,
 | 
					,
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  "name":"org.asamk.signal.json.JsonPayment",
 | 
				
			||||||
 | 
					  "allDeclaredFields":true,
 | 
				
			||||||
 | 
					  "queryAllDeclaredMethods":true,
 | 
				
			||||||
 | 
					  "queryAllDeclaredConstructors":true,
 | 
				
			||||||
 | 
					  "methods":[
 | 
				
			||||||
 | 
					    {"name":"note","parameterTypes":[] }, 
 | 
				
			||||||
 | 
					    {"name":"receipt","parameterTypes":[] }
 | 
				
			||||||
 | 
					  ]}
 | 
				
			||||||
 | 
					,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  "name":"org.asamk.signal.json.JsonQuote",
 | 
					  "name":"org.asamk.signal.json.JsonQuote",
 | 
				
			||||||
  "allDeclaredFields":true,
 | 
					  "allDeclaredFields":true,
 | 
				
			||||||
@ -2216,6 +2226,29 @@
 | 
				
			|||||||
    {"name":"eraId_"}
 | 
					    {"name":"eraId_"}
 | 
				
			||||||
  ]}
 | 
					  ]}
 | 
				
			||||||
,
 | 
					,
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  "name":"org.whispersystems.signalservice.internal.push.SignalServiceProtos$DataMessage$Payment",
 | 
				
			||||||
 | 
					  "fields":[
 | 
				
			||||||
 | 
					    {"name":"itemCase_"}, 
 | 
				
			||||||
 | 
					    {"name":"item_"}
 | 
				
			||||||
 | 
					  ]}
 | 
				
			||||||
 | 
					,
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  "name":"org.whispersystems.signalservice.internal.push.SignalServiceProtos$DataMessage$Payment$Notification",
 | 
				
			||||||
 | 
					  "fields":[
 | 
				
			||||||
 | 
					    {"name":"bitField0_"}, 
 | 
				
			||||||
 | 
					    {"name":"note_"}, 
 | 
				
			||||||
 | 
					    {"name":"transactionCase_"}, 
 | 
				
			||||||
 | 
					    {"name":"transaction_"}
 | 
				
			||||||
 | 
					  ]}
 | 
				
			||||||
 | 
					,
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  "name":"org.whispersystems.signalservice.internal.push.SignalServiceProtos$DataMessage$Payment$Notification$MobileCoin",
 | 
				
			||||||
 | 
					  "fields":[
 | 
				
			||||||
 | 
					    {"name":"bitField0_"}, 
 | 
				
			||||||
 | 
					    {"name":"receipt_"}
 | 
				
			||||||
 | 
					  ]}
 | 
				
			||||||
 | 
					,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  "name":"org.whispersystems.signalservice.internal.push.SignalServiceProtos$DataMessage$Preview",
 | 
					  "name":"org.whispersystems.signalservice.internal.push.SignalServiceProtos$DataMessage$Preview",
 | 
				
			||||||
  "fields":[
 | 
					  "fields":[
 | 
				
			||||||
 | 
				
			|||||||
@ -101,6 +101,7 @@ public record MessageEnvelope(
 | 
				
			|||||||
            boolean hasProfileKey,
 | 
					            boolean hasProfileKey,
 | 
				
			||||||
            Optional<Reaction> reaction,
 | 
					            Optional<Reaction> reaction,
 | 
				
			||||||
            Optional<Quote> quote,
 | 
					            Optional<Quote> quote,
 | 
				
			||||||
 | 
					            Optional<Payment> payment,
 | 
				
			||||||
            List<Attachment> attachments,
 | 
					            List<Attachment> attachments,
 | 
				
			||||||
            Optional<Long> remoteDeleteId,
 | 
					            Optional<Long> remoteDeleteId,
 | 
				
			||||||
            Optional<Sticker> sticker,
 | 
					            Optional<Sticker> sticker,
 | 
				
			||||||
@ -130,6 +131,9 @@ public record MessageEnvelope(
 | 
				
			|||||||
                    Optional.ofNullable(dataMessage.getQuote()
 | 
					                    Optional.ofNullable(dataMessage.getQuote()
 | 
				
			||||||
                            .transform(q -> Quote.from(q, recipientResolver, addressResolver, fileProvider))
 | 
					                            .transform(q -> Quote.from(q, recipientResolver, addressResolver, fileProvider))
 | 
				
			||||||
                            .orNull()),
 | 
					                            .orNull()),
 | 
				
			||||||
 | 
					                    Optional.ofNullable(dataMessage.getPayment()
 | 
				
			||||||
 | 
					                            .transform(p -> p.getPaymentNotification().isPresent() ? Payment.from(p) : null)
 | 
				
			||||||
 | 
					                            .orNull()),
 | 
				
			||||||
                    dataMessage.getAttachments()
 | 
					                    dataMessage.getAttachments()
 | 
				
			||||||
                            .transform(a -> a.stream()
 | 
					                            .transform(a -> a.stream()
 | 
				
			||||||
                                    .map(as -> Attachment.from(as, fileProvider))
 | 
					                                    .map(as -> Attachment.from(as, fileProvider))
 | 
				
			||||||
@ -229,6 +233,12 @@ public record MessageEnvelope(
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public record Payment(String note, byte[] receipt) {
 | 
				
			||||||
 | 
					            static Payment from(SignalServiceDataMessage.Payment payment) {
 | 
				
			||||||
 | 
					                return new Payment(payment.getPaymentNotification().get().getNote(), payment.getPaymentNotification().get().getReceipt());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public record Mention(RecipientAddress recipient, int start, int length) {
 | 
					        public record Mention(RecipientAddress recipient, int start, int length) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            static Mention from(
 | 
					            static Mention from(
 | 
				
			||||||
 | 
				
			|||||||
@ -680,6 +680,7 @@ public class DbusManagerImpl implements Manager {
 | 
				
			|||||||
                                false,
 | 
					                                false,
 | 
				
			||||||
                                Optional.empty(),
 | 
					                                Optional.empty(),
 | 
				
			||||||
                                Optional.empty(),
 | 
					                                Optional.empty(),
 | 
				
			||||||
 | 
					                                Optional.empty(),
 | 
				
			||||||
                                getAttachments(extras),
 | 
					                                getAttachments(extras),
 | 
				
			||||||
                                Optional.empty(),
 | 
					                                Optional.empty(),
 | 
				
			||||||
                                Optional.empty(),
 | 
					                                Optional.empty(),
 | 
				
			||||||
@ -749,6 +750,7 @@ public class DbusManagerImpl implements Manager {
 | 
				
			|||||||
                                        false,
 | 
					                                        false,
 | 
				
			||||||
                                        Optional.empty(),
 | 
					                                        Optional.empty(),
 | 
				
			||||||
                                        Optional.empty(),
 | 
					                                        Optional.empty(),
 | 
				
			||||||
 | 
					                                        Optional.empty(),
 | 
				
			||||||
                                        getAttachments(extras),
 | 
					                                        getAttachments(extras),
 | 
				
			||||||
                                        Optional.empty(),
 | 
					                                        Optional.empty(),
 | 
				
			||||||
                                        Optional.empty(),
 | 
					                                        Optional.empty(),
 | 
				
			||||||
 | 
				
			|||||||
@ -15,6 +15,7 @@ record JsonDataMessage(
 | 
				
			|||||||
        @JsonInclude(JsonInclude.Include.NON_NULL) Boolean viewOnce,
 | 
					        @JsonInclude(JsonInclude.Include.NON_NULL) Boolean viewOnce,
 | 
				
			||||||
        @JsonInclude(JsonInclude.Include.NON_NULL) JsonReaction reaction,
 | 
					        @JsonInclude(JsonInclude.Include.NON_NULL) JsonReaction reaction,
 | 
				
			||||||
        @JsonInclude(JsonInclude.Include.NON_NULL) JsonQuote quote,
 | 
					        @JsonInclude(JsonInclude.Include.NON_NULL) JsonQuote quote,
 | 
				
			||||||
 | 
					        @JsonInclude(JsonInclude.Include.NON_NULL) JsonPayment payment,
 | 
				
			||||||
        @JsonInclude(JsonInclude.Include.NON_NULL) List<JsonMention> mentions,
 | 
					        @JsonInclude(JsonInclude.Include.NON_NULL) List<JsonMention> mentions,
 | 
				
			||||||
        @JsonInclude(JsonInclude.Include.NON_NULL) List<JsonAttachment> attachments,
 | 
					        @JsonInclude(JsonInclude.Include.NON_NULL) List<JsonAttachment> attachments,
 | 
				
			||||||
        @JsonInclude(JsonInclude.Include.NON_NULL) JsonSticker sticker,
 | 
					        @JsonInclude(JsonInclude.Include.NON_NULL) JsonSticker sticker,
 | 
				
			||||||
@ -32,6 +33,7 @@ record JsonDataMessage(
 | 
				
			|||||||
        final var viewOnce = dataMessage.isViewOnce();
 | 
					        final var viewOnce = dataMessage.isViewOnce();
 | 
				
			||||||
        final var reaction = dataMessage.reaction().map(JsonReaction::from).orElse(null);
 | 
					        final var reaction = dataMessage.reaction().map(JsonReaction::from).orElse(null);
 | 
				
			||||||
        final var quote = dataMessage.quote().isPresent() ? JsonQuote.from(dataMessage.quote().get()) : null;
 | 
					        final var quote = dataMessage.quote().isPresent() ? JsonQuote.from(dataMessage.quote().get()) : null;
 | 
				
			||||||
 | 
					        final var payment = dataMessage.payment().isPresent() ? JsonPayment.from(dataMessage.payment().get()) : null;
 | 
				
			||||||
        final var mentions = dataMessage.mentions().size() > 0 ? dataMessage.mentions()
 | 
					        final var mentions = dataMessage.mentions().size() > 0 ? dataMessage.mentions()
 | 
				
			||||||
                .stream()
 | 
					                .stream()
 | 
				
			||||||
                .map(JsonMention::from)
 | 
					                .map(JsonMention::from)
 | 
				
			||||||
@ -55,6 +57,7 @@ record JsonDataMessage(
 | 
				
			|||||||
                viewOnce,
 | 
					                viewOnce,
 | 
				
			||||||
                reaction,
 | 
					                reaction,
 | 
				
			||||||
                quote,
 | 
					                quote,
 | 
				
			||||||
 | 
					                payment,
 | 
				
			||||||
                mentions,
 | 
					                mentions,
 | 
				
			||||||
                attachments,
 | 
					                attachments,
 | 
				
			||||||
                sticker,
 | 
					                sticker,
 | 
				
			||||||
@ -72,6 +75,7 @@ record JsonDataMessage(
 | 
				
			|||||||
                null,
 | 
					                null,
 | 
				
			||||||
                null,
 | 
					                null,
 | 
				
			||||||
                null,
 | 
					                null,
 | 
				
			||||||
 | 
					                null,
 | 
				
			||||||
                messageReceived.getAttachments().stream().map(JsonAttachment::from).collect(Collectors.toList()),
 | 
					                messageReceived.getAttachments().stream().map(JsonAttachment::from).collect(Collectors.toList()),
 | 
				
			||||||
                null,
 | 
					                null,
 | 
				
			||||||
                null,
 | 
					                null,
 | 
				
			||||||
@ -88,6 +92,7 @@ record JsonDataMessage(
 | 
				
			|||||||
                null,
 | 
					                null,
 | 
				
			||||||
                null,
 | 
					                null,
 | 
				
			||||||
                null,
 | 
					                null,
 | 
				
			||||||
 | 
					                null,
 | 
				
			||||||
                messageReceived.getAttachments().stream().map(JsonAttachment::from).collect(Collectors.toList()),
 | 
					                messageReceived.getAttachments().stream().map(JsonAttachment::from).collect(Collectors.toList()),
 | 
				
			||||||
                null,
 | 
					                null,
 | 
				
			||||||
                null,
 | 
					                null,
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										9
									
								
								src/main/java/org/asamk/signal/json/JsonPayment.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								src/main/java/org/asamk/signal/json/JsonPayment.java
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,9 @@
 | 
				
			|||||||
 | 
					package org.asamk.signal.json;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.asamk.signal.manager.api.MessageEnvelope;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public record JsonPayment(String note, byte[] receipt) {
 | 
				
			||||||
 | 
					    static JsonPayment from(MessageEnvelope.Data.Payment payment) {
 | 
				
			||||||
 | 
					        return new JsonPayment(payment.note(), payment.receipt());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user