一方关注只记关注。双方互关时写入已有双向好友边;取消关注若不再互关只删好友边,不删消息。 Co-authored-by: Cursor <cursoragent@cursor.com>
54 lines
1.2 KiB
Go
54 lines
1.2 KiB
Go
package entity
|
|
|
|
import "time"
|
|
|
|
const (
|
|
RequestPending RequestStatus = 1
|
|
RequestAccepted RequestStatus = 2
|
|
RequestRejected RequestStatus = 3
|
|
)
|
|
|
|
// RequestStatus is persisted as friend_requests.status and returned as apply `status`.
|
|
type RequestStatus int
|
|
|
|
func (s RequestStatus) Valid() bool {
|
|
return s == RequestPending || s == RequestAccepted || s == RequestRejected
|
|
}
|
|
|
|
const (
|
|
SourceUnknown Source = 0
|
|
SourceQRCode Source = 1
|
|
SourceEmail Source = 2
|
|
SourceSparkID Source = 3
|
|
SourceFollow Source = 4
|
|
)
|
|
|
|
// Source is friend add origin on the request and the directed edge.
|
|
type Source int
|
|
|
|
func (s Source) Valid() bool {
|
|
return s == SourceUnknown || s == SourceQRCode || s == SourceEmail || s == SourceSparkID || s == SourceFollow
|
|
}
|
|
|
|
const (
|
|
ReasonMax = 128
|
|
RemarkMax = 64
|
|
)
|
|
|
|
// Request is one from→to application. Repeats update this row; they do not insert another.
|
|
type Request struct {
|
|
ID int64
|
|
FromUser int64
|
|
ToUser int64
|
|
Source Source
|
|
Reason string
|
|
Remark string
|
|
Status RequestStatus
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
func ValidSource(src int) bool {
|
|
return Source(src).Valid() && Source(src) != SourceUnknown
|
|
}
|