Skip to content

Commit 841eac4

Browse files
committed
Add channel.config.sharedLocationsEnabled
1 parent 4a420b9 commit 841eac4

File tree

10 files changed

+25
-4
lines changed

10 files changed

+25
-4
lines changed

DemoApp/StreamChat/Components/CustomAttachments/DemoComposerVC.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ class DemoComposerVC: ComposerVC {
1212

1313
override var attachmentsPickerActions: [UIAlertAction] {
1414
var actions = super.attachmentsPickerActions
15-
16-
if AppConfig.shared.demoAppConfig.isLocationAttachmentsEnabled && content.isInsideThread == false {
15+
16+
let isDemoAppLocationsEnabled = AppConfig.shared.demoAppConfig.isLocationAttachmentsEnabled
17+
let isLocationEnabled = channelController?.channel?.config.sharedLocationsEnabled == true
18+
if isLocationEnabled && isDemoAppLocationsEnabled && content.isInsideThread == false {
1719
let sendLocationAction = UIAlertAction(
1820
title: "Send Current Location",
1921
style: .default,

Sources/StreamChat/APIClient/Endpoints/Payloads/ChannelListPayload.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,14 @@ public class ChannelConfig: Codable {
233233
case updatedAt = "updated_at"
234234
case skipLastMsgAtUpdateForSystemMsg = "skip_last_msg_update_for_system_msgs"
235235
case messageRemindersEnabled = "user_message_reminders"
236+
case sharedLocationsEnabled = "shared_locations"
236237
}
237238

238239
/// If users are allowed to add reactions to messages. Enabled by default.
239240
public let reactionsEnabled: Bool
240241
/// Controls if typing indicators are shown. Enabled by default.
241242
public let typingEventsEnabled: Bool
242-
/// Controls whether the chat shows how far youve read. Enabled by default.
243+
/// Controls whether the chat shows how far you've read. Enabled by default.
243244
public let readEventsEnabled: Bool
244245
/// Determines if events are fired for connecting and disconnecting to a chat. Enabled by default.
245246
public let connectEventsEnabled: Bool
@@ -271,6 +272,8 @@ public class ChannelConfig: Codable {
271272
public let skipLastMsgAtUpdateForSystemMsg: Bool
272273
/// Determines if user message reminders are enabled.
273274
public let messageRemindersEnabled: Bool
275+
/// Determines if shared locations are enabled.
276+
public let sharedLocationsEnabled: Bool
274277

275278
public required init(from decoder: Decoder) throws {
276279
let container = try decoder.container(keyedBy: CodingKeys.self)
@@ -297,6 +300,7 @@ public class ChannelConfig: Codable {
297300
pollsEnabled = try container.decodeIfPresent(Bool.self, forKey: .pollsEnabled) ?? false
298301
skipLastMsgAtUpdateForSystemMsg = try container.decodeIfPresent(Bool.self, forKey: .skipLastMsgAtUpdateForSystemMsg) ?? false
299302
messageRemindersEnabled = try container.decodeIfPresent(Bool.self, forKey: .messageRemindersEnabled) ?? false
303+
sharedLocationsEnabled = try container.decodeIfPresent(Bool.self, forKey: .sharedLocationsEnabled) ?? false
300304
}
301305

302306
internal required init(
@@ -313,6 +317,7 @@ public class ChannelConfig: Codable {
313317
urlEnrichmentEnabled: Bool = false,
314318
skipLastMsgAtUpdateForSystemMsg: Bool = false,
315319
messageRemindersEnabled: Bool = false,
320+
sharedLocationsEnabled: Bool = false,
316321
messageRetention: String = "",
317322
maxMessageLength: Int = 0,
318323
commands: [Command] = [],
@@ -337,5 +342,6 @@ public class ChannelConfig: Codable {
337342
self.pollsEnabled = pollsEnabled
338343
self.skipLastMsgAtUpdateForSystemMsg = skipLastMsgAtUpdateForSystemMsg
339344
self.messageRemindersEnabled = messageRemindersEnabled
345+
self.sharedLocationsEnabled = sharedLocationsEnabled
340346
}
341347
}

Sources/StreamChat/Database/DTOs/ChannelConfigDTO.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ final class ChannelConfigDTO: NSManagedObject {
2525
@NSManaged var createdAt: DBDate
2626
@NSManaged var updatedAt: DBDate
2727
@NSManaged var commands: NSOrderedSet
28+
@NSManaged var sharedLocationsEnabled: Bool
2829

2930
func asModel() throws -> ChannelConfig {
3031
try isNotDeleted()
@@ -42,6 +43,7 @@ final class ChannelConfigDTO: NSManagedObject {
4243
urlEnrichmentEnabled: urlEnrichmentEnabled,
4344
skipLastMsgAtUpdateForSystemMsg: skipLastMsgAtUpdateForSystemMsg,
4445
messageRemindersEnabled: messageRemindersEnabled,
46+
sharedLocationsEnabled: sharedLocationsEnabled,
4547
messageRetention: messageRetention,
4648
maxMessageLength: Int(maxMessageLength),
4749
commands: Array(Set(
@@ -83,6 +85,7 @@ extension ChannelConfig {
8385
dto.pollsEnabled = pollsEnabled
8486
dto.skipLastMsgAtUpdateForSystemMsg = skipLastMsgAtUpdateForSystemMsg
8587
dto.messageRemindersEnabled = messageRemindersEnabled
88+
dto.sharedLocationsEnabled = sharedLocationsEnabled
8689
return dto
8790
}
8891
}

Sources/StreamChat/Database/StreamChatModel.xcdatamodeld/StreamChatModel.xcdatamodel/contents

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<attribute name="readEventsEnabled" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
3030
<attribute name="repliesEnabled" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
3131
<attribute name="searchEnabled" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
32+
<attribute name="sharedLocationsEnabled" optional="YES" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
3233
<attribute name="skipLastMsgAtUpdateForSystemMsg" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
3334
<attribute name="typingEventsEnabled" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
3435
<attribute name="updatedAt" attributeType="Date" usesScalarValueType="NO"/>

TestTools/StreamChatTestTools/Fixtures/JSONs/Channel.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,7 @@
13201320
"automod" : "AI",
13211321
"read_events" : true,
13221322
"skip_last_msg_update_for_system_msgs": true,
1323+
"shared_locations": true,
13231324
"commands" : [
13241325
{
13251326
"set" : "fun_set",

TestTools/StreamChatTestTools/Fixtures/JSONs/ChannelPayload.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"member_count":4,
2121
"updated_at":"2019-05-10T14:03:49.505006Z",
2222
"config":{
23+
"shared_locations": true,
2324
"automod_behavior":"flag",
2425
"reactions":true,
2526
"typing_events":true,

TestTools/StreamChatTestTools/Mocks/Models + Extensions/ChatChannel_Mock.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public extension ChannelConfig {
1919
mutesEnabled: Bool = true,
2020
urlEnrichmentEnabled: Bool = true,
2121
skipLastMsgAtUpdateForSystemMsg: Bool = false,
22+
messageRemindersEnabled: Bool = false,
23+
sharedLocationsEnabled: Bool = false,
2224
messageRetention: String = "",
2325
maxMessageLength: Int = 0,
2426
commands: [Command] = [Command(name: "Giphy", description: "", set: "", args: "")],
@@ -37,6 +39,8 @@ public extension ChannelConfig {
3739
mutesEnabled: mutesEnabled,
3840
urlEnrichmentEnabled: urlEnrichmentEnabled,
3941
skipLastMsgAtUpdateForSystemMsg: skipLastMsgAtUpdateForSystemMsg,
42+
messageRemindersEnabled: messageRemindersEnabled,
43+
sharedLocationsEnabled: sharedLocationsEnabled,
4044
messageRetention: messageRetention,
4145
maxMessageLength: maxMessageLength,
4246
commands: commands,

TestTools/StreamChatTestTools/TestData/DummyData/ChannelPayload.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ extension ChannelPayload {
1818
pinnedMessages: [MessagePayload] = [],
1919
channelReads: [ChannelReadPayload] = [],
2020
isHidden: Bool? = nil,
21-
draft: DraftPayload? = nil
21+
draft: DraftPayload? = nil,
22+
sharedLocationsEnabled: Bool = false
2223
) -> Self {
2324
.init(
2425
channel: channel,

Tests/StreamChatTests/APIClient/Endpoints/Payloads/ChannelListPayload_Tests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ final class ChannelPayload_Tests: XCTestCase {
332332
XCTAssertEqual(config.messageRetention, "infinite")
333333
XCTAssertEqual(config.maxMessageLength, 5000)
334334
XCTAssertEqual(config.skipLastMsgAtUpdateForSystemMsg, true)
335+
XCTAssertEqual(config.sharedLocationsEnabled, true)
335336
XCTAssertEqual(
336337
config.commands,
337338
[.init(name: "giphy", description: "Post a random gif to the channel", set: "fun_set", args: "[text]")]

Tests/StreamChatTests/Database/DTOs/ChannelDTO_Tests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ final class ChannelDTO_Tests: XCTestCase {
397397
Assert.willBeEqual(payload.channel.config.createdAt, loadedChannel.config.createdAt)
398398
Assert.willBeEqual(payload.channel.config.updatedAt, loadedChannel.config.updatedAt)
399399
Assert.willBeEqual(payload.channel.config.messageRemindersEnabled, loadedChannel.config.messageRemindersEnabled)
400+
Assert.willBeEqual(payload.channel.config.sharedLocationsEnabled, loadedChannel.config.sharedLocationsEnabled)
400401

401402
// Own Capabilities
402403
Assert.willBeEqual(payload.channel.ownCapabilities, ["join-channel", "delete-channel"])

0 commit comments

Comments
 (0)