github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/engine/favorite_ignore.go (about)

     1  // Copyright 2015 Keybase, Inc. All rights reserved. Use of
     2  // this source code is governed by the included BSD license.
     3  
     4  package engine
     5  
     6  import (
     7  	"fmt"
     8  
     9  	"github.com/keybase/client/go/libkb"
    10  	keybase1 "github.com/keybase/client/go/protocol/keybase1"
    11  )
    12  
    13  // FavoriteIgnore is an engine.
    14  type FavoriteIgnore struct {
    15  	arg *keybase1.FavoriteIgnoreArg
    16  	libkb.Contextified
    17  }
    18  
    19  // NewFavoriteIgnore creates a FavoriteIgnore engine.
    20  func NewFavoriteIgnore(g *libkb.GlobalContext, arg *keybase1.FavoriteIgnoreArg) *FavoriteIgnore {
    21  	return &FavoriteIgnore{
    22  		arg:          arg,
    23  		Contextified: libkb.NewContextified(g),
    24  	}
    25  }
    26  
    27  // Name is the unique engine name.
    28  func (e *FavoriteIgnore) Name() string {
    29  	return "FavoriteIgnore"
    30  }
    31  
    32  // GetPrereqs returns the engine prereqs.
    33  func (e *FavoriteIgnore) Prereqs() Prereqs {
    34  	return Prereqs{
    35  		Device: true,
    36  	}
    37  }
    38  
    39  // RequiredUIs returns the required UIs.
    40  func (e *FavoriteIgnore) RequiredUIs() []libkb.UIKind {
    41  	return []libkb.UIKind{}
    42  }
    43  
    44  // SubConsumers returns the other UI consumers for this engine.
    45  func (e *FavoriteIgnore) SubConsumers() []libkb.UIConsumer {
    46  	return nil
    47  }
    48  
    49  // Run starts the engine.
    50  func (e *FavoriteIgnore) Run(m libkb.MetaContext) error {
    51  	if e.arg == nil {
    52  		return fmt.Errorf("FavoriteIgnore arg is nil")
    53  	}
    54  	_, err := m.G().API.Post(m, libkb.APIArg{
    55  		Endpoint:    "kbfs/favorite/add",
    56  		SessionType: libkb.APISessionTypeREQUIRED,
    57  		Args: libkb.HTTPArgs{
    58  			"tlf_name":    libkb.S{Val: e.arg.Folder.Name},
    59  			"folder_type": libkb.I{Val: int(e.arg.Folder.FolderType)},
    60  			"status":      libkb.S{Val: "ignored"},
    61  		},
    62  	})
    63  	return err
    64  }