tsk-54: Tweak instant message endpoint to save contact and message identification (#56)
Closes #54 Reviewed-on: phoenix/textsender-api#56 Co-authored-by: phoenix <kundeng00@pm.me> Co-committed-by: phoenix <kundeng00@pm.me>
This commit is contained in:
@@ -54,14 +54,14 @@ func (c *ContactHandler) AddContact(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
defer r.Body.Close()
|
||||
|
||||
newContact := contact.Contact{PhoneNumber: req.PhoneNumber, UserId: req.UserId}
|
||||
newContact := contact.Contact{PhoneNumber: req.PhoneNumber, UserId: &req.UserId}
|
||||
|
||||
var statusCode int
|
||||
var resp AddContactResponse
|
||||
|
||||
ctx := r.Context()
|
||||
|
||||
if exists, err := c.ContactStore.ContactExists(ctx, newContact.PhoneNumber, newContact.UserId); err != nil {
|
||||
if exists, err := c.ContactStore.ContactExists(ctx, newContact.PhoneNumber, *newContact.UserId); err != nil {
|
||||
fmt.Printf("Error: %v", err)
|
||||
statusCode = http.StatusInternalServerError
|
||||
resp.Message = err.Error()
|
||||
@@ -157,7 +157,7 @@ func (c *ContactHandler) GetContact(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Println("Checking with User Id")
|
||||
if contacts, err := c.ContactStore.GetAllContacts(ctx); err == nil {
|
||||
for _, con := range contacts {
|
||||
if con.UserId == userId {
|
||||
if *con.UserId == userId {
|
||||
resp.Data = append(resp.Data, *con)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user