Skip to content

Commit 4ea4c74

Browse files
committed
Added gateways and methods in UserDatabase for conversation history-related use cases
Will uncomment after entities/objects are available
1 parent f24cc10 commit 4ea4c74

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

src/main/java/ConvHistGateway.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public interface ConvHistGateway {
2+
// public ArrayList<Message> getConversationHistory(ConvHistDsRequestModel dsRequestModel);
3+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
3+
public interface MsgSenderGateway {
4+
// public void saveMessage(MsgSenderDsRequestModel dsRequestModel);
5+
}

src/main/java/UserDatabase.java

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import java.io.*;
22
import java.util.ArrayList;
33
import java.util.List;
4-
public class UserDatabase implements UserExists, UserRetriever, UserCreator, IRetrieveList, UserModificationGateway{
4+
public class UserDatabase implements UserExists, UserRetriever, UserCreator, IRetrieveList, UserModificationGateway,
5+
ConvHistGateway, MsgSenderGateway {
56
File accounts;
67
List<User> accountList;
78
public UserDatabase(){
@@ -114,4 +115,36 @@ public void modifyUser(String oldUsername, User modified){
114115
System.out.println("Error");
115116
}
116117
}
118+
119+
// Below two methods are used by conversation history-related interactors
120+
// (Commented as objects are not found)
121+
// /**
122+
// * Pushes a new message to a chat's conversation history (in memory not persisting storage)
123+
// * @param dsRequestModel input data containing user ID, chat ID, message content
124+
// */
125+
// public void saveMessage(MsgSenderDsRequestModel dsRequestModel) {
126+
// String userID = dsRequestModel.getUserID();
127+
// String chatID = dsRequestModel.getChatID();
128+
// Message message = dsRequestModel.getMessage();
129+
//
130+
// // Find chat under specified User
131+
// Chat chat = this.getUser(userID).getChat(chatID);
132+
//
133+
// chat.addMessage(message);
134+
// }
135+
//
136+
// /**
137+
// * Gets a chat's conversation history (from memory not persisting storage)
138+
// * @param dsRequestModel input data containing user ID, chat ID
139+
// * @return a chat's conversation history
140+
// */
141+
// public ArrayList<Message> getConversationHistory(ConvHistDsRequestModel dsRequestModel) {
142+
// String userID = dsRequestModel.getUserID();
143+
// String chatID = dsRequestModel.getChatID();
144+
//
145+
// // Find chat under specified User
146+
// Chat chat = this.getUser(userID).getChat(chatID);
147+
//
148+
// return Chat.getConversationHistory();
149+
// }
117150
}

0 commit comments

Comments
 (0)