diff options
author | TheJackiMonster <thejackimonster@gmail.com> | 2024-01-20 10:51:00 +0100 |
---|---|---|
committer | TheJackiMonster <thejackimonster@gmail.com> | 2024-01-20 10:51:00 +0100 |
commit | 24ebc1a6e2ef727c1ceee2da47834c0737e1745e (patch) | |
tree | b3b0fe8515f5b08ecb1a767ac325fd0b2720136c /src | |
parent | d821d81f7ab2a519ae5df181bb4ac0ba89d47508 (diff) | |
download | gnunet-24ebc1a6e2ef727c1ceee2da47834c0737e1745e.tar.gz gnunet-24ebc1a6e2ef727c1ceee2da47834c0737e1745e.zip |
MESSENGER: Add function to delete messages
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/include/gnunet_messenger_service.h | 16 | ||||
-rw-r--r-- | src/service/messenger/messenger_api.c | 24 | ||||
-rw-r--r-- | src/service/messenger/messenger_api_message.c | 2 |
3 files changed, 40 insertions, 2 deletions
diff --git a/src/include/gnunet_messenger_service.h b/src/include/gnunet_messenger_service.h index e0ccea27a..8e1cd666d 100644 --- a/src/include/gnunet_messenger_service.h +++ b/src/include/gnunet_messenger_service.h | |||
@@ -957,6 +957,22 @@ GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room, | |||
957 | const struct GNUNET_MESSENGER_Contact *contact); | 957 | const struct GNUNET_MESSENGER_Contact *contact); |
958 | 958 | ||
959 | /** | 959 | /** |
960 | * Delete a message identified by its <i>hash</i> from a <i>room</i>. A deletion will be propagated to all members | ||
961 | * of the room as with any other sent message. Notice that a deletion will only request other members of the room | ||
962 | * to delete the selected message. If you are not permitted to delete the message, the deletion will be ignored. | ||
963 | * | ||
964 | * Depending on the implementation other clients may also ignore your deletion request in other circumstances. | ||
965 | * | ||
966 | * @param[in,out] room Room handle | ||
967 | * @param[in] message Message to delete | ||
968 | * @param[in] delay Delay to delete the message | ||
969 | */ | ||
970 | void | ||
971 | GNUNET_MESSENGER_delete_message (struct GNUNET_MESSENGER_Room *room, | ||
972 | const struct GNUNET_HashCode *hash, | ||
973 | const struct GNUNET_TIME_Relative delay); | ||
974 | |||
975 | /** | ||
960 | * Get the message in a <i>room</i> identified by its <i>hash</i>. | 976 | * Get the message in a <i>room</i> identified by its <i>hash</i>. |
961 | * | 977 | * |
962 | * @param[in] room Room handle | 978 | * @param[in] room Room handle |
diff --git a/src/service/messenger/messenger_api.c b/src/service/messenger/messenger_api.c index 2981b1a71..1756ac91b 100644 --- a/src/service/messenger/messenger_api.c +++ b/src/service/messenger/messenger_api.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include "gnunet-service-messenger.h" | 30 | #include "gnunet-service-messenger.h" |
31 | 31 | ||
32 | #include "gnunet_reclaim_service.h" | 32 | #include "gnunet_reclaim_service.h" |
33 | #include "gnunet_time_lib.h" | ||
33 | #include "messenger_api_contact.h" | 34 | #include "messenger_api_contact.h" |
34 | #include "messenger_api_contact_store.h" | 35 | #include "messenger_api_contact_store.h" |
35 | #include "messenger_api_handle.h" | 36 | #include "messenger_api_handle.h" |
@@ -1209,7 +1210,28 @@ GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room, | |||
1209 | else | 1210 | else |
1210 | public_key = NULL; | 1211 | public_key = NULL; |
1211 | 1212 | ||
1212 | send_message_to_room_with_key (room, copy_message(message), public_key); | 1213 | send_message_to_room_with_key (room, copy_message(message), NULL); |
1214 | } | ||
1215 | |||
1216 | |||
1217 | void | ||
1218 | GNUNET_MESSENGER_delete_message (struct GNUNET_MESSENGER_Room *room, | ||
1219 | const struct GNUNET_HashCode *hash, | ||
1220 | const struct GNUNET_TIME_Relative delay) | ||
1221 | { | ||
1222 | if ((! room) || (! hash)) | ||
1223 | return; | ||
1224 | |||
1225 | struct GNUNET_MESSENGER_Message *message = create_message_delete(hash, delay); | ||
1226 | |||
1227 | if (! message) | ||
1228 | { | ||
1229 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1230 | "Sending deletion aborted: Message creation failed!\n"); | ||
1231 | return; | ||
1232 | } | ||
1233 | |||
1234 | send_message_to_room_with_key (room, message, NULL); | ||
1213 | } | 1235 | } |
1214 | 1236 | ||
1215 | 1237 | ||
diff --git a/src/service/messenger/messenger_api_message.c b/src/service/messenger/messenger_api_message.c index 884adabed..f6d8c31f7 100644 --- a/src/service/messenger/messenger_api_message.c +++ b/src/service/messenger/messenger_api_message.c | |||
@@ -1312,7 +1312,7 @@ filter_message_sending (const struct GNUNET_MESSENGER_Message *message) | |||
1312 | case GNUNET_MESSENGER_KIND_PRIVATE: | 1312 | case GNUNET_MESSENGER_KIND_PRIVATE: |
1313 | return GNUNET_NO; // Use #GNUNET_MESSENGER_send_message(...) with a contact instead! | 1313 | return GNUNET_NO; // Use #GNUNET_MESSENGER_send_message(...) with a contact instead! |
1314 | case GNUNET_MESSENGER_KIND_DELETE: | 1314 | case GNUNET_MESSENGER_KIND_DELETE: |
1315 | return GNUNET_YES; | 1315 | return GNUNET_NO; // Use #GNUNET_MESSENGER_delete_message(...) instead! |
1316 | case GNUNET_MESSENGER_KIND_CONNECTION: | 1316 | case GNUNET_MESSENGER_KIND_CONNECTION: |
1317 | return GNUNET_SYSERR; // Reserved for connection handling only! | 1317 | return GNUNET_SYSERR; // Reserved for connection handling only! |
1318 | case GNUNET_MESSENGER_KIND_TICKET: | 1318 | case GNUNET_MESSENGER_KIND_TICKET: |