Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

46
LINES

< > BotCompany Repo | #1011399 // ai_postTriple - posts if triple not in cache yet - returns web.globalID - posts verified unless specified by ai_postTriple_verified

JavaX fragment (include)

static new ThreadLocal<Bool> ai_postTriple_verified;
static new ThreadLocal<Bool> ai_postTriple_recursion;

static S ai_postTriple(T3<S> triple) {
  // check, clean
  
  ping();
  if (triple_anyPartNull(triple)) null;
  triple = trimTriple(triple);
  if (!ai_tripleAllowedToPost(triple)) null; // fail("No");
  
  // existing?

  if (has(triple)) null;
  
  // invalid?
  
  if (has(ai_tripleToInvalid(triple))) null;
  
  // post verified?
  
  bool ver = !isFalse(ai_postTriple_verified!);

  // post handler?
  
  AI_PostHandler handler = ai_postHandler();
  T3<Symbol> striple = toSymbolTriple(triple);
  if (handler != null && !isTrue(ai_postTriple_recursion!)) {
    ai_postTriple_recursion.set(true);
    try {
      ret strOrNull(handler.postTriple(striple, ver));
    } finally {
      ai_postTriple_recursion.set(null);
    }
  } else {
    // post web the normal way
    Web web = webFromTriple(striple);
    web.unverified = !ver;
    postSoftwareMadeWeb(web);
    ret web.globalID();
  }
}

static S ai_postTriple(S a, S b, S c) {
  ret ai_postTriple(t3(a, b, c));
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1011399
Snippet name: ai_postTriple - posts if triple not in cache yet - returns web.globalID - posts verified unless specified by ai_postTriple_verified
Eternal ID of this version: #1011399/31
Text MD5: ec847f06d37188b26a7a69f8cdd1b660
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-12-16 13:56:21
Source code size: 1124 bytes / 46 lines
Pitched / IR pitched: No / No
Views / Downloads: 545 / 580
Version history: 30 change(s)
Referenced in: [show references]