Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permissions admin and super admin lists #397

Merged
merged 4 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -901,13 +901,93 @@ class XMTPModule : Module() {
}
}

AsyncFunction("isGroupAdmin") Coroutine { clientAddress: String, id: String ->
AsyncFunction("creatorInboxId") Coroutine { clientAddress: String, id: String ->
withContext(Dispatchers.IO) {
logV("creatorInboxId")
val client = clients[clientAddress] ?: throw XMTPException("No client")
val group = findGroup(clientAddress, id)

group?.creatorInboxId()
}
}

AsyncFunction("isAdmin") Coroutine { clientAddress: String, id: String, inboxId: String ->
withContext(Dispatchers.IO) {
logV("isGroupAdmin")
val client = clients[clientAddress] ?: throw XMTPException("No client")
val group = findGroup(clientAddress, id)

group?.isAdmin(client.inboxId)
group?.isAdmin(inboxId)
}
}

AsyncFunction("isSuperAdmin") Coroutine { clientAddress: String, id: String, inboxId: String ->
withContext(Dispatchers.IO) {
logV("isSuperAdmin")
val client = clients[clientAddress] ?: throw XMTPException("No client")
val group = findGroup(clientAddress, id)

group?.isSuperAdmin(inboxId)
}
}

AsyncFunction("listAdmins") Coroutine { clientAddress: String, id: String ->
withContext(Dispatchers.IO) {
logV("listAdmins")
val client = clients[clientAddress] ?: throw XMTPException("No client")
val group = findGroup(clientAddress, id)

group?.listAdmins()
}
}

AsyncFunction("listSuperAdmins") Coroutine { clientAddress: String, id: String ->
withContext(Dispatchers.IO) {
logV("listSuperAdmins")
val client = clients[clientAddress] ?: throw XMTPException("No client")
val group = findGroup(clientAddress, id)

group?.listSuperAdmins()
}
}

AsyncFunction("addAdmin") Coroutine { clientAddress: String, id: String, inboxId: String ->
withContext(Dispatchers.IO) {
logV("addAdmin")
val client = clients[clientAddress] ?: throw XMTPException("No client")
val group = findGroup(clientAddress, id)

group?.addAdmin(inboxId)
}
}

AsyncFunction("addSuperAdmin") Coroutine { clientAddress: String, id: String, inboxId: String ->
withContext(Dispatchers.IO) {
logV("addSuperAdmin")
val client = clients[clientAddress] ?: throw XMTPException("No client")
val group = findGroup(clientAddress, id)

group?.addSuperAdmin(inboxId)
}
}

AsyncFunction("removeAdmin") Coroutine { clientAddress: String, id: String, inboxId: String ->
withContext(Dispatchers.IO) {
logV("removeAdmin")
val client = clients[clientAddress] ?: throw XMTPException("No client")
val group = findGroup(clientAddress, id)

group?.removeAdmin(inboxId)
}
}

AsyncFunction("removeSuperAdmin") Coroutine { clientAddress: String, id: String, inboxId: String ->
withContext(Dispatchers.IO) {
logV("removeSuperAdmin")
val client = clients[clientAddress] ?: throw XMTPException("No client")
val group = findGroup(clientAddress, id)

group?.removeSuperAdmin(inboxId)
}
}

Expand Down
2 changes: 1 addition & 1 deletion example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -769,4 +769,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 95d6ace79946933ecf80684613842ee553dd76a2

COCOAPODS: 1.14.2
COCOAPODS: 1.15.2
7 changes: 7 additions & 0 deletions example/src/TestScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { useEffect, useState } from 'react'
import { View, Text, Button, ScrollView } from 'react-native'

import { createdAtTests } from './tests/createdAtTests'
import { groupPermissionsTests } from './tests/groupPermissionsTests'
import { groupTests } from './tests/groupTests'
import { restartStreamTests } from './tests/restartStreamsTests'
import { Test } from './tests/test-utils'
Expand Down Expand Up @@ -108,6 +109,7 @@ export enum TestCategory {
group = 'group',
createdAt = 'createdAt',
restartStreans = 'restartStreams',
groupPermissions = 'groupPermissions',
}

export default function TestScreen(): JSX.Element {
Expand All @@ -121,6 +123,7 @@ export default function TestScreen(): JSX.Element {
...groupTests,
...createdAtTests,
...restartStreamTests,
...groupPermissionsTests,
]
let activeTests, title
switch (params.testSelection) {
Expand All @@ -144,6 +147,10 @@ export default function TestScreen(): JSX.Element {
activeTests = restartStreamTests
title = 'Restart Streams Unit Tests'
break
case TestCategory.groupPermissions:
activeTests = groupPermissionsTests
title = 'Group Permissions Unit Tests'
break
}

return (
Expand Down
Loading
Loading