Skip to content

Commit

Permalink
Merge pull request #97 from buddypress/feature/messages
Browse files Browse the repository at this point in the history
Messages: improvements to the `generate` command
  • Loading branch information
renatonascalves authored Dec 9, 2022
2 parents 4effecc + 8c691c6 commit c484b34
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function create( $args, $assoc_args ) {
}

// Existing thread recipients will be assumed.
$recipient = ( ! empty( $r['thread-id'] ) ) ? array() : array( $recipient->ID );
$recipient = ! empty( $r['thread-id'] ) ? array() : array( $recipient->ID );

$thread_id = messages_new_message(
array(
Expand Down Expand Up @@ -312,6 +312,13 @@ public function list_( $args, $assoc_args ) { // phpcs:ignore PSR2.Methods.Metho
*
* ## OPTIONS
*
* [--from=<user>]
* : Identifier for the user. Accepts either a user_login or a numeric ID.
*
* [--to=<user>]
* : Identifier for the recipient. To is not required when thread id is set.
* Accepts either a user_login or a numeric ID.
*
* [--thread-id=<thread-id>]
* : Thread ID to generate messages against.
* ---
Expand All @@ -326,6 +333,7 @@ public function list_( $args, $assoc_args ) { // phpcs:ignore PSR2.Methods.Metho
*
* ## EXAMPLES
*
* $ wp bp message generate --from=1 --to=2 --thread-id=6465 --count=30
* $ wp bp message generate --thread-id=6465 --count=10
* $ wp bp message generate --count=100
*/
Expand All @@ -336,10 +344,11 @@ public function generate( $args, $assoc_args ) {
$this->create(
array(),
array(
'from' => $this->get_random_user_id(),
'to' => $this->get_random_user_id(),
'from' => empty( $assoc_args['from'] ) ? $this->get_random_user_id() : $assoc_args['from'],
'to' => empty( $assoc_args['to'] ) ? $this->get_random_user_id() : $assoc_args['to'],
'subject' => sprintf( 'Message Subject - #%d', $i ),
'thread-id' => $assoc_args['thread-id'],
'content' => $this->generate_random_text(),
'thread-id' => empty( $assoc_args['thread-id'] ) ? false : $assoc_args['thread-id'],
'silent',
)
);
Expand Down

0 comments on commit c484b34

Please sign in to comment.