verify

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWorldsNotSynced worldSyncError = errors.New("worlds are not synched")
)

Errors raised.

View Source
var WorldNames = map[int]World{
	1001: {1001, "Anvil Rock"},
	1002: {1002, "Borlis Pass"},
	1003: {1003, "Yak's Bend"},
	1004: {1004, "Henge of Denravi"},
	1005: {1005, "Maguuma"},
	1006: {1006, "Sorrow's Furnace"},
	1007: {1007, "Gate of Madness"},
	1008: {1008, "Jade Quarry"},
	1009: {1009, "Fort Aspenwood"},
	1010: {1010, "Ehmry Bay"},
	1011: {1011, "Stormbluff Isle"},
	1012: {1012, "Darkhaven"},
	1013: {1013, "Sanctum of Rall"},
	1014: {1014, "Crystal Desert"},
	1015: {1015, "Isle of Janthir"},
	1016: {1016, "Sea of Sorrows"},
	1017: {1017, "Tarnished Coast"},
	1018: {1018, "Northern Shiverpeaks"},
	1019: {1019, "Blackgate"},
	1020: {1020, "Ferguson's Crossing"},
	1021: {1021, "Dragonbrand"},
	1022: {1022, "Kaineng"},
	1023: {1023, "Devona's Rest"},
	1024: {1024, "Eredon Terrace"},
	2001: {2001, "Fissure of Woe"},
	2002: {2002, "Desolation"},
	2003: {2003, "Gandara"},
	2004: {2004, "Blacktide"},
	2005: {2005, "Ring of Fire"},
	2006: {2006, "Underworld"},
	2007: {2007, "Far Shiverpeaks"},
	2008: {2008, "Whiteside Ridge"},
	2009: {2009, "Ruins of Surmia"},
	2010: {2010, "Seafarer's Rest"},
	2011: {2011, "Vabbi"},
	2012: {2012, "Piken Square"},
	2013: {2013, "Aurora Glade"},
	2014: {2014, "Gunnar's Hold"},
	2101: {2101, "Jade Sea [FR]"},
	2102: {2102, "Fort Ranik [FR]"},
	2103: {2103, "Augury Rock [FR]"},
	2104: {2104, "Vizunah Square [FR]"},
	2105: {2105, "Arborstone [FR]"},
	2201: {2201, "Kodash [DE]"},
	2202: {2202, "Riverside [DE]"},
	2203: {2203, "Elona Reach [DE]"},
	2204: {2204, "Abaddon's Mouth [DE]"},
	2205: {2205, "Drakkar Lake [DE]"},
	2206: {2206, "Miller's Sound [DE]"},
	2207: {2207, "Dzagonur [DE]"},
	2301: {2301, "Baruch Bay [SP]"},
}

WorldNames is a hardcoded list of all world id's and its respective world representation object

Functions

func GetAPIKeyCode

func GetAPIKeyCode(platformID int, platformUserId string) string

GetAPIKeyCode creates a 16 character MD5 hash based on the platformUserId The hash doesn't need to be secure, so don't worry about it being MD5

func GetAPIKeyName

func GetAPIKeyName(worldPerspective *int, platformID int, platformUserId string) string

GetAPIKeyName creates a 16 character MD5 hash based on the platformUserId The hash doesn't need to be secure, so don't worry about it being MD5 Additionally it prefixes the apikey prefix, along with the service id, if it is above 0

func GetActiveBan

func GetActiveBan(bans []api.Ban) *api.Ban

GetActiveBan returns the longest active ban on an account, if they have any

func GetBan

func GetBan(acc *orm.Account) *orm.Ban

GetBan returns the longest active ban on an account, if they have any

func GetOrInsertUser

func GetOrInsertUser(tx bun.Tx, platformID int, platformUserID string) (*api.User, error)

func GrantEphemeralWorldAssignment

func GrantEphemeralWorldAssignment(tx bun.Tx, userID int64, world int, until time.Time) (err error, userErr error)

GrantEphemeralWorldAssignment temporarily mark the account as being from the given world This will grant the user temporary access, if they are set to be a from a world that would normally grant access

func NormalizedWorldName

func NormalizedWorldName(worldID int) string

NormalizedWorldName returns the string representation of the world by its id

func SetOrReplacePlatformLink(idb bun.IDB, platformID int, platformUserID string, primary bool, userID int64) (err error)

SetOrReplacePlatformLink creates or replaces a service link between a service user and an account

Types

type BanService

type BanService struct {
	// contains filtered or unexported fields
}

func NewBanService

func NewBanService(em *EventEmitter) *BanService

func (*BanService) BanServiceUser

func (bs *BanService) BanServiceUser(expiration time.Time, reason string, platformID int, platformUserId string) error

BanServiceUser bans a user's gw2 account for the given duration

func (*BanService) BanUser

func (bs *BanService) BanUser(expiration time.Time, reason string, userID int64) error

BanServiceUser bans a user's gw2 account for the given duration

type EventEmitter

type EventEmitter struct {
	// contains filtered or unexported fields
}

func NewEventEmitter

func NewEventEmitter(verification *Verification) *EventEmitter

func (*EventEmitter) Emit

func (em *EventEmitter) Emit(user *api.User)

func (*EventEmitter) GetStatusListener

func (em *EventEmitter) GetStatusListener(id string, platformID *int, worldPerspective int) chan *api.VerificationStatus

func (*EventEmitter) GetUserListener

func (em *EventEmitter) GetUserListener(id string, platformID *int) chan *api.User

func (*EventEmitter) Process

func (em *EventEmitter) Process(oldUser *api.User, newUser *api.User)

func (*EventEmitter) ShouldEmitAccount

func (em *EventEmitter) ShouldEmitAccount(oldAccount *api.Account, newAccount *api.Account) bool

func (*EventEmitter) ShouldEmitAccounts

func (em *EventEmitter) ShouldEmitAccounts(oldAccounts []api.Account, newAccounts []api.Account) bool

func (*EventEmitter) ShouldEmitEphemeralAssociations

func (em *EventEmitter) ShouldEmitEphemeralAssociations(olds []api.EphemeralAssociation, news []api.EphemeralAssociation) bool

type LinkedWorlds

type LinkedWorlds map[string]api.WorldLinks

type UserEventListener

type UserEventListener struct {
	ID         string
	PlatformID *int
	// contains filtered or unexported fields
}

type Verification

type Verification struct {
	// contains filtered or unexported fields
}

func NewVerification

func NewVerification(worlds *Worlds) *Verification

func (*Verification) AccountStatus

func (v *Verification) AccountStatus(worldPerspective int, acc *api.Account) api.Status

AccountStatus checks the verification api.ACCESS status for an account given a world perspective

func (*Verification) AccountWorldStatus

func (v *Verification) AccountWorldStatus(worldPerspective int, world int, ephemeral bool) api.Status

func (*Verification) Status

func (v *Verification) Status(worldPerspective int, user *api.User) api.Status

type VerificationStatusListener

type VerificationStatusListener struct {
	ID               string
	WorldPerspective int
	PlatformID       *int
	// contains filtered or unexported fields
}

type World

type World struct {
	ID   int
	Name string
}

World represents a server world

type Worlds

type Worlds struct {
	// contains filtered or unexported fields
}

func NewWorlds

func NewWorlds(gw2API *gw2api.Session) *Worlds
func (ws *Worlds) GetAllWorldLinks() LinkedWorlds
func (ws *Worlds) GetWorldLinks(worldPerspective int) (links []int, err error)

func (*Worlds) IsWorldLinksSynchronized

func (ws *Worlds) IsWorldLinksSynchronized() bool

func (*Worlds) Start

func (ws *Worlds) Start()
func (ws *Worlds) SynchronizeWorldLinks(gw2API *gw2api.Session) error

Jump to

Keyboard shortcuts

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