Module: kamailio Branch: master Commit: 3991350b1acdcd8b3cd575cdbc8932b4f8540e13 URL: https://github.com/kamailio/kamailio/commit/3991350b1acdcd8b3cd575cdbc8932b4...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2024-11-30T10:39:20+01:00
ndb_mongodb: mongoc_collection_command_with_opts() for mongodb_cmd()
- mongoc_collection_command() is deprecated with lib v1.29.0 - GH #4037
---
Modified: src/modules/ndb_mongodb/mongodb_client.c
---
Diff: https://github.com/kamailio/kamailio/commit/3991350b1acdcd8b3cd575cdbc8932b4... Patch: https://github.com/kamailio/kamailio/commit/3991350b1acdcd8b3cd575cdbc8932b4...
---
diff --git a/src/modules/ndb_mongodb/mongodb_client.c b/src/modules/ndb_mongodb/mongodb_client.c index dd48e5d471e..94d1b87500b 100644 --- a/src/modules/ndb_mongodb/mongodb_client.c +++ b/src/modules/ndb_mongodb/mongodb_client.c @@ -274,8 +274,24 @@ int mongodbc_exec_cmd( bson_destroy(&reply); } else { if(emode == 1) { +#if MONGOC_CHECK_VERSION(1, 29, 0) + opts = bson_new(); + ret = mongoc_collection_command_with_opts( + rpl->collection, &command, NULL, opts, &reply, &error); + bson_free(opts); + if(!ret) { + LM_ERR("Failed to run command: %s\n", error.message); + bson_destroy(&command); + goto error_exec; + } + rpl->jsonrpl.s = _ksr_bson_as_json(&reply, NULL); + rpl->jsonrpl.len = (rpl->jsonrpl.s) ? strlen(rpl->jsonrpl.s) : 0; + bson_destroy(&reply); + goto done; +#else rpl->cursor = mongoc_collection_command(rpl->collection, MONGOC_QUERY_NONE, 0, 0, 0, &command, NULL, 0); +#endif } else { #if MONGOC_CHECK_VERSION(1, 5, 0) if(emode == 3) @@ -313,6 +329,10 @@ int mongodbc_exec_cmd( rpl->jsonrpl.len = (rpl->jsonrpl.s) ? strlen(rpl->jsonrpl.s) : 0; }
+#if MONGOC_CHECK_VERSION(1, 29, 0) +done: +#endif + LM_DBG("command result: [[%s]]\n", (rpl->jsonrpl.s) ? rpl->jsonrpl.s : "<null>");