mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-01 17:38:33 +00:00
mitigate Block by future StartTime
This commit is contained in:
parent
1b35bd2911
commit
0ddc2db46a
4 changed files with 21 additions and 2 deletions
|
@ -4,6 +4,7 @@
|
|||
package forgefed
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
|
@ -39,6 +40,9 @@ func (info FederationInfo) Validate() []string {
|
|||
result = append(result, validation.ValidateNotEmpty(info.HostFqdn, "HostFqdn")...)
|
||||
result = append(result, validation.ValidateMaxLen(info.HostFqdn, 255, "HostFqdn")...)
|
||||
result = append(result, info.NodeInfo.Validate()...)
|
||||
if !info.LatestActivity.IsZero() && info.LatestActivity.After(time.Now().Add(10*time.Minute)) {
|
||||
result = append(result, fmt.Sprintf("Latest Activity may not be far futurer: %v", info.LatestActivity))
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
|
|
@ -30,4 +30,15 @@ func Test_FederationInfoValidation(t *testing.T) {
|
|||
if res, _ := validation.IsValid(sut); res {
|
||||
t.Errorf("sut should be invalid")
|
||||
}
|
||||
|
||||
sut = FederationInfo{
|
||||
HostFqdn: "host.do.main",
|
||||
NodeInfo: NodeInfo{
|
||||
Source: "forgejo",
|
||||
},
|
||||
LatestActivity: time.Now().Add(1 * time.Hour),
|
||||
}
|
||||
if res, _ := validation.IsValid(sut); res {
|
||||
t.Errorf("sut should be invalid")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue