cmd/accounts.go
changeset 223 0412068a9445
parent 222 e93d9c738273
child 224 d33a2c4fdfbf
equal deleted inserted replaced
222:e93d9c738273 223:0412068a9445
    35 	accountIDs            string // For account relationships
    35 	accountIDs            string // For account relationships
    36 	statusIDs             string // For account reports
    36 	statusIDs             string // For account reports
    37 	comment               string // For account reports
    37 	comment               string // For account reports
    38 	displayName, note     string // For account update
    38 	displayName, note     string // For account update
    39 	avatar, header        string // For account update
    39 	avatar, header        string // For account update
       
    40 	defaultLanguage       string // For account update
       
    41 	defaultPrivacy        string // For account update
       
    42 	defaultSensitive      bool   // For account update
    40 	locked, bot           bool   // For account update
    43 	locked, bot           bool   // For account update
    41 	muteNotifications     bool   // For account mute
    44 	muteNotifications     bool   // For account mute
    42 	following             bool   // For account search
    45 	following             bool   // For account search
    43 }
    46 }
    44 
    47 
    84 
    87 
    85 	accountUpdateSubcommand.Flags().StringVar(&accountsOpts.displayName, "display-name", "", "User display name")
    88 	accountUpdateSubcommand.Flags().StringVar(&accountsOpts.displayName, "display-name", "", "User display name")
    86 	accountUpdateSubcommand.Flags().StringVar(&accountsOpts.note, "note", "", "User note (a.k.a. bio)")
    89 	accountUpdateSubcommand.Flags().StringVar(&accountsOpts.note, "note", "", "User note (a.k.a. bio)")
    87 	accountUpdateSubcommand.Flags().StringVar(&accountsOpts.avatar, "avatar", "", "User avatar image")
    90 	accountUpdateSubcommand.Flags().StringVar(&accountsOpts.avatar, "avatar", "", "User avatar image")
    88 	accountUpdateSubcommand.Flags().StringVar(&accountsOpts.header, "header", "", "User header image")
    91 	accountUpdateSubcommand.Flags().StringVar(&accountsOpts.header, "header", "", "User header image")
       
    92 	accountUpdateSubcommand.Flags().StringVar(&accountsOpts.defaultLanguage, "default-language", "", "Default toots language (iso 639 code)")
       
    93 	accountUpdateSubcommand.Flags().StringVar(&accountsOpts.defaultPrivacy, "default-privacy", "", "Default toot privacy (public, unlisted, private)")
       
    94 	accountUpdateSubcommand.Flags().BoolVar(&accountsOpts.defaultSensitive, "default-sensitive", false, "Mark medias as sensitive by default")
    89 	accountUpdateSubcommand.Flags().BoolVar(&accountsOpts.locked, "locked", false, "Following account requires approval")
    95 	accountUpdateSubcommand.Flags().BoolVar(&accountsOpts.locked, "locked", false, "Following account requires approval")
    90 	accountUpdateSubcommand.Flags().BoolVar(&accountsOpts.bot, "bot", false, "Set as service (automated) account")
    96 	accountUpdateSubcommand.Flags().BoolVar(&accountsOpts.bot, "bot", false, "Set as service (automated) account")
    91 
    97 
    92 	// Those variables will be used to check if the options were
    98 	// Those variables will be used to check if the options were
    93 	// explicitly set or not
    99 	// explicitly set or not
   623 		var report *madon.Report
   629 		var report *madon.Report
   624 		report, err = gClient.ReportUser(opt.accountID, ids, opt.comment)
   630 		report, err = gClient.ReportUser(opt.accountID, ids, opt.comment)
   625 		obj = report
   631 		obj = report
   626 	case "update":
   632 	case "update":
   627 		var updateParams madon.UpdateAccountParams
   633 		var updateParams madon.UpdateAccountParams
       
   634 		var source *madon.SourceParams
   628 		change := false
   635 		change := false
   629 
   636 
   630 		if accountUpdateFlags.Lookup("display-name").Changed {
   637 		if accountUpdateFlags.Lookup("display-name").Changed {
   631 			updateParams.DisplayName = &opt.displayName
   638 			updateParams.DisplayName = &opt.displayName
   632 			change = true
   639 			change = true
   645 		}
   652 		}
   646 		if accountUpdateFlags.Lookup("locked").Changed {
   653 		if accountUpdateFlags.Lookup("locked").Changed {
   647 			updateParams.Locked = &opt.locked
   654 			updateParams.Locked = &opt.locked
   648 			change = true
   655 			change = true
   649 		}
   656 		}
   650 
       
   651 		if accountUpdateFlags.Lookup("bot").Changed {
   657 		if accountUpdateFlags.Lookup("bot").Changed {
   652 			updateParams.Bot = &opt.bot
   658 			updateParams.Bot = &opt.bot
       
   659 			change = true
       
   660 		}
       
   661 		if accountUpdateFlags.Lookup("default-language").Changed {
       
   662 			if source == nil {
       
   663 				source = &madon.SourceParams{}
       
   664 			}
       
   665 			source.Language = &opt.defaultLanguage
       
   666 			change = true
       
   667 		}
       
   668 		if accountUpdateFlags.Lookup("default-privacy").Changed {
       
   669 			if source == nil {
       
   670 				source = &madon.SourceParams{}
       
   671 			}
       
   672 			source.Privacy = &opt.defaultPrivacy
       
   673 			change = true
       
   674 		}
       
   675 		if accountUpdateFlags.Lookup("default-sensitive").Changed {
       
   676 			if source == nil {
       
   677 				source = &madon.SourceParams{}
       
   678 			}
       
   679 			source.Sensitive = &opt.defaultSensitive
   653 			change = true
   680 			change = true
   654 		}
   681 		}
   655 
   682 
   656 		/*
   683 		/*
   657 			TODO:
   684 			TODO:
   658 			updateParams.FieldsAttributes
   685 			updateParams.FieldsAttributes
   659 			updateParams.Source
       
   660 		*/
   686 		*/
   661 
   687 
   662 		if !change { // We want at least one update
   688 		if !change { // We want at least one update
   663 			return errors.New("missing parameters")
   689 			return errors.New("missing parameters")
   664 		}
   690 		}
       
   691 
       
   692 		updateParams.Source = source
   665 
   693 
   666 		var account *madon.Account
   694 		var account *madon.Account
   667 		account, err = gClient.UpdateAccount(updateParams)
   695 		account, err = gClient.UpdateAccount(updateParams)
   668 		obj = account
   696 		obj = account
   669 	default:
   697 	default: