Skip to content

Commit f00bc7c

Browse files
committed
bug fixed
1 parent d035d93 commit f00bc7c

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/com/lld/chatapplication/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
<b> Requirements </b>
44

5-
1. Users should be able to add other users to their uniqueUserContact list.
6-
2. Users should be able to create, join or invite other users.
5+
1. Users should be able to add / remove other users to / from their contact list.
6+
2. Users should be able to create, join groups.
77
3. The application should support one-on-one and group chat.
8+
4. Private messages can be sent to a user if the receiver exists in the sender's contact list.
9+
5. Group messages can be sent by any group member to the whole group.
810
4. No need to support features like encryption, media sharing etc.

src/com/lld/chatapplication/service/impl/ChatServiceImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ public void sendGroupMessage(Group group, Message message) throws ServiceExcepti
3838
throw new ServiceException("sender, group and message should be non null");
3939
}
4040

41+
if (!group.getParticipants().contains(message.getSender())) {
42+
throw new ServiceException("The sender " + message.getSender().getName()
43+
+ " is not a member of the group: " + group.getName());
44+
}
45+
4146
this.conversationService.addMessage(group, message);
4247
}
4348
}

0 commit comments

Comments
 (0)