InsertAddressBook implements POST /local/insert/addressBook
( req *http.Request, profileAPI userapi.ClientUserAPI, )
| 92 | |
| 93 | // InsertAddressBook implements POST /local/insert/addressBook |
| 94 | func InsertAddressBook( |
| 95 | req *http.Request, profileAPI userapi.ClientUserAPI, |
| 96 | ) util.JSONResponse { |
| 97 | r := struct { |
| 98 | Localpart string `json:"localpart"` |
| 99 | FriendLocalpart []string `json:"friend_localpart"` |
| 100 | }{} |
| 101 | if resErr := httputil.UnmarshalJSONRequest(req, &r); resErr != nil { |
| 102 | return *resErr |
| 103 | } |
| 104 | if r.Localpart == "" || len(r.FriendLocalpart) == 0 { |
| 105 | return util.JSONResponse{ |
| 106 | Code: http.StatusBadRequest, |
| 107 | JSON: jsonerror.BadJSON("'localpart' and 'friend_localpart' must be supplied."), |
| 108 | } |
| 109 | } |
| 110 | err := profileAPI.InsertAddressBook(req.Context(), r.Localpart, r.FriendLocalpart) |
| 111 | if err != nil { |
| 112 | return util.JSONResponse{ |
| 113 | Code: http.StatusBadRequest, |
| 114 | JSON: jsonerror.BadJSON("InsertAddressBook err."), |
| 115 | } |
| 116 | } |
| 117 | return util.JSONResponse{ |
| 118 | Code: http.StatusOK, |
| 119 | JSON: struct{}{}, |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | // AddTelNumbers implements POST /local/add/telNumbers |
| 124 | func AddTelNumbers( |
no test coverage detected