X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fhttp%2Fpages%2Fannounceidentitypage.cpp;h=32a13cc0546970081125a06afa5a0a79b5650438;hb=befd91205eff729a182f66de15374a577a8718f7;hp=710904c274b9f61ec2b6bb98c77c1613120fd007;hpb=b9c3763a932cebaa015a27fe111017f6f34dfbaa;p=fms.git diff --git a/src/http/pages/announceidentitypage.cpp b/src/http/pages/announceidentitypage.cpp index 710904c..32a13cc 100644 --- a/src/http/pages/announceidentitypage.cpp +++ b/src/http/pages/announceidentitypage.cpp @@ -18,12 +18,18 @@ const std::string AnnounceIdentityPage::CreateLocalIdentityDropDown(const std::s std::string id; std::string name; std::string pubkey; + std::string keypart=""; st.ResultText(0,id); st.ResultText(1,name); st.ResultText(2,pubkey); - rval+=""; + if(pubkey.size()>8) + { + keypart=pubkey.substr(3,5); + } + + rval+=""; st.Step(); } rval+=""; @@ -40,6 +46,8 @@ const std::string AnnounceIdentityPage::GeneratePage(const std::string &method, std::string lastid=""; std::string thisid=""; std::string day=""; + int requestindex=0; + bool willshow=false; if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="announce") { @@ -81,14 +89,13 @@ const std::string AnnounceIdentityPage::GeneratePage(const std::string &method, content+="
Select Identity : "; content+=CreateLocalIdentityDropDown("localidentityid",""); content+=""; - content+="
Type the answers of a few puzzles"; + content+="
Type the answers of a few puzzles. The puzzles are case sensitive. Getting announced will take some time. DO NOT continuously solve captchas. Solve 30 at most, wait a day, and if your identity has not been announced, repeat until it is."; content+=""; - //TODO if we are already inserting a solution for an identity - we shouldn't select any puzzles that are older than the one we are inserting date.SetToGMTime(); date.Add(0,0,0,-1); - SQLite3DB::Statement st=m_db->Prepare("SELECT UUID,Day,IdentityID FROM tblIntroductionPuzzleRequests WHERE UUID NOT IN (SELECT UUID FROM tblIdentityIntroductionInserts) AND UUID NOT IN (SELECT UUID FROM tblIntroductionPuzzleInserts) AND Day>='"+date.Format("%Y-%m-%d")+"' AND Found='true' ORDER BY IdentityID, Day DESC, RequestIndex DESC;"); + SQLite3DB::Statement st=m_db->Prepare("SELECT UUID,Day,IdentityID,RequestIndex FROM tblIntroductionPuzzleRequests WHERE UUID NOT IN (SELECT UUID FROM tblIdentityIntroductionInserts) AND UUID NOT IN (SELECT UUID FROM tblIntroductionPuzzleInserts) AND Day>='"+date.Format("%Y-%m-%d")+"' AND Found='true' ORDER BY IdentityID, Day DESC, RequestIndex DESC;"); st.Step(); if(st.RowReturned()==false) @@ -101,8 +108,25 @@ const std::string AnnounceIdentityPage::GeneratePage(const std::string &method, st.ResultText(0,uuid); st.ResultText(1,day); st.ResultText(2,thisid); + st.ResultInt(3,requestindex); + + // if we are already inserting a solution for an identity - we shouldn't show any puzzles that are older than the one we are inserting + // get the last index # we are inserting this day from this identity + // if the index here is greater than the index in the st statement, we will skip this puzzle because we are already inserting a puzzle with a greater index + willshow=true; + SQLite3DB::Statement st2=m_db->Prepare("SELECT MAX(RequestIndex) FROM tblIdentityIntroductionInserts INNER JOIN tblIntroductionPuzzleRequests ON tblIdentityIntroductionInserts.UUID=tblIntroductionPuzzleRequests.UUID WHERE tblIdentityIntroductionInserts.Day=? AND tblIdentityIntroductionInserts.UUID IN (SELECT UUID FROM tblIntroductionPuzzleRequests WHERE IdentityID=? AND Day=?) GROUP BY tblIdentityIntroductionInserts.Day;"); + st2.Step(); + if(st2.RowReturned()==true) + { + int index=0; + st2.ResultInt(0,index); + if(index>=requestindex) + { + willshow=false; + } + } - if(thisid!=lastid) + if(willshow && thisid!=lastid) { StringFunctions::Convert(shown,countstr); if(shown>0 && shown%4==0) @@ -115,7 +139,7 @@ const std::string AnnounceIdentityPage::GeneratePage(const std::string &method, content+=""; content+=""; content+="\r\n"; - thisid=lastid; + lastid=thisid; shown++; }