REST - Attachment and Hyperlink
Hello,
I have to redevelopp the "Recent Topics" component and I would like to know if there is a "easy" way" to find if there are attachments and hyperlinks in a thread (as we can see in the current "Recent Topics" component)
Some ideas?
Thanks,
Laurent
Hi Laurent,
To determine if there are attachments for a message would require an additional REST API call. The MessageUploadsContext has an "attachments" method. So basically, you would want to get the results of that call and test for the presence of any attachments in the response. If you don't care about any of the details for these attachments (it sounds like you probably don't), you could even just use the "attachments/count" method instead, and test for whether the count is greater than 0.
As for whether or not there are hyperlinks, that's a bit more tricky. I don't think there are any REST API calls that will really help you out there. Probably the best approach available would be to examine the message body and determine if there are any anchor tags present. There are some Freemarker built-ins that you could use for searching for a given string within the message body, for example:
http://freemarker.sourceforge.net/docs/ref_builtins_string.html#ref_builtin_contains
I hope this helps,
Adam