Skip to content

Commit 8046dda

Browse files
committed
fix(message): type checking
1 parent 7df3884 commit 8046dda

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

AVOS/Sources/Realtime/IM/Message/LCIMMessage.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ @implementation LCIMMessagePatchedReason
2828
@implementation LCIMMessage
2929

3030
+ (instancetype)messageWithContent:(NSString *)content {
31+
if (content && ![NSString _lc_isTypeOf:content]) {
32+
[NSException raise:NSInvalidArgumentException
33+
format:@"The type of content is not `NSString`."];
34+
}
3135
LCIMMessage *message = [[self alloc] init];
3236
message.content = content;
3337
return message;

AVOS/Sources/Realtime/IM/TypedMessages/LCIMTypedMessage.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ - (NSString *)text
174174

175175
- (void)setText:(NSString *)text
176176
{
177+
if (text && ![NSString _lc_isTypeOf:text]) {
178+
[NSException raise:NSInvalidArgumentException
179+
format:@"The type of text is not `NSString`."];
180+
}
177181
self.messageObject._lctext = text;
178182
}
179183

0 commit comments

Comments
 (0)