Version 5.0.13

This commit is contained in:
Neo committed 2025-12-19 19:04:57 -08:00
1 parent b89858b2ff
commit 5efe744c5f
1407 files changed
+69690 -30177

No files matched your search

+65 -4
View File
@@ -17,10 +17,12 @@ use IPS\Api\Controller;
use IPS\Api\Exception;
use IPS\Api\PaginatedResponse;
use IPS\Api\Response;
use IPS\Api\Webhook;
use IPS\Application;
use IPS\Content\Item;
use IPS\core\Achievements\Badge;
use IPS\core\Followed\Follow;
use IPS\core\Messenger\Message;
use IPS\core\Warnings\Reason;
use IPS\core\Warnings\Warning;
use IPS\DateTime;
@@ -75,6 +77,7 @@ class members extends Controller
* @apiparam int|array group Group ID or IDs to search for
* @apiparam int activity_after Find members that have been active since unix timestamp
* @apiparam int activity_before Find members that have been active before unix timestamp
* @apiparam int joined_after Find members that joined after a unix timestamp
* @apiparam int page Page number
* @apiparam int perPage Number of results per page - defaults to 25
* @apireturn PaginatedResponse<IPS\Member>
@@ -112,6 +115,11 @@ class members extends Controller
$where[] = array( 'last_activity < ?', Request::i()->activity_before );
}
if( isset( Request::i()->joined_after ) )
{
$where[] = array( 'joined > ?', Request::i()->joined_after );
}
if( isset( Request::i()->group ) )
{
if( is_array( Request::i()->group ) )
@@ -624,7 +632,7 @@ class members extends Controller
{
throw new Exception( 'INVALID_CONTENT', '2C292/J', 404 );
}
/* If we are already following this, update instead of insert */
try
{
@@ -761,10 +769,13 @@ class members extends Controller
{
throw new Exception( 'INVALID_FOLLOW_KEY', '2C292/E', 404 );
}
$thing = Follow::constructFromData( $follow);
/* Unfollow */
Db::i()->delete( 'core_follow', array( 'follow_id=?', $followKey ) );
Webhook::fire( 'content_unfollowed', $thing);
/* If this is a club, unfollow all nodes in the club too */
if( $follow['follow_app'] == 'core' AND $follow['follow_area'] == 'club' )
{
@@ -779,8 +790,17 @@ class members extends Controller
$itemClass = $node['node_class']::$contentItemClass;
$followApp = $itemClass::$application;
$followArea = mb_strtolower( mb_substr( $node['node_class'], mb_strrpos( $node['node_class'], '\\' ) + 1 ) );
Db::i()->delete( 'core_follow', array( 'follow_id=? AND follow_member_id=?', md5( $followApp . ';' . $followArea . ';' . $node['node_id'] . ';' . $member->member_id ), $member->member_id ) );
$where = array( 'follow_id=? AND follow_member_id=?', md5( $followApp . ';' . $followArea . ';' . $node['node_id'] . ';' . $member->member_id ), $member->member_id );
try
{
$currentData = Db::i()->select( '*', 'core_follow', $where )->first();
$current = Follow::constructFromData( $currentData);
$current->delete();
}
catch ( UnderflowException $e )
{
}
}
}
catch ( OutOfRangeException $e ){}
@@ -1386,4 +1406,45 @@ class members extends Controller
return new Response( 201, $member->apiOutput( $this->member ) );
}
/**
* GET /core/members/{id}/messages
* Get personal conversations for a specific member
*
* @param int $id ID Number
* @apiparam int page Page number
* @apiparam int perPage Number of results per page - defaults to 25
* @apireturn PaginatedResponse<IPS\core\Messenger\Message>
* @return PaginatedResponse<Message>
* @throws 1G200/1 INVALID_ID The member ID does not exist
* */
public function GETitem_messages( int $id ) : PaginatedResponse
{
try
{
$member = Member::load( $id );
if ( !$member->member_id )
{
throw new OutOfRangeException;
}
$where = array( 'msg_author_id=?', $member->member_id );
/* Return */
return new PaginatedResponse(
200,
Db::i()->select( '*', 'core_message_posts', $where ),
Request::i()->page ?? 1,
'IPS\core\Messenger\Message',
Db::i()->select( 'COUNT(*)', 'core_message_posts', $where )->first(),
$this->member,
Request::i()->perPage ?? null
);
}
catch ( OutOfRangeException $e )
{
throw new Exception( 'INVALID_ID', '1G200/1', 404 );
}
}
}