From 011d0f500dbf213a85e639c7dcdcc9cca2de2b3d Mon Sep 17 00:00:00 2001 From: nekobit Date: Wed, 10 Aug 2022 23:20:09 +0000 Subject: [PATCH] mstdnt_notification_t_to_str FossilOrigin-Name: 32263f1cf39d349d73fafb27f82c0b7d3f23ca101a4a75d5e9233812fac9099c --- include/mastodont_notif_types.h | 8 ++++++++ src/notification.c | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/include/mastodont_notif_types.h b/include/mastodont_notif_types.h index 662901a..d96b72a 100644 --- a/include/mastodont_notif_types.h +++ b/include/mastodont_notif_types.h @@ -32,4 +32,12 @@ typedef uint16_t mstdnt_notification_t; +/** + * Turns a notification type into a string + * + * @param type Notification type. + * @return String literal representing type, e.g. 'follow', 'follow request' + */ +const char* mstdnt_notification_t_to_str(mstdnt_notification_t type); + #endif /* MASTODONT_NOTIF_TYPES */ diff --git a/src/notification.c b/src/notification.c index 773cb90..6488f62 100644 --- a/src/notification.c +++ b/src/notification.c @@ -144,3 +144,22 @@ void mstdnt_cleanup_notification(struct mstdnt_notification* notif) } } +const char* mstdnt_notification_t_to_str(mstdnt_notification_t type) +{ + switch (type) + { + case MSTDNT_NOTIFICATION_FOLLOW: return "follow"; + case MSTDNT_NOTIFICATION_FOLLOW_REQUEST: return "follow request"; + case MSTDNT_NOTIFICATION_MENTION: return "mention"; + case MSTDNT_NOTIFICATION_REBLOG: return "reblog"; + case MSTDNT_NOTIFICATION_FAVOURITE: return "favourite"; + case MSTDNT_NOTIFICATION_POLL: return "poll"; + case MSTDNT_NOTIFICATION_STATUS: return "status"; + case MSTDNT_NOTIFICATION_EMOJI_REACT: return "emoji reaction"; + case MSTDNT_NOTIFICATION_CHAT_MENTION: return "chat mention"; + case MSTDNT_NOTIFICATION_REPORT: return "report"; + case MSTDNT_NOTIFICATION_NOOP: + default: + return "unknown"; + } +}