account

package
v0.0.0-...-89b6d9c Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Show action.Action = func(ctx context.Context) error {
	l := logger.WithField("func", "Show")

	dbClient, err := bun.New(ctx)
	if err != nil {
		l.Errorf("db: %s", err.Error())
		return err
	}
	defer func() {
		err := dbClient.Close(ctx)
		if err != nil {
			l.Errorf("closing db: %s", err.Error())
		}
	}()

	account := viper.GetString(config.Keys.UserAccount)
	l.Infof("reading account %s", account)
	username, domain, err := fedi.SplitAccount(account)
	if err != nil {
		l.Errorf("splitting account: %s", err.Error())
		return err
	}

	instance, err := dbClient.ReadFediInstanceByDomain(ctx, domain)
	if err != nil {
		l.Errorf("read instance: %s", err.Error())
		return err
	}
	if instance == nil {
		l.Infof("instance '%s' not found", domain)
	}

	user, err := dbClient.ReadFediAccountByUsername(ctx, instance, username)
	if err != nil {
		l.Errorf("readng : %s", err.Error())
		return err
	}

	l.Infof("DB ID:          %d", user.ID)
	l.Infof("Account:        @%s@%s", user.Username, instance.Domain)
	l.Infof("Display Name:   %s", user.DisplayName)
	l.Infof("Sign In Count:  %d", user.SignInCount)

	return nil
}

Show displays info about a account

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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