88
99#import " ProjectActivities.h"
1010
11+
1112@implementation ProjectActivities
1213
1314- (instancetype )init
@@ -147,210 +148,4 @@ - (void)refreshListGroupWithArray:(NSArray *)responseA isAdd:(BOOL)isAdd{
147148 }
148149 }
149150}
150- @end
151- @implementation ProjectActivity
152- @synthesize actionStr = _actionStr, contentStr = _contentStr;
153- - (instancetype )init
154- {
155- self = [super init ];
156- if (self) {
157- _propertyArrayMap = [NSDictionary dictionaryWithObjectsAndKeys:
158- @" Commit" , @" commits" , nil ];
159- _actionMediaItems = [[NSMutableArray alloc ] init ];
160- _contentMediaItems = [[NSMutableArray alloc ] init ];
161- }
162- return self;
163- }
164-
165- - (void )setComment_content : (NSString *)comment_content {
166- if (comment_content) {
167- _comment_content = [comment_content stringByRemoveHtmlTag ];
168- }else {
169- _comment_content = @" " ;
170- }
171- }
172-
173- - (void )addActionUser : (User *)curUser {
174- if (curUser) {
175- [HtmlMedia addMediaItemUser: curUser toString: _actionStr andMediaItems: _actionMediaItems];
176- }
177- }
178-
179- // - (void)addActionLinkStr:(NSString *)linkStr{
180- // [HtmlMedia addLinkStr:linkStr type:HtmlMediaItemType_CustomLink toString:_actionStr andMediaItems:_actionMediaItems];
181- // }
182-
183- - (void )addContentLinkStr : (NSString *)linkStr {
184- [HtmlMedia addLinkStr: linkStr type: HtmlMediaItemType_CustomLink toString: _contentStr andMediaItems: _contentMediaItems];
185- }
186-
187- - (NSMutableString *)actionStr {
188- if (!_actionStr) {
189- _actionStr = [[NSMutableString alloc ] init ];
190- if ([_target_type isEqualToString: @" ProjectMember" ]) {
191- if ([_action isEqualToString: @" quit" ]) {
192- [self addActionUser: _target_user];
193- [_actionStr appendString: _action_msg];
194- [_actionStr appendString: @" 项目" ];
195- }else {
196- [self addActionUser: _user];
197- [_actionStr appendString: _action_msg];
198- [_actionStr appendString: @" 项目成员" ];
199- }
200- }else if ([_target_type isEqualToString: @" Task" ]){
201- [self addActionUser: _user];
202- if ([_action isEqualToString: @" update_priority" ]) {
203- [_actionStr appendFormat: @" 更新了任务<%@ >的优先级" , _task.title];
204- }else if ([_action isEqualToString: @" update_deadline" ]) {
205- if (_task.deadline && _task.deadline .length > 0 ) {
206- [_actionStr appendFormat: @" 更新了任务<%@ >的截止日期" , _task.title];
207- }else {
208- [_actionStr appendFormat: @" 移除了任务<%@ >的截止日期" , _task.title];
209- }
210- }else if ([_action isEqualToString: @" update_description" ]) {
211- [_actionStr appendFormat: @" 更新了任务<%@ >的描述" , _task.title];
212- }else {
213- [_actionStr appendString: _action_msg];
214- if (_origin_task.owner ) {
215- [self addActionUser: _origin_task.owner];
216- [_actionStr appendString: @" 的" ];
217- }
218- [_actionStr appendString: @" 任务" ];
219-
220- if ([_action isEqualToString: @" reassign" ]) {
221- [_actionStr appendString: @" 给" ];
222- [self addActionUser: _task.owner];
223- }
224- }
225- }else if ([_target_type isEqualToString: @" TaskComment" ]){
226- [self addActionUser: _user];
227- [_actionStr appendFormat: @" %@ 任务<%@ >的评论" , _action_msg, _task.title];
228- }else {
229- [self addActionUser: _user];
230- [_actionStr appendString: _action_msg];
231- if ([_target_type isEqualToString: @" ProjectTopic" ]){
232- [_actionStr appendString: @" 讨论" ];
233- if ([_action isEqualToString: @" comment" ]) {
234- [_actionStr appendString: @" :" ];
235- [_actionStr appendString: _project_topic.parent.title];
236- }
237- }else if ([_target_type isEqualToString: @" ProjectFile" ]){
238- if ([_type isEqualToString: @" dir" ]) {
239- [_actionStr appendString: @" 文件夹" ];
240- }else {
241- [_actionStr appendString: @" 文件" ];
242- }
243- }else if ([_target_type isEqualToString: @" Depot" ]){
244- if (!_ref && _ref.length <= 0 ) {
245- _ref = @" " ;
246- }
247- if ([_action isEqualToString: @" push" ]) {
248- [_actionStr appendString: @" 项目分支:" ];
249- [_actionStr appendString: _ref];
250- }else if ([_action isEqualToString: @" fork" ]){
251- [_actionStr appendString: @" 项目" ];
252- [_actionStr appendString: _source_depot.name];
253- [_actionStr appendString: @" 到" ];
254- [_actionStr appendString: _depot.name];
255- }
256- }else {
257- [_actionStr appendString: @" 项目" ];
258- if ([_target_type isEqualToString: @" Project" ]){
259- }else if ([_target_type isEqualToString: @" QcTask" ]){
260- [_actionStr appendString: [NSString stringWithFormat: @" [%@ ]" , _project.full_name]];
261- [_actionStr appendString: @" 的质量分析任务" ];
262- }else if ([_target_type isEqualToString: @" ProjectStar" ]){
263- [_actionStr appendString: [NSString stringWithFormat: @" [%@ ]" , _project.full_name]];
264- }else if ([_target_type isEqualToString: @" ProjectWatcher" ]){
265- [_actionStr appendString: [NSString stringWithFormat: @" [%@ ]" , _project.full_name]];
266- }else if ([_target_type isEqualToString: @" PullRequestBean" ]){
267- [_actionStr appendString: [NSString stringWithFormat: @" [%@ ]" , _depot.name]];
268- [_actionStr appendString: @" 中的 Pull Request" ];
269- }else if ([_target_type isEqualToString: @" PullRequestComment" ]){
270- [_actionStr appendString: [NSString stringWithFormat: @" [%@ ]" , _depot.name]];
271- [_actionStr appendString: @" 中的 Pull Request" ];
272- [_actionStr appendString: _pull_request_title];
273- }else if ([_target_type isEqualToString: @" MergeRequestBean" ]){
274- [_actionStr appendString: [NSString stringWithFormat: @" [%@ ]" , _depot.name]];
275- [_actionStr appendString: @" 中的 Merge Request" ];
276- }else if ([_target_type isEqualToString: @" MergeRequestComment" ]){
277- [_actionStr appendString: [NSString stringWithFormat: @" [%@ ]" , _depot.name]];
278- [_actionStr appendString: @" 中的 Merge Request" ];
279- [_actionStr appendString: _merge_request_title];
280- }
281- }
282- }
283- }
284- return _actionStr;
285- }
286-
287- - (NSMutableString *)contentStr {
288- if (!_contentStr) {
289- _contentStr = [[NSMutableString alloc ] init ];
290-
291- if ([_target_type isEqualToString: @" Task" ]) {
292- NSString *linkStr;
293- if ([_action isEqualToString: @" update_priority" ]) {
294- if (_task.priority && _task.priority .intValue < kTaskPrioritiesDisplay .count ) {
295- linkStr = [NSString stringWithFormat: @" [%@ ] %@ " , kTaskPrioritiesDisplay [_task.priority.intValue], _task.title];
296- }
297- }else if ([_action isEqualToString: @" update_deadline" ] && _task.deadline && _task.deadline .length > 0 ) {
298- linkStr = [NSString stringWithFormat: @" [%@ ] %@ " , [NSDate convertStr_yyyy_MM_ddToDisplay: _task.deadline], _task.title];
299- }else if ([_action isEqualToString: @" update_description" ]) {
300- linkStr = _task.description_mine ;
301- }else {
302- linkStr = _task.title ;
303- }
304- [self addContentLinkStr: linkStr];
305- }else if ([_target_type isEqualToString: @" TaskComment" ]){
306- if (_taskComment.content ) {
307- [self addContentLinkStr: _taskComment.content];
308- }
309- }else if ([_target_type isEqualToString: @" ProjectTopic" ]){
310- if ([_action isEqualToString: @" comment" ]) {
311- [self addContentLinkStr: _project_topic.content];
312- }else {
313- [self addContentLinkStr: _project_topic.title];
314- }
315- }else if ([_target_type isEqualToString: @" ProjectFile" ]){
316- [self addContentLinkStr: _file.name];
317- }else if ([_target_type isEqualToString: @" Depot" ]){
318- if (_commits && [_commits count ] > 0 ) {
319- Commit *curCommit = _commits.firstObject ;
320- [_contentStr appendString: curCommit.contentStr];
321- for (int i = 1 ; i<[_commits count ]; i++) {
322- curCommit = [_commits objectAtIndex: i];
323- [_contentStr appendString: [NSString stringWithFormat: @" \n %@ " ,curCommit.contentStr]];
324- }
325- }
326- }else {
327- if ([_target_type isEqualToString: @" ProjectMember" ]) {
328- if ([_action isEqualToString: @" quit" ]) {
329- [_contentStr appendString: _project.full_name];
330- }else {
331- [self addContentLinkStr: _target_user.name];
332- }
333- }else if ([_target_type isEqualToString: @" Project" ]){
334- [_contentStr appendString: _project.full_name];
335- }else if ([_target_type isEqualToString: @" QcTask" ]){
336- [_contentStr appendString: _qc_task.link];
337- }else if ([_target_type isEqualToString: @" ProjectStar" ]){
338- [_contentStr appendString: _project.full_name];
339- }else if ([_target_type isEqualToString: @" ProjectWatcher" ]){
340- [_contentStr appendString: _project.full_name];
341- }else if ([_target_type isEqualToString: @" PullRequestBean" ]){
342- [_contentStr appendString: _pull_request_title];
343- }else if ([_target_type isEqualToString: @" PullRequestComment" ]){
344- [_contentStr appendString: _comment_content];
345- }else if ([_target_type isEqualToString: @" MergeRequestBean" ]){
346- [_contentStr appendString: _merge_request_title];
347- }else if ([_target_type isEqualToString: @" MergeRequestComment" ]){
348- [_contentStr appendString: _comment_content];
349- }else {
350- [_contentStr appendString: @" **未知**" ];
351- }
352- }
353- }
354- return _contentStr;
355- }
356151@end
0 commit comments