diff options
Diffstat (limited to 'toxcore/Messenger.c')
-rw-r--r-- | toxcore/Messenger.c | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 55464cb5..1809fc4c 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -194,7 +194,7 @@ static int32_t init_new_friend(Messenger *m, const uint8_t *real_pk, uint8_t sta | |||
194 | int friendcon_id = new_friend_connection(m->fr_c, real_pk); | 194 | int friendcon_id = new_friend_connection(m->fr_c, real_pk); |
195 | 195 | ||
196 | if (friendcon_id == -1) | 196 | if (friendcon_id == -1) |
197 | return FAERR_UNKNOWN; | 197 | return FAERR_NOMEM; |
198 | 198 | ||
199 | uint32_t i; | 199 | uint32_t i; |
200 | 200 | ||
@@ -227,7 +227,7 @@ static int32_t init_new_friend(Messenger *m, const uint8_t *real_pk, uint8_t sta | |||
227 | } | 227 | } |
228 | } | 228 | } |
229 | 229 | ||
230 | return FAERR_UNKNOWN; | 230 | return FAERR_NOMEM; |
231 | } | 231 | } |
232 | 232 | ||
233 | /* | 233 | /* |
@@ -241,7 +241,6 @@ static int32_t init_new_friend(Messenger *m, const uint8_t *real_pk, uint8_t sta | |||
241 | * return FAERR_NOMESSAGE if no message (message length must be >= 1 byte). | 241 | * return FAERR_NOMESSAGE if no message (message length must be >= 1 byte). |
242 | * return FAERR_OWNKEY if user's own key. | 242 | * return FAERR_OWNKEY if user's own key. |
243 | * return FAERR_ALREADYSENT if friend request already sent or already a friend. | 243 | * return FAERR_ALREADYSENT if friend request already sent or already a friend. |
244 | * return FAERR_UNKNOWN for unknown error. | ||
245 | * return FAERR_BADCHECKSUM if bad checksum in address. | 244 | * return FAERR_BADCHECKSUM if bad checksum in address. |
246 | * return FAERR_SETNEWNOSPAM if the friend was already there but the nospam was different. | 245 | * return FAERR_SETNEWNOSPAM if the friend was already there but the nospam was different. |
247 | * (the nospam for that friend was set to the new one). | 246 | * (the nospam for that friend was set to the new one). |
@@ -303,21 +302,15 @@ int32_t m_addfriend(Messenger *m, const uint8_t *address, const uint8_t *data, u | |||
303 | int32_t m_addfriend_norequest(Messenger *m, const uint8_t *real_pk) | 302 | int32_t m_addfriend_norequest(Messenger *m, const uint8_t *real_pk) |
304 | { | 303 | { |
305 | if (getfriend_id(m, real_pk) != -1) | 304 | if (getfriend_id(m, real_pk) != -1) |
306 | return -1; | 305 | return FAERR_ALREADYSENT; |
307 | 306 | ||
308 | if (!public_key_valid(real_pk)) | 307 | if (!public_key_valid(real_pk)) |
309 | return -1; | 308 | return FAERR_BADCHECKSUM; |
310 | 309 | ||
311 | if (id_equal(real_pk, m->net_crypto->self_public_key)) | 310 | if (id_equal(real_pk, m->net_crypto->self_public_key)) |
312 | return -1; | 311 | return FAERR_OWNKEY; |
313 | |||
314 | int32_t ret = init_new_friend(m, real_pk, FRIEND_CONFIRMED); | ||
315 | 312 | ||
316 | if (ret < 0) { | 313 | return init_new_friend(m, real_pk, FRIEND_CONFIRMED); |
317 | return -1; | ||
318 | } else { | ||
319 | return ret; | ||
320 | } | ||
321 | } | 314 | } |
322 | 315 | ||
323 | /* Remove a friend. | 316 | /* Remove a friend. |