void CompatibilityManager::resigner(const shared_ptr<IPortalDatabase> &database, shared_ptr<IdeSession> session) { shared_ptr<ObjectsUser> user = session->getUser(database); if(user != nullptr) { Buffer signature = user->signature; if( (signature.getSize() == 1) && (signature.getAt(0) == 0) ) { // Need re-sign. DataTable result; String sql = String::format(_S("select id,entity_author,author from os_entries where author='%S' union select id,entity_author,author from os_entries where entity_author='%S'").c_str(),user->id->toUTF16().c_str(),user->id->toUTF16().c_str()); database->execute(sql,result); for(uint32 r=0;r<result.rows();r++) { String id = result.get(r,_S("id")); String entityAuthor = result.get(r,_S("entity_author")); String author = result.get(r,_S("author")); shared_ptr<ObjectsIObject> object = database->getPortal()->getObject(database, id.to_ascii()); if(object != nullptr) { LanguageResult acceptable = object->acceptable(database); if(acceptable.empty()) { if( (entityAuthor == user->id->toUTF16()) && (author == user->id->toUTF16()) ) { shared_ptr<ObjectsIRevisionable> revisionable = objects_revisionable_cast(object); if(revisionable != nullptr) { bool done = revisionable->signEntity(session->getPrivateKey(), database->getPortal()->getPortalID()); OS_ASSERT(done); } } if(author == user->id->toUTF16()) { bool done = object->sign(session->getPrivateKey(), database->getPortal()->getPortalID()); OS_ASSERT(done); } LanguageResult result = object->store(database); OS_ASSERT(result.empty()); } } } } } }
LanguageResult ObjectsReputation::acceptable(shared_ptr<IPortalDatabase> database) const { LanguageResult result = EntryBase::acceptable(database); if(result.empty() == false) return result; if(reference->empty()) return LanguageResult("reference_required"); if(IPortalDatabase::getUserReputationID(getAuthor(), reference) != id) return LanguageResult("id_mismatch"); if(getAuthor() == reference) return LanguageResult("autovalutation"); if(score < OS_REPUTATION_MIN || score > OS_REPUTATION_MAX) return LanguageResult("score_outofrange"); return LanguageResult(); }