Skip to content

Commit 1273ee6

Browse files
renamed reminders to message hooks
1 parent e65ed3b commit 1273ee6

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed

lib/GetStream/StreamChat/Client.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,21 @@ public function getAppSettings(): StreamResponse
294294
*/
295295
public function updateAppSettings(array $settings): StreamResponse
296296
{
297+
$settings = $this->mapAppSettingsBackwardsCompatibility($settings);
297298
return $this->patch("app", $settings);
298299
}
299300

301+
/** Maps backwards compatible attribute names for app settings.
302+
* @internal
303+
*/
304+
private function mapAppSettingsBackwardsCompatibility(array $settings): array
305+
{
306+
if (isset($settings['reminders_interval'])) {
307+
$settings['message_re_engagement_hooks_interval'] = $settings['reminders_interval'];
308+
}
309+
return $settings;
310+
}
311+
300312
/** Sends a test push.
301313
* @link https://getstream.io/chat/docs/php/push_introduction/?language=php
302314
* @throws StreamException
@@ -959,9 +971,21 @@ public function listChannelTypes(): StreamResponse
959971
*/
960972
public function updateChannelType(string $channelTypeName, array $settings): StreamResponse
961973
{
974+
$settings = $this->mapChannelTypeBackwardsCompatibility($settings);
962975
return $this->put("channeltypes/" . $channelTypeName, $settings);
963976
}
964977

978+
/** Maps backwards compatible attribute names for channel type settings.
979+
* @internal
980+
*/
981+
private function mapChannelTypeBackwardsCompatibility(array $settings): array
982+
{
983+
if (isset($settings['reminders'])) {
984+
$settings['message_re_engagement_hooks'] = $settings['reminders'];
985+
}
986+
return $settings;
987+
}
988+
965989
/** Deletes a channel type.
966990
* @link https://getstream.io/chat/docs/php/channel_features/?language=php
967991
* @throws StreamException

tests/integration/IntegrationTest.php

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,4 +1828,77 @@ public function testSharedLocations()
18281828
$this->assertEquals(-118.2437, $newUserLocations["active_live_locations"][0]["longitude"]);
18291829
$this->assertEquals('test-device-123', $newUserLocations["active_live_locations"][0]["created_by_device_id"]);
18301830
}
1831+
1832+
/**
1833+
* Test backwards compatibility for reminders -> message_re_engagement_hooks
1834+
* Changes:
1835+
* - app_config.reminders_interval -> message_re_engagement_hooks_interval
1836+
* - channel_config.reminders -> message_re_engagement_hooks
1837+
*/
1838+
public function testBackwardsCompatibilityMessageReEngagementHooksIntervalIncludedInAppSettings()
1839+
{
1840+
$response = $this->client->getAppSettings();
1841+
1842+
$this->assertArrayHasKey('app', $response);
1843+
$this->assertArrayHasKey('message_re_engagement_hooks_interval', $response['app']);
1844+
$this->assertArrayHasKey('reminders_interval', $response['app']);
1845+
}
1846+
1847+
public function testBackwardsCompatibilityMessageReEngagementHooksIntervalCanBeChangedServerSide()
1848+
{
1849+
$this->client->updateAppSettings(['message_re_engagement_hooks_interval' => 68]);
1850+
$response = $this->client->getAppSettings();
1851+
1852+
$this->assertEquals(68, $response['app']['message_re_engagement_hooks_interval']);
1853+
$this->assertEquals(68, $response['app']['reminders_interval']);
1854+
}
1855+
1856+
public function testBackwardsCompatibilityCanBeEnabledForChannelType()
1857+
{
1858+
$response = $this->client->updateChannelType('messaging', [
1859+
'message_re_engagement_hooks' => true,
1860+
]);
1861+
1862+
$this->assertTrue($response['message_re_engagement_hooks']);
1863+
$this->assertTrue($response['reminders']);
1864+
}
1865+
1866+
public function testBackwardsCompatibilityCanBeDisabledForChannelType()
1867+
{
1868+
$response = $this->client->updateChannelType('messaging', [
1869+
'message_re_engagement_hooks' => false,
1870+
]);
1871+
1872+
$this->assertFalse($response['message_re_engagement_hooks']);
1873+
$this->assertFalse($response['reminders']);
1874+
}
1875+
1876+
public function testBackwardsCompatibilityOldRemindersIntervalStillWorks()
1877+
{
1878+
$this->client->updateAppSettings(['reminders_interval' => 45]);
1879+
$response = $this->client->getAppSettings();
1880+
1881+
$this->assertEquals(45, $response['app']['message_re_engagement_hooks_interval']);
1882+
$this->assertEquals(45, $response['app']['reminders_interval']);
1883+
}
1884+
1885+
public function testBackwardsCompatibilityOldRemindersAttributeCanEnableChannelType()
1886+
{
1887+
$response = $this->client->updateChannelType('messaging', [
1888+
'reminders' => true,
1889+
]);
1890+
1891+
$this->assertTrue($response['message_re_engagement_hooks']);
1892+
$this->assertTrue($response['reminders']);
1893+
}
1894+
1895+
public function testBackwardsCompatibilityOldRemindersAttributeCanDisableChannelType()
1896+
{
1897+
$response = $this->client->updateChannelType('messaging', [
1898+
'reminders' => false,
1899+
]);
1900+
1901+
$this->assertFalse($response['message_re_engagement_hooks']);
1902+
$this->assertFalse($response['reminders']);
1903+
}
18311904
}

0 commit comments

Comments
 (0)