models

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 20 Imported by: 2

Documentation

Index

Constants

View Source
const KEYSIZE = 32

KEYSIZE AES-256-GCMに必要なキーのサイズ

Variables

This section is empty.

Functions

func CheckColumns

func CheckColumns(df dataframe.DataFrame) error

func CheckDupID

func CheckDupID(id, spreadID string, accounts []Account) error

CheckDupID SpreadID, UserIDの重複を確認

func CheckDuplicate

func CheckDuplicate(str []string) []string

配列の重複チェック

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

func DecryptPassword

func DecryptPassword(ciphertext string, key []byte) (string, error)

DecryptPassword は、与えられた暗号文を復号化します

func DfNrowToLastNrow

func DfNrowToLastNrow(df dataframe.DataFrame) int

DfNrowToLastNrow Nrowを末尾に追加するためのNrowを返す

func EncryptPassword

func EncryptPassword(password string, key []byte) (string, error)

EncryptPassword は、与えられたパスワードを暗号化します

func GenerateKey

func GenerateKey() ([]byte, error)

GenerateKey は、AES-256-GCMに必要なキーを生成します

func GetUniqueKeys

func GetUniqueKeys[T any](data []T, extractor GetUniqueExtractor[T]) []string

GetUniqueKeys は汎用的な型 T のスライスに対応し、ユニークなキーのリストを返します。 extractor パラメータは、各要素からキーを抽出する関数です。

func IsTime

func IsTime(times []time.Time, t time.Time) bool

func Mask

func Mask(s string) string

Mask 文字伏せ

func StrUpsideDown

func StrUpsideDown(s string) string

StrUpsideDown は文字列を伏せ字にします。

func ToHash

func ToHash(password string) (string, error)

Types

type Account

type Account struct {
	UUID         string         `csv:"uuid" dataframe:"uuid" firestore:"uuid,omitempty" json:"uuid,omitempty"`
	ID           string         `csv:"id" dataframe:"id" firestore:"id,omitempty" json:"id,omitempty"`
	Password     string         `csv:"password" dataframe:"password" firestore:"password,omitempty" json:"password,omitempty"`
	SpreadID     string         `csv:"spread_id" dataframe:"spread_id" firestore:"spread_id,omitempty" json:"spread_id,omitempty"`
	AccessToken  string         `csv:"access_token" dataframe:"access_token" firestore:"access_token,omitempty" json:"access_token,omitempty"`
	AccessSecret string         `csv:"access_secret" dataframe:"access_secret" firestore:"access_secret,omitempty" json:"access_secret,omitempty"`
	Subscribed   SubscribedPlan `csv:"subscribed" dataframe:"subscribed" firestore:"subscribed,omitempty" json:"subscribed,omitempty"`
}

func NewAccount

func NewAccount(id, sheetID, accessToken, accessSecret string) *Account

NewAccountForFree 初回会員登録用

func (Account) GetID

func (p Account) GetID() string

GetID for interface

func (*Account) SetSubscribed

func (a *Account) SetSubscribed(level SubscribedPlan) *Account

SetSubscribed 有料プランの設定

type Claims

type Claims struct {
	ID string `firestore:"id" json:"id,omitempty"`

	AccessToken  string `firestore:"access_token" json:"access_token,omitempty"`
	AccessSecret string `firestore:"access_secret" json:"access_secret,omitempty"`

	// Auth Request Token
	RequestToken       string `firestore:"request_token" json:"request_token,omitempty"`
	RequestTokenSecret string `firestore:"request_token_secret" json:"request_token_secret,omitempty"`

	SpreadsheetID string `firestore:"spreadsheet_id" json:"spreadsheet_id,omitempty"`
}

func (Claims) GetID

func (p Claims) GetID() string

GetID for interface

type ClientForFirestore

type ClientForFirestore struct {
	ProjectID      string
	CredentialFile string
}

func (*ClientForFirestore) Get

func (p *ClientForFirestore) Get(ctx context.Context, colName, docKey string, data any) error

Get dataはpointer, 参照渡し

func (*ClientForFirestore) IsExist

func (p *ClientForFirestore) IsExist(ctx context.Context, colName string, docKeys ...string) (isExistKeys []string, err error)

func (*ClientForFirestore) NewClient

func (p *ClientForFirestore) NewClient(ctx context.Context) (*firestore.Client, error)

func (*ClientForFirestore) Set

func (p *ClientForFirestore) Set(ctx context.Context, colName, docKey string, data any) error

Set dataはnot pointer, 値渡し

type GetUniqueExtractor

type GetUniqueExtractor[T any] func(T) string

GetUniqueExtractor は一意なキーを取得する関数型

type Group

type Group struct {
	ParentPostId string `firestore:"parentPost_id" csv:"-" json:"parent_post_id,omitempty"`
	OwnerId      string `firestore:"owner_id" csv:"-" json:"owner_id,omitempty"`

	// IsOn: 連投投稿のグループかどうか
	IsOn bool `firestore:"is_on,omitempty" csv:"-" json:"is_on,omitempty"`

	ChildPostIds []string `firestore:"post_id,omitempty" csv:"-" json:"child_post_ids,omitempty"`
}

Group struct: 連投投稿のグループを表す ParentPostId: 親投稿のID

type Post

type Post struct {
	UUID string `csv:"uuid" dataframe:"uuid" firestore:"uuid,omitempty" json:"uuid,omitempty"`
	// ID is Twitter/X AccountID
	ID        string `csv:"id" dataframe:"id" firestore:"id" json:"id,omitempty"`
	Text      string `csv:"text" dataframe:"text" firestore:"text" json:"text,omitempty"`
	File1     string `csv:"file1" dataframe:"file1" firestore:"file_1,omitempty" json:"file_1,omitempty"`
	File2     string `csv:"file2" dataframe:"file2" firestore:"file_2,omitempty" json:"file_2,omitempty"`
	File3     string `csv:"file3" dataframe:"file3" firestore:"file_3,omitempty" json:"file_3,omitempty"`
	File4     string `csv:"file4" dataframe:"file4" firestore:"file_4,omitempty" json:"file_4,omitempty"`
	WithFiles int    `csv:"with_files" dataframe:"with_files" firestore:"with_files" json:"with_files,omitempty"`
	Checked   int    `csv:"checked" dataframe:"checked" firestore:"checked" json:"checked,omitempty"`
	Priority  int    `csv:"priority" dataframe:"priority" firestore:"priority" json:"priority,omitempty"`
	Count     int    `csv:"count" dataframe:"count" firestore:"count,omitempty" json:"count,omitempty"`
	PostURL   string `csv:"post_url" dataframe:"post_url" firestore:"post_url,omitempty" json:"post_url,omitempty"`

	IsSchedule bool `csv:"is_schedule" dataframe:"is_schedule" firestore:"is_schedule" json:"is_schedule,omitempty"`

	// 以下は、csv, dataframeには含まれない
	IsDelete     bool      `csv:"-" dataframe:"-" firestore:"is_delete" json:"-,omitempty"`
	LastPostedAt time.Time `csv:"-" dataframe:"-" firestore:"last_posted_at,omitempty" json:"last_posted_at,omitempty"`
	CreatedAt    time.Time `csv:"-" dataframe:"-" firestore:"created_at,omitempty" json:"created_at,omitempty"`
}

func (Post) GetID

func (p Post) GetID() string

func (*Post) IsPastLastPostedAt

func (p *Post) IsPastLastPostedAt(minutes int) bool

IsLastPostedAt LastPostedAtの時間を比較 More than the specified time has elapsed.

func (*Post) SetCreateAt

func (p *Post) SetCreateAt() bool

func (*Post) SetLastPostedAt

func (p *Post) SetLastPostedAt() bool

func (*Post) ToURLValues

func (p *Post) ToURLValues() url.Values

ToURLValues PostID, AccountIDをURLValuesに変換 この値を使って、Firestore[Accounts,Posts]からデータを取得する

type Rule

type Rule struct {
	UUID string `csv:"-" dataframe:"uuid" firestore:"uuid,omitempty" json:"uuid,omitempty"`

	// IsDisenable is a flag for enable posting.
	// why: 一時的な投稿停止を行うためのフラグ。投稿停止中は投稿を行わない。
	IsDisenable bool `csv:"-" dataframe:"is_disenable" firestore:"is_disenable,omitempty" json:"is_disenable,omitempty"`

	// IsImmediate is a flag for immediate posting.
	IsImmediate bool `csv:"-" dataframe:"is_immediate" firestore:"is_immediate,omitempty" json:"is_immediate,omitempty"`

	// IsScheduleAllPosts 同時刻のスケジュール予約がある場合、全ての投稿を有効にするかどうか
	// why: 複数投稿を同時刻に行う場合、全ての投稿を有効にするかどうかを設定する。年・月・週指定の同時刻投稿を行いたい。
	IsScheduleAllPosts bool `csv:"-" dataframe:"is_schedule_all_posts" firestore:"is_schedule_all_posts,omitempty" json:"is_schedule_all_posts,omitempty"`

	// 投稿期間: 投稿情報の投稿最終時間からの計画時間
	// TermHours is the default posting period.
	TermHours int `csv:"-" dataframe:"term_hours" firestore:"term_hours,omitempty" json:"term_hours,omitempty"`

	// 投稿時間群
	// Times is setting multiple times. Rule.Times > Schedule.Times
	Times []time.Time `csv:"-" dataframe:"times" firestore:"times,omitempty" json:"times,omitempty"`
}

Rule is a struct that represents the setting of a row.

type Schedule

type Schedule struct {
	PostID string `csv:"-" dataframe:"post_id" firestore:"post_id,omitempty" json:"post_id,omitempty"`

	OwnerId string `csv:"-" dataframe:"owner_id" firestore:"owner_id,omitempty" json:"owner_id,omitempty"`

	IsSchedule bool `csv:"-" dataframe:"is_schedule" firestore:"is_schedule,omitempty" json:"is_schedule,omitempty"`

	// IsImmediate is a flag for immediate posting.
	// 即時投稿設定
	IsImmediate bool `csv:"-" dataframe:"is_immediate" firestore:"is_immediate,omitempty" json:"is_immediate,omitempty"`

	TypeSchedule TypeSchedule `csv:"-" dataframe:"type_schedule" firestore:"type_schedule,omitempty" json:"type_schedule,omitempty"`

	// Month is the day of the month.
	// set day
	Month time.Month `csv:"-" dataframe:"month" firestore:"month,omitempty" json:"month,omitempty"`

	// Day is the day.
	Day int `csv:"-" dataframe:"day" firestore:"day,omitempty" json:"day,omitempty"`

	// Week is the day of the week.
	// set weekday
	Week time.Weekday `csv:"-" dataframe:"week" firestore:"week,omitempty" json:"week,omitempty"`

	// Times is setting multiple times.
	Times []time.Time `csv:"-" dataframe:"times" firestore:"times,omitempty" json:"times,omitempty"`
}

Schedule is a struct for scheduling posts.

func (Schedule) IsScheduleToday

func (s Schedule) IsScheduleToday(t time.Time) bool

IsScheduleToday is a function to determine if the schedule is today. Yearly, Monthly, Weekly, Dailyは個別投稿設定扱い

type SubscribedPlan

type SubscribedPlan uint8
const (
	Unsubscribed SubscribedPlan = iota
	SubscribedFree
	SubscribedBasic
	SubscribedPro
)

type TypeSchedule

type TypeSchedule int
const (
	None    TypeSchedule = iota
	Yearly               // 1年ごと
	Monthly              // 1ヶ月ごと
	Weekly               // 1週間ごと
	Daily                // 1日ごと
)

func (TypeSchedule) String

func (p TypeSchedule) String() string

Jump to

Keyboard shortcuts

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