58 lines
2 KiB
Go
58 lines
2 KiB
Go
package models
|
|
|
|
import "time"
|
|
|
|
// Board represents a message board (conference/forum).
|
|
//
|
|
// Original: struct Board_Header in BOARD.H
|
|
// Changes:
|
|
// - ID replaces positional linked-list ordering
|
|
// - Access ranges kept intact — same security model
|
|
// - LatestTime becomes LatestPost as time.Time
|
|
type Board struct {
|
|
ID int64
|
|
Name string
|
|
ReadLow int // Minimum SecBoard to read
|
|
ReadHigh int // Maximum SecBoard to read
|
|
WriteLow int // Minimum SecBoard to write
|
|
WriteHigh int // Maximum SecBoard to write
|
|
MaxPosts int // Maximum messages before oldest are purged
|
|
PostCount int // Current number of posts (Highest_Post)
|
|
LatestPost *time.Time // nil if no posts yet
|
|
CreatedAt time.Time
|
|
}
|
|
|
|
// CanRead returns true if the given security level can read this board.
|
|
func (b *Board) CanRead(secBoard int) bool {
|
|
return secBoard >= b.ReadLow && secBoard <= b.ReadHigh
|
|
}
|
|
|
|
// CanWrite returns true if the given security level can post to this board.
|
|
func (b *Board) CanWrite(secBoard int) bool {
|
|
return secBoard >= b.WriteLow && secBoard <= b.WriteHigh
|
|
}
|
|
|
|
// Message represents a single post on a message board.
|
|
//
|
|
// Original: struct Board_Data in BOARD.H + the message body stored
|
|
// in a separate .Data file at a fixed offset. Here the body is stored
|
|
// inline in the database.
|
|
// Changes:
|
|
// - ID replaces positional slot number
|
|
// - BoardID foreign key replaces the implicit file-per-board association
|
|
// - Body stored with the record instead of in a separate file
|
|
// - ReplyTo enables threading (not present in original)
|
|
// - Locked replaces the Lock field
|
|
type Message struct {
|
|
ID int64
|
|
BoardID int64
|
|
Number int // Display number within the board (1-based)
|
|
Title string
|
|
Author string // Display name (BoardOps could override in original)
|
|
AuthorID int64 // User ID of the poster
|
|
Body string
|
|
ReplyTo int64 // ID of parent message, 0 if top-level
|
|
Locked bool
|
|
CreatedAt time.Time
|
|
}
|