feat(@community): add backend for intro message

issue: #5746
This commit is contained in:
Patryk Osmaczko 2022-05-24 20:54:49 +02:00 committed by osmaczko
parent be8587177d
commit 6cda41e183
16 changed files with 97 additions and 13 deletions

View File

@ -377,6 +377,8 @@ proc editCommunity*(
self: Controller,
name: string,
description: string,
introMessage: string,
outroMessage: string,
access: int,
color: string,
logoJsonStr: string,
@ -387,6 +389,8 @@ proc editCommunity*(
self.sectionId,
name,
description,
introMessage,
outroMessage,
access,
color,
logoJsonStr,

View File

@ -252,7 +252,7 @@ method removeUserFromCommunity*(self: AccessInterface, pubKey: string) {.base.}
method banUserFromCommunity*(self: AccessInterface, pubKey: string) {.base.} =
raise newException(ValueError, "No implementation available")
method editCommunity*(self: AccessInterface, name: string, description: string, access: int, color: string, logoJsonData: string, bannerJsonData: string, historyArchiveSupportEnabled: bool, pinMessageAllMembersEnabled: bool) {.base.} =
method editCommunity*(self: AccessInterface, name: string, description, introMessage, outroMessage: string, access: int, color: string, logoJsonData: string, bannerJsonData: string, historyArchiveSupportEnabled: bool, pinMessageAllMembersEnabled: bool) {.base.} =
raise newException(ValueError, "No implementation available")
method exportCommunity*(self: AccessInterface): string {.base.} =

View File

@ -739,13 +739,14 @@ method removeUserFromCommunity*(self: Module, pubKey: string) =
method banUserFromCommunity*(self: Module, pubKey: string) =
self.controller.banUserFromCommunity(pubkey)
method editCommunity*(self: Module, name: string, description: string,
method editCommunity*(self: Module, name: string,
description, introMessage, outroMessage: string,
access: int, color: string,
logoJsonStr: string,
bannerJsonStr: string,
historyArchiveSupportEnabled: bool,
pinMessageAllMembersEnabled: bool) =
self.controller.editCommunity(name, description, access, color, logoJsonStr, bannerJsonStr, historyArchiveSupportEnabled, pinMessageAllMembersEnabled)
self.controller.editCommunity(name, description, introMessage, outroMessage, access, color, logoJsonStr, bannerJsonStr, historyArchiveSupportEnabled, pinMessageAllMembersEnabled)
method exportCommunity*(self: Module): string =
self.controller.exportCommunity()

View File

@ -186,9 +186,6 @@ QtObject:
proc removeMemberFromGroupChat*(self: View, communityID: string, chatId: string, pubKey: string) {.slot.} =
self.delegate.removeMemberFromGroupChat(communityID, chatId, pubKey)
proc removeMembersFromGroupChat*(self: View, communityID: string, chatId: string, pubKeys: string) {.slot.} =
self.delegate.removeMembersFromGroupChat(communityID, chatId, pubKeys)
proc renameGroupChat*(self: View, chatId: string, newName: string) {.slot.} =
self.delegate.renameGroupChat(chatId, newName)
@ -247,8 +244,8 @@ QtObject:
proc banUserFromCommunity*(self: View, pubKey: string) {.slot.} =
self.delegate.banUserFromCommunity(pubKey)
proc editCommunity*(self: View, name: string, description: string, access: int, color: string, logoJsonData: string, bannerJsonData: string, historyArchiveSupportEnabled: bool, pinMessageAllMembersEnabled: bool) {.slot.} =
self.delegate.editCommunity(name, description, access, color, logoJsonData, bannerJsonData, historyArchiveSupportEnabled, pinMessageAllMembersEnabled)
proc editCommunity*(self: View, name: string, description: string, introMessage: string, outroMessage: string, access: int, color: string, logoJsonData: string, bannerJsonData: string, historyArchiveSupportEnabled: bool, pinMessageAllMembersEnabled: bool) {.slot.} =
self.delegate.editCommunity(name, description, introMessage, outroMessage, access, color, logoJsonData, bannerJsonData, historyArchiveSupportEnabled, pinMessageAllMembersEnabled)
proc exportCommunity*(self: View): string {.slot.} =
self.delegate.exportCommunity()

View File

@ -78,6 +78,8 @@ proc createCommunity*(
self: Controller,
name: string,
description: string,
introMessage: string,
outroMessage: string,
access: int,
color: string,
imageUrl: string,
@ -87,6 +89,8 @@ proc createCommunity*(
self.communityService.createCommunity(
name,
description,
introMessage,
outroMessage,
access,
color,
imageUrl,

View File

@ -25,7 +25,7 @@ method getCommunityItem*(self: AccessInterface, community: CommunityDto): Sectio
method joinCommunity*(self: AccessInterface, communityId: string): string {.base.} =
raise newException(ValueError, "No implementation available")
method createCommunity*(self: AccessInterface, name: string, description: string, access: int, color: string, imagePath: string, aX: int, aY: int, bX: int, bY: int, historyArchiveSupportEnabled: bool, pinMessageAllMembersEnabled: bool) {.base.} =
method createCommunity*(self: AccessInterface, name: string, description, introMessage, outroMessage: string, access: int, color: string, imagePath: string, aX: int, aY: int, bX: int, bY: int, historyArchiveSupportEnabled: bool, pinMessageAllMembersEnabled: bool) {.base.} =
raise newException(ValueError, "No implementation available")
method deleteCommunityCategory*(self: AccessInterface, communityId: string, categoryId: string) {.base.} =

View File

@ -78,6 +78,8 @@ method getCommunityItem(self: Module, c: CommunityDto): SectionItem =
c.name,
c.admin,
c.description,
c.introMessage,
c.outroMessage,
c.images.thumbnail,
c.images.banner,
icon = "",
@ -171,13 +173,14 @@ method communityCategoryDeleted*(self: Module) =
# TODO to model or view
discard
method createCommunity*(self: Module, name: string, description: string,
method createCommunity*(self: Module, name: string,
description, introMessage: string, outroMessage: string,
access: int, color: string,
imagePath: string,
aX: int, aY: int, bX: int, bY: int,
historyArchiveSupportEnabled: bool,
pinMessageAllMembersEnabled: bool) =
self.controller.createCommunity(name, description, access, color, imagePath, aX, aY, bX, bY, historyArchiveSupportEnabled, pinMessageAllMembersEnabled)
self.controller.createCommunity(name, description, introMessage, outroMessage, access, color, imagePath, aX, aY, bX, bY, historyArchiveSupportEnabled, pinMessageAllMembersEnabled)
method deleteCommunityCategory*(self: Module, communityId: string, categoryId: string) =
self.controller.deleteCommunityCategory(communityId, categoryId)

View File

@ -82,13 +82,14 @@ QtObject:
proc joinCommunity*(self: View, communityId: string): string {.slot.} =
result = self.delegate.joinCommunity(communityId)
proc createCommunity*(self: View, name: string, description: string,
proc createCommunity*(self: View, name: string,
description: string, introMessage: string, outroMessage: string,
access: int, color: string,
imagePath: string,
aX: int, aY: int, bX: int, bY: int,
historyArchiveSupportEnabled: bool,
pinMessageAllMembersEnabled: bool) {.slot.} =
self.delegate.createCommunity(name, description, access, color, imagePath, aX, aY, bX, bY, historyArchiveSupportEnabled, pinMessageAllMembersEnabled)
self.delegate.createCommunity(name, description, introMessage, outroMessage, access, color, imagePath, aX, aY, bX, bY, historyArchiveSupportEnabled, pinMessageAllMembersEnabled)
proc deleteCommunityCategory*(self: View, communityId: string, categoryId: string): string {.slot.} =
self.delegate.deleteCommunityCategory(communityId, categoryId)

View File

@ -201,6 +201,8 @@ proc createChannelGroupItem[T](self: Module[T], c: ChannelGroupDto): SectionItem
c.name,
c.admin,
c.description,
c.introMessage,
c.outroMessage,
c.images.thumbnail,
c.images.banner,
icon = if (isCommunity): "" else: conf.CHAT_SECTION_ICON,
@ -306,6 +308,8 @@ method load*[T](
let walletSectionItem = initItem(conf.WALLET_SECTION_ID, SectionType.Wallet, conf.WALLET_SECTION_NAME,
amISectionAdmin = false,
description = "",
introMessage = "",
outroMessage = "",
image = "",
icon = conf.WALLET_SECTION_ICON,
color = "",
@ -321,6 +325,8 @@ method load*[T](
let browserSectionItem = initItem(conf.BROWSER_SECTION_ID, SectionType.Browser, conf.BROWSER_SECTION_NAME,
amISectionAdmin = false,
description = "",
introMessage = "",
outroMessage = "",
image = "",
icon = conf.BROWSER_SECTION_ICON,
color = "",
@ -337,6 +343,8 @@ method load*[T](
conf.NODEMANAGEMENT_SECTION_NAME,
amISectionAdmin = false,
description = "",
introMessage = "",
outroMessage = "",
image = "",
icon = conf.NODEMANAGEMENT_SECTION_ICON,
color = "",
@ -353,6 +361,8 @@ method load*[T](
conf.SETTINGS_SECTION_NAME,
amISectionAdmin = false,
description = "",
introMessage = "",
outroMessage = "",
image = "",
icon = conf.SETTINGS_SECTION_ICON,
color = "",

View File

@ -53,6 +53,18 @@ QtObject:
QtProperty[string] description:
read = description
proc introMessage(self: ActiveSection): string {.slot.} =
return self.item.introMessage
QtProperty[string] introMessage:
read = introMessage
proc outroMessage(self: ActiveSection): string {.slot.} =
return self.item.outroMessage
QtProperty[string] outroMessage:
read = outroMessage
proc getImage(self: ActiveSection): string {.slot.} =
return self.item.image

View File

@ -19,6 +19,8 @@ type
name: string
amISectionAdmin: bool
description: string
introMessage: string
outroMessage: string
image: string
bannerImageData: string
icon: string
@ -46,6 +48,8 @@ proc initItem*(
name: string,
amISectionAdmin = false,
description = "",
introMessage = "",
outroMessage = "",
image = "",
bannerImageData = "",
icon = "",
@ -72,6 +76,8 @@ proc initItem*(
result.name = name
result.amISectionAdmin = amISectionAdmin
result.description = description
result.introMessage = introMessage
result.outroMessage = outroMessage
result.image = image
result.bannerImageData = bannerImageData
result.icon = icon
@ -105,6 +111,8 @@ proc `$`*(self: SectionItem): string =
name: {self.name},
amISectionAdmin: {self.amISectionAdmin},
description: {self.description},
introMessage: {self.introMessage},
outroMessage: {self.outroMessage},
image: {self.image},
bannerImageData: {self.bannerImageData},
icon: {self.icon},
@ -141,6 +149,12 @@ proc amISectionAdmin*(self: SectionItem): bool {.inline.} =
proc description*(self: SectionItem): string {.inline.} =
self.description
proc introMessage*(self: SectionItem): string {.inline.} =
self.introMessage
proc outroMessage*(self: SectionItem): string {.inline.} =
self.outroMessage
proc image*(self: SectionItem): string {.inline.} =
self.image

View File

@ -11,6 +11,8 @@ type
Name
AmISectionAdmin
Description
IntroMessage
OutroMessage
Image
BannerImageData
Icon
@ -73,6 +75,8 @@ QtObject:
ModelRole.Name.int:"name",
ModelRole.AmISectionAdmin.int: "amISectionAdmin",
ModelRole.Description.int:"description",
ModelRole.IntroMessage.int:"introMessage",
ModelRole.OutroMessage.int:"outroMessage",
ModelRole.Image.int:"image",
ModelRole.BannerImageData.int:"bannerImageData",
ModelRole.Icon.int:"icon",
@ -116,6 +120,10 @@ QtObject:
result = newQVariant(item.amISectionAdmin)
of ModelRole.Description:
result = newQVariant(item.description)
of ModelRole.IntroMessage:
result = newQVariant(item.introMessage)
of ModelRole.OutroMessage:
result = newQVariant(item.outroMessage)
of ModelRole.Image:
result = newQVariant(item.image)
of ModelRole.BannerImageData:
@ -243,6 +251,8 @@ QtObject:
self.dataChanged(dataIndex, dataIndex, @[
ModelRole.Name.int,
ModelRole.Description.int,
ModelRole.IntroMessage.int,
ModelRole.OutroMessage.int,
ModelRole.Image.int,
ModelRole.BannerImageData.int,
ModelRole.Icon.int,
@ -346,6 +356,8 @@ QtObject:
"name": item.name,
"amISectionAdmin": item.amISectionAdmin,
"description": item.description,
"introMessage": item.introMessage,
"outroMessage": item.outroMessage,
"image": item.image,
"bannerImageData": item.bannerImageData,
"icon": item.icon,

View File

@ -80,6 +80,8 @@ type ChannelGroupDto* = object
name*: string
ensName*: string
description*: string
introMessage*: string
outroMessage*: string
chats*: seq[ChatDto]
categories*: seq[Category]
images*: Images
@ -224,6 +226,8 @@ proc toChannelGroupDto*(jsonObj: JsonNode): ChannelGroupDto =
discard jsonObj.getProp("verified", result.verified)
discard jsonObj.getProp("name", result.name)
discard jsonObj.getProp("description", result.description)
discard jsonObj.getProp("introMessage", result.introMessage)
discard jsonObj.getProp("outroMessage", result.outroMessage)
result.channelGroupType = ChannelGroupType.Unknown
var channelGroupTypeString: string

View File

@ -50,6 +50,8 @@ type CommunityDto* = object
requestedAccessAt: int64
name*: string
description*: string
introMessage*: string
outroMessage*: string
chats*: seq[ChatDto]
categories*: seq[Category]
images*: Images
@ -84,6 +86,8 @@ proc toCommunityDto*(jsonObj: JsonNode): CommunityDto =
discard jsonObj.getProp("requestedAccessAt", result.requestedAccessAt)
discard jsonObj.getProp("name", result.name)
discard jsonObj.getProp("description", result.description)
discard jsonObj.getProp("introMessage", result.introMessage)
discard jsonObj.getProp("outroMessage", result.outroMessage)
var chatsObj: JsonNode
if(jsonObj.getProp("chats", chatsObj)):
@ -172,6 +176,8 @@ proc toChannelGroupDto*(communityDto: CommunityDto): ChannelGroupDto =
admin: communityDto.admin,
verified: communityDto.verified,
description: communityDto.description,
introMessage: communityDto.introMessage,
outroMessage: communityDto.outroMessage,
color: communityDto.color,
permissions: communityDto.permissions,
members: communityDto.members.map(m => ChatMember(

View File

@ -562,6 +562,8 @@ QtObject:
self: Service,
name: string,
description: string,
introMessage: string,
outroMessage: string,
access: int,
color: string,
imageUrl: string,
@ -573,6 +575,8 @@ QtObject:
let response = status_go.createCommunity(
name,
description,
introMessage,
outroMessage,
access,
color,
image,
@ -602,6 +606,8 @@ QtObject:
id: string,
name: string,
description: string,
introMessage: string,
outroMessage: string,
access: int,
color: string,
logoJsonStr: string,
@ -616,6 +622,8 @@ QtObject:
id,
name,
description,
introMessage,
outroMessage,
access,
color,
logoJson["imagePath"].getStr(),

View File

@ -38,6 +38,8 @@ proc leaveCommunity*(communityId: string): RpcResponse[JsonNode] {.raises: [Exce
proc createCommunity*(
name: string,
description: string,
introMessage: string,
outroMessage: string,
access: int,
color: string,
imageUrl: string,
@ -50,6 +52,8 @@ proc createCommunity*(
"Membership": access,
"name": name,
"description": description,
"introMessage": introMessage,
"outroMessage": outroMessage,
"ensOnly": false, # TODO ensOnly is no longer supported. Remove this when we remove it in status-go
"color": color,
"image": imageUrl,
@ -65,6 +69,8 @@ proc editCommunity*(
communityId: string,
name: string,
description: string,
introMessage: string,
outroMessage: string,
access: int,
color: string,
imageUrl: string,
@ -83,6 +89,8 @@ proc editCommunity*(
"Membership": access,
"name": name,
"description": description,
"introMessage": introMessage,
"outroMessage": outroMessage,
"ensOnly": false, # TODO ensOnly is no longer supported. Remove this when we remove it in status-go
"color": color,
"image": imageUrl,