Skip to content

Commit

Permalink
Merge pull request #1859 from matrix-org/stefan/reportRooms
Browse files Browse the repository at this point in the history
Add RestClient method for reporting rooms through MSC4151
  • Loading branch information
stefanceriu committed Jun 12, 2024
2 parents f03778f + d1836af commit 3052a39
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
15 changes: 15 additions & 0 deletions MatrixSDK/MXRestClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -1583,6 +1583,21 @@ NS_REFINED_FOR_SWIFT;
success:(void (^)(void))success
failure:(void (^)(NSError *error))failure;

/**
Report a room.
@param roomId the id of the room.
@param reason the redaction reason (optional).
@param success A block object called when the operation succeeds.
@param failure A block object called when the operation fails.
@return a MXHTTPOperation instance.
*/
-(MXHTTPOperation *)reportRoom:(NSString *)roomId
reason:(NSString *)reason
success:(void (^)(void))success
failure:(void (^)(NSError *))failure;

/**
Report an event.
Expand Down
23 changes: 23 additions & 0 deletions MatrixSDK/MXRestClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -3091,6 +3091,29 @@ - (MXHTTPOperation*)redactEvent:(NSString*)eventId
}
failure:^(NSError *error) {
MXStrongifyAndReturnIfNil(self);
[self dispatchFailure:error inBlock:failure];
}];
}

-(MXHTTPOperation *)reportRoom:(NSString *)roomId
reason:(NSString *)reason
success:(void (^)(void))success
failure:(void (^)(NSError *))failure
{
NSString *path = [NSString stringWithFormat:@"%@/org.matrix.msc4151/rooms/%@/report", kMXAPIPrefixPathUnstable, roomId];

NSDictionary *parameters = @{ @"reason": reason.length > 0 ? reason : @"" };

MXWeakify(self);
return [httpClient requestWithMethod:@"POST"
path:path
parameters:parameters
success:^(NSDictionary *JSONResponse) {
MXStrongifyAndReturnIfNil(self);
[self dispatchSuccess:success];
}
failure:^(NSError *error) {
MXStrongifyAndReturnIfNil(self);
[self dispatchFailure:error inBlock:failure];
}];
}
Expand Down

0 comments on commit 3052a39

Please sign in to comment.