| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -2,6 +2,7 @@ package Messages | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import ( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						"encoding/json" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						"fmt" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						"net/http" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						"net/url" | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						"strings" | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -14,10 +15,10 @@ import ( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					// EncryptedConversationList returns an encrypted list of all Conversations
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					func EncryptedConversationList(w http.ResponseWriter, r *http.Request) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						var ( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							userConversations []Models.UserConversation | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							userSession       Models.Session | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							returnJSON        []byte | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							err               error | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							conversationDetails []Models.UserConversation | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							userSession         Models.Session | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							returnJSON          []byte | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							err                 error | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						userSession, err = Auth.CheckCookie(r) | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -26,7 +27,7 @@ func EncryptedConversationList(w http.ResponseWriter, r *http.Request) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							return | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						userConversations, err = Database.GetUserConversationsByUserId( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						conversationDetails, err = Database.GetUserConversationsByUserId( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							userSession.UserID.String(), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						if err != nil { | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -34,7 +35,7 @@ func EncryptedConversationList(w http.ResponseWriter, r *http.Request) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							return | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						returnJSON, err = json.MarshalIndent(userConversations, "", "  ") | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						returnJSON, err = json.MarshalIndent(conversationDetails, "", "  ") | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						if err != nil { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							http.Error(w, "Error", http.StatusInternalServerError) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							return | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -47,12 +48,14 @@ func EncryptedConversationList(w http.ResponseWriter, r *http.Request) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					// EncryptedConversationDetailsList returns an encrypted list of all  ConversationDetails
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					func EncryptedConversationDetailsList(w http.ResponseWriter, r *http.Request) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						var ( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							userConversations []Models.ConversationDetail | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							query             url.Values | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							conversationIds   []string | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							returnJSON        []byte | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							ok                bool | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							err               error | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							conversationDetails []Models.ConversationDetail | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							detail              Models.ConversationDetail | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							query               url.Values | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							conversationIds     []string | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							returnJSON          []byte | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							i                   int | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							ok                  bool | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							err                 error | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						query = r.URL.Query() | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -65,7 +68,7 @@ func EncryptedConversationDetailsList(w http.ResponseWriter, r *http.Request) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						// TODO: Fix error handling here
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						conversationIds = strings.Split(conversationIds[0], ",") | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						userConversations, err = Database.GetConversationDetailsByIds( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						conversationDetails, err = Database.GetConversationDetailsByIds( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							conversationIds, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						if err != nil { | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -73,7 +76,18 @@ func EncryptedConversationDetailsList(w http.ResponseWriter, r *http.Request) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							return | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						returnJSON, err = json.MarshalIndent(userConversations, "", "  ") | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						for i, detail = range conversationDetails { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if detail.AttachmentID == nil { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								continue | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							conversationDetails[i].Attachment.ImageLink = fmt.Sprintf( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								"http://192.168.1.5:8080/files/%s", | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								detail.Attachment.FilePath, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						returnJSON, err = json.MarshalIndent(conversationDetails, "", "  ") | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						if err != nil { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							http.Error(w, "Error", http.StatusInternalServerError) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							return | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |