fixed bugs in post link decoding and AmGetConferenceByAlias
This commit is contained in:
@@ -190,8 +190,11 @@ func AmGetConference(id int32) (*Conference, error) {
|
||||
* Standard Go error status.
|
||||
*/
|
||||
func AmGetConferenceByAlias(alias string) (*Conference, error) {
|
||||
confid, ok := conferenceAliasMap.Load(alias)
|
||||
if !ok {
|
||||
var confid int32
|
||||
xconf, ok := conferenceAliasMap.Load(alias)
|
||||
if ok {
|
||||
confid = xconf.(int32)
|
||||
} else {
|
||||
rs, err := amdb.Query("SELECT confid FROM confalias WHERE alias = ?", alias)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -202,7 +205,7 @@ func AmGetConferenceByAlias(alias string) (*Conference, error) {
|
||||
rs.Scan(&confid)
|
||||
conferenceAliasMap.Store(alias, confid)
|
||||
}
|
||||
return AmGetConference(int32(confid.(int)))
|
||||
return AmGetConference(confid)
|
||||
}
|
||||
|
||||
/* AmGetConferenceByAliasInCommunity returns a conference in a community given its alias.
|
||||
|
||||
@@ -192,6 +192,7 @@ func AmDecodePostLink(data string) (*PostLinkData, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &rc, nil
|
||||
}
|
||||
|
||||
// Peel off the initial substring before the dot.
|
||||
@@ -199,23 +200,22 @@ func AmDecodePostLink(data string) (*PostLinkData, error) {
|
||||
work = work[pos+1:]
|
||||
if len(work) == 0 {
|
||||
// we had "conference." or "topic." or maybe "community!conference."
|
||||
var err error
|
||||
if rc.Community == "" {
|
||||
// it's either "conference." or "topic." - try the latter first
|
||||
err := decodeTopicNumber(confOrTopic, &rc)
|
||||
err = decodeTopicNumber(confOrTopic, &rc)
|
||||
if err != nil {
|
||||
// it's not a topic number, try it as a conference name
|
||||
err = validateConference(confOrTopic, &rc)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
// it was "community!conference."
|
||||
err := validateConference(confOrTopic, &rc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = validateConference(confOrTopic, &rc)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &rc, nil
|
||||
}
|
||||
|
||||
// Third test: Dot #2
|
||||
|
||||
@@ -64,13 +64,13 @@ type htmlCheckerBackend interface {
|
||||
|
||||
// State constants for the state machine.
|
||||
const (
|
||||
stateWhitespace = 0
|
||||
stateChars = 1
|
||||
stateLeftAngle = 2
|
||||
stateTag = 3
|
||||
stateParen = 4
|
||||
stateTagQuote = 5
|
||||
stateNewline = 6
|
||||
stateWhitespace = 0 // processing whitespace
|
||||
stateChars = 1 // processing character data
|
||||
stateLeftAngle = 2 // processing a left angle bracket
|
||||
stateTag = 3 // processing the contents of a tag
|
||||
stateParen = 4 // processing a string in parentheses
|
||||
stateTagQuote = 5 // processing a quoted string inside a tag
|
||||
stateNewline = 6 // processing newlines
|
||||
)
|
||||
|
||||
// htmlMarginSlop is a number of characters at the end of the line used to control word-wrapping.
|
||||
|
||||
Reference in New Issue
Block a user