File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 17
17
}
18
18
19
19
- (void )retrieveMessageArchiveWithFields : (NSArray *)fields withResultSet : (XMPPResultSet *)resultSet ;
20
+ - (void )retrieveMessageArchiveAt : (XMPPJID *)archiveJID withFields : (NSArray *)fields withResultSet : (XMPPResultSet *)resultSet ;
20
21
- (void )retrieveFormFields ;
21
22
+ (NSXMLElement *)fieldWithVar : (NSString *)var type : (NSString *)type andValue : (NSString *)value ;
22
23
Original file line number Diff line number Diff line change @@ -20,10 +20,18 @@ @interface XMPPMessageArchiveManagement()
20
20
@implementation XMPPMessageArchiveManagement
21
21
22
22
- (void )retrieveMessageArchiveWithFields : (NSArray *)fields withResultSet : (XMPPResultSet *)resultSet {
23
+ [self retrieveMessageArchiveAt: nil withFields: fields withResultSet: resultSet];
24
+ }
25
+
26
+ - (void )retrieveMessageArchiveAt : (XMPPJID *)archiveJID withFields : (NSArray *)fields withResultSet : (XMPPResultSet *)resultSet {
23
27
dispatch_block_t block = ^{
24
28
25
29
XMPPIQ *iq = [XMPPIQ iqWithType: @" set" ];
26
30
[iq addAttributeWithName: @" id" stringValue: [XMPPStream generateUUID ]];
31
+
32
+ if (archiveJID) {
33
+ [iq addAttributeWithName: @" to" stringValue: [archiveJID full ]];
34
+ }
27
35
28
36
self.queryID = [XMPPStream generateUUID ];
29
37
Original file line number Diff line number Diff line change @@ -92,6 +92,30 @@ - (void)testRetriveMessageArchiveWithFields {
92
92
}];
93
93
}
94
94
95
+ - (void )testRetrieveTargetedMessageArchive {
96
+ XCTestExpectation *expectation = [self expectationWithDescription: @" Handler IQ with \" to\" " ];
97
+
98
+ XMPPJID *archiveJID = [XMPPJID
jidWithString: @" [email protected] " ];
99
+
100
+ XMPPMockStream *streamTest = [[XMPPMockStream alloc ] init ];
101
+ streamTest.elementReceived = ^void (NSXMLElement *element) {
102
+ XMPPIQ *iq = [XMPPIQ iqFromElement: element];
103
+ XCTAssertEqualObjects ([iq to ], archiveJID);
104
+
105
+ [expectation fulfill ];
106
+ };
107
+
108
+ XMPPMessageArchiveManagement *messageArchiveManagement = [[XMPPMessageArchiveManagement alloc ] init ];
109
+ [messageArchiveManagement activate: streamTest];
110
+ [messageArchiveManagement retrieveMessageArchiveAt: archiveJID withFields: nil withResultSet: nil ];
111
+
112
+ [self waitForExpectationsWithTimeout: 1 handler: ^(NSError * _Nullable error) {
113
+ if (error){
114
+ XCTFail (@" Expectation Failed with error: %@ " , error);
115
+ }
116
+ }];
117
+ }
118
+
95
119
- (void )testDelegateDidReceiveMAMMessage {
96
120
self.delegateExpectation = [self expectationWithDescription: @" Delegate" ];
97
121
You can’t perform that action at this time.
0 commit comments