summary refs log tree commit diff stats
Commit message (Expand)AuthorAgeFilesLines
* Weekday parse/format (replacement) (#21857)Carlo Capocasa2023-05-213-79/+134
* Fixed generic parameters failing to be used in inheritance (#21866)Jason Beetham2023-05-212-11/+63
* implements: "Allow bycopy to work in params #21874" (#21877)Juan M Gómez2023-05-213-4/+9
* implements allow byref to work in params #21873 (#21875)Juan M Gómez2023-05-218-52/+76
* remove legacy define for zero_functional tests (#21871)metagn2023-05-211-1/+1
* Moves virtual under its own section manual_experimental.md (#21870)Juan M Gómez2023-05-201-2/+2
* fix #14254 (#21837)metagn2023-05-205-4/+17
* refactor gettypedesc so it accepts its own kind instead of symkind (#21867)Juan M Gómez2023-05-194-81/+100
* potential fix for C++ codegen with ARC/ORC and goto exceptions fixes #21579, ...heterodoxic2023-05-191-1/+2
* Update threadpool.nim with correct link to typedthreads module (#21865)noah edward hall2023-05-191-1/+1
* documents virtual (#21860)Juan M Gómez2023-05-191-0/+76
* Cpp Vfunctions draft (#21790)Juan M Gómez2023-05-178-13/+260
* tasks that support return values (#21859)Andreas Rumpf2023-05-172-25/+53
* fixes #21847; let `parseFloat` behave like `strtod` (#21854)ringabout2023-05-172-3/+11
* fixes #21708; skip colons for tuples in VM (#21850)ringabout2023-05-172-1/+17
* close #19990; adds a test case (#21853)ringabout2023-05-151-0/+14
* fix #21848 (#21852)heterodoxic2023-05-151-7/+8
* isolation spec update; WIP (#21843)Andreas Rumpf2023-05-149-15/+284
* closes #7590; add a test case (#21846)ringabout2023-05-141-0/+20
* improve `wasMoved` hooks; allow reset to use the overridden `wasMoved` hook (...ringabout2023-05-125-20/+43
* add getDataDir to std/appdirs.nim (#21754)Ecorous2023-05-121-0/+17
* fixes #21840; nested local template lookup regression (#21841)ringabout2023-05-122-7/+81
* make deprecated statement a no-op (#21836)metagn2023-05-128-56/+48
* fixes nightlies regressions; disable `build-id=none` on macos (#21839)ringabout2023-05-121-2/+4
* Add `minmax` to comparisons (#21820)Matt Wilson2023-05-123-0/+18
* just set CallNodes = nnkCallKinds, follows up #21829 (#21833)metagn2023-05-111-2/+1
* cursor fields cannot form reference cycles (#21832)ringabout2023-05-112-13/+28
* Bootstrap: Allow to override number of CPUs (#21823)Tanguy2023-05-111-1/+5
* switch to the official URL of loop-fusion in the impoerant packages (#21830)ringabout2023-05-111-1/+1
* Add nnkHiddenCallConv to nnkCallKinds (#21781) (#21829)Matt Wilson2023-05-111-1/+3
* adds documentation for `=wasMoved` and `=dup` hooks and small fixes (#21827)ringabout2023-05-117-7/+44
* Improve nimsuggest (#21825)Juan Carlos2023-05-111-1/+1
* bring #21802 back; fixes #21753 [backport] (#21815)ringabout2023-05-117-26/+174
* clean up SOME pending/xxx/issue link comments (#21826)metagn2023-05-1135-178/+111
* Remove LineTooLong (#21819)Juan Carlos2023-05-117-19/+13
* make `reset` use the `=destroy` and `wasMoved` pair (#21821)ringabout2023-05-111-1/+9
* fixes links of generic `define` pragma (#21828)ringabout2023-05-112-2/+2
* make ORC threadlocal, take two (#21818)Andreas Rumpf2023-05-103-8/+8
* fix #9423 followup #17594: distinct generics now work in VM (#21816)ringabout2023-05-105-19/+40
* ignore inline hint for dynlib procs in codegen [backport] (#21817)metagn2023-05-091-14/+14
* fix nimrtl and nimhcr on arc/orc (#21814)metagn2023-05-095-22/+23
* Improve and refactor cellseqs_v2 in Nim standard library (#21796)Jordan Gillard2023-05-091-13/+10
* re-enable badssl test (#21775)metagn2023-05-091-4/+4
* Add build-id=none for GCC when build for Release (#21808)Juan Carlos2023-05-082-0/+7
* Windows: use __declspec(thread) TLS implementation, it is MUCH faster… (#21...Andreas Rumpf2023-05-081-1/+7
* documents codegendecl for object types (#21811)Juan M Gómez2023-05-081-2/+25
* adds an experimental `mm:atomicArc` switch (#21798)ringabout2023-05-0819-53/+71
* fixes #21801; object field initialization with overloaded functions (#21805)ringabout2023-05-082-1/+24
* 🚀 Enhancing CellSeq for Better Readability and Maintainability (#21797)Jordan Gillard2023-05-071-8/+11
* revert #21799 and #21802 which don't pass the tests (#21804)ringabout2023-05-074-13/+10
color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
package main

import (
	"fmt"
	"log"
	"net/http"

	"github.com/getwtxt/registry"
)

// Requests to apiEndpointPOSTHandler are passed off to this
// function. apiPostUser then fetches the twtxt data, then if
// it's an individual user's file, adds it. If it's registry
// output, it scrapes the users/urls/statuses from the remote
// registry before adding each user to the local cache.
func apiPostUser(w http.ResponseWriter, r *http.Request) {
	if err := r.ParseForm(); err != nil {
		log400(w, r, "Error Parsing Values: "+err.Error())
		return
	}

	nick := r.FormValue("nickname")
	urls := r.FormValue("url")
	if nick == "" || urls == "" {
		log400(w, r, "Nickname or URL missing")
		return
	}

	uip := getIPFromCtx(r.Context())

	out, remoteRegistry, err := registry.GetTwtxt(urls)
	if err != nil {
		log400(w, r, "Error Fetching twtxt Data: "+err.Error())
		return
	}

	if remoteRegistry {
		remoteRegistries.Mu.Lock()
		remoteRegistries.List = append(remoteRegistries.List, urls)
		remoteRegistries.Mu.Unlock()

		if err := twtxtCache.CrawlRemoteRegistry(urls); err != nil {
			log400(w, r, "Error Crawling Remote Registry: "+err.Error())
			return
		}
		log200(r)
		return
	}

	statuses, err := registry.ParseUserTwtxt(out, nick, urls)
	if err != nil {
		log.Printf("Error Parsing User Data: %v\n", err.Error())
	}

	if err := twtxtCache.AddUser(nick, urls, uip, statuses); err != nil {
		log400(w, r, "Error Adding User to Cache: "+err.Error())
		return
	}

	log200(r)
	_, err = w.Write([]byte(fmt.Sprintf("200 OK\n")))
	if err != nil {
		log.Printf("%v\n", err.Error())
	}
}