webbuild: fixes for sociallog from webbuild.db

This commit is contained in:
Silvan Calarco 2019-07-28 20:40:09 +02:00
parent 5a0fa63a96
commit 1c15fcfb25
2 changed files with 7 additions and 13 deletions

View File

@ -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 "<socialbox>"
@ -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 "</webbuild>"
exit
fi

View File

@ -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
}