Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RestClient method for reporting rooms through MSC4151 #1859

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading