Skip to content

Commit 415eabe

Browse files
Soft delete samples
1 parent f4c89e5 commit 415eabe

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

unity-chat/PubnubChatUnity/Assets/Snippets/DeleteChannelSample.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,30 @@ public static async Task RestoreChannelSample()
7272
}
7373
// snippet.end
7474
}
75+
76+
public static async Task SoftDeleteSample()
77+
{
78+
// snippet.channel_soft_delete
79+
// using Channel object
80+
var channelResult = await chat.GetChannel("support");
81+
if (!channelResult.Error)
82+
{
83+
var channel = channelResult.Result;
84+
var softDeleteResult = await channel.Delete(soft: true);
85+
//Could be for example because it was already soft deleted
86+
if (softDeleteResult.Error)
87+
{
88+
Debug.LogError($"Error when trying to soft delete channel: {softDeleteResult.Exception.Message}");
89+
}
90+
}
91+
92+
// or using Chat object
93+
var softDeleteFromChat = await chat.DeleteChannel("support", soft: true);
94+
//Same as above, could be because it was already soft deleted
95+
if (softDeleteFromChat.Error)
96+
{
97+
Debug.LogError($"Error when trying to soft delete channel: {softDeleteFromChat.Exception.Message}");
98+
}
99+
// snippet.end
100+
}
75101
}

unity-chat/PubnubChatUnity/Assets/Snippets/DeleteUserSample.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,30 @@ public static async Task RestoreUserSample()
7272
}
7373
// snippet.end
7474
}
75+
76+
public static async Task SoftDeleteSample()
77+
{
78+
// snippet.user_soft_delete
79+
// using User object
80+
var userResult = await chat.GetUser("support-agent-15");
81+
if (!userResult.Error)
82+
{
83+
var user = userResult.Result;
84+
var softDeleteResult = await user.DeleteUser(soft: true);
85+
//Could be for example because it was already soft deleted
86+
if (softDeleteResult.Error)
87+
{
88+
Debug.LogError($"Error when trying to soft delete user: {softDeleteResult.Exception.Message}");
89+
}
90+
}
91+
92+
// or using Chat object
93+
var softDeleteFromChat = await chat.DeleteUser("support-agent-15", soft: true);
94+
//Same as above, could be because it was already soft deleted
95+
if (softDeleteFromChat.Error)
96+
{
97+
Debug.LogError($"Error when trying to soft delete user: {softDeleteFromChat.Exception.Message}");
98+
}
99+
// snippet.end
100+
}
75101
}

0 commit comments

Comments
 (0)