mirror of
				https://github.com/ergochat/ergo.git
				synced 2025-11-03 23:37:22 +01:00 
			
		
		
		
	clean up constant redefinition
This commit is contained in:
		
							parent
							
								
									a1c46a4be7
								
							
						
					
					
						commit
						253972a9d2
					
				@ -41,8 +41,7 @@ const (
 | 
			
		||||
	DefaultMaxLineLen = 512
 | 
			
		||||
 | 
			
		||||
	// IdentTimeout is how long before our ident (username) check times out.
 | 
			
		||||
	IdentTimeout         = time.Second + 500*time.Millisecond
 | 
			
		||||
	IRCv3TimestampFormat = utils.IRCv3TimestampFormat
 | 
			
		||||
	IdentTimeout = time.Second + 500*time.Millisecond
 | 
			
		||||
	// limit the number of device IDs a client can use, as a DoS mitigation
 | 
			
		||||
	maxDeviceIDsPerClient = 64
 | 
			
		||||
	// maximum total read markers that can be stored
 | 
			
		||||
@ -1463,7 +1462,7 @@ func (session *Session) sendFromClientInternal(blocking bool, serverTime time.Ti
 | 
			
		||||
 | 
			
		||||
func composeMultilineBatch(batchID, fromNickMask, fromAccount string, isBot bool, tags map[string]string, command, target string, message utils.SplitMessage) (result []ircmsg.Message) {
 | 
			
		||||
	batchStart := ircmsg.MakeMessage(tags, fromNickMask, "BATCH", "+"+batchID, caps.MultilineBatchType, target)
 | 
			
		||||
	batchStart.SetTag("time", message.Time.Format(IRCv3TimestampFormat))
 | 
			
		||||
	batchStart.SetTag("time", message.Time.Format(utils.IRCv3TimestampFormat))
 | 
			
		||||
	batchStart.SetTag("msgid", message.Msgid)
 | 
			
		||||
	if fromAccount != "*" {
 | 
			
		||||
		batchStart.SetTag("account", fromAccount)
 | 
			
		||||
@ -1571,7 +1570,7 @@ func (session *Session) setTimeTag(msg *ircmsg.Message, serverTime time.Time) {
 | 
			
		||||
		if serverTime.IsZero() {
 | 
			
		||||
			serverTime = time.Now()
 | 
			
		||||
		}
 | 
			
		||||
		msg.SetTag("time", serverTime.UTC().Format(IRCv3TimestampFormat))
 | 
			
		||||
		msg.SetTag("time", serverTime.UTC().Format(utils.IRCv3TimestampFormat))
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -517,7 +517,7 @@ func (client *Client) GetReadMarker(cfname string) (result string) {
 | 
			
		||||
	t, ok := client.readMarkers[cfname]
 | 
			
		||||
	client.stateMutex.RUnlock()
 | 
			
		||||
	if ok {
 | 
			
		||||
		return fmt.Sprintf("timestamp=%s", t.Format(IRCv3TimestampFormat))
 | 
			
		||||
		return fmt.Sprintf("timestamp=%s", t.Format(utils.IRCv3TimestampFormat))
 | 
			
		||||
	}
 | 
			
		||||
	return "*"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -719,7 +719,7 @@ func chathistoryHandler(server *Server, client *Client, msg ircmsg.Message, rb *
 | 
			
		||||
				for _, target := range targets {
 | 
			
		||||
					name := server.UnfoldName(target.CfName)
 | 
			
		||||
					rb.Add(nil, server.name, "CHATHISTORY", "TARGETS", name,
 | 
			
		||||
						target.Time.Format(IRCv3TimestampFormat))
 | 
			
		||||
						target.Time.Format(utils.IRCv3TimestampFormat))
 | 
			
		||||
				}
 | 
			
		||||
			} else if channel != nil {
 | 
			
		||||
				channel.replayHistoryItems(rb, items, true)
 | 
			
		||||
@ -754,7 +754,7 @@ func chathistoryHandler(server *Server, client *Client, msg ircmsg.Message, rb *
 | 
			
		||||
			msgid, err = history.NormalizeMsgid(value), nil
 | 
			
		||||
			return
 | 
			
		||||
		} else if identifier == "timestamp" {
 | 
			
		||||
			timestamp, err = time.Parse(IRCv3TimestampFormat, value)
 | 
			
		||||
			timestamp, err = time.Parse(utils.IRCv3TimestampFormat, value)
 | 
			
		||||
			if err == nil {
 | 
			
		||||
				timestamp = timestamp.UTC()
 | 
			
		||||
				if timestamp.Before(unixEpoch) {
 | 
			
		||||
@ -3055,14 +3055,14 @@ func markReadHandler(server *Server, client *Client, msg ircmsg.Message, rb *Res
 | 
			
		||||
 | 
			
		||||
	// "MARKREAD client set command": MARKREAD <target> <timestamp>
 | 
			
		||||
	readTimestamp := strings.TrimPrefix(msg.Params[1], "timestamp=")
 | 
			
		||||
	readTime, err := time.Parse(IRCv3TimestampFormat, readTimestamp)
 | 
			
		||||
	readTime, err := time.Parse(utils.IRCv3TimestampFormat, readTimestamp)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		rb.Add(nil, server.name, "FAIL", "MARKREAD", "INVALID_PARAMS", utils.SafeErrorParam(readTimestamp), client.t("Invalid timestamp"))
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	readTime = readTime.UTC()
 | 
			
		||||
	result := client.SetReadMarker(cftarget, readTime)
 | 
			
		||||
	readTimestamp = fmt.Sprintf("timestamp=%s", result.Format(IRCv3TimestampFormat))
 | 
			
		||||
	readTimestamp = fmt.Sprintf("timestamp=%s", result.Format(utils.IRCv3TimestampFormat))
 | 
			
		||||
	// inform the originating session whether it was a success or a no-op:
 | 
			
		||||
	rb.Add(nil, server.name, "MARKREAD", unfoldedTarget, readTimestamp)
 | 
			
		||||
	if result.Equal(readTime) {
 | 
			
		||||
 | 
			
		||||
@ -164,7 +164,7 @@ func histservExportHandler(service *ircService, server *Server, client *Client,
 | 
			
		||||
 | 
			
		||||
	config := server.Config()
 | 
			
		||||
	// don't include the account name in the filename because of escaping concerns
 | 
			
		||||
	filename := fmt.Sprintf("%s-%s.json", utils.GenerateSecretToken(), time.Now().UTC().Format(IRCv3TimestampFormat))
 | 
			
		||||
	filename := fmt.Sprintf("%s-%s.json", utils.GenerateSecretToken(), time.Now().UTC().Format(utils.IRCv3TimestampFormat))
 | 
			
		||||
	pathname := config.getOutputPath(filename)
 | 
			
		||||
	outfile, err := os.Create(pathname)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
 | 
			
		||||
@ -45,7 +45,7 @@ type MessageCache struct {
 | 
			
		||||
 | 
			
		||||
func addAllTags(msg *ircmsg.Message, tags map[string]string, serverTime time.Time, msgid, accountName string, isBot bool) {
 | 
			
		||||
	msg.UpdateTags(tags)
 | 
			
		||||
	msg.SetTag("time", serverTime.Format(IRCv3TimestampFormat))
 | 
			
		||||
	msg.SetTag("time", serverTime.Format(utils.IRCv3TimestampFormat))
 | 
			
		||||
	if accountName != "*" {
 | 
			
		||||
		msg.SetTag("account", accountName)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user