model

package
v0.0.0-...-83adff0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2020 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TempTaskPrefix used to separate from the DB tasks.
	TempTaskPrefix = "t"

	// APPIDBBPhone 哔哩哔哩动画
	APPIDBBPhone = 1

	// HTTPCodeOk http response normally.
	HTTPCodeOk = 0

	// SwitchOff off.
	SwitchOff = 0
	// SwitchOn on.
	SwitchOn = 1

	// DelMiFeedback feedback 删除 (无效token删除方式)
	DelMiFeedback = 1
	// DelMiUninstalled 卸载
	DelMiUninstalled = 2

	// DefaultMessageTitle .
	DefaultMessageTitle = "哔哩哔哩消息"

	// UnknownBuild 未知build号
	UnknownBuild = 0
)
View Source
const (
	// MobiAndroid mobi_app android
	MobiAndroid = 1
	// MobiIPhone mobi_app iPhone
	MobiIPhone = 2
	// MobiIPad mobi_app iPad
	MobiIPad = 3
	// MobiAndroidComic
	MobiAndroidComic = 4
)
View Source
const (
	// TaskStatusPending 待审核
	TaskStatusPending = int8(-5)
	// TaskStatusStop 主动�停止
	TaskStatusStop = int8(-4)
	// TaskStatusDelay 延期
	TaskStatusDelay = int8(-3)
	// TaskStatusExpired 过期
	TaskStatusExpired = int8(-2)
	// TaskStatusFailed 失败
	TaskStatusFailed = int8(-1)
	// TaskStatusPrepared 未开始
	TaskStatusPrepared = int8(0)
	// TaskStatusDoing 进行中
	TaskStatusDoing = int8(1)
	// TaskStatusDone 已完成
	TaskStatusDone = int8(2)
	// TaskStatusPretreatmentPrepared 等待预处理,处理完后是按平台拆成任务(token形式)
	TaskStatusPretreatmentPrepared = int8(3)
	// TaskStatusPretreatmentDoing 预处理中
	TaskStatusPretreatmentDoing = int8(4)
	// TaskStatusPretreatmentDone 预处理完成
	TaskStatusPretreatmentDone = int8(5)
	// TaskStatusPretreatmentFailed 预处理失败
	TaskStatusPretreatmentFailed = int8(6)
	// TaskStatusWaitDataPlatform 等待从数据平台获取数据
	TaskStatusWaitDataPlatform = int8(7)
)

task status

View Source
const (
	// DpCondStatusNoFile 没有查询到文件
	DpCondStatusNoFile = -3
	// DpCondStatusPending 待审核
	DpCondStatusPending = -2
	// DpCondStatusFailed 失败的查询
	DpCondStatusFailed = -1
	// DpCondStatusPrepared 准备提交到数据平台的查询
	DpCondStatusPrepared = 0
	// DpCondStatusSubmitting 提交中
	DpCondStatusSubmitting = 1
	// DpCondStatusSubmitted 已经提交的查询
	DpCondStatusSubmitted = 2
	// DpCondStatusPolling 轮询任务看有没有生成文件
	DpCondStatusPolling = 3
	// DpCondStatusDownloading 正在下载文件
	DpCondStatusDownloading = 4
	// DpCondStatusDone 已经完成的查询
	DpCondStatusDone = 5

	// DpTaskTypeMid mid维度查询
	DpTaskTypeMid = 1
	// DptaskTypeToken token维度查询
	DpTaskTypeToken = 2
)

data platform

View Source
const (
	// TaskTypeAll 后台全量
	TaskTypeAll = 1
	// TaskTypePart 后台批量
	TaskTypePart = 2
	// TaskTypeBusiness 业务推送
	TaskTypeBusiness = 3
	// TaskTypeTokens 批量token推送
	TaskTypeTokens = 4
	// TaskTypeMngMid 后台按mid推送
	TaskTypeMngMid = 5
	// TaskTypeMngToken 后台按token推送
	TaskTypeMngToken = 6
	// TaskTypeStrategyMid 策略层按mid推送
	TaskTypeStrategyMid = 7
	// TaskTypeDataPlatformMid 通过mid维度从数据平台获取token
	TaskTypeDataPlatformMid = 8
	// TaskTypeDataPlatformToken 通过token维度从数据平台获取token
	TaskTypeDataPlatformToken = 9
)
View Source
const (
	// LinkTypeBangumi bangumi 协议链接类型
	LinkTypeBangumi = int8(1)
	// LinkTypeVideo 视频
	LinkTypeVideo = int8(2)
	// LinkTypeLive 直播
	LinkTypeLive = int8(3)
	// LinkTypeSplist 专题页
	LinkTypeSplist = int8(4)
	// LinkTypeSearch 搜索
	LinkTypeSearch = int8(5)
	// LinkTypeAuthor 个人空间
	LinkTypeAuthor = int8(6)
	// LinkTypeBrowser 浏览器
	LinkTypeBrowser = int8(7)
	// LinkTypeVipBuy 大会员购买页
	LinkTypeVipBuy = int8(10)
	// LinkTypeCustom 自定义协议内容
	LinkTypeCustom = int8(11)
)
View Source
const (

	// SchemeBangumiSeasonIOS 番剧详情 iPhone,iPadHD 支持番剧
	SchemeBangumiSeasonIOS = "bilibili://bangumi/season/"
	// SchemeBangumiSeasonAndroid .
	SchemeBangumiSeasonAndroid = "bili:///?type=season&season_id="

	// SchemeVideoIOS 视频详情页 iPhone,iPadHD 支持视频
	SchemeVideoIOS = "bilibili://video/"
	// SchemeVideoAndroid .
	SchemeVideoAndroid = "bili:///?type=bilivideo&avid="

	// SchemeLive 直播详情页, 支持 iOS 和 Android 新协议
	SchemeLive = "bilibili://live/"
	// SchemeLiveAndroid Android 老协议
	SchemeLiveAndroid = "bili:///?type=bililive&roomid="

	// SchemeSplist 专题页 iPhone, iPadHD, Android 支持专题
	SchemeSplist = "bilibili://splist/"

	// SchemeSearchIOS 搜索 iPhone,iPadHD 支持搜索
	SchemeSearchIOS = "bilibili://search/?keyword="
	// SchemeSearchAndroid .
	SchemeSearchAndroid = "bilibili://search/"

	// SchemeAuthorIOS 个人空间 iPhone,iPadHD 支持个人空间
	SchemeAuthorIOS = "bilibili://user/"
	// SchemeAuthorAndroid .
	SchemeAuthorAndroid = "bilibili://author/"

	// SchemeBrowserIOS 指定URL iPhone,iPadHD 支持H5
	SchemeBrowserIOS = "bilibili://browser/?url="
	// SchemeBrowserAndroid .
	SchemeBrowserAndroid = "bili:///?type=weblink&url="

	// SchemeVipBuy 大会员购买页
	SchemeVipBuy = "bilibili://user_center/vip/buy/"
)
View Source
const (
	// PushSDKApns apns sdk.
	PushSDKApns = 1
	// PushSDKXiaomi mipush sdk.
	PushSDKXiaomi = 2
	// PushSDKHuawei huawei sdk.
	PushSDKHuawei = 3
	// PushSDKOppo oppo sdk.
	PushSDKOppo = 5
	// PushSDKJpush jpush sdk.
	PushSDKJpush = 6
	// PushSDKFCM fcm sdk
	PushSDKFCM = 7
)

PushSDK* for parameter 'push_sdk' in http report API.

View Source
const (
	// PlatformUnknown unknown.
	PlatformUnknown = 0
	// PlatformAndroid Android.
	PlatformAndroid = 1
	// PlatformIPhone iPhone.
	PlatformIPhone = 2
	// PlatformIPad iPad.
	PlatformIPad = 3
	// PlatformXiaomi mipush.
	PlatformXiaomi = 4
	// PlatformHuawei huawei.
	PlatformHuawei = 5
	// PlatformOppo oppo.
	PlatformOppo = 8
	// PlatformJpush jpush.
	PlatformJpush = 9
	// PlatformFCM fcm
	PlatformFCM = 10
)
View Source
const (
	// UserSettingArchive up主新投稿提醒
	UserSettingArchive = 1
	// UserSettingLive 主播开播提醒
	UserSettingLive = 2
)

Variables

Platforms all platform

Settings .

Functions

func DeviceBrand

func DeviceBrand(s string) int

DeviceBrand .

func ExistsInt

func ExistsInt(ints []int, item int) (exists bool)

ExistsInt judge if item in the ints.

func Hash

func Hash(salt string) string

Hash gen hash value by solt.

func HashToken

func HashToken(token string) int64

HashToken gets token's hash value.

func IsAndroid

func IsAndroid(platformID int) bool

IsAndroid .

func JobName

func JobName(timestamp int64, content, linkValue, group string) int64

JobName gen job name.

func JoinInts

func JoinInts(ints []int) string

JoinInts merges int slice to string.

func ParseBuild

func ParseBuild(s string) (builds map[int]*Build)

ParseBuild parses string to build struct.

func Platform

func Platform(platform string, pushSDK int) int

Platform gets real platform.

func RealTime

func RealTime(reportZone int) time.Time

RealTime culculates real time by timezone.

func Scheme

func Scheme(typ int8, val string, platform, build int) (uri string)

Scheme gets uri scheme.

func SplitInts

func SplitInts(s string) (res []int)

SplitInts splts string to int-slice by ,

func TempTaskID

func TempTaskID() string

TempTaskID gen temporary task ID.

func ValidateBuild

func ValidateBuild(platform, build int, builds map[int]*Build) bool

ValidateBuild checks token&platform valid.

Types

type APP

type APP struct {
	ID            int64
	Name          string
	PushLimitUser int
}

APP appication

type ArgCallback

type ArgCallback struct {
	Task     string
	APP      int64
	Platform int
	Mid      int64
	Pid      int // mobi_app ID
	Token    string
	Buvid    string
	Click    uint8 // 是否被点击
	Extra    *CallbackExtra
}

ArgCallback .

type ArgDelInvalidReport

type ArgDelInvalidReport struct {
	Type   int
	RealIP string
}

ArgDelInvalidReport .

type ArgMid

type ArgMid struct {
	Mid    int64
	RealIP string
}

ArgMid .

type ArgMidProgress

type ArgMidProgress struct {
	Task     string
	MidTotal int64
	MidValid int64
	RealIP   string
}

ArgMidProgress .

type ArgMidToken

type ArgMidToken struct {
	Mid    int64
	Token  string
	RealIP string
}

ArgMidToken .

type ArgReport

type ArgReport struct {
	ID           int64
	APPID        int64
	PlatformID   int
	Mid          int64
	Buvid        string
	DeviceToken  string
	Build        int
	TimeZone     int
	NotifySwitch int
	DeviceBrand  string
	DeviceModel  string
	OSVersion    string
	Extra        string
	RealIP       string
}

ArgReport .

type ArgReports

type ArgReports struct {
	Reports []*Report
}

ArgReports .

type ArgSetting

type ArgSetting struct {
	Mid    int64
	Type   int
	Value  int
	RealIP string
}

ArgSetting .

type ArgToken

type ArgToken struct {
	Token  string
	RealIP string
}

ArgToken .

type ArgUserReports

type ArgUserReports struct {
	Mid     int64
	Reports []*Report
}

ArgUserReports .

type Auth

type Auth struct {
	APPID      int64
	PlatformID int
	Name       string // 第三方名称 for android,例如 小米
	Key        string // android的包名 或 iOS的 cert key
	Value      string // android的 auth 或 iOS的 cert value
	BundleID   string // just for iOS
}

Auth cert or auth info.

type Build

type Build struct {
	Build     int    `json:"build"`
	Condition string `json:"condition"`
}

Build version limit.

type Business

type Business struct {
	ID            int64              `json:"id"`
	APPID         int64              `json:"app_id"`
	Name          string             `json:"name"`
	Desc          string             `json:"desc"`
	Token         string             `json:"token"`
	Sound         int                `json:"sound"`
	Vibration     int                `json:"vibration"`
	ReceiveSwitch int                `json:"receive_switch"`
	PushSwitch    int                `json:"push_switch"`
	SilentTime    BusinessSilentTime `json:"silent_time"`
	PushLimitUser int                `json:"push_limit_user"`
	Whitelist     int                `json:"whitelist"`
}

Business business

type BusinessSilentTime

type BusinessSilentTime struct {
	BeginHour, EndHour     int
	BeginMinute, EndMinute int
}

BusinessSilentTime .

func ParseSilentTime

func ParseSilentTime(s string) (st BusinessSilentTime)

ParseSilentTime .

type Callback

type Callback struct {
	Task     string
	APP      int64
	Platform int
	Mid      int64
	Pid      int // mobi_app ID
	Token    string
	Buvid    string
	Click    uint8 // 是否被点击
	Brand    int
	Extra    *CallbackExtra
}

Callback push callback.

type CallbackExtra

type CallbackExtra struct {
	Status  int `json:"st"`
	Channel int `json:"chan"`
}

CallbackExtra .

type HTTPResponse

type HTTPResponse struct {
	Code int
	Msg  string
}

HTTPResponse http response.

type Progress

type Progress struct {
	// total indicators
	Status           int8  `json:"st"`            // 任务状态
	MidTotal         int64 `json:"mid_total"`     // 任务接收到的mid总数
	MidValid         int64 `json:"mid_valid"`     // 能查到token的mid数
	MidMissed        int64 `json:"mm"`            // mid_missed 查不到token的mid数
	MidMissedSuccess int64 `json:"mms"`           // mid_missed_success 无效mid补偿推送成功的
	MidMissedFailed  int64 `json:"mmf"`           // mid_missed_failed 无效mid补偿推送失败的
	TokenTotal       int64 `json:"token_total"`   // 一共要推送的token数
	TokenValid       int64 `json:"token_valid"`   // 有效token
	TokenDelay       int64 `json:"token_delay"`   // 延迟推送的token
	TokenSuccess     int64 `json:"token_success"` // 推送成功的
	TokenFailed      int64 `json:"token_failed"`  // 推送失败的

	// brand indicators
	Brands map[int]int64 `json:"brands"` // 各品牌统计数据

	// server indicators
	RetryTimes int64      `json:"retry"` // 重试次数
	BeginTime  xtime.Time `json:"btime"` // 开始时间
	PushTime   xtime.Time `json:"ptime"` // 开始推送时间
	EndTime    xtime.Time `json:"etime"` // 结束时间
}

Progress task push progress.

type PushChanItem

type PushChanItem struct {
	Info *PushInfo
	Item *PushItem
}

PushChanItem push channel item.

type PushChanItems

type PushChanItems struct {
	Info  *PushInfo
	Items []*PushItem
}

PushChanItems push channel item.

type PushInfo

type PushInfo struct {
	Job         int64
	TaskID      string
	APPID       int64
	Title       string
	Summary     string
	LinkType    int8
	LinkValue   string
	PushTime    xtime.Time
	ExpireTime  xtime.Time
	PassThrough int
	Sound       int
	Vibration   int
	ImageURL    string
}

PushInfo push message.

type PushItem

type PushItem struct {
	Platform  int
	Token     string
	Mid       int64
	Sound     int
	Vibration int
	Build     int
}

PushItem push item.

type Report

type Report struct {
	ID           int64  `json:"id"`
	APPID        int64  `json:"app_id"` // application
	PlatformID   int    `json:"platform_id"`
	Mid          int64  `json:"mid"`
	Buvid        string `json:"buvid"`
	Build        int    `json:"build"`
	TimeZone     int    `json:"time_zone"`
	NotifySwitch int    `json:"notify_switch"` // global notification switch
	DeviceToken  string `json:"device_token"`
	DeviceBrand  string `json:"device_brand"`
	DeviceModel  string `json:"device_model"`
	OSVersion    string `json:"os_version"`
	Extra        string `json:"extra"`
	Dtime        int64  `json:"dtime"`
}

Report APP report info.

type Task

type Task struct {
	ID          string         `json:"id"`   // task id
	Job         int64          `json:"job"`  // 多个子任务拥有同一个 job name
	Type        int            `json:"type"` // 任务类型 1:后台全量 2:后台批量 3:业务推送
	APPID       int64          `json:"app_id"`
	BusinessID  int64          `json:"business_id"`
	PlatformID  int            `json:"platform_id"`
	Platform    []int          `json:"platform"`
	Title       string         `json:"title"`
	Summary     string         `json:"summary"`
	LinkType    int8           `json:"link_type"`
	LinkValue   string         `json:"link_value"`
	Build       map[int]*Build `json:"build"`
	Sound       int            `json:"sound"`
	Vibration   int            `json:"vibration"`
	PassThrough int            `json:"pass_through"`
	MidFile     string         `json:"mid_file"`
	Progress    *Progress      `json:"progress"`
	PushTime    xtime.Time     `json:"push_time"`
	ExpireTime  xtime.Time     `json:"expire_time"`
	Status      int8           `json:"status"`
	Group       string         `json:"group"`
	ImageURL    string         `json:"image_url"`
	Extra       *TaskExtra     `json:"extra"`
}

Task push task info.

type TaskExtra

type TaskExtra struct {
	Group    string `json:"group"`
	Filename string `json:"filename,omitempty"` // 任务文件的名称(前端展示用)
}

TaskExtra task extra.

Jump to

Keyboard shortcuts

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