diff options
-rw-r--r-- | store.c | 23 |
1 files changed, 18 insertions, 5 deletions
@@ -108,9 +108,6 @@ static bool filter(struct TdMessage *msg) { } } - if (msg->content_->ID != CODE_MessageText) { - return false; - } return true; } @@ -121,8 +118,24 @@ void store(struct TdMessage *msg, void (*cb)(bool)) { cb(false); return; } - struct TdMessageText *text = (struct TdMessageText *) msg->content_; - const char *t = text->text_->text_; + char *t; + switch (msg->content_->ID) { + case CODE_MessageText: { + struct TdMessageText *text = (struct TdMessageText *) msg->content_; + t = text->text_->text_; + break; + } + case CODE_MessagePhoto: { + struct TdMessagePhoto *photo = (struct TdMessagePhoto *) msg->content_; + if (!photo->caption_ || !photo->caption_->text_) goto f; + t = photo->caption_->text_; + break; + } + default: { + goto f; + } + } + assert(t); struct say *s; if (!(s = malloc(sizeof(struct say)))) { LOGEV("Cannot allocate memory: %s.", strerror(errno)); |