parsav  Diff

Differences From Artifact [cc5cf170ae]:

To Artifact [e8c2143a0c]:


   164    164   			return
   165    165   		end
   166    166   		if subj == nil then subj = '' end
   167    167   
   168    168   		var p = lib.store.post {
   169    169   			author = co.who.id, acl = acl;
   170    170   			body = text, subject = subj;
          171  +			parent = 0;
   171    172   		}
   172    173   		var newid = p:publish(co.srv)
   173    174   
   174    175   		var idbuf: int8[lib.math.shorthand.maxlen]
   175    176   		var idlen = lib.math.shorthand.gen(newid, idbuf)
   176    177   		var redirto: lib.str.acc redirto:compose('/post/',{idbuf,idlen}) defer redirto:free()
   177    178   		co:reroute(redirto.buf)
................................................................................
   380    381   		end
   381    382   	end
   382    383   	lib.render.conf(co,path,msg)
   383    384   	do return end
   384    385   
   385    386   	::nopriv:: co:complain(403,'insufficient privileges','you do not have the necessary powers to perform this action')
   386    387   end
          388  +
          389  +terra http.user_notices(co: &lib.srv.convo, meth: method.t)
          390  +	if meth == method.post then
          391  +		var act = co:ppostv('act')
          392  +		if act:cmp(lib.str.plit'clear') then
          393  +			co.srv:actor_conf_int_set(co.who.id, 'notice-clear-time', lib.osclock.time(nil))
          394  +			co:reroute('/')
          395  +			return
          396  +		else goto badop end
          397  +	end
          398  +
          399  +	lib.render.notices(co)
          400  +	do return end
          401  +
          402  +	::badop :: do co:complain(405, 'invalid operation', 'the operation you have attempted on this post is not meaningful') return end
          403  +end
   387    404   
   388    405   do local branches = quote end
   389    406   	local filename, flen = symbol(&int8), symbol(intptr)
   390    407   	local page = symbol(lib.http.page)
   391    408   	local send = label()
   392    409   	local storage = data.stmap
   393    410   	for i,e in ipairs(config.embeds) do local id,mime = e[1],e[2]
................................................................................
   442    459   	elseif uri.ptr[1] == @'@' then
   443    460   		http.actor_profile_xid(co, uri, meth)
   444    461   	elseif uri.ptr[1] == @'s' and uri.ptr[2] == @'/' and uri.ct > 3 then
   445    462   		if not meth_get(meth) then goto wrongmeth end
   446    463   		if not http.static_content(co, uri.ptr + 3, uri.ct - 3) then goto notfound end
   447    464   	elseif lib.str.ncmp('/avi/', uri.ptr, 5) == 0 then
   448    465   		http.local_avatar(co, [lib.mem.ptr(int8)] {ptr = uri.ptr + 5, ct = uri.ct - 5})
   449         -	elseif lib.str.ncmp('/compose', uri.ptr, lib.math.biggest(uri.ct,8)) == 0 then
          466  +	elseif uri:cmp(lib.str.plit '/notices') then
          467  +		if co.aid == 0 then co:reroute('/login') return end
          468  +		http.user_notices(co,meth)
          469  +	elseif uri:cmp(lib.str.plit '/compose') then
   450    470   		if co.aid == 0 then co:reroute('/login') return end
   451    471   		http.post_compose(co,meth)
   452         -	elseif lib.str.ncmp('/login', uri.ptr, lib.math.biggest(uri.ct,6)) == 0 then
          472  +	elseif uri:cmp(lib.str.plit '/login') then
   453    473   		if co.aid == 0
   454    474   			then http.login_form(co, meth)
   455    475   			else co:reroute('/')
   456    476   		end
   457         -	elseif lib.str.ncmp('/logout', uri.ptr, lib.math.biggest(uri.ct,7)) == 0 then
          477  +	elseif uri:cmp(lib.str.plit '/logout') then
   458    478   		if co.aid == 0
   459    479   			then goto notfound
   460    480   			else co:reroute_cookie('/','auth=; Path=/')
   461    481   		end
   462    482   	else -- hierarchical routes
   463    483   		var path = lib.http.hier(uri) defer path:free()
   464    484   		if path.ct > 1 and path(0):cmp(lib.str.lit('user')) then