From 1c15fcfb25e51fcecabe8d499592878d21e4e37b Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Sun, 28 Jul 2019 20:40:09 +0200 Subject: [PATCH] webbuild: fixes for sociallog from webbuild.db --- webbuild/webbuild-cgi | 18 ++++++------------ webbuild/webbuild-functions | 2 +- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/webbuild/webbuild-cgi b/webbuild/webbuild-cgi index cf45825..6792550 100755 --- a/webbuild/webbuild-cgi +++ b/webbuild/webbuild-cgi @@ -137,12 +137,6 @@ if [ "$USER_ENABLED" != "1" -a "${REQUEST:0:7}" != "refresh" ]; then exit fi -if [ -e $WEBBUILD_STATEDIR/webbuild.state ]; then - . $WEBBUILD_STATEDIR/users/webbuild.state -else - touch $WEBBUILD_STATEDIR/users/webbuild.state -fi - if [ "$USER_ADMIN" -a "$FAKEUSERSWITCH" != "" ]; then if [ "$FAKEUSERSWITCH" = "_disabled_" ]; then set_user_state_var STATE_FAKEUSER @@ -209,7 +203,7 @@ fi if [ "$REQUEST" = "refresh" -o "$REQUEST" = "refreshsocial" -o ! "$USER" ]; then if [ "$WEBBUILD_URL" -a "${WEBBUILD_URL/\/localhost\//}" = "$WEBBUILD_URL" ]; then curl -s "$WEBBUILD_URL?REQUEST=refreshsocial&USER=$USER&SECRET=`cgi_encodevar \"$USER_SECRET\"`&USER_EMAIL=$USER_EMAIL&FROMID=$FROMID" - else + else [ -e "$WEBBUILD_STATEDIR/webbuild.db" ] || exit # social box echo -n "" @@ -217,13 +211,13 @@ if [ "$REQUEST" = "refresh" -o "$REQUEST" = "refreshsocial" -o ! "$USER" ]; then if [ ! "$FROMID" -o "$FROMID" = "0" -o "$FROMID" = "NaN" ]; then # Find id of last row - 25 if [ "$USER" ]; then - LASTID_QUERY="SELECT id FROM (SELECT id FROM social_log WHERE id!='$USER' ORDER BY id DESC LIMIT 25) sub ORDER BY id ASC LIMIT 1;" + LASTID_QUERY="SELECT id FROM (SELECT id FROM social_log WHERE user!='$USER' ORDER BY id DESC LIMIT 25) sub ORDER BY id ASC LIMIT 1;" else - LASTID_QUERY="SELECT id FROM (SELECT id FROM social_log WHERE target!='$DEVELOPERS' ORDER BY id DESC LIMIT 25) sub ORDER BY id ASC LIMIT 1;" + LASTID_QUERY="SELECT id FROM (SELECT id FROM social_log WHERE target!='developers' ORDER BY id DESC LIMIT 25) sub ORDER BY id ASC LIMIT 1;" fi FROMID=`sqlite3 $WEBBUILD_STATEDIR/webbuild.db "$LASTID_QUERY"` fi - sqlite3 $WEBBUILD_STATEDIR/webbuild.db "select *,strftime('%s',time) from social_log where id>$FROMID" | while read line; do + sqlite3 $WEBBUILD_STATEDIR/webbuild.db "SELECT *,strftime('%s',time) FROM social_log WHERE id>$FROMID LIMIT 100" | while read line; do SAVEIFS=$IFS IFS="|" set -- $line @@ -236,7 +230,7 @@ if [ "$REQUEST" = "refresh" -o "$REQUEST" = "refreshsocial" -o ! "$USER" ]; then STEXT="$7" STIME="$9" [ "$STARGET" = "developers" -a ! "$USER" ] && continue - [ "$SUSER" = "$USER" -a "$STARGET" == "developers" ] && continue + [ "$SUSER" = "$USER" -a "$STARGET" = "developers" ] && continue if [ "$SPRIVACY" -a ! "$USER" ]; then USER_GRAVATAR= else @@ -473,7 +467,7 @@ fi if [ "$REQUEST" = "message" -a "$USER" -a "$USER_CANSENDMESSAGES" ]; then # external (autodist) social messages [ "$MESSAGETYPE" ] || MESSAGETYPE=broadcastmessage - social_log "SUSER=$USER STYPE=$MESSAGETYPE SEMAIL=$USER_EMAIL STEXT=\"$MESSAGE\" STIME=`date +%s`" + social_log "SUSER=$USER STYPE=$MESSAGETYPE STARGET=\"$TARGET\" SEMAIL=$USER_EMAIL STEXT=\"$MESSAGE\" STIME=`date +%s`" echo "" exit fi diff --git a/webbuild/webbuild-functions b/webbuild/webbuild-functions index a08c75b..d0dd147 100644 --- a/webbuild/webbuild-functions +++ b/webbuild/webbuild-functions @@ -48,7 +48,7 @@ function social_log() { eval $line USER_SECRET_FIXED=`echo $USER_SECRET | sed "s|\$|\\$|"` curl -s "$WEBBUILD_URL?REQUEST=message&USER=$USER&SECRET=`cgi_encodevar \"$USER_SECRET\"`&USER_EMAIL=$USER_EMAIL&\ -MESSAGE=`cgi_encodevar \"$STEXT\"`" >/dev/null +TARGET=$STARGET&MESSAGE=`cgi_encodevar \"$STEXT\"`" >/dev/null fi fi }