Sync with Madon; switch IDs to int64 integers
authorMikael Berthe <mikael@lilotux.net>
Sun, 30 Apr 2017 20:45:40 +0200
changeset 44 6da40ca4534c
parent 43 59ebd755fdc9
child 45 b58a7ea1aeb2
Sync with Madon; switch IDs to int64 integers
cmd/accounts.go
cmd/madon.go
cmd/media.go
cmd/notifications.go
cmd/status.go
cmd/stream.go
cmd/timelines.go
cmd/toot.go
--- a/cmd/accounts.go	Sun Apr 30 20:02:11 2017 +0200
+++ b/cmd/accounts.go	Sun Apr 30 20:45:40 2017 +0200
@@ -17,10 +17,11 @@
 )
 
 var accountsOpts struct {
-	accountID                 int
+	accountID                 int64
 	accountUID                string
 	unset                     bool   // TODO remove eventually?
-	limit, sinceID, maxID     uint   // Limit the results
+	limit                     uint   // Limit the results
+	sinceID, maxID            int64  // Query boundaries
 	all                       bool   // Try to fetch all results
 	onlyMedia, excludeReplies bool   // For acccount statuses
 	remoteUID                 string // For account follow
@@ -43,11 +44,11 @@
 	accountsCmd.AddCommand(accountSubcommands...)
 
 	// Global flags
-	accountsCmd.PersistentFlags().IntVarP(&accountsOpts.accountID, "account-id", "a", 0, "Account ID number")
+	accountsCmd.PersistentFlags().Int64VarP(&accountsOpts.accountID, "account-id", "a", 0, "Account ID number")
 	accountsCmd.PersistentFlags().StringVarP(&accountsOpts.accountUID, "user-id", "u", "", "Account user ID")
 	accountsCmd.PersistentFlags().UintVarP(&accountsOpts.limit, "limit", "l", 0, "Limit number of results")
-	accountsCmd.PersistentFlags().UintVar(&accountsOpts.sinceID, "since-id", 0, "Request IDs greater than a value")
-	accountsCmd.PersistentFlags().UintVar(&accountsOpts.maxID, "max-id", 0, "Request IDs less (or equal) than a value")
+	accountsCmd.PersistentFlags().Int64Var(&accountsOpts.sinceID, "since-id", 0, "Request IDs greater than a value")
+	accountsCmd.PersistentFlags().Int64Var(&accountsOpts.maxID, "max-id", 0, "Request IDs less (or equal) than a value")
 	accountsCmd.PersistentFlags().BoolVar(&accountsOpts.all, "all", false, "Fetch all results")
 
 	// Subcommand flags
@@ -355,10 +356,10 @@
 		limOpts.Limit = int(opt.limit)
 	}
 	if opt.maxID > 0 {
-		limOpts.MaxID = int(opt.maxID)
+		limOpts.MaxID = opt.maxID
 	}
 	if opt.sinceID > 0 {
-		limOpts.SinceID = int(opt.sinceID)
+		limOpts.SinceID = opt.sinceID
 	}
 
 	// All account subcommands need to have signed in
@@ -460,13 +461,13 @@
 		}
 		obj = accountList
 	case "relationships":
-		var ids []int
+		var ids []int64
 		ids, err = splitIDs(opt.accountIDs)
 		if err != nil {
 			return errors.New("cannot parse account IDs")
 		}
 		if opt.accountID > 0 { // Allow --account-id
-			ids = []int{opt.accountID}
+			ids = []int64{opt.accountID}
 		}
 		if len(ids) < 1 {
 			return errors.New("missing account IDs")
@@ -485,7 +486,7 @@
 			break
 		}
 		// Send a report
-		var ids []int
+		var ids []int64
 		ids, err = splitIDs(opt.statusIDs)
 		if err != nil {
 			return errors.New("cannot parse status IDs")
--- a/cmd/madon.go	Sun Apr 30 20:02:11 2017 +0200
+++ b/cmd/madon.go	Sun Apr 30 20:45:40 2017 +0200
@@ -100,15 +100,15 @@
 	return fmt.Errorf("login failed: %s", err.Error())
 }
 
-// splitIDs splits a list of IDs into an int array
-func splitIDs(ids string) (list []int, err error) {
-	var i int
+// splitIDs splits a list of IDs into an int64 array
+func splitIDs(ids string) (list []int64, err error) {
+	var i int64
 	if ids == "" {
 		return
 	}
 	l := strings.Split(ids, ",")
 	for _, s := range l {
-		i, err = strconv.Atoi(s)
+		i, err = strconv.ParseInt(s, 10, 64)
 		if err != nil {
 			return
 		}
--- a/cmd/media.go	Sun Apr 30 20:02:11 2017 +0200
+++ b/cmd/media.go	Sun Apr 30 20:45:40 2017 +0200
@@ -56,7 +56,7 @@
 }
 
 // uploadFile uploads a media file and returns the attachment ID
-func uploadFile(filePath string) (int, error) {
+func uploadFile(filePath string) (int64, error) {
 	attachment, err := gClient.UploadMedia(filePath)
 	if err != nil {
 		return 0, err
--- a/cmd/notifications.go	Sun Apr 30 20:02:11 2017 +0200
+++ b/cmd/notifications.go	Sun Apr 30 20:45:40 2017 +0200
@@ -15,7 +15,7 @@
 
 var notificationsOpts struct {
 	list, clear, dismiss bool
-	notifID              int
+	notifID              int64
 }
 
 // notificationsCmd represents the notifications subcommand
@@ -37,7 +37,7 @@
 	notificationsCmd.Flags().BoolVar(&notificationsOpts.list, "list", false, "List all current notifications")
 	notificationsCmd.Flags().BoolVar(&notificationsOpts.clear, "clear", false, "Clear all current notifications")
 	notificationsCmd.Flags().BoolVar(&notificationsOpts.dismiss, "dismiss", false, "Delete a notification")
-	notificationsCmd.Flags().IntVar(&notificationsOpts.notifID, "notification-id", 0, "Get a notification")
+	notificationsCmd.Flags().Int64Var(&notificationsOpts.notifID, "notification-id", 0, "Get a notification")
 }
 
 func notificationRunE(cmd *cobra.Command, args []string) error {
@@ -61,10 +61,10 @@
 		limOpts.Limit = int(accountsOpts.limit)
 	}
 	if accountsOpts.maxID > 0 {
-		limOpts.MaxID = int(accountsOpts.maxID)
+		limOpts.MaxID = int64(accountsOpts.maxID)
 	}
 	if accountsOpts.sinceID > 0 {
-		limOpts.SinceID = int(accountsOpts.sinceID)
+		limOpts.SinceID = int64(accountsOpts.sinceID)
 	}
 
 	var obj interface{}
--- a/cmd/status.go	Sun Apr 30 20:02:11 2017 +0200
+++ b/cmd/status.go	Sun Apr 30 20:45:40 2017 +0200
@@ -16,21 +16,21 @@
 )
 
 var statusOpts struct {
-	statusID int
+	statusID int64
 	unset    bool
 
 	// The following fields are used for the post/toot command
 	visibility    string
 	sensitive     bool
 	spoiler       string
-	inReplyToID   int
+	inReplyToID   int64
 	mediaIDs      string
 	mediaFilePath string
 	textFilePath  string
 
 	// Used for several subcommands to limit the number of results
 	limit uint
-	//sinceID, maxID uint
+	//sinceID, maxID int64
 	all bool
 }
 
@@ -41,10 +41,10 @@
 	statusCmd.AddCommand(statusSubcommands...)
 
 	// Global flags
-	statusCmd.PersistentFlags().IntVarP(&statusOpts.statusID, "status-id", "s", 0, "Status ID number")
+	statusCmd.PersistentFlags().Int64VarP(&statusOpts.statusID, "status-id", "s", 0, "Status ID number")
 	statusCmd.PersistentFlags().UintVarP(&statusOpts.limit, "limit", "l", 0, "Limit number of results")
-	//statusCmd.PersistentFlags().UintVar(&statusOpts.sinceID, "since-id", 0, "Request IDs greater than a value")
-	//statusCmd.PersistentFlags().UintVar(&statusOpts.maxID, "max-id", 0, "Request IDs less (or equal) than a value")
+	//statusCmd.PersistentFlags().Int64Var(&statusOpts.sinceID, "since-id", 0, "Request IDs greater than a value")
+	//statusCmd.PersistentFlags().Int64Var(&statusOpts.maxID, "max-id", 0, "Request IDs less (or equal) than a value")
 	statusCmd.PersistentFlags().BoolVar(&statusOpts.all, "all", false, "Fetch all results (for reblogged-by/favourited-by)")
 
 	statusCmd.MarkPersistentFlagRequired("status-id")
@@ -58,7 +58,7 @@
 	statusPostSubcommand.Flags().StringVar(&statusOpts.mediaIDs, "media-ids", "", "Comma-separated list of media IDs")
 	statusPostSubcommand.Flags().StringVarP(&statusOpts.mediaFilePath, "file", "f", "", "Media file name")
 	statusPostSubcommand.Flags().StringVar(&statusOpts.textFilePath, "text-file", "", "Text file name (message content)")
-	statusPostSubcommand.Flags().IntVarP(&statusOpts.inReplyToID, "in-reply-to", "r", 0, "Status ID to reply to")
+	statusPostSubcommand.Flags().Int64VarP(&statusOpts.inReplyToID, "in-reply-to", "r", 0, "Status ID to reply to")
 
 	// Flag completion
 	annotation := make(map[string][]string)
@@ -185,10 +185,10 @@
 	}
 	/*
 		if opt.maxID > 0 {
-			limOpts.MaxID = int(opt.maxID)
+			limOpts.MaxID = int64(opt.maxID)
 		}
 		if opt.sinceID > 0 {
-			limOpts.SinceID = int(opt.sinceID)
+			limOpts.SinceID = int64(opt.sinceID)
 		}
 	*/
 
--- a/cmd/stream.go	Sun Apr 30 20:02:11 2017 +0200
+++ b/cmd/stream.go	Sun Apr 30 20:45:40 2017 +0200
@@ -125,7 +125,7 @@
 				continue
 			case "delete":
 				// TODO PrintObj ?
-				errPrint("Event: [%s] Status %d was deleted", ev.Event, ev.Data.(int))
+				errPrint("Event: [%s] Status %d was deleted", ev.Event, ev.Data.(int64))
 			default:
 				errPrint("Unhandled event: [%s] %T", ev.Event, ev.Data)
 			}
--- a/cmd/timelines.go	Sun Apr 30 20:02:11 2017 +0200
+++ b/cmd/timelines.go	Sun Apr 30 20:45:40 2017 +0200
@@ -12,8 +12,9 @@
 )
 
 var timelineOpts struct {
-	local                 bool
-	limit, sinceID, maxID uint
+	local          bool
+	limit          uint
+	sinceID, maxID int64
 }
 
 // timelineCmd represents the timelines command
@@ -37,8 +38,8 @@
 
 	timelineCmd.Flags().BoolVar(&timelineOpts.local, "local", false, "Posts from the local instance")
 	timelineCmd.Flags().UintVarP(&timelineOpts.limit, "limit", "l", 0, "Limit number of results")
-	timelineCmd.PersistentFlags().UintVar(&timelineOpts.sinceID, "since-id", 0, "Request IDs greater than a value")
-	timelineCmd.PersistentFlags().UintVar(&timelineOpts.maxID, "max-id", 0, "Request IDs less (or equal) than a value")
+	timelineCmd.PersistentFlags().Int64Var(&timelineOpts.sinceID, "since-id", 0, "Request IDs greater than a value")
+	timelineCmd.PersistentFlags().Int64Var(&timelineOpts.maxID, "max-id", 0, "Request IDs less (or equal) than a value")
 }
 
 func timelineRunE(cmd *cobra.Command, args []string) error {
@@ -53,10 +54,10 @@
 		limOpts.Limit = int(opt.limit)
 	}
 	if opt.maxID > 0 {
-		limOpts.MaxID = int(opt.maxID)
+		limOpts.MaxID = opt.maxID
 	}
 	if opt.sinceID > 0 {
-		limOpts.SinceID = int(opt.sinceID)
+		limOpts.SinceID = opt.sinceID
 	}
 
 	tl := "home"
--- a/cmd/toot.go	Sun Apr 30 20:02:11 2017 +0200
+++ b/cmd/toot.go	Sun Apr 30 20:45:40 2017 +0200
@@ -24,7 +24,7 @@
 	tootAliasCmd.Flags().StringVar(&statusOpts.mediaIDs, "media-ids", "", "Comma-separated list of media IDs")
 	tootAliasCmd.Flags().StringVarP(&statusOpts.mediaFilePath, "file", "f", "", "Media attachment file name")
 	tootAliasCmd.Flags().StringVar(&statusOpts.textFilePath, "text-file", "", "Text file name (message content)")
-	tootAliasCmd.Flags().IntVarP(&statusOpts.inReplyToID, "in-reply-to", "r", 0, "Status ID to reply to")
+	tootAliasCmd.Flags().Int64VarP(&statusOpts.inReplyToID, "in-reply-to", "r", 0, "Status ID to reply to")
 
 	// Flag completion
 	annotation := make(map[string][]string)