| 50 | } |
| 51 | |
| 52 | func sendCmd() *cobra.Command { |
| 53 | cmd := &cobra.Command{ |
| 54 | Use: "send-reaction --message-id [message-id] --user-id [user-id] --reaction-type [reaction-type]", |
| 55 | Short: "Send a reaction to a message", |
| 56 | Long: heredoc.Doc(` |
| 57 | Stream Chat has built-in support for user Reactions. Common examples are |
| 58 | likes, comments, loves, etc. Reactions can be customized so that you |
| 59 | are able to use any type of reaction your application requires. |
| 60 | `), |
| 61 | Example: heredoc.Doc(` |
| 62 | # Send a reaction to a [08f64828-3bba-42bd-8430-c26a3634ee5c] message |
| 63 | $ stream-cli chat send-reaction --message-id 08f64828-3bba-42bd-8430-c26a3634ee5c --user-id 12345 --reaction-type like |
| 64 | `), |
| 65 | RunE: func(cmd *cobra.Command, args []string) error { |
| 66 | c, err := config.GetConfig(cmd).GetClient(cmd) |
| 67 | if err != nil { |
| 68 | return err |
| 69 | } |
| 70 | |
| 71 | reactionType, _ := cmd.Flags().GetString("reaction-type") |
| 72 | msgID, _ := cmd.Flags().GetString("message-id") |
| 73 | userID, _ := cmd.Flags().GetString("user-id") |
| 74 | |
| 75 | r := &stream_chat.Reaction{Type: reactionType} |
| 76 | |
| 77 | _, err = c.Channel("", "").SendReaction(cmd.Context(), r, msgID, userID) |
| 78 | if err != nil { |
| 79 | return err |
| 80 | } |
| 81 | |
| 82 | cmd.Println("Successfully sent reaction") |
| 83 | return nil |
| 84 | }, |
| 85 | } |
| 86 | |
| 87 | fl := cmd.Flags() |
| 88 | fl.StringP("reaction-type", "r", "", "[required] The reaction type to send") |
| 89 | fl.StringP("message-id", "m", "", "[required] The message id to send the reaction to") |
| 90 | fl.StringP("user-id", "u", "", "[required] The user id of the user sending the reaction") |
| 91 | _ = cmd.MarkFlagRequired("reaction-type") |
| 92 | _ = cmd.MarkFlagRequired("message-id") |
| 93 | _ = cmd.MarkFlagRequired("user-id") |
| 94 | |
| 95 | return cmd |
| 96 | } |
| 97 | |
| 98 | func deleteCmd() *cobra.Command { |
| 99 | cmd := &cobra.Command{ |