<p>Thanks, sounds interesting, but I have couple of observations:</p>
<ul>
<li>the module should be named <strong>pua_json</strong> -- being related to presence services, we put first the services group token (see how are the other modules are named, like: presence_<em>, pua_</em>, db_<em>, ndb_</em>)</li>
<li>there are a lot of unsafe<code>sprintf()</code>, they should be replaced with <code>snprintf()</code> -- that will also give the len of the output string, <code>strlen()</code> no longer being needed</li>
<li>if I got it right, the module works directly with the database table <code>presentity</code> from presence modules, (re)defining variables with column names. This is not maintainable in long term, if someone changes the structure of the table in presence module, will have to change in other modules. I think it is better to add a function to presence module for what you need here and export it to the presence api, which in turn is going to be used in this module. The presence module is already exporting an API, so you can just add a new member there</li>
<li>for API functions, I suggest to define a structure instead of a long list of parameters, because if a new value needs to be inserted, the prototype of the API function stays unchanged, only a new member is added to the structure</li>
<li>also the way functions from json module are used inside this module are exposing a risk over the time. You declared them static inline, but if one needs to make them more complex in the future, with use of additional functions inside, then things are going to break. I suggest to do the same approach with exporting the functions in json module through an API, which is imported inside the new module</li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/pull/1408#issuecomment-360279115">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AF36ZXv73ECT87iDNSSgmssEEV1Cr01Yks5tN6BlgaJpZM4RrNKQ">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AF36ZSNGB0AUB4Xz3_kiDXoy3NyhJPsdks5tN6BlgaJpZM4RrNKQ.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/kamailio/kamailio/pull/1408#issuecomment-360279115"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>

<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/kamailio/kamailio","title":"kamailio/kamailio","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/kamailio/kamailio"}},"updates":{"snippets":[{"icon":"PERSON","message":"@miconda in #1408: Thanks, sounds interesting, but I have couple of observations:\r\n\r\n  * the module should be named **pua_json** -- being related to presence services, we put first the services group token (see how are the other modules are named, like: presence_*, pua_*, db_*, ndb_*)\r\n  * there are a lot of unsafe`sprintf()`, they should be replaced with `snprintf()` -- that will also give the len of the output string, `strlen()` no longer being needed\r\n  * if I got it right, the module works directly with the database table `presentity` from presence modules, (re)defining variables with column names. This is not maintainable in long term, if someone changes the structure of the table in presence module, will have to change in other modules. I think it is better to add a function to presence module for what you need here and export it to the presence api, which in turn is going to be used in this module. The presence module is already exporting an API, so you can just add a new member there\r\n  * for API functions, I suggest to define a structure instead of a long list of parameters, because if a new value needs to be inserted, the prototype of the API function stays unchanged, only a new member is added to the structure\r\n  * also the way functions from json module are used inside this module are exposing a risk over the time. You declared them static inline, but if one needs to make them more complex in the future, with use of additional functions inside, then things are going to break. I suggest to do the same approach with exporting the functions in json module through an API, which is imported inside the new module"}],"action":{"name":"View Pull Request","url":"https://github.com/kamailio/kamailio/pull/1408#issuecomment-360279115"}}}</script>