I have a WIP JavaScript to create a page from a series of user inputs. The new page contains a Page Properties macro with several rows, one of which is a list of users. I'd like to format the users as if they were added to the page by a Mention (optimally, I would also like the mentioned users to be notified).
I am submitting the created links as part of the <content> tag in the storePage request. As of right now, I have tried to do this by mimicing the structure of the <a> tag as displayed in this post (https://answers.atlassian.com/questions/97923/how-can-i-get-the-hover-profiles-to-appear-in-my-user-search-plugin), and also by mirroring the structure of the <a> tag from an existing page on which a user was mentioned, so it looks like:
<a class="confluence-userlink user-mention" data-username="the user's username" href="user's relative profile link" data-linked-resource-id="user's ID" data-linked-resource-type="userinfo" data-base-url="Confluence base path URL">user's full name</a>
Neither of these options fully works. I can see the user's name and the link to their page, but the hover functionality doesn't work (comes up with "user 'undefined' not found") and the user is not notified. The resulting link looks like this:
<a class="url fn confluence-userlink user-mention userlink-1" href="user's full profile link" rel="nofollow">user's full name</a>
For some reason the 'data-linked-resource-id' and 'data-linked-resource-type' properties seem to be removed from the resulting link. Is this what's breaking the hover functionality?
Is there a better way to perform this functionality from a front-end JavaScript? Back-end code isn't an option at this point, and I am not familiar with plugin development.
Community moderators have prevented the ability to post new answers.
if you look at a mention in storage format is not an anchor, but a resource identifier for a user. It looks like the 'user' resource, specified on this page https://confluence.atlassian.com/display/DOC/Confluence+Storage+Format#ConfluenceStorageFormat-Resourceidentifiers
Therefore, to trigger a mention, you need to directly create xhtml storage format (which the storePage json rpc call should be able to handle).
E.g.:
<ac:link><ri:user ri:username="someusername" /></ac:link>
I tried this using both a username and an ID (retrieved via the getUserInformation function) and neither seem to work as expected. I'm receiving an error code 500 with a parsing exception that states 'Unexpected close tag </ac:link>; expected </td>.'
The generated code is wrapped in an HTML table and looks something like this:
<tr><th>Presenters</th><td>ac:link><ri:user ri:userkey="36833446"/></ac:link></td></tr>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.