// TODO : Unclear how big this dataset would be, decide if this should be removed bool RegDB::getUnexpiredContactsInstrument(const string& instrument, int timeNow, Bindings& bindings) const { mongo::BSONObj query = BSON( "instrument" << instrument << "expirationTime" << BSON_GREATER_THAN(timeNow)); mongo::ScopedDbConnection conn(_info.getConnectionString()); auto_ptr<mongo::DBClientCursor> pCursor = conn->query(_info.getNS(), query); if (pCursor.get() && pCursor->more()) { while (pCursor->more()) { bindings.push_back(RegBinding(pCursor->next())); } conn.done(); return true; } conn.done(); return false; }
bool RegDB::getUnexpiredContactsUserContaining(const string& matchIdentity, int timeNow, Bindings& bindings) const { mongo::BSONObj query = BSON("expirationTime" << BSON_GREATER_THAN(timeNow)); mongo::ScopedDbConnection conn(_info.getConnectionString()); auto_ptr<mongo::DBClientCursor> pCursor = conn->query(_info.getNS(), query); if (pCursor.get() && pCursor->more()) { while (pCursor->more()) { RegBinding binding(pCursor->next()); if (binding.getContact().find(matchIdentity) != string::npos) bindings.push_back(binding); } conn.done(); return bindings.size() > 0; } conn.done(); return false; }
bool RegDB::getUnexpiredContactsUser(const string& identity, int timeNow, Bindings& bindings) const { static string gruuPrefix = GRUU_PREFIX; bool isGruu = identity.substr(0, gruuPrefix.size()) == gruuPrefix; mongo::BSONObj query; if (isGruu) { string searchString(identity); searchString += ";"; searchString += SIP_GRUU_URI_PARAM; query = BSON( "gruu" << searchString << "expirationTime" << BSON_GREATER_THAN(timeNow)); } else { query = BSON( "identity" << identity << "expirationTime" << BSON_GREATER_THAN(timeNow)); } mongo::ScopedDbConnection conn(_info.getConnectionString()); auto_ptr<mongo::DBClientCursor> pCursor = conn->query(_info.getNS(), query); if (pCursor.get() && pCursor->more()) { while (pCursor->more()) { bindings.push_back(RegBinding(pCursor->next())); } conn.done(); return true; } conn.done(); return false; }