rock

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 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 ErrInvalidReason = errors.New("invalid rock reason")
View Source
var ErrMaxRocksReached = errors.New("user has reached maximum outstanding rocks")
View Source
var ErrRockAlreadyThrown = errors.New("a rock has already been thrown at this conversation")
View Source
var ErrRockNotFound = errors.New("rock not found")
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 GetConversationIDForUserRockByOrdinal

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

GetConversationIDForUserRockByOrdinal returns the conversation ID at the given ordinal position (0-based) for rocks bound to a user (where rock_thrower_id = owner_id AND inquirer_id = userID), ordered by rock_thrown_at DESC

func GetConversationIDsForUserRocks

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

GetConversationIDsForUserRocks returns conversation IDs for rocks bound to a user (where rock_thrower_id = owner_id, meaning owner threw rock at inquirer)

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 rocks bound to the ad (rock_thrower_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 rocks bound to the ad (rock_thrower_id = inquirer_id)

func GetRockCountForConversation

func GetRockCountForConversation(conversationID int) (int, error)

GetRockCountForConversation returns whether a rock exists for a conversation

func GetRockCountForUser

func GetRockCountForUser(userID int) (int, error)

GetRockCountForUser returns the count of rocks bound to a user (rocks where owner threw at this user)

func GetUserRockCount

func GetUserRockCount(userID int) (int, error)

GetUserRockCount returns the count of outstanding rocks thrown by a user

func HasUserThrownRock

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

HasUserThrownRock checks if a user has thrown a rock at a conversation

func ReasonLabel

func ReasonLabel(code string) string

func ReasonLabelForTarget

func ReasonLabelForTarget(code string, atAd bool) string

func SyncAdRockCount

func SyncAdRockCount(adID int) error

SyncAdRockCount sets ads.rock_count from ad-bound rocks on conversations.

func ThrowRock

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

ThrowRock throws a rock at a conversation, making it public If inquirer throws: rock_thrower_id = inquirer_id (bound to ad) If owner throws: rock_thrower_id = owner_id (bound to inquirer)

func UnthrowActiveForAd

func UnthrowActiveForAd(adID int) error

UnthrowActiveForAd clears active rocks on all conversations for an ad.

func UnthrowActiveForUser

func UnthrowActiveForUser(userID int) error

UnthrowActiveForUser clears rocks thrown by or bound to the user.

func UnthrowRock

func UnthrowRock(userID, conversationID int) error

UnthrowRock removes a rock from a conversation

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