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