second round of public beta bugfixes:

- fixed a bug in navigation between conferences via post links
- fixed the "your post is 'new'" bug (this was actually another bug, in
  postNewMessage())
- some other stuff
This commit is contained in:
Eric J. Bowersox
2001-04-07 05:30:33 +00:00
parent 8f31704563
commit 3d32fe95c5
6 changed files with 75 additions and 17 deletions
@@ -475,14 +475,29 @@ class TopicUserContextImpl implements TopicContext
public void setUnreadMessages(int count) throws DataException
{
if (logger.isDebugEnabled())
logger.debug("[raw] setUnreadMessages(" + count + ") entry");
if (conf.userIsAnonymous())
return; // no-op
{ // this is effectively a no-op, but log it
logger.debug("reject 1: anonymous user");
return;
} // end if
if (count>(top_message+1)) // constrain count to [0, top_message+1]
count = top_message + 1;
else if (count<0)
count = 0;
if ((count==unread) || deleted)
return; // no-op
{ // this is effectively a no-op, but log it
if (logger.isDebugEnabled())
logger.debug("reject 2: count=" + count + ", unread=" + unread + ", deleted=" + deleted);
return;
} // end if
if (logger.isInfoEnabled())
logger.info("[cooked] setUnreadMessages(" + count + ") entry");
int last_msg = top_message - count;
Connection conn = null; // pooled database connection
@@ -498,8 +513,11 @@ class TopicUserContextImpl implements TopicContext
StringBuffer sql = new StringBuffer("UPDATE topicsettings SET last_message = ");
sql.append(last_msg).append(" WHERE topicid = ").append(topicid).append(" AND uid = ");
sql.append(conf.realUID()).append(';');
if (logger.isDebugEnabled())
logger.debug("SQL: " + sql.toString());
if (stmt.executeUpdate(sql.toString())>0)
{ // that was all we needed - just save the flag and exit
logger.debug("--> bailed out after update - done with setUnreadMessages{");
conf.touchRead(conn);
unread = count;
return;
@@ -509,9 +527,12 @@ class TopicUserContextImpl implements TopicContext
// OK, check: Is the topic still there?!?
sql.setLength(0);
sql.append("SELECT topicid from topics WHERE topicid = ").append(topicid).append(';');
if (logger.isDebugEnabled())
logger.debug("SQL: " + sql.toString());
ResultSet rs = stmt.executeQuery(sql.toString());
if (!(rs.next()))
{ // the topic's been deleted - bail out
logger.debug("--> bailed out because topic is deleted - done with setUnreadMessages{");
makeDeleted();
return;
@@ -521,6 +542,8 @@ class TopicUserContextImpl implements TopicContext
sql.setLength(0);
sql.append("INSERT INTO topicsettings (topicid, uid, last_message) VALUES (").append(topicid);
sql.append(", ").append(conf.realUID()).append(", ").append(last_msg).append(");");
if (logger.isDebugEnabled())
logger.debug("SQL: " + sql.toString());
stmt.executeUpdate(sql.toString());
conf.touchRead(conn);
unread = count; // successful completion
@@ -589,6 +612,9 @@ class TopicUserContextImpl implements TopicContext
public TopicMessageContext postNewMessage(long parent, String pseud, String text)
throws DataException, AccessError
{
if (logger.isInfoEnabled())
logger.info("postNewMessage(" + parent + ", '" + pseud + "',<text>) entry");
if (!(conf.userCanPost()))
{ // they can't post in this topic!
logger.error("trying to post w/o permission!");
@@ -642,6 +668,8 @@ class TopicUserContextImpl implements TopicContext
real_pseud = pseud_ch.getValue();
real_text = text_ch.getValue();
text_linecount = text_ch.getLines();
if (logger.isDebugEnabled())
logger.debug("new post has " + text_linecount + " lines");
} // end try
catch (NotYetFinishedException e)
@@ -691,6 +719,8 @@ class TopicUserContextImpl implements TopicContext
// Determine what the new post number is.
new_post_num = top_message + 1;
if (logger.isDebugEnabled())
logger.debug("New post number: " + new_post_num);
// Add the post "header" to the posts table.
StringBuffer sql = new StringBuffer("INSERT INTO posts (parent, topicid, num, linecount, creator_uid, "
@@ -708,6 +738,8 @@ class TopicUserContextImpl implements TopicContext
if (!(rs.next()))
throw new InternalStateError("postMessage(): Unable to get new post ID!");
new_post_id = rs.getLong(1);
if (logger.isDebugEnabled())
logger.debug("New post ID: " + new_post_id);
// Touch the topic values to reflect the added post.
sql.setLength(0);
@@ -727,9 +759,14 @@ class TopicUserContextImpl implements TopicContext
conf.touchUpdate(conn,posted_date);
conf.touchPost(conn,posted_date);
// fill in our own local variables to reflect the update
// Fill in our own local variables to reflect the update. This includes the recalculation
// of "unread" based on the new value of "top_message".
int tmp_last_msg = top_message - unread;
top_message = new_post_num;
lastupdate = posted_date;
unread = top_message - tmp_last_msg;
logger.debug("message post completed successfully");
} // end try
finally