flag

package
v0.0.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ReasonPolicy  = "policy"
	ReasonConduct = "conduct"
	ReasonDeal    = "deal"
)

Variables

View Source
var ErrFlagAlreadyRaised = errors.New("a flag has already been raised on this conversation")
View Source
var ErrFlagNotFound = errors.New("flag not found")
View Source
var ErrInvalidReason = errors.New("invalid flag reason")
View Source
var ErrMaxFlagsReached = errors.New("user has reached maximum outstanding flags")
View Source
var Reasons = ReasonsAtAd

Reasons is the union used for code validation.

View Source
var ReasonsAtAd = []ReasonInfo{
	{
		Code:  ReasonPolicy,
		Label: "Listing or content violates policies",
		Examples: []string{
			"Scam or fake listing",
			"Illegal goods",
			"Spam or impersonation",
			"Sexual or prohibited images",
			"Stolen photos or IP issues",
		},
	},
	{
		Code:  ReasonConduct,
		Label: "Seller harassment or bad-faith conduct",
		Examples: []string{
			"Threats or abuse in messages",
			"Pressure to share personal info",
			"Repeated hostile contact",
			"Bad-faith negotiation",
		},
	},
	{
		Code:  ReasonDeal,
		Label: "Deal or transaction went wrong",
		Examples: []string{
			"No-show",
			"Item not as described",
			"Payment or meetup dispute",
			"Bait-and-switch after chat",
		},
	},
}

ReasonsAtAd is for inquirer throwing at a listing.

View Source
var ReasonsAtUser = []ReasonInfo{
	{
		Code:  ReasonPolicy,
		Label: "Scam, spam, or prohibited requests",
		Examples: []string{
			"Advance-fee or deposit scam",
			"Spam or mass messaging",
			"Requests for illegal goods or services",
			"Phishing or credential harvesting",
		},
	},
	{
		Code:  ReasonConduct,
		Label: "Harassment or bad-faith conduct",
		Examples: []string{
			"Threats or abuse in messages",
			"Pressure to share personal info",
			"Repeated hostile contact",
			"Bad-faith negotiation",
		},
	},
	{
		Code:  ReasonDeal,
		Label: "Deal or meetup went wrong",
		Examples: []string{
			"No-show",
			"Changed terms after agreeing",
			"Payment dispute",
			"Unsafe or dishonest meetup behavior",
		},
	},
}

ReasonsAtUser is for owner throwing at an inquirer.

Functions

func GetConversationIDForUserFlagByOrdinal

func GetConversationIDForUserFlagByOrdinal(userID int, ordinal int) (int, error)

GetConversationIDForUserFlagByOrdinal returns the conversation ID at the given ordinal position (0-based) for flags bound to a user (where flag_raiser_id = owner_id AND inquirer_id = userID), ordered by flag_raised_at DESC

func GetConversationIDsForUserFlags

func GetConversationIDsForUserFlags(userID int) ([]int, error)

GetConversationIDsForUserFlags returns conversation IDs for flags bound to a user (where flag_raiser_id = owner_id, meaning owner threw flag at inquirer)

func GetFlagCountForConversation

func GetFlagCountForConversation(conversationID int) (int, error)

GetFlagCountForConversation returns whether a flag exists for a conversation

func GetFlagCountForUser

func GetFlagCountForUser(userID int) (int, error)

GetFlagCountForUser returns the count of flags bound to a user (flags where owner threw at this user)

func GetPublicConversationIDByOrdinal

func GetPublicConversationIDByOrdinal(adID int, ordinal int) (int, error)

GetPublicConversationIDByOrdinal returns the conversation ID at the given ordinal position (0-based) for public conversations with flags bound to the ad (flag_raiser_id = inquirer_id), ordered by latest activity DESC

func GetPublicConversationsForAd

func GetPublicConversationsForAd(adID int) ([]int, error)

GetPublicConversationsForAd returns public conversation IDs for an ad Only returns conversations with flags bound to the ad (flag_raiser_id = inquirer_id)

func GetUserFlagCount

func GetUserFlagCount(userID int) (int, error)

GetUserFlagCount returns the count of outstanding flags thrown by a user

func HasUserRaisedFlag

func HasUserRaisedFlag(userID, conversationID int) (bool, error)

HasUserRaisedFlag checks if a user has thrown a flag at a conversation

func LowerActiveForAd

func LowerActiveForAd(adID int) error

LowerActiveForAd clears active flags on all conversations for an ad.

func LowerActiveForUser

func LowerActiveForUser(userID int) error

LowerActiveForUser clears flags thrown by or bound to the user.

func LowerFlag

func LowerFlag(userID, conversationID int) error

LowerFlag removes a flag from a conversation

func RaiseFlag

func RaiseFlag(userID, conversationID int, reason string) error

RaiseFlag raises a flag on a conversation, making it public. If the inquirer raises it, flag_raiser_id is the inquirer (bound to the ad). If the owner raises it, flag_raiser_id is the owner (bound to the inquirer).

func ReasonLabel

func ReasonLabel(code string) string

func ReasonLabelForTarget

func ReasonLabelForTarget(code string, atAd bool) string

func SyncAdFlagCount

func SyncAdFlagCount(adID int) error

SyncAdFlagCount sets ads.flag_count from ad-bound flags on conversations.

func ValidReason

func ValidReason(code string) bool

Types

type ReasonInfo

type ReasonInfo struct {
	Code     string
	Label    string
	Examples []string
}

func ReasonsForTarget

func ReasonsForTarget(atAd bool) []ReasonInfo

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL