Browse code

Merge pull request #247 from kamailio/vseva/pua_reginfo

pua_reginfo: fix NOTIFY xml

ng-voice GmbH authored on 15/07/2015 19:36:04
Showing 1 changed files
... ...
@@ -101,10 +101,14 @@ str* build_reginfo_full(urecord_t * record, str uri, ucontact_t* c, int type) {
101 101
 	snprintf(buf, sizeof(buf), "%p", record);
102 102
 	xmlNewProp(registration_node, BAD_CAST "id", BAD_CAST buf);
103 103
 
104
+	LM_DBG("Updated Contact %.*s[%.*s]\n", c->c.len, c->c.s,
105
+		c->ruid.len, c->ruid.s);
106
+
104 107
 	ptr = record->contacts;
105 108
 	while (ptr) {
106 109
 		if (VALID_CONTACT(ptr, cur_time)) {
107
-			LM_DBG("Contact %.*s, %p\n", ptr->c.len, ptr->c.s, ptr);
110
+			LM_DBG("Contact %.*s[%.*s]\n", ptr->c.len, ptr->c.s,
111
+				ptr->ruid.len, ptr->ruid.s);
108 112
 			/* Contact-Node */
109 113
 			contact_node =xmlNewChild(registration_node, NULL, BAD_CAST "contact", NULL) ;
110 114
 			if( contact_node ==NULL) {
... ...
@@ -115,7 +119,9 @@ str* build_reginfo_full(urecord_t * record, str uri, ucontact_t* c, int type) {
115 119
 			snprintf(buf, sizeof(buf), "%p", ptr);
116 120
 			xmlNewProp(contact_node, BAD_CAST "id", BAD_CAST buf);
117 121
 			/* Check, if this is the modified contact: */
118
-			if (ptr == c) {
122
+			if ((c->ruid.len == ptr->ruid.len) &&
123
+				!memcmp(c->ruid.s, ptr->ruid.s, c->ruid.len))
124
+			{
119 125
 				if ((type & UL_CONTACT_INSERT) || (type & UL_CONTACT_UPDATE)) {
120 126
 					reg_active = 1;
121 127
 					xmlNewProp(contact_node, BAD_CAST "state", BAD_CAST "active");
... ...
@@ -218,9 +224,9 @@ void reginfo_usrloc_cb(ucontact_t* c, int type, void* param) {
218 224
 	str content_type;
219 225
 	udomain_t * domain;
220 226
 	urecord_t * record;
227
+	ucontact_t* _c = NULL;
221 228
 	int res;
222 229
 	str uri = {NULL, 0};
223
-	str user = {NULL, 0};
224 230
 
225 231
 	char* at = NULL;
226 232
 	char id_buf[512];
... ...
@@ -245,9 +251,6 @@ void reginfo_usrloc_cb(ucontact_t* c, int type, void* param) {
245 251
 		LM_ERR("Unknown Type %i\n", type);
246 252
 		return;
247 253
 	}
248
-	/* make a local copy of the AOR */
249
-	user.len = c->aor->len;
250
-	user.s = c->aor->s;
251 254
 
252 255
 	/* Get the UDomain for this account */
253 256
 	res = ul.get_udomain(c->domain->s, &domain);
... ...
@@ -256,10 +259,11 @@ void reginfo_usrloc_cb(ucontact_t* c, int type, void* param) {
256 259
 		return;
257 260
 	}
258 261
 
259
-	/* Get the URecord for this AOR */
260
-	res = ul.get_urecord(domain, &user, &record);
261
-	if (res > 0) {
262
-		LM_ERR("' %.*s (%.*s)' Not found in usrloc\n", c->aor->len, c->aor->s, c->domain->len, c->domain->s);
262
+	/* Get the URecord for this ruid */
263
+	res = ul.get_urecord_by_ruid(domain, ul.get_aorhash(c->aor), &(c->ruid),
264
+		&record, &_c);
265
+	if (res < 0) {
266
+		LM_ERR("'%.*s (%.*s)' Not found in usrloc\n", c->aor->len, c->aor->s, c->domain->len, c->domain->s);
263 267
 		return;
264 268
 	}
265 269