forked from dylex/slack-libpurple
-
Notifications
You must be signed in to change notification settings - Fork 2
/
slack-conversation.h
37 lines (30 loc) · 1.08 KB
/
slack-conversation.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef _PURPLE_SLACK_CONVERSATION_H
#define _PURPLE_SLACK_CONVERSATION_H
#include "json.h"
#include "slack.h"
#include "slack-object.h"
#include "slack-channel.h"
#include "slack-user.h"
static inline const char *slack_conversation_id(SlackObject *chan) {
g_return_val_if_fail(chan, NULL);
if (SLACK_IS_CHANNEL(chan))
return chan->id;
if (SLACK_IS_USER(chan))
return ((SlackUser*)chan)->im;
return NULL;
}
static inline SlackObject *slack_conversation_lookup_id(SlackAccount *sa, const slack_object_id id) {
return g_hash_table_lookup(sa->channels, id) ?: g_hash_table_lookup(sa->ims, id);
}
static inline SlackObject *slack_conversation_lookup_sid(SlackAccount *sa, const char *sid) {
if (!sid)
return NULL;
slack_object_id id;
slack_object_id_set(id, sid);
return slack_conversation_lookup_id(sa, id);
}
/* Initialization */
void slack_conversations_load(SlackAccount *sa);
SlackObject *slack_conversation_get_conversation(SlackAccount *sa, PurpleConversation *conv);
void slack_mark_conversation(SlackAccount *sa, PurpleConversation *conv);
#endif // _PURPLE_SLACK_CONVERSATION_H